]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working on cleaning up weapon spawn functions
authorSamual Lenks <samual@xonotic.org>
Tue, 11 Jun 2013 20:14:04 +0000 (16:14 -0400)
committerSamual Lenks <samual@xonotic.org>
Tue, 11 Jun 2013 20:14:04 +0000 (16:14 -0400)
16 files changed:
qcsrc/common/weapons/w_arc.qc
qcsrc/common/weapons/w_blaster.qc
qcsrc/common/weapons/w_crylink.qc
qcsrc/common/weapons/w_devastator.qc
qcsrc/common/weapons/w_electro.qc
qcsrc/common/weapons/w_fireball.qc
qcsrc/common/weapons/w_hagar.qc
qcsrc/common/weapons/w_hlac.qc
qcsrc/common/weapons/w_hook.qc
qcsrc/common/weapons/w_machinegun.qc
qcsrc/common/weapons/w_minstanex.qc
qcsrc/common/weapons/w_nex.qc
qcsrc/common/weapons/w_shockwave.qc
qcsrc/server/progs.src
qcsrc/server/t_items.qc
qcsrc/server/weapons/cl_weapons.qc

index 71d1fd564fb0a996265b2a07807cafb056312d4a..ab06a8a92327d9348cb25488cd0da6e5c94adf85 100644 (file)
@@ -39,10 +39,7 @@ void ArcInit();
 #endif
 #else
 #ifdef SVQC
-void spawnfunc_weapon_arc (void) // should this really be here?
-{
-       weapon_defaultspawnfunc(WEP_ARC);
-}
+void spawnfunc_weapon_arc() { weapon_defaultspawnfunc(WEP_ARC); }
 
 float W_Arc_Beam_Send(entity to, float sf)
 {
index c331c5b525573b4ac8febdc2b1edc56129479e39..e13ca5f1c192352d7e66027670441346f968410a 100644 (file)
@@ -12,6 +12,7 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_laser() { weapon_defaultspawnfunc(WEP_LASER); }
 void(float imp) W_SwitchWeapon;
 void() W_LastWeapon;
 .float swing_prev;
@@ -432,11 +433,6 @@ void W_Laser_Attack(float issecondary)
        }
 }
 
-void spawnfunc_weapon_laser(void)
-{
-       weapon_defaultspawnfunc(WEP_LASER);
-}
-
 float W_Laser(float request)
 {
        switch(request)
index e70a9c3c13719478cf372dd3eb0e71bab33bc074..983b3305d0070bc301601b3f04d2c645bd0854b7 100644 (file)
@@ -12,6 +12,7 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_crylink() { weapon_defaultspawnfunc(WEP_CRYLINK); }
 .float gravity;
 .float crylink_waitrelease;
 .entity crylink_lastgroup;
@@ -577,11 +578,6 @@ void W_Crylink_Attack2 (void)
        }
 }
 
-void spawnfunc_weapon_crylink (void)
-{
-       weapon_defaultspawnfunc(WEP_CRYLINK);
-}
-
 float w_crylink(float req)
 {
        float ammo_amount;
index c2264c3b351e03231ccac42c441f60815bb009df..6815cc2f9c7e0f50bb135138fc05baf5530c0eeb 100644 (file)
@@ -47,10 +47,8 @@ DEVASTATOR_SETTINGS(devastator)
 #endif
 #else
 #ifdef SVQC
-void spawnfunc_weapon_rocketlauncher()
-{
-       weapon_defaultspawnfunc(WEP_DEVASTATOR);
-}
+void spawnfunc_weapon_devastator() { weapon_defaultspawnfunc(WEP_DEVASTATOR); }
+void spawnfunc_weapon_rocketlauncher() { spawnfunc_weapon_devastator(); }
 
 void W_Devastator_Unregister()
 {
index 74e6e51246562161daccf7dc3aa60a6adc27c765..2e19540d019aeaf936b7d0689935b27b4af2ca23 100644 (file)
@@ -17,6 +17,8 @@ vector electro_shotorigin[4];
 #endif
 #else
 #ifdef SVQC
+void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
+
 .float electro_count;
 .float electro_secondarytime;
 
@@ -373,11 +375,6 @@ void ElectroInit()
        electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 4);
 }
 
