X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fdevastator.qc;h=a77136b397f874bdd56f1b615125cc8d4f43f415;hp=c53e110fddb07a699988578d09067db6e73a462c;hb=1219bc076f56dc651a53f5d43acc74b329713f98;hpb=6acd27fcdb3e405b0eaa6b972880996e95f9808a diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index c53e110fdd..a77136b397 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -46,12 +46,11 @@ void W_Devastator_Explode(entity this, entity directhitentity) .entity weaponentity = this.weaponentity_fld; if(this.realowner.(weaponentity).m_weapon == thiswep) { - if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) + if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) { - this.realowner.cnt = WEP_DEVASTATOR.m_id; - int slot = weaponslot(weaponentity); - ATTACK_FINISHED(this.realowner, slot) = time; + this.realowner.cnt = thiswep.m_id; + ATTACK_FINISHED(this.realowner, weaponentity) = time; this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity); } } @@ -72,8 +71,11 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) bool handled_as_rocketjump = false; entity head = NULL; + bool allow_rocketjump = WEP_CVAR(devastator, remote_jump); + MUTATOR_CALLHOOK(AllowRocketJumping, allow_rocketjump); + allow_rocketjump = M_ARGV(0, bool); - if(WEP_CVAR(devastator, remote_jump_radius)) + if(allow_rocketjump && WEP_CVAR(devastator, remote_jump_radius)) { head = WarpZone_FindRadius( this.origin, @@ -140,12 +142,11 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) Weapon thiswep = WEP_DEVASTATOR; if(this.realowner.(weaponentity).m_weapon == thiswep) { - if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) + if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) { - this.realowner.cnt = WEP_DEVASTATOR.m_id; - int slot = weaponslot(weaponentity); - ATTACK_FINISHED(this.realowner, slot) = time; + this.realowner.cnt = thiswep.m_id; + ATTACK_FINISHED(this.realowner, weaponentity) = time; this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity); } } @@ -289,24 +290,24 @@ void W_Devastator_Touch(entity this, entity toucher) void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(this.health <= 0) + if(GetResource(this, RES_HEALTH) <= 0) return; if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions return; // g_projectiles_damage says to halt - this.health = this.health - damage; + TakeResource(this, RES_HEALTH, damage); this.angles = vectoangles(this.velocity); - if(this.health <= 0) + if(GetResource(this, RES_HEALTH) <= 0) W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think); } -void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) +void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int fire) { 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), WEP_DEVASTATOR.m_id); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage), thiswep.m_id); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); entity missile = WarpZone_RefSys_SpawnSameRefSys(actor); @@ -324,14 +325,14 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) missile.takedamage = DAMAGE_YES; missile.damageforcescale = WEP_CVAR(devastator, damageforcescale); - missile.health = WEP_CVAR(devastator, health); + SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(devastator, health)); missile.event_damage = W_Devastator_Damage; missile.damagedbycontents = true; IL_PUSH(g_damagedbycontents, missile); set_movetype(missile, MOVETYPE_FLY); PROJECTILE_MAKETRIGGER(missile); - missile.projectiledeathtype = WEP_DEVASTATOR.m_id; + missile.projectiledeathtype = thiswep.m_id; setsize(missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point @@ -342,6 +343,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) setthink(missile, W_Devastator_Think); missile.nextthink = time; missile.cnt = time + WEP_CVAR(devastator, lifetime); + missile.rl_detonate_later = (fire & 2); // allow instant detonation missile.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, missile); IL_PUSH(g_bot_dodge, missile); @@ -358,6 +360,11 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) // common properties MUTATOR_CALLHOOK(EditProjectile, actor, missile); + + if (time >= missile.nextthink) + { + getthink(missile)(missile); + } } METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) @@ -431,7 +438,7 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponenti // but don't fire a new shot at the same time! if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events PHYS_INPUT_BUTTON_ATCK2(actor) = true; - if((skill > 6.5) && (selfdamage > actor.health)) + if((skill > 6.5) && (selfdamage > GetResource(actor, RES_HEALTH))) PHYS_INPUT_BUTTON_ATCK2(actor) = false; //if(PHYS_INPUT_BUTTON_ATCK2(actor) == true) // dprint(ftos(desirabledamage),"\n"); @@ -449,7 +456,7 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen 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); + W_Devastator_Attack(thiswep, actor, weaponentity, fire); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); actor.(weaponentity).rl_release = 0; } @@ -458,7 +465,7 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen actor.(weaponentity).rl_release = 1; if(fire & 2) - if(actor.(weaponentity).m_switchweapon == WEP_DEVASTATOR) + if(actor.(weaponentity).m_switchweapon == thiswep) { bool rockfound = false; IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket", @@ -482,15 +489,15 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea { #if 0 // don't switch while guiding a missile - if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR) + if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_DEVASTATOR) { ammo_amount = false; if(WEP_CVAR(devastator, reload_ammo)) { - if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) + if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) ammo_amount = true; } - else if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) + else if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) ammo_amount = true; return !ammo_amount; } @@ -498,19 +505,19 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea #if 0 if(actor.rl_release == 0) { - LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo)); + LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo)); return true; } else { - ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo); + ammo_amount = GetResource(actor, thiswep.ammo_type) >= 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", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); + LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); return ammo_amount; } #else - float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo); - ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); + float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(devastator, ammo); return ammo_amount; #endif }