]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Give wr_setup a weaponentity parameter so it isn't resetting the other weapon entitie...
authorMario <mario@smbclan.net>
Mon, 3 Oct 2016 14:14:50 +0000 (00:14 +1000)
committerMario <mario@smbclan.net>
Mon, 3 Oct 2016 14:14:50 +0000 (00:14 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/triggers/trigger/magicear.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/weapons/weaponsystem.qc

index baa9cd8a348db8123745c9da8e85ab8d17c58614..c26ef4619561548d36b233562f1b9d168ee65a52 100644 (file)
@@ -899,7 +899,7 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we
     }
 }
 
-METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
+METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     //weapon_setup(WEP_PORTO.m_id);
index 065d8c932ac1ffdd04c2cf0b1054cf231877b6d4..354ed1bfedd61f284ad76ae0f0fa73107b34abda 100644 (file)
@@ -1,7 +1,7 @@
 #include "magicear.qh"
 #ifdef SVQC
 float magicear_matched;
-float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
+float W_Tuba_HasPlayed(entity pl, .entity weaponentity, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
 {
        float domatch, dotrigger, matchstart, l;
@@ -22,8 +22,12 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
                if (!(ear.spawnflags & 256))
                        return msgin;
 
-               if(!W_Tuba_HasPlayed(source, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z))
-                       return msgin;
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(!W_Tuba_HasPlayed(source, weaponentity, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z))
+                               return msgin;
+               }
 
                magicear_matched = true;
 
index 2e4f0c263c405d33e9ab884a472e48d82006d19c..9629b175d56f32a2f82e8c98f0edac4d7eac57e1 100644 (file)
@@ -87,7 +87,7 @@ CLASS(Weapon, Object)
     ATTRIB(Weapon, m_pickup, entity);
 
     /** (SERVER) setup weapon data */
-    METHOD(Weapon, wr_setup, void(Weapon this, entity actor)) {}
+    METHOD(Weapon, wr_setup, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (SERVER) logic to run every frame */
     METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
     /** (SERVER) checks ammo for weapon primary */
index 821ffb8ed51d932a55d187cfd568b85b3893471e..31038fc4fca8c46024940ee7d972425f9dfa4572 100644 (file)
@@ -529,13 +529,9 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
         }
     }
 }
-METHOD(Devastator, wr_setup, void(entity thiswep, entity actor))
+METHOD(Devastator, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       actor.(weaponentity).rl_release = 1;
-    }
+    actor.(weaponentity).rl_release = 1;
 }
 METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
index a4bf9cfc19415771c187f9ce1a79f75a6bbaa525..b00b181cfd2509033b789ebbb9a91b4e44e2fb6f 100644 (file)
@@ -491,18 +491,14 @@ METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor, .entity weaponent
        W_Hagar_Attack2_Load_Release(actor, weaponentity);
     }
 }
-METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
+METHOD(Hagar, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
        actor.hagar_load = 0;
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+    actor.(weaponentity).hagar_loadblock = false;
+    if(actor.(weaponentity).hagar_load)
     {
-       .entity weaponentity = weaponentities[slot];
-       actor.(weaponentity).hagar_loadblock = false;
-       if(actor.(weaponentity).hagar_load)
-       {
-               W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.(weaponentity).hagar_load * -1, weaponentity); // give back ammo if necessary
-               actor.(weaponentity).hagar_load = 0;
-       }
+       W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.(weaponentity).hagar_load * -1, weaponentity); // give back ammo if necessary
+       actor.(weaponentity).hagar_load = 0;
     }
 }
 METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
index ce7bbc3f916786604ab972ae5c422f06fa3f805d..a2717140770a3ebffcb15980c0aec60b7a0cf573 100644 (file)
@@ -280,13 +280,9 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         actor.(weaponentity).hook_state &= ~HOOK_REMOVING;
     }
 }
-METHOD(Hook, wr_setup, void(entity thiswep, entity actor))
+METHOD(Hook, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
-    }
+       actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
 }
 METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentity))
 {
index 26025a0ca334e1128736ad8536c3974992044695..48469864ce22b42c47a1927eb8bb874a83d91b3a 100644 (file)
@@ -56,23 +56,23 @@ REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
 
 spawnfunc(weapon_tuba) { weapon_defaultspawnfunc(this, WEP_TUBA); }
 
-bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
+bool W_Tuba_HasPlayed(entity pl, .entity weaponentity, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
 {
        float i, j, mmin, mmax, nolength;
        float n = tokenize_console(melody);
-       if(n > pl.tuba_lastnotes_cnt)
+       if(n > pl.(weaponentity).tuba_lastnotes_cnt)
                return false;
        float pitchshift = 0;
 
        if(instrument >= 0)
-               if(pl.tuba_instrument != instrument)
+               if(pl.(weaponentity).tuba_instrument != instrument)
                        return false;
 
        // verify notes...
        nolength = false;
        for(i = 0; i < n; ++i)
        {
-               vector v = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
+               vector v = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
                float ai = stof(argv(n - i - 1));
                float np = floor(ai);
                if(ai == np)
@@ -109,13 +109,13 @@ bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch
 
                for(i = 0; i < n; ++i)
                {
-                       vector vi = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
+                       vector vi = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
                        float ai = stof(argv(n - i - 1));
                        ti -= 1 / (ai - floor(ai));
                        float tj = ti;
                        for(j = i+1; j < n; ++j)
                        {
-                               vector vj = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - j + MAX_TUBANOTES) % MAX_TUBANOTES]);
+                               vector vj = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - j + MAX_TUBANOTES) % MAX_TUBANOTES]);
                                float aj = stof(argv(n - j - 1));
                                tj -= (aj - floor(aj));
 