-void spawnfunc_weapon_electro (void)
-{
-       weapon_defaultspawnfunc(WEP_ELECTRO);
-}
-
 void w_electro_checkattack()
 {
        if(self.electro_count > 1)
index 1bfdfaeca50f6752c0e1b77ecb9a0ec0a87eb657..f68050f383c7ecf089ed96cdffc8677360d1cc78 100644 (file)
@@ -12,6 +12,8 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
+
 .float bot_primary_fireballmooth; // whatever a mooth is
 .vector fireball_impactvec;
 .float fireball_primarytime;
@@ -307,11 +309,6 @@ void W_Fireball_Attack2()
        other = proj; MUTATOR_CALLHOOK(EditProjectile);
 }
 
-void spawnfunc_weapon_fireball (void)
-{
-       weapon_defaultspawnfunc(WEP_FIREBALL);
-}
-
 float w_fireball(float req)
 {
        switch(req)
index aa773ea2a1a17068247c1494f61d15479d150eaa..18a14fb99b2fbf5d449709aa15dd35e2b042e580 100644 (file)
@@ -12,6 +12,7 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
 // NO bounce protection, as bounces are limited!
 
 void W_Hagar_Explode (void)
@@ -345,11 +346,6 @@ void W_Hagar_Attack2_Load (void)
        }
 }
 
-void spawnfunc_weapon_hagar (void)
-{
-       weapon_defaultspawnfunc(WEP_HAGAR);
-}
-
 float w_hagar(float req)
 {
        float ammo_amount;
index d6d7de6f1da89a95256f87c487343cedde11efc0..0c49744cd5a14752a4cd2651bb5e0f14f83f2371 100644 (file)
@@ -12,6 +12,7 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_hlac() { weapon_defaultspawnfunc(WEP_HLAC); }
 
 void W_HLAC_Touch (void)
 {
@@ -166,11 +167,6 @@ void HLAC_fire1_02()
        }
 }
 
-void spawnfunc_weapon_hlac (void)
-{
-       weapon_defaultspawnfunc(WEP_HLAC);
-}
-
 float w_hlac(float req)
 {
        float ammo_amount;
index bbd07904f384f71517685553311fc3474812388c..ae0f756d49d0514895c05d00e0a434d15c06f1e3 100644 (file)
@@ -12,6 +12,17 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_hook()
+{
+       if(g_grappling_hook) // offhand hook
+       {
+               startitem_failed = TRUE;
+               remove(self);
+               return;
+       }
+       weapon_defaultspawnfunc(WEP_HOOK);
+}
+
 .float dmg;
 .float dmg_edge;
 .float dmg_radius;
@@ -127,17 +138,6 @@ void W_Hook_Attack2()
        other = gren; MUTATOR_CALLHOOK(EditProjectile);
 }
 
-void spawnfunc_weapon_hook (void)
-{
-       if(g_grappling_hook) // offhand hook
-       {
-               startitem_failed = TRUE;
-               remove(self);
-               return;
-       }
-       weapon_defaultspawnfunc(WEP_HOOK);
-}
-
 float w_hook(float req)
 {
        float hooked_time_max, hooked_fuel;
index 8df318d0933bf576e5e6c70db9746b68b9fcef31..78a70dc834b2b1b94716f4e058af3afaf5b34cc9 100644 (file)
@@ -10,8 +10,21 @@ REGISTER_WEAPON(
 /* shortname */ "uzi",
 /* fullname  */ _("Machine Gun")
 );
+
+#ifdef SVQC
+#endif
 #else
 #ifdef SVQC
+void spawnfunc_weapon_uzi()
+{
+       if(autocvar_sv_q3acompat_machineshotgunswap)
+       if(self.classname != "droppedweapon")
+       {
+               weapon_defaultspawnfunc(WEP_SHOTGUN);
+               return;
+       }
+       weapon_defaultspawnfunc(WEP_UZI);
+}
 
 // leilei's fancy muzzleflash stuff
 void UZI_Flash_Go()
@@ -187,8 +200,6 @@ void uzi_mode1_fire_burst()
 
 }
 
