From 3f8d5c3f18ce666a76355843475c50d95bd124e2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 8 Aug 2016 20:42:34 +1000 Subject: [PATCH] Make some arc fields slot/weaponentity specific --- qcsrc/common/weapons/weapon/arc.qc | 71 ++++++++++++++++-------------- qcsrc/server/cl_client.qc | 20 ++++++++- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 0a5995100..2f78116ef 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -101,7 +101,7 @@ const int ARC_SF_LOCALMASK = ARC_SF_START | ARC_SF_WANTDIR | ARC_SF_BEAMDIR; #endif #ifdef SVQC .entity arc_beam; -.bool arc_BUTTON_ATCK_prev; // for better animation control +.bool arc_BUTTON_ATCK_prev[MAX_WEAPONSLOTS]; // for better animation control .float beam_prev; .float beam_initialized; .float beam_bursting; @@ -199,14 +199,17 @@ bool W_Arc_Beam_Send(entity this, entity to, int sf) void Reset_ArcBeam(entity player, vector forward) { - if (!player.arc_beam) { - return; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(!player.(weaponentity).arc_beam) + continue; + player.(weaponentity).arc_beam.beam_dir = forward; + player.(weaponentity).arc_beam.beam_teleporttime = time; } - player.arc_beam.beam_dir = forward; - player.arc_beam.beam_teleporttime = time; } -float Arc_GetHeat_Percent(entity player) +float Arc_GetHeat_Percent(entity player, .entity weaponentity) { if ( WEP_CVAR(arc, overheat_max) <= 0 || WEP_CVAR(arc, overheat_max) <= 0 ) { @@ -214,8 +217,8 @@ float Arc_GetHeat_Percent(entity player) return 0; } - if ( player.arc_beam ) - return player.arc_beam.beam_heat/WEP_CVAR(arc, overheat_max); + if ( player.(weaponentity).arc_beam ) + return player.(weaponentity).arc_beam.beam_heat/WEP_CVAR(arc, overheat_max); if ( player.arc_overheat > time ) { @@ -225,9 +228,9 @@ float Arc_GetHeat_Percent(entity player) return 0; } -void Arc_Player_SetHeat(entity player) +void Arc_Player_SetHeat(entity player, .entity weaponentity) { - player.arc_heat_percent = Arc_GetHeat_Percent(player); + player.arc_heat_percent = Arc_GetHeat_Percent(player, weaponentity); //dprint("Heat: ",ftos(player.arc_heat_percent*100),"%\n"); } @@ -309,13 +312,13 @@ void W_Arc_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) void W_Arc_Beam_Think(entity this) { - if(this != this.owner.arc_beam) + .entity weaponentity = this.weaponentity_fld; + if(this != this.owner.(weaponentity).arc_beam) { delete(this); return; } - float burst = 0; if( (PHYS_INPUT_BUTTON_ATCK2(this.owner) && !WEP_CVAR(arc, bolt)) || this.beam_bursting) { @@ -369,7 +372,7 @@ void W_Arc_Beam_Think(entity this) } } - if(this == this.owner.arc_beam) { this.owner.arc_beam = NULL; } + if(this == this.owner.(weaponentity).arc_beam) { this.owner.(weaponentity).arc_beam = NULL; } entity own = this.owner; Weapon w = WEP_ARC; if(!w.wr_checkammo1(w, own) && !w.wr_checkammo2(w, own)) @@ -405,7 +408,7 @@ void W_Arc_Beam_Think(entity this) W_SetupShot_Range( this.owner, - weaponentities[0], // TODO + weaponentity, // TODO true, 0, SND_Null, @@ -673,14 +676,15 @@ void W_Arc_Beam_Think(entity this) this.nextthink = time; } -void W_Arc_Beam(float burst, entity actor) +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) sound(actor, CH_WEAPON_A, SND_ARC_FIRE, VOL_BASE, ATTN_NORM); - entity beam = actor.arc_beam = new(W_Arc_Beam); + entity beam = actor.(weaponentity).arc_beam = new(W_Arc_Beam); + beam.weaponentity_fld = weaponentity; beam.solid = SOLID_NOT; setthink(beam, W_Arc_Beam_Think); beam.owner = actor; @@ -712,10 +716,10 @@ void Arc_Smoke(entity actor, .entity weaponentity) } } } - else if ( actor.arc_beam && WEP_CVAR(arc, overheat_max) > 0 && - actor.arc_beam.beam_heat > WEP_CVAR(arc, overheat_min) ) + else if ( actor.(weaponentity).arc_beam && WEP_CVAR(arc, overheat_max) > 0 && + actor.(weaponentity).arc_beam.beam_heat > WEP_CVAR(arc, overheat_min) ) { - if ( random() < (actor.arc_beam.beam_heat-WEP_CVAR(arc, overheat_min)) / + if ( random() < (actor.(weaponentity).arc_beam.beam_heat-WEP_CVAR(arc, overheat_min)) / ( WEP_CVAR(arc, overheat_max)-WEP_CVAR(arc, overheat_min) ) ) Send_Effect(EFFECT_ARC_SMOKE, smoke_origin, '0 0 0', 1 ); } @@ -753,16 +757,17 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor)) } METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - Arc_Player_SetHeat(actor); + Arc_Player_SetHeat(actor, weaponentity); Arc_Smoke(actor, weaponentity); bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt)); + int slot = weaponslot(weaponentity); if (time >= actor.arc_overheat) - if ((fire & 1) || beam_fire2 || actor.arc_beam.beam_bursting) + if ((fire & 1) || beam_fire2 || actor.(weaponentity).arc_beam.beam_bursting) { - if(actor.arc_BUTTON_ATCK_prev) + if(actor.arc_BUTTON_ATCK_prev[slot]) { #if 0 if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y) @@ -772,16 +777,16 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), w_ready); } - if((!actor.arc_beam) || wasfreed(actor.arc_beam)) + if((!actor.(weaponentity).arc_beam) || wasfreed(actor.(weaponentity).arc_beam)) { if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(beam_fire2), 0)) { - W_Arc_Beam(boolean(beam_fire2), actor); + W_Arc_Beam(boolean(beam_fire2), actor, weaponentity); - if(!actor.arc_BUTTON_ATCK_prev) + if(!actor.arc_BUTTON_ATCK_prev[slot]) { weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - actor.arc_BUTTON_ATCK_prev = true; + actor.arc_BUTTON_ATCK_prev[slot] = true; } } } @@ -797,14 +802,13 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i } } - if(actor.arc_BUTTON_ATCK_prev) + if(actor.arc_BUTTON_ATCK_prev[slot]) { sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - int slot = weaponslot(weaponentity); ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor); } - actor.arc_BUTTON_ATCK_prev = false; + actor.arc_BUTTON_ATCK_prev[slot] = false; #if 0 if(fire & 2) @@ -856,7 +860,8 @@ METHOD(Arc, wr_drop, void(entity thiswep, entity actor)) weapon_dropevent_item.arc_cooldown = actor.arc_cooldown; actor.arc_overheat = 0; actor.arc_cooldown = 0; - actor.arc_BUTTON_ATCK_prev = false; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + actor.arc_BUTTON_ATCK_prev[slot] = false; } METHOD(Arc, wr_pickup, void(entity thiswep, entity actor)) { @@ -871,13 +876,15 @@ METHOD(Arc, wr_resetplayer, void(entity thiswep, entity actor)) { actor.arc_overheat = 0; actor.arc_cooldown = 0; - actor.arc_BUTTON_ATCK_prev = false; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + actor.arc_BUTTON_ATCK_prev[slot] = false; } METHOD(Arc, wr_playerdeath, void(entity thiswep, entity actor)) { actor.arc_overheat = 0; actor.arc_cooldown = 0; - actor.arc_BUTTON_ATCK_prev = false; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + actor.arc_BUTTON_ATCK_prev[slot] = false; } #endif #ifdef CSQC diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index a8bd4e735..d50b89857 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1733,8 +1733,24 @@ void SetSpectatee(entity this, entity spectatee) // WEAPONTODO // these are required to fix the spectator bug with arc - if(old_spectatee && old_spectatee.arc_beam) { old_spectatee.arc_beam.SendFlags |= ARC_SF_SETTINGS; } - if(this.enemy && this.enemy.arc_beam) { this.enemy.arc_beam.SendFlags |= ARC_SF_SETTINGS; } + if(old_spectatee) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(old_spectatee.(weaponentity).arc_beam) + old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS; + } + } + if(this.enemy) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.enemy.(weaponentity).arc_beam) + this.enemy.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS; + } + } // needed to update spectator list if(old_spectatee) { ClientData_Touch(old_spectatee); } -- 2.39.2