@@ -142,7 +142,7 @@ bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch
                        return false;
        }
 
-       pl.tuba_lastnotes_cnt = 0;
+       pl.(weaponentity).tuba_lastnotes_cnt = 0;
 
        return true;
 }
@@ -154,12 +154,13 @@ void W_Tuba_NoteOff(entity this)
        //   on: this.spawnshieldtime
        //   off: time
        //   note: this.cnt
-       if (actor.tuba_note == this)
+       .entity weaponentity = this.weaponentity_fld;
+       if (actor.(weaponentity).tuba_note == this)
        {
-               actor.tuba_lastnotes_last = (actor.tuba_lastnotes_last + 1) % MAX_TUBANOTES;
-               actor.(tuba_lastnotes[actor.tuba_lastnotes_last]) = eX * this.spawnshieldtime + eY * time + eZ * this.cnt;
-               actor.tuba_note = NULL;
-               actor.tuba_lastnotes_cnt = bound(0, actor.tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
+               actor.(weaponentity).tuba_lastnotes_last = (actor.(weaponentity).tuba_lastnotes_last + 1) % MAX_TUBANOTES;
+               actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = eX * this.spawnshieldtime + eY * time + eZ * this.cnt;
+               actor.(weaponentity).tuba_note = NULL;
+               actor.(weaponentity).tuba_lastnotes_cnt = bound(0, actor.(weaponentity).tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
 
                string s = trigger_magicear_processmessage_forallears(actor, 0, NULL, string_null);
                if (s != "")
@@ -320,41 +321,43 @@ void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
        n = W_Tuba_GetNote(actor, hittype);
 
        hittype = 0;
-       if(actor.tuba_instrument & 1)
+       if(actor.(weaponentity).tuba_instrument & 1)
                hittype |= HITTYPE_SECONDARY;
-       if(actor.tuba_instrument & 2)
+       if(actor.(weaponentity).tuba_instrument & 2)
                hittype |= HITTYPE_BOUNCE;
 
-       if(actor.tuba_note)
+       if(actor.(weaponentity).tuba_note)
        {
-               if(actor.tuba_note.cnt != n || actor.tuba_note.tuba_instrument != actor.tuba_instrument)
+               if(actor.(weaponentity).tuba_note.cnt != n || actor.(weaponentity).tuba_note.tuba_instrument != actor.(weaponentity).tuba_instrument)
                {
-                       W_Tuba_NoteOff(actor.tuba_note);
+                       W_Tuba_NoteOff(actor.(weaponentity).tuba_note);
                }
        }
 
-       if(!actor.tuba_note)
+       if(!actor.(weaponentity).tuba_note)
        {
-               actor.tuba_note = new(tuba_note);
-               actor.tuba_note.owner = actor.tuba_note.realowner = actor;
-               actor.tuba_note.cnt = n;
-               actor.tuba_note.tuba_instrument = actor.tuba_instrument;
-               setthink(actor.tuba_note, W_Tuba_NoteThink);
-               actor.tuba_note.nextthink = time;
-               actor.tuba_note.spawnshieldtime = time;
-               Net_LinkEntity(actor.tuba_note, false, 0, W_Tuba_NoteSendEntity);
+               entity note = new(tuba_note);
+               note.weaponentity_fld = weaponentity;
+               actor.(weaponentity).tuba_note = note;
+               note.owner = note.realowner = actor;
+               note.cnt = n;
+               note.tuba_instrument = actor.(weaponentity).tuba_instrument;
+               setthink(note, W_Tuba_NoteThink);
+               note.nextthink = time;
+               note.spawnshieldtime = time;
+               Net_LinkEntity(note, false, 0, W_Tuba_NoteSendEntity);
        }
 
-       actor.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(actor); // so it can get prolonged safely
+       actor.(weaponentity).tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(actor); // so it can get prolonged safely
 
        //sound(actor, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
        RadiusDamage(actor, actor, WEP_CVAR(tuba, damage), WEP_CVAR(tuba, edgedamage), WEP_CVAR(tuba, radius), NULL, NULL, WEP_CVAR(tuba, force), hittype | WEP_TUBA.m_id, NULL);
 
        o = gettaginfo(actor.exteriorweaponentity, 0);
-       if(time > actor.tuba_smoketime)
+       if(time > actor.(weaponentity).tuba_smoketime)
        {
                Send_Effect(EFFECT_SMOKE_RING, o + v_up * 45 + v_right * -6 + v_forward * 8, v_up * 100, 1);
-               actor.tuba_smoketime = time + 0.25;
+               actor.(weaponentity).tuba_smoketime = time + 0.25;
        }
 }
 #endif
@@ -387,18 +390,18 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f
                W_Tuba_NoteOn(actor, weaponentity, HITTYPE_SECONDARY);
                weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
        }
-       if (actor.tuba_note)
+       if (actor.(weaponentity).tuba_note)
        {
                if (!(fire & 1) && !(fire & 2))
                {
-                       W_Tuba_NoteOff(actor.tuba_note);
+                       W_Tuba_NoteOff(actor.(weaponentity).tuba_note);
                }
        }
 }
 