-void spawnfunc_weapon_machinegun(); // defined in t_items.qc
-
 float w_uzi(float req)
 {
        float ammo_amount;
index bfa1338578f127f85a89c3fbdaa1e514b790a709..5f4c131452f3f236ccbbf3ece34894cd917e7766 100644 (file)
@@ -10,6 +10,13 @@ REGISTER_WEAPON(
 /* shortname */ "minstanex",
 /* fullname  */ _("MinstaNex")
 );
+
+#ifdef SVQC
+void spawnfunc_weapon_minstanex (void)
+{
+       weapon_defaultspawnfunc(WEP_MINSTANEX);
+}
+#endif
 #else
 #ifdef SVQC
 .float minstanex_lasthit;
@@ -78,8 +85,6 @@ void W_MinstaNex_Attack (void)
        W_DecreaseAmmo(ammo_cells, ((g_minstagib) ? 1 : autocvar_g_balance_minstanex_ammo), autocvar_g_balance_minstanex_reload_ammo);
 }
 
-void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
-
 float w_minstanex(float req)
 {
        float ammo_amount;
index 81d4c3d5891bd2ff5f5415e328c85d738cda460d..8b0ba60748b920f49413f0178f91b2abda7f7ca0 100644 (file)
@@ -10,6 +10,13 @@ REGISTER_WEAPON(
 /* shortname */ "nex",
 /* fullname  */ _("Nex")
 );
+
+#ifdef SVQC
+void spawnfunc_weapon_nex (void)
+{
+       weapon_defaultspawnfunc(WEP_NEX);
+}
+#endif
 #else
 #ifdef SVQC
 
index 476d4d3fd2b5624e383c59cf0181983a98062dc7..9e8787de5ae78391a2514be940ddfc582719d9c5 100644 (file)
@@ -12,6 +12,17 @@ REGISTER_WEAPON(
 );
 #else
 #ifdef SVQC
+void spawnfunc_weapon_shotgun()
+{
+       if(autocvar_sv_q3acompat_machineshotgunswap)
+       if(self.classname != "droppedweapon")
+       {
+               weapon_defaultspawnfunc(WEP_UZI);
+               return;
+       }
+       weapon_defaultspawnfunc(WEP_SHOTGUN);
+}
+
 
 void W_Shotgun_Attack (void)
 {
index 9cd064845b630f25c8a7693106728f625bdd5734..037e10449c9aaa3b9e86e1beb285bd09aa2b6ddf 100644 (file)
@@ -16,7 +16,8 @@ sys-post.qh
 ../common/teams.qh
 ../common/util.qh
 ../common/counting.qh
-../common/weapons/weapons.qh // TODO
+weapons/cl_weapons.qh
+../common/weapons/weapons.qh // WEAPONTODO
 ../common/urllib.qh
 ../common/command/markup.qh
 ../common/command/rpn.qh
index 66676bf2f4883e052e758585fc9833da9035fb85..07ddfdd3c625db57296e1df77c4b0647785714e1 100644 (file)
@@ -1146,180 +1146,6 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        }
 }
 
