]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Send alpha as part of weapon state, rather than when firing
authorMario <mario@smbclan.net>
Thu, 29 Sep 2016 02:48:50 +0000 (12:48 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Sep 2016 02:48:50 +0000 (12:48 +1000)
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/wepent.qc
qcsrc/server/weapons/weaponsystem.qc

index 1faa1a0455d582904c20720e5e9a5c58c41e47b0..99b232730a26104acd4be494bc33f7cb4fde93ad 100644 (file)
@@ -563,7 +563,6 @@ NET_HANDLE(wframe, bool isNew)
        anim_set(wepent, a, !restartanim, restartanim, restartanim);
        wepent.state = ReadByte();
        wepent.weapon_nextthink = ReadFloat();
-       wepent.alpha = ReadByte() / 255;
        switch (wepent.state)
        {
                case WS_RAISE:
@@ -594,7 +593,6 @@ void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim)
        WriteByte(channel, restartanim);
        WriteByte(channel, weaponentity.state);
        WriteFloat(channel, weaponentity.weapon_nextthink);
-       WriteByte(channel, weaponentity.m_alpha * 255);
 }
 #endif
 
index 9570e8c561aaac732a39ba63ae1a5d51fdbf68e9..90cbe28db5c6e801f2317e3b5c69ccff823232af 100644 (file)
@@ -333,6 +333,12 @@ vector weaponentity_glowmod(Weapon wep, entity actor, int c)
     return g;
 }
 
+#ifdef SVQC
+.entity gunaligns[5];
+#else
+entity gunaligns[5];
+#endif
+
 //.int weapon; // current weapon
 .string weaponname; // name of .weapon
 
index 0a2754f065cc835ae1d4a74bfad66d96b052ac91..6cee619816128daef945ab4b9d27328f1a403aed 100644 (file)
@@ -159,6 +159,7 @@ bool W_Arc_Beam_Send(entity this, entity to, int sf)
        if(drawlocal) { sf &= ~ARC_SF_LOCALMASK; }
 
        WriteByte(MSG_ENTITY, sf);
+       WriteByte(MSG_ENTITY, weaponslot(this.weaponentity_fld));
 
        if(sf & ARC_SF_SETTINGS) // settings information
        {
@@ -674,7 +675,7 @@ void W_Arc_Beam_Think(entity this)
                this.beam_type = new_beam_type;
        }
 
-       this.owner.beam_prev = time;
+       this.owner.(weaponentity).beam_prev = time;
        this.nextthink = time;
 }
 
