From: Mircea Kitsune Date: Wed, 4 Apr 2012 12:52:42 +0000 (+0300) Subject: div said this might work as a mutator, so add a new mutator and a hook and prepare... X-Git-Tag: xonotic-v0.7.0~111^2~21 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cf4fffb8f56fbd5f42a130974812dcf72f44a0c4;p=xonotic%2Fxonotic-data.pk3dir.git div said this might work as a mutator, so add a new mutator and a hook and prepare to move it there. Also rename cvars --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index f32a199484..6be29e7401 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1387,8 +1387,8 @@ alias sethostname "set menu_use_default_hostname 0; hostname $*" set sv_foginterval 1 "force enable fog in regular intervals" -set physics_ode_droppedweapon 1 "use ODE physics instead of simple physics for dropped weapons, requires physics_ode to be enabled" -set physics_ode_droppedweapon_damageforcescale 3 "how affected physical weapons are by damage" +set g_ode_weapons 1 "use ODE physics instead of simple physics for dropped weapons, requires physics_ode to be enabled" +set g_ode_weapons_damageforcescale 3 "how affected physical weapons are by damage" // Audio track names (for old-style "cd loop NUMBER" usage) set _cdtrack_first "1" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 9ff8b038f4..e4c99f9ffa 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1216,5 +1216,5 @@ float autocvar_g_sandbox_object_material_velocity_min; float autocvar_g_sandbox_object_material_velocity_factor; float autocvar_g_max_info_autoscreenshot; float autocvar_physics_ode; -float autocvar_physics_ode_droppedweapon; -float autocvar_physics_ode_droppedweapon_damageforcescale; +float autocvar_g_ode_weapons; +float autocvar_g_ode_weapons_damageforcescale; diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index dcd9d16f15..ffb18ae211 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -311,7 +311,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto wep.pickup_anyway = TRUE; // these are ALWAYS pickable // make the dropped weapon physical - if(autocvar_physics_ode && autocvar_physics_ode_droppedweapon) + /*if(autocvar_physics_ode && autocvar_physics_ode_droppedweapon) { entity wep2; wep2 = spawn(); @@ -333,7 +333,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto wep.effects |= EF_NOMODELFLAGS; // disable the spinning wep.movetype = MOVETYPE_FOLLOW; wep.aiment = wep2; - } + }*/ return s; } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 1359c05669..6598468f4b 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1078,6 +1078,8 @@ void readlevelcvars(void) MUTATOR_ADD(mutator_vampire); if(cvar("g_spawn_near_teammate")) MUTATOR_ADD(mutator_spawn_near_teammate); + if(cvar("g_ode_weapons")) + MUTATOR_ADD(mutator_physical_weapons); // is this a mutator? is this a mode? if(cvar("g_sandbox")) diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 137eebadb8..ff5de6cfa4 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -205,3 +205,9 @@ MUTATOR_HOOKABLE(SV_StartFrame); MUTATOR_HOOKABLE(SetModname); // OUT string modname; // name of the mutator/mod if it warrants showing as such in the server browser + +MUTATOR_HOOKABLE(Item_Spawn); + // called for each item being spawned on a map, including dropped weapons + // return 1 to remove an item + // INPUT + entity self; // the item diff --git a/qcsrc/server/mutators/mutator_physical_weapons.qc b/qcsrc/server/mutators/mutator_physical_weapons.qc new file mode 100644 index 0000000000..a950177506 --- /dev/null +++ b/qcsrc/server/mutators/mutator_physical_weapons.qc @@ -0,0 +1,13 @@ +MUTATOR_HOOKFUNCTION(item_spawning) +{ + dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + + return 0; +} + +MUTATOR_DEFINITION(mutator_physical_weapons) +{ + MUTATOR_HOOK(Item_Spawn, item_spawning, CBC_ORDER_ANY); + + return 0; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index bc3c3fbd44..072e652fff 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -10,5 +10,6 @@ MUTATOR_DECLARATION(mutator_rocketflying); MUTATOR_DECLARATION(mutator_vampire); MUTATOR_DECLARATION(mutator_spawn_near_teammate); MUTATOR_DECLARATION(mutator_spawn_near_teammate); +MUTATOR_DECLARATION(mutator_physical_weapons); MUTATOR_DECLARATION(sandbox); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 0dbe537818..92f9fa6a21 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -215,6 +215,7 @@ mutators/mutator_dodging.qc mutators/mutator_rocketflying.qc mutators/mutator_vampire.qc mutators/mutator_spawn_near_teammate.qc +mutators/mutator_physical_weapons.qc mutators/sandbox.qc ../warpzonelib/anglestransform.qc diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 5b9a2e5f99..1870dddf00 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -751,6 +751,13 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, self.weapons = weaponid; self.flags = FL_ITEM | itemflags; + if(MUTATOR_CALLHOOK(Item_Spawn)) + { + startitem_failed = TRUE; + remove(self); + return; + } + // is it a dropped weapon? if (self.classname == "droppedweapon") {