-float weaponswapping;
-float internalteam;
-
-void weapon_defaultspawnfunc(float wpn)
-{
-       entity e;
-       float t;
-       var .float ammofield;
-       string s;
-       entity oldself;
-       float i, j;
-       float f;
-
-       if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
-       {
-               e = get_weaponinfo(wpn);
-
-               if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
-               {
-                       print("Attempted to spawn a mutator-blocked weapon; these guns will in the future require a mutator\n");
-                       /*
-                       objerror("Attempted to spawn a mutator-blocked weapon rejected");
-                       startitem_failed = TRUE;
-                       return;
-                       */
-               }
-
-               s = W_Apply_Weaponreplace(e.netname);
-               ret_string = s;
-               other = e;
-               MUTATOR_CALLHOOK(SetWeaponreplace);
-               s = ret_string;
-               if(s == "")
-               {
-                       remove(self);
-                       startitem_failed = TRUE;
-                       return;
-               }
-               t = tokenize_console(s);
-               if(t >= 2)
-               {
-                       self.team = --internalteam;
-                       oldself = self;
-                       for(i = 1; i < t; ++i)
-                       {
-                               s = argv(i);
-                               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
-                               {
-                                       e = get_weaponinfo(j);
-                                       if(e.netname == s)
-                                       {
-                                               self = spawn();
-                                               copyentity(oldself, self);
-                                               self.classname = "replacedweapon";
-                                               weapon_defaultspawnfunc(j);
-                                               break;
-                                       }
-                               }
-                               if(j > WEP_LAST)
-                               {
-                                       print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
-                               }
-                       }
-                       self = oldself;
-               }
-               if(t >= 1) // always the case!
-               {
-                       s = argv(0);
-                       wpn = 0;
-                       for(j = WEP_FIRST; j <= WEP_LAST; ++j)
-                       {
-                               e = get_weaponinfo(j);
-                               if(e.netname == s)
-                               {
-                                       wpn = j;
-                                       break;
-                               }
-                       }
-                       if(j > WEP_LAST)
-                       {
-                               print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
-                       }
-               }
-               if(wpn == 0)
-               {
-                       remove(self);
-                       startitem_failed = TRUE;
-                       return;
-               }
-       }
-
-       e = get_weaponinfo(wpn);
-
-       if(!self.respawntime)
-       {
-               if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
-               {
-                       self.respawntime = g_pickup_respawntime_superweapon;
-                       self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
-               }
-               else
-               {
-                       self.respawntime = g_pickup_respawntime_weapon;
-                       self.respawntimejitter = g_pickup_respawntimejitter_weapon;
-               }
-       }
-
-       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
-               if(!self.superweapons_finished)
-                       self.superweapons_finished = autocvar_g_balance_superweapons_time;
-
-       if(e.items)
-       {
-               for(i = 0, j = 1; i < 24; ++i, j *= 2)
-               {
-                       if(e.items & j)
-                       {
-                               ammofield = Item_CounterField(j);
-                               if(!self.ammofield)
-                                       self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
-                       }
-               }
-       }
-
-       // pickup anyway
-       if(g_pickup_weapons_anyway)
-               self.pickup_anyway = TRUE;
-
-       f = FL_WEAPON;
-
-       // no weapon-stay on superweapons
-       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
-               f |= FL_NO_WEAPON_STAY;
-
-       // weapon stay isn't supported for teamed weapons
-       if(self.team)
-               f |= FL_NO_WEAPON_STAY;
-
-       StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
-       if (self.modelindex) // don't precache if self was removed
-               weapon_action(e.weapon, WR_PRECACHE);
-}
-
-void spawnfunc_weapon_shotgun (void);
-void spawnfunc_weapon_uzi (void) {
-       if(autocvar_sv_q3acompat_machineshotgunswap)
-       if(self.classname != "droppedweapon")
-       {
-               weapon_defaultspawnfunc(WEP_SHOTGUN);
-               return;
-       }
-       weapon_defaultspawnfunc(WEP_UZI);
-}
-
-void spawnfunc_weapon_shotgun (void) {
-       if(autocvar_sv_q3acompat_machineshotgunswap)
-       if(self.classname != "droppedweapon")
-       {
-               weapon_defaultspawnfunc(WEP_UZI);
-               return;
-       }
-       weapon_defaultspawnfunc(WEP_SHOTGUN);
-}
-
-void spawnfunc_weapon_nex (void)
-{
-       weapon_defaultspawnfunc(WEP_NEX);
-}
-
-void spawnfunc_weapon_minstanex (void)
-{
-       weapon_defaultspawnfunc(WEP_MINSTANEX);
-}
-
 void spawnfunc_item_rockets (void) {
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
index cec4b8dab4f7845a7f7a8862da7bdde99f58ccfc..1b47fef3b95584890a0cded9d3737d886ed5d90b 100644 (file)
@@ -527,3 +527,143 @@ string W_Apply_Weaponreplace(string in)
        }
        return substring(out, 1, -1);
 }
