X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fdevastator.qc;h=7bae89368b3ec992524b61c2aa78f01eaeec6d70;hp=df9bd470a31b9fe70caaf68cde8a2d4ff6aebf7f;hb=a3d9634886e52c442bd9d68a86b8df77e6ed26ed;hpb=80869a0c1266387f4ffe026fc31930ff4d5eac83 diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index df9bd470a3..7bae89368b 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -63,7 +63,7 @@ ENDCLASS(Devastator) REGISTER_WEAPON(DEVASTATOR, devastator, NEW(Devastator)); #ifdef SVQC -.float rl_release[MAX_WEAPONSLOTS]; +.float rl_release; .float rl_detonate_later; #endif #endif @@ -116,15 +116,16 @@ void W_Devastator_Explode(entity this, entity directhitentity) ); Weapon thiswep = WEP_DEVASTATOR; - if(PS(this.realowner).m_weapon == thiswep) + .entity weaponentity = this.weaponentity_fld; + if(this.realowner.(weaponentity).m_weapon == thiswep) { if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) { this.realowner.cnt = WEP_DEVASTATOR.m_id; - int slot = 0; // TODO: unhardcode + int slot = weaponslot(weaponentity); ATTACK_FINISHED(this.realowner, slot) = time; - PS(this.realowner).m_switchweapon = w_getbestweapon(this.realowner); + this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity); } } delete(this); @@ -208,7 +209,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) ); Weapon thiswep = WEP_DEVASTATOR; - if(PS(this.realowner).m_weapon == thiswep) + if(this.realowner.(weaponentity).m_weapon == thiswep) { if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) @@ -216,7 +217,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) this.realowner.cnt = WEP_DEVASTATOR.m_id; int slot = weaponslot(weaponentity); ATTACK_FINISHED(this.realowner, slot) = time; - PS(this.realowner).m_switchweapon = w_getbestweapon(this.realowner); + this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity); } } delete(this); @@ -289,13 +290,11 @@ void W_Devastator_Think(entity this) this.velocity = this.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor(this.realowner) * frametime, velspeed); // laser guided, or remote detonation - if(PS(this.realowner).m_weapon == WEP_DEVASTATOR) + .entity weaponentity = this.weaponentity_fld; + if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR) { - .entity weaponentity = this.weaponentity_fld; - int slot = weaponslot(weaponentity); - if(this == this.realowner.(weaponentity).lastrocket) - if(!this.realowner.rl_release[slot]) + if(!this.realowner.(weaponentity).rl_release) if(!PHYS_INPUT_BUTTON_ATCK2(this)) if(WEP_CVAR(devastator, guiderate)) if(time > this.pushltime) @@ -368,7 +367,7 @@ void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float d void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo), weaponentity); W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -423,10 +422,10 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) MUTATOR_CALLHOOK(EditProjectile, actor, missile); } -METHOD(Devastator, wr_aim, void(entity thiswep, entity actor)) +METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { // aim and decide to fire if appropriate - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false); if(skill >= 2) // skill 0 and 1 bots won't detonate rockets! { // decide whether to detonate rockets @@ -504,25 +503,24 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor)) METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload + if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else { - int slot = weaponslot(weaponentity); if(fire & 1) { - if(actor.rl_release[slot] || WEP_CVAR(devastator, guidestop)) + if(actor.(weaponentity).rl_release || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire))) { W_Devastator_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); - actor.rl_release[slot] = 0; + actor.(weaponentity).rl_release = 0; } } else - actor.rl_release[slot] = 1; + actor.(weaponentity).rl_release = 1; if(fire & 2) - if(PS(actor).m_switchweapon == WEP_DEVASTATOR) + if(actor.(weaponentity).m_switchweapon == WEP_DEVASTATOR) { bool rockfound = false; IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket", @@ -538,12 +536,11 @@ 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) - actor.rl_release[slot] = 1; + actor.(weaponentity).rl_release = 1; } -METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor)) +METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { #if 0 // don't switch while guiding a missile @@ -552,7 +549,7 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor)) ammo_amount = false; if(WEP_CVAR(devastator, reload_ammo)) { - if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) + if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) ammo_amount = true; } else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) @@ -569,17 +566,17 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor)) else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); - ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); return ammo_amount; } #else float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); - ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); return ammo_amount; #endif } -METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor)) +METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { return false; } @@ -589,7 +586,7 @@ METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor)) { .entity weaponentity = weaponentities[slot]; actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave! - actor.rl_release[slot] = 0; + actor.(weaponentity).rl_release = 0; } } METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))