From: Mario Date: Tue, 13 Feb 2018 00:21:24 +0000 (+1000) Subject: Move some weapon stats into wepent fields, and make spectating weapons a bit more... X-Git-Tag: xonotic-v0.8.5~2313^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a4f308123b521372793edfb0747dc718de0cfc48;p=xonotic%2Fxonotic-data.pk3dir.git Move some weapon stats into wepent fields, and make spectating weapons a bit more reliable --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 2c10ae9ff..cf7ca8087 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1195,26 +1195,24 @@ void HUD_Crosshair(entity this) weapon_clipload = STAT(WEAPON_CLIPLOAD); weapon_clipsize = STAT(WEAPON_CLIPSIZE); - float vortex_charge, vortex_chargepool; - vortex_charge = STAT(VORTEX_CHARGE); - vortex_chargepool = STAT(VORTEX_CHARGEPOOL); + entity wepent = viewmodels[0]; // TODO: unhardcode - float arc_heat = STAT(ARC_HEAT); + float arc_heat = wepent.arc_heat_percent; + float vcharge = wepent.vortex_charge; + float vchargepool = wepent.vortex_chargepool_ammo; if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game - vortex_charge_movingavg = vortex_charge; - - entity wepent = viewmodels[0]; // TODO: unhardcode + vortex_charge_movingavg = vcharge; // handle the values - if (autocvar_crosshair_ring && wepent.activeweapon == WEP_VORTEX && vortex_charge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex + if (autocvar_crosshair_ring && wepent.activeweapon == WEP_VORTEX && vcharge && autocvar_crosshair_ring_vortex) // ring around crosshair representing velocity-dependent damage for the vortex { - if (vortex_chargepool || use_vortex_chargepool) { + if (vchargepool || use_vortex_chargepool) { use_vortex_chargepool = 1; - ring_inner_value = vortex_chargepool; + ring_inner_value = vchargepool; } else { - vortex_charge_movingavg = (1 - autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate) * vortex_charge_movingavg + autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate * vortex_charge; - ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (vortex_charge - vortex_charge_movingavg), 1); + vortex_charge_movingavg = (1 - autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate) * vortex_charge_movingavg + autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate * vcharge; + ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (vcharge - vortex_charge_movingavg), 1); } ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha; @@ -1222,21 +1220,21 @@ void HUD_Crosshair(entity this) ring_inner_image = "gfx/crosshair_ring_inner.tga"; // draw the outer ring to show the current charge of the weapon - ring_value = vortex_charge; + ring_value = vcharge; ring_alpha = autocvar_crosshair_ring_vortex_alpha; ring_rgb = wcross_color; ring_image = "gfx/crosshair_ring_nexgun.tga"; } else if (autocvar_crosshair_ring && wepent.activeweapon == WEP_MINE_LAYER && WEP_CVAR(minelayer, limit) && autocvar_crosshair_ring_minelayer) { - ring_value = bound(0, STAT(LAYED_MINES) / WEP_CVAR(minelayer, limit), 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to. + ring_value = bound(0, wepent.minelayer_mines / WEP_CVAR(minelayer, limit), 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to. ring_alpha = autocvar_crosshair_ring_minelayer_alpha; ring_rgb = wcross_color; ring_image = "gfx/crosshair_ring.tga"; } - else if (wepent.activeweapon == WEP_HAGAR && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar) + else if (wepent.activeweapon == WEP_HAGAR && wepent.hagar_load && autocvar_crosshair_ring_hagar) { - ring_value = bound(0, STAT(HAGAR_LOAD) / WEP_CVAR_SEC(hagar, load_max), 1); + ring_value = bound(0, wepent.hagar_load / WEP_CVAR_SEC(hagar, load_max), 1); ring_alpha = autocvar_crosshair_ring_hagar_alpha; ring_rgb = wcross_color; ring_image = "gfx/crosshair_ring.tga"; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index daa1d3c8b..e3ff0b3d4 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -73,7 +73,6 @@ REGISTER_STAT(GAMESTARTTIME, float, game_starttime) REGISTER_STAT(STRENGTH_FINISHED, float) REGISTER_STAT(INVINCIBLE_FINISHED, float) /** arc heat in [0,1] */ -REGISTER_STAT(ARC_HEAT, float) REGISTER_STAT(PRESSED_KEYS, int) /** this stat could later contain some other bits of info, like, more server-side particle config */ REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool, autocvar_g_allow_oldvortexbeam) @@ -85,15 +84,11 @@ REGISTER_STAT(LEADLIMIT, float, autocvar_leadlimit) REGISTER_STAT(WEAPON_CLIPLOAD, int) REGISTER_STAT(WEAPON_CLIPSIZE, int) -REGISTER_STAT(VORTEX_CHARGE, float) REGISTER_STAT(LAST_PICKUP, float) REGISTER_STAT(HUD, int) -REGISTER_STAT(VORTEX_CHARGEPOOL, float) REGISTER_STAT(HIT_TIME, float) REGISTER_STAT(DAMAGE_DEALT_TOTAL, int) REGISTER_STAT(TYPEHIT_TIME, float) -REGISTER_STAT(LAYED_MINES, int) -REGISTER_STAT(HAGAR_LOAD, int) REGISTER_STAT(SUPERWEAPONS_FINISHED, float) REGISTER_STAT(VEHICLESTAT_HEALTH, int) REGISTER_STAT(VEHICLESTAT_SHIELD, int) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 23e3dbcb2..763a979df 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -87,7 +87,7 @@ float Arc_GetHeat_Percent(entity player, .entity weaponentity) } void Arc_Player_SetHeat(entity player, .entity weaponentity) { - player.arc_heat_percent = Arc_GetHeat_Percent(player, weaponentity); + player.(weaponentity).arc_heat_percent = Arc_GetHeat_Percent(player, weaponentity); //dprint("Heat: ",ftos(player.arc_heat_percent*100),"%\n"); } @@ -565,7 +565,7 @@ void Arc_Smoke(entity actor, .entity weaponentity) vector smoke_origin = w_shotorg + actor.velocity*frametime; if ( actor.arc_overheat > time ) { - if ( random() < actor.arc_heat_percent ) + if ( random() < actor.(weaponentity).arc_heat_percent ) Send_Effect(EFFECT_ARC_SMOKE, smoke_origin, '0 0 0', 1 ); if ( PHYS_INPUT_BUTTON_ATCK(actor) || PHYS_INPUT_BUTTON_ATCK2(actor) ) { diff --git a/qcsrc/common/weapons/weapon/arc.qh b/qcsrc/common/weapons/weapon/arc.qh index 4ec2d4edc..187e58402 100644 --- a/qcsrc/common/weapons/weapon/arc.qh +++ b/qcsrc/common/weapons/weapon/arc.qh @@ -112,7 +112,7 @@ const int ARC_SF_LOCALMASK = ARC_SF_START | ARC_SF_WANTDIR | ARC_SF_BEAMDIR; .float beam_heat; // (beam) amount of heat produced .float arc_overheat; // (dropped arc/player) time during which it's too hot .float arc_cooldown; // (dropped arc/player) cooling speed -.float arc_heat_percent = _STAT(ARC_HEAT); +.float arc_heat_percent; .float arc_smoke_sound; #endif #ifdef CSQC diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index ff2e74539..b7c4c8c16 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -247,9 +247,6 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready); actor.(weaponentity).hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(actor); actor.(weaponentity).hagar_load = 0; - - if(weaponslot(weaponentity) == 0) - actor.hagar_load = 0; } void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) @@ -283,8 +280,6 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) actor.(weaponentity).state = WS_READY; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.(weaponentity).hagar_load * -1, weaponentity); // give back ammo actor.(weaponentity).hagar_load = 0; - if(weaponslot(weaponentity) == 0) - actor.hagar_load = 0; sound(actor, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM); // pause until we can load rockets again, once we re-press the alt fire button @@ -404,8 +399,6 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { float loadable_secondary; loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary)); - if(weaponslot(weaponentity) == 0) - actor.hagar_load = actor.(weaponentity).hagar_load; if(loadable_secondary) W_Hagar_Attack2_Load(thiswep, actor, weaponentity); // must always run each frame @@ -437,7 +430,6 @@ METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor, .entity weaponent } METHOD(Hagar, wr_setup, void(entity thiswep, entity actor, .entity weaponentity)) { - actor.hagar_load = 0; actor.(weaponentity).hagar_loadblock = false; if(actor.(weaponentity).hagar_load) { @@ -459,7 +451,6 @@ METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponen } METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor)) { - actor.hagar_load = 0; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 575b76d72..727ac08c6 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -446,9 +446,6 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit } METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - if(weaponslot(weaponentity) == 0) - actor.minelayer_mines = actor.(weaponentity).minelayer_mines; - if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload { // not if we're holding the minelayer without enough ammo, but can detonate existing mines @@ -492,7 +489,6 @@ METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weap } METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor)) { - actor.minelayer_mines = 0; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 257faed6b..7790d681f 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -168,9 +168,6 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity if(WEP_CVAR(vortex, charge) && actor.(weaponentity).vortex_charge < WEP_CVAR(vortex, charge_limit)) actor.(weaponentity).vortex_charge = min(1, actor.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME); - if(weaponslot(weaponentity) == 0) - actor.vortex_charge = actor.(weaponentity).vortex_charge; - if(WEP_CVAR_SEC(vortex, chargepool)) if(actor.(weaponentity).vortex_chargepool_ammo < 1) { @@ -179,9 +176,6 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen)); } - if(weaponslot(weaponentity) == 0) - actor.vortex_chargepool_ammo = actor.(weaponentity).vortex_chargepool_ammo; - if(autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else @@ -296,10 +290,6 @@ METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapone METHOD(Vortex, wr_resetplayer, void(entity thiswep, entity actor)) { if (WEP_CVAR(vortex, charge)) { - if (WEP_CVAR_SEC(vortex, chargepool)) { - actor.vortex_chargepool_ammo = 1; - } - actor.vortex_charge = WEP_CVAR(vortex, charge_start); for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; diff --git a/qcsrc/common/wepent.qc b/qcsrc/common/wepent.qc index 8d74a7b32..36ab27dfa 100644 --- a/qcsrc/common/wepent.qc +++ b/qcsrc/common/wepent.qc @@ -41,6 +41,22 @@ MACRO_END PROP(false, tuba_instrument, WEPENT_SET_NORMAL, \ { WriteByte(chan, this.tuba_instrument); }, \ { (viewmodels[this.m_wepent_slot]).tuba_instrument = ReadByte(); }) \ + \ + PROP(false, hagar_load, WEPENT_SET_NORMAL, \ + { WriteByte(chan, this.hagar_load); }, \ + { (viewmodels[this.m_wepent_slot]).hagar_load = ReadByte(); }) \ + \ + PROP(false, minelayer_mines, WEPENT_SET_NORMAL, \ + { WriteByte(chan, this.minelayer_mines); }, \ + { (viewmodels[this.m_wepent_slot]).minelayer_mines = ReadByte(); }) \ + \ + PROP(false, arc_heat_percent, WEPENT_SET_NORMAL, \ + { WriteByte(chan, this.arc_heat_percent * 16); }, \ + { (viewmodels[this.m_wepent_slot]).arc_heat_percent = ReadByte() / 16; }) \ + \ + PROP(false, vortex_chargepool_ammo, WEPENT_SET_NORMAL, \ + { WriteByte(chan, this.vortex_chargepool_ammo * 16); }, \ + { (viewmodels[this.m_wepent_slot]).vortex_chargepool_ammo = ReadByte() / 16; }) \ \ /**/ @@ -115,9 +131,9 @@ MACRO_END bool wepent_customize(entity this, entity client) { - //entity e = WaypointSprite_getviewentity(client); + entity e = WaypointSprite_getviewentity(client); .entity weaponentity = this.owner.weaponentity_fld; - return client.(weaponentity) == this.owner; + return e.(weaponentity) == this.owner; } void wepent_link(entity wep) diff --git a/qcsrc/common/wepent.qh b/qcsrc/common/wepent.qh index 46180d7c0..ad2bba02e 100644 --- a/qcsrc/common/wepent.qh +++ b/qcsrc/common/wepent.qh @@ -4,7 +4,11 @@ REGISTER_NET_LINKED(ENT_CLIENT_WEPENT) REGISTER_NET_TEMP(CLIENT_WEPENT) .float vortex_charge; +.float vortex_chargepool_ammo; .int tuba_instrument; +.int minelayer_mines; +.float arc_heat_percent; +.int hagar_load; #ifdef SVQC diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c460f9dde..7dc26025e 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1776,11 +1776,6 @@ void SpectateCopy(entity this, entity spectatee) this.superweapons_finished = spectatee.superweapons_finished; STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee); this.weapons = spectatee.weapons; - this.vortex_charge = spectatee.vortex_charge; - this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo; - this.hagar_load = spectatee.hagar_load; - this.arc_heat_percent = spectatee.arc_heat_percent; - this.minelayer_mines = spectatee.minelayer_mines; this.punchangle = spectatee.punchangle; this.view_ofs = spectatee.view_ofs; this.velocity = spectatee.velocity; @@ -1798,12 +1793,6 @@ void SpectateCopy(entity this, entity spectatee) setsize(this, spectatee.mins, spectatee.maxs); SetZoomState(this, CS(spectatee).zoomstate); - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - { - .entity weaponentity = weaponentities[slot]; - this.(weaponentity) = spectatee.(weaponentity); - } - anticheat_spectatecopy(this, spectatee); this.hud = spectatee.hud; if(spectatee.vehicle) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index df94c7781..52f269845 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -328,11 +328,11 @@ float client_cefc_accumulatortime; .float old_clip_load; .float clip_size = _STAT(WEAPON_CLIPSIZE); -.float minelayer_mines = _STAT(LAYED_MINES); -.float vortex_charge = _STAT(VORTEX_CHARGE); +.int minelayer_mines; +.float vortex_charge; .float vortex_charge_rottime; -.float vortex_chargepool_ammo = _STAT(VORTEX_CHARGEPOOL); -.float hagar_load = _STAT(HAGAR_LOAD); +.float vortex_chargepool_ammo; +.int hagar_load; .int grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and team mates can grab, 3 = anyone can grab