+
+void weapon_defaultspawnfunc(float wpn)
+{
+       entity e;
+       float t;
+       var .float ammofield;
+       string s;
+       entity oldself;
+       float i, j;
+       float f;
+
+       if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
+       {
+               e = get_weaponinfo(wpn);
+
+               if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
+               {
+                       print("Attempted to spawn a mutator-blocked weapon; these guns will in the future require a mutator\n");
+                       /*
+                       objerror("Attempted to spawn a mutator-blocked weapon rejected");
+                       startitem_failed = TRUE;
+                       return;
+                       */
+               }
+
+               s = W_Apply_Weaponreplace(e.netname);
+               ret_string = s;
+               other = e;
+               MUTATOR_CALLHOOK(SetWeaponreplace);
+               s = ret_string;
+               if(s == "")
+               {
+                       remove(self);
+                       startitem_failed = TRUE;
+                       return;
+               }
+               t = tokenize_console(s);
+               if(t >= 2)
+               {
+                       self.team = --internalteam;
+                       oldself = self;
+                       for(i = 1; i < t; ++i)
+                       {
+                               s = argv(i);
+                               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+                               {
+                                       e = get_weaponinfo(j);
+                                       if(e.netname == s)
+                                       {
+                                               self = spawn();
+                                               copyentity(oldself, self);
+                                               self.classname = "replacedweapon";
+                                               weapon_defaultspawnfunc(j);
+                                               break;
+                                       }
+                               }
+                               if(j > WEP_LAST)
+                               {
+                                       print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
+                               }
+                       }
+                       self = oldself;
+               }
+               if(t >= 1) // always the case!
+               {
+                       s = argv(0);
+                       wpn = 0;
+                       for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+                       {
+                               e = get_weaponinfo(j);
+                               if(e.netname == s)
+                               {
+                                       wpn = j;
+                                       break;
+                               }
+                       }
+                       if(j > WEP_LAST)
+                       {
+                               print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
+                       }
+               }
+               if(wpn == 0)
+               {
+                       remove(self);
+                       startitem_failed = TRUE;
+                       return;
+               }
+       }
+
+       e = get_weaponinfo(wpn);
+
+       if(!self.respawntime)
+       {
+               if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+               {
+                       self.respawntime = g_pickup_respawntime_superweapon;
+                       self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
+               }
+               else
+               {
+                       self.respawntime = g_pickup_respawntime_weapon;
+                       self.respawntimejitter = g_pickup_respawntimejitter_weapon;
+               }
+       }
+
+       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+               if(!self.superweapons_finished)
+                       self.superweapons_finished = autocvar_g_balance_superweapons_time;
+
+       if(e.items)
+       {
+               for(i = 0, j = 1; i < 24; ++i, j *= 2)
+               {
+                       if(e.items & j)
+                       {
+                               ammofield = Item_CounterField(j);
+                               if(!self.ammofield)
+                                       self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
+                       }
+               }
+       }
+
+       // pickup anyway
+       if(g_pickup_weapons_anyway)
+               self.pickup_anyway = TRUE;
+
+       f = FL_WEAPON;
+
+       // no weapon-stay on superweapons
+       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+               f |= FL_NO_WEAPON_STAY;
+
+       // weapon stay isn't supported for teamed weapons
+       if(self.team)
+               f |= FL_NO_WEAPON_STAY;
+
+       StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
+       if (self.modelindex) // don't precache if self was removed
+               weapon_action(e.weapon, WR_PRECACHE);
+}