-METHOD(Tuba, wr_setup, void(Tuba this, entity actor))
+METHOD(Tuba, wr_setup, void(Tuba this, entity actor, .entity weaponentity))
 {
-       actor.tuba_instrument = 0;
+       actor.(weaponentity).tuba_instrument = 0;
 }
 #endif
 
@@ -407,52 +410,55 @@ REGISTER_NET_S2C(tuba_instrument)
 NET_HANDLE(tuba_instrument, bool)
 {
        int i = ReadByte();
+       int slot = ReadByte();
        return = true;
        string s = (i == 0) ? "tuba" :
                   (i == 1) ? "akordeon" :
                              "kleinbottle" ;
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       entity wep = viewmodels[slot];
-       if(wep.activeweapon == WEP_TUBA)
-               CL_WeaponEntity_SetModel(wep, s, true);
-    }
+
+    entity wep = viewmodels[slot];
+    CL_WeaponEntity_SetModel(wep, s, true);
 }
 #endif
 #ifdef SVQC
-void tuba_instrument_send(entity this, int instr)
+void tuba_instrument_send(entity this, .entity weaponentity, int instr)
 {
        msg_entity = this;
        int chan = MSG_ONE;
        WriteHeader(chan, tuba_instrument);
        WriteByte(chan, instr);
+       WriteByte(chan, weaponslot(weaponentity));
 }
 SPECTATE_COPY()
 {
-       if (this.tuba_instrument != spectatee.tuba_instrument)
-               tuba_instrument_send(this, this.tuba_instrument = spectatee.tuba_instrument);
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity).tuba_instrument != spectatee.(weaponentity).tuba_instrument)
+                       tuba_instrument_send(this, weaponentity, this.(weaponentity).tuba_instrument = spectatee.(weaponentity).tuba_instrument);
+       }
 }
 METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
 {
        // switch to alternate instruments :)
        if (actor.(weaponentity).state == WS_READY)
        {
-               switch (actor.tuba_instrument)
+               switch (actor.(weaponentity).tuba_instrument)
                {
                        case 0:
-                               actor.tuba_instrument = 1;
+                               actor.(weaponentity).tuba_instrument = 1;
                                actor.(weaponentity).weaponname = "akordeon";
                                break;
                        case 1:
-                               actor.tuba_instrument = 2;
+                               actor.(weaponentity).tuba_instrument = 2;
                                actor.(weaponentity).weaponname = "kleinbottle";
                                break;
                        case 2:
-                               actor.tuba_instrument = 0;
+                               actor.(weaponentity).tuba_instrument = 0;
                                actor.(weaponentity).weaponname = "tuba";
                                break;
                }
-               tuba_instrument_send(actor, actor.tuba_instrument);
+               tuba_instrument_send(actor, weaponentity, actor.(weaponentity).tuba_instrument);
                W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0);
                Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
                actor.(weaponentity).state = WS_INUSE;
index 77595290bd1bd4ecd8fd5beeee3e44107815cd37..cb55c5ddafede9f71efcc7ce43c2cd4f56dd12c5 100644 (file)
@@ -434,7 +434,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     else
         actor.(weaponentity).held_down = false;
 }
-METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor))
+METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
     actor.vaporizer_lasthit = 0;
 }
index 7adfd85101d62c9d0d9c9abdd2783c57fedad8cb..7a30516ede14bf6a3387ba7699342c49972251dc 100644 (file)
@@ -331,7 +331,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         }
     }
 }
-METHOD(Vortex, wr_setup, void(entity thiswep, entity actor))
+METHOD(Vortex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
     actor.vortex_lasthit = 0;
 }
index 68b7da46a85eb6c91d3f25fd3e7552a4f84f2246..6b3ab1e4b05d2de7a41bbdbbc54244356c4f7318 100644 (file)
@@ -1067,7 +1067,7 @@ float bot_cmd_debug_assert_canfire(entity this)
                        LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n");
                }
        }
-       else if(this.tuba_note)
+       else if(this.(weaponentity).tuba_note)
        {
                if(f)
                {
index 01d5052988fe2c3968443388e7eec49a22a286d6..ff3a10a97b9af7c6e72808b0727d09b6baa733eb 100644 (file)
@@ -484,7 +484,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                this.m_weapon = newwep;
                                this.weaponname = newwep.mdl;
                                this.bulletcounter = 0;
-                               newwep.wr_setup(newwep, actor);
+                               newwep.wr_setup(newwep, actor, weaponentity);
                                this.state = WS_RAISE;
 
                                // set our clip load to the load of the weapon we switched to, if it's reloadable