@@ -682,7 +683,7 @@ void W_Arc_Beam(float burst, entity actor, .entity weaponentity)
 {
 
        // only play fire sound if 1 sec has passed since player let go the fire button
-       if(time - actor.beam_prev > 1)
+       if(time - actor.(weaponentity).beam_prev > 1)
                sound(actor, CH_WEAPON_A, SND_ARC_FIRE, VOL_BASE, ATTN_NORM);
 
        entity beam = actor.(weaponentity).arc_beam = new(W_Arc_Beam);
@@ -1297,13 +1298,22 @@ void Remove_ArcBeam(entity this)
 NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
 {
        int sf = ReadByte();
+       int slot = ReadByte();
        entity flash;
 
        if(isnew)
        {
                int gunalign = W_GunAlign(NULL, STAT(GUNALIGN));
 
-               this.beam_shotorigin = arc_shotorigin[gunalign];
+               this.beam_shotorigin = arc_shotorigin[gunalign]; // quick
+               for(int j = 1; j < 5; ++j)
+               {
+                       if(gunaligns[j] == viewmodels[slot])
+                       {
+                               this.beam_shotorigin = arc_shotorigin[j - 1]; // accurate
+                               break;
+                       }
+               }
 
                // set other main attributes of the beam
                this.draw = Draw_ArcBeam;
index c2b93747c8c4c14d7d9437f6c50e2cc2934b8d89..7ba71aaa733078bfd309a2ab8a134fdb512ab59e 100644 (file)
@@ -314,7 +314,7 @@ void W_Fireball_Attack2(entity actor, .entity weaponentity)
        vector f_diff;
        float c;
 
-       c = actor.bulletcounter % 4;
+       c = actor.(weaponentity).bulletcounter % 4;
        switch(c)
        {
                case 0:
index fb22362328d1c9b97207dbe075302699ef2fdeb0..ca5ecf4dd652ead869c7026a07489271eb5e4106 100644 (file)
@@ -337,7 +337,7 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity)
 
        W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, flac_ammo), weaponentity);
 
-       c = actor.bulletcounter % 4;
+       c = actor.(weaponentity).bulletcounter % 4;
        switch(c)
        {
                case 0:
index 036867888d9e96dc10c8557e51a368435a71e269..cfd846d0c5df19179be8e4a48e5caab4f49dca8c 100644 (file)
@@ -15,6 +15,7 @@ MACRO_END
 .Weapon w_m_switchingweapon;
 .Weapon w_m_weapon;
 //.float w_weapon_nextthink;
+.float w_m_alpha;
 
 // #define PROP(public, fld, set, sv, cl)
 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
@@ -29,6 +30,10 @@ MACRO_END
     PROP(false, m_weapon, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.m_weapon.m_id); }, \
        { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
+    \
+    PROP(false, m_alpha, WEPENT_SET_NORMAL, \
+       { WriteByte(chan, this.m_alpha * 16); }, \
+       { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
     \
        /**/
 
index 3b8047efa19184abedfa0da26394ec0fdb0797f9..45838350018d2fc87d774dca1131a0696845e2e1 100644 (file)
@@ -290,7 +290,7 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponenti
        {
                int slot = weaponslot(weaponentity);
                // don't fire if previous attack is not finished
-               if (ATTACK_FINISHED(actor, slot) > time + actor.weapon_frametime * 0.5) return false;
+               if (ATTACK_FINISHED(actor, slot) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
                entity this = actor.(weaponentity);
                // don't fire while changing weapon
                if (this.state != WS_READY) return false;
@@ -310,14 +310,14 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary,
        if (attacktime >= 0)
        {
                int slot = weaponslot(weaponentity);
-               if (ATTACK_FINISHED(actor, slot) < time - actor.weapon_frametime * 1.5)
+               if (ATTACK_FINISHED(actor, slot) < time - this.weapon_frametime * 1.5)
                {
                        ATTACK_FINISHED(actor, slot) = time;
                        // dprint("resetting attack finished to ", ftos(time), "\n");
                }
                ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor);
        }
-       actor.bulletcounter += 1;
+       actor.(weaponentity).bulletcounter += 1;
        // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
 }
 
@@ -381,8 +381,8 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(
                this.weapon_nextthink = time;
                // dprint("started firing at ", ftos(time), "\n");
        }
-       if (this.weapon_nextthink < time - actor.weapon_frametime * 1.5
-           || this.weapon_nextthink > time + actor.weapon_frametime * 1.5)
+       if (this.weapon_nextthink < time - this.weapon_frametime * 1.5
+           || this.weapon_nextthink > time + this.weapon_frametime * 1.5)
        {
                this.weapon_nextthink = time;
                // dprint("reset weapon animation timer at ", ftos(time), "\n");
@@ -401,8 +401,8 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(
 
        if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
        {
-               bool primary_melee = boolean(fr == WFRAME_FIRE1 && (actor.(weaponentity).m_weapon.spawnflags & WEP_TYPE_MELEE_PRI));
-               bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (actor.(weaponentity).m_weapon.spawnflags & WEP_TYPE_MELEE_SEC));
+               bool primary_melee = boolean(fr == WFRAME_FIRE1 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_PRI));
+               bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_SEC));
                int act = (primary_melee || secondary_melee)
                        ? ANIMACTION_MELEE
                        : ANIMACTION_SHOOT
@@ -434,14 +434,14 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
     TC(Player, actor);
     TC(PlayerState, PS(actor));
        entity this = actor.(weaponentity);
-       if (frametime) actor.weapon_frametime = frametime;
+       if (frametime) this.weapon_frametime = frametime;
 
        if (!this || actor.health < 1) return;  // Dead player can't use weapons and injure impulse commands
 
 
        if (forbidWeaponUse(actor))
        {
-               if (actor.(weaponentity).state != WS_CLEAR)
+               if (this.state != WS_CLEAR)
                {
                        Weapon wpn = this.m_weapon;
                        w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
@@ -484,7 +484,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                // the two weapon entities will notice this has changed and update their models
                                this.m_weapon = newwep;
                                this.weaponname = newwep.mdl;
-                               actor.bulletcounter = 0;
+                               this.bulletcounter = 0;
                                actor.ammo_field = newwep.ammo_field;
                                newwep.wr_setup(newwep, actor);
                                this.state = WS_RAISE;
@@ -516,7 +516,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                entity oldwep = this.m_weapon;
 
                                // set up weapon switch think in the future, and start drop anim
-                               if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + actor.weapon_frametime * 0.5)
+                               if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + this.weapon_frametime * 0.5)
                                {
                                        sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
                                        this.state = WS_DROP;
@@ -585,7 +585,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                        }
                }
 
-               if (time + actor.weapon_frametime * 0.5 >= this.weapon_nextthink)
+               if (time + this.weapon_frametime * 0.5 >= this.weapon_nextthink)
                {
                        if (this.weapon_think)
                        {