X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fmortar.qc;h=56338da17182d72edbc50b1887e3fbb968786e8b;hb=00d7a93f67cca196b2781899d5510b6aaf9816d7;hp=61fa98b4b5544df6233fd595973be9e35b957f9e;hpb=67db56b06d6333621dc19ba3b8dcf8976f5acfbb;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 61fa98b4b..6e2bc91cf 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -1,68 +1,6 @@ -#ifndef IMPLEMENTATION -CLASS(Mortar, Weapon) -/* ammotype */ ATTRIB(Mortar, ammo_field, .int, ammo_rockets) -/* impulse */ ATTRIB(Mortar, impulse, int, 4) -/* flags */ ATTRIB(Mortar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); -/* rating */ ATTRIB(Mortar, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID); -/* color */ ATTRIB(Mortar, wpcolor, vector, '1 0 0'); -/* modelname */ ATTRIB(Mortar, mdl, string, "gl"); -#ifndef MENUQC -/* model */ ATTRIB(Mortar, m_model, Model, MDL_MORTAR_ITEM); -#endif -/* crosshair */ ATTRIB(Mortar, w_crosshair, string, "gfx/crosshairgrenadelauncher"); -/* crosshair */ ATTRIB(Mortar, w_crosshair_size, float, 0.7); -/* wepimg */ ATTRIB(Mortar, model2, string, "weapongrenadelauncher"); -/* refname */ ATTRIB(Mortar, netname, string, "mortar"); -/* wepname */ ATTRIB(Mortar, m_name, string, _("Mortar")); - -#define X(BEGIN, P, END, class, prefix) \ - BEGIN(class) \ - P(class, prefix, ammo, float, BOTH) \ - P(class, prefix, animtime, float, BOTH) \ - P(class, prefix, bouncefactor, float, NONE) \ - P(class, prefix, bouncestop, float, NONE) \ - P(class, prefix, damageforcescale, float, BOTH) \ - P(class, prefix, damage, float, BOTH) \ - P(class, prefix, edgedamage, float, BOTH) \ - P(class, prefix, force, float, BOTH) \ - P(class, prefix, health, float, BOTH) \ - P(class, prefix, lifetime, float, BOTH) \ - P(class, prefix, lifetime_bounce, float, SEC) \ - P(class, prefix, lifetime_stick, float, BOTH) \ - P(class, prefix, radius, float, BOTH) \ - P(class, prefix, refire, float, BOTH) \ - P(class, prefix, reload_ammo, float, NONE) \ - P(class, prefix, reload_time, float, NONE) \ - P(class, prefix, remote_detonateprimary, float, SEC) \ - P(class, prefix, remote_minbouncecnt, float, PRI) \ - P(class, prefix, speed, float, BOTH) \ - P(class, prefix, speed_up, float, BOTH) \ - P(class, prefix, speed_z, float, BOTH) \ - P(class, prefix, spread, float, BOTH) \ - P(class, prefix, switchdelay_drop, float, NONE) \ - P(class, prefix, switchdelay_raise, float, NONE) \ - P(class, prefix, type, float, BOTH) \ - P(class, prefix, weaponreplace, string, NONE) \ - P(class, prefix, weaponstartoverride, float, NONE) \ - P(class, prefix, weaponstart, float, NONE) \ - P(class, prefix, weaponthrowable, float, NONE) \ - END() - W_PROPS(X, Mortar, mortar) -#undef X -ENDCLASS(Mortar) -REGISTER_WEAPON(MORTAR, mortar, NEW(Mortar)); - +#include "mortar.qh" #ifdef SVQC -.float gl_detonate_later; -.float gl_bouncecnt; -#endif -#endif -#ifdef IMPLEMENTATION -#ifdef SVQC - -spawnfunc(weapon_mortar) { weapon_defaultspawnfunc(this, WEP_MORTAR); } -spawnfunc(weapon_grenadelauncher) { spawnfunc_weapon_mortar(this); } void W_Mortar_Grenade_Explode(entity this, entity directhitentity) { @@ -79,7 +17,7 @@ void W_Mortar_Grenade_Explode(entity this, entity directhitentity) if(this.move_movetype == MOVETYPE_NONE) this.velocity = this.oldvelocity; - RadiusDamage(this, this.realowner, WEP_CVAR_PRI(mortar, damage), WEP_CVAR_PRI(mortar, edgedamage), WEP_CVAR_PRI(mortar, radius), NULL, NULL, WEP_CVAR_PRI(mortar, force), this.projectiledeathtype, directhitentity); + RadiusDamage(this, this.realowner, WEP_CVAR_PRI(mortar, damage), WEP_CVAR_PRI(mortar, edgedamage), WEP_CVAR_PRI(mortar, radius), NULL, NULL, WEP_CVAR_PRI(mortar, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); delete(this); } @@ -104,7 +42,7 @@ void W_Mortar_Grenade_Explode2(entity this, entity directhitentity) if(this.move_movetype == MOVETYPE_NONE) this.velocity = this.oldvelocity; - RadiusDamage(this, this.realowner, WEP_CVAR_SEC(mortar, damage), WEP_CVAR_SEC(mortar, edgedamage), WEP_CVAR_SEC(mortar, radius), NULL, NULL, WEP_CVAR_SEC(mortar, force), this.projectiledeathtype, directhitentity); + RadiusDamage(this, this.realowner, WEP_CVAR_SEC(mortar, damage), WEP_CVAR_SEC(mortar, edgedamage), WEP_CVAR_SEC(mortar, radius), NULL, NULL, WEP_CVAR_SEC(mortar, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); delete(this); } @@ -114,17 +52,17 @@ void W_Mortar_Grenade_Explode2_use(entity this, entity actor, entity trigger) W_Mortar_Grenade_Explode2(this, trigger); } -void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(this.health <= 0) + if(GetResourceAmount(this, RESOURCE_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, RESOURCE_HEALTH, damage); - if(this.health <= 0) + if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) W_PrepareExplosionByDamage(this, attacker, adaptor_think2use); } @@ -150,14 +88,14 @@ void W_Mortar_Grenade_Touch1(entity this, entity toucher) } else if(WEP_CVAR_PRI(mortar, type) == 1) // bounce { - spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTN_NORM); + spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTN_NORM); Send_Effect(EFFECT_HAGAR_BOUNCE, this.origin, this.velocity, 1); this.projectiledeathtype |= HITTYPE_BOUNCE; this.gl_bouncecnt += 1; } else if(WEP_CVAR_PRI(mortar, type) == 2 && (!toucher || (toucher.takedamage != DAMAGE_AIM && toucher.move_movetype == MOVETYPE_NONE))) // stick { - spamsound(this, CH_SHOTS, SND(GRENADE_STICK), VOL_BASE, ATTN_NORM); + spamsound(this, CH_SHOTS, SND_GRENADE_STICK, VOL_BASE, ATTN_NORM); // let it stick whereever it is this.oldvelocity = this.velocity; @@ -182,7 +120,7 @@ void W_Mortar_Grenade_Touch2(entity this, entity toucher) } else if(WEP_CVAR_SEC(mortar, type) == 1) // bounce { - spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTN_NORM); + spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTN_NORM); Send_Effect(EFFECT_HAGAR_BOUNCE, this.origin, this.velocity, 1); this.projectiledeathtype |= HITTYPE_BOUNCE; this.gl_bouncecnt += 1; @@ -193,7 +131,7 @@ void W_Mortar_Grenade_Touch2(entity this, entity toucher) } else if(WEP_CVAR_SEC(mortar, type) == 2 && (!toucher || (toucher.takedamage != DAMAGE_AIM && toucher.move_movetype == MOVETYPE_NONE))) // stick { - spamsound(this, CH_SHOTS, SND(GRENADE_STICK), VOL_BASE, ATTN_NORM); + spamsound(this, CH_SHOTS, SND_GRENADE_STICK, VOL_BASE, ATTN_NORM); // let it stick whereever it is this.oldvelocity = this.velocity; @@ -211,9 +149,9 @@ void W_Mortar_Grenade_Touch2(entity this, entity toucher) void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(mortar, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(mortar, ammo), weaponentity); - W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage), thiswep.m_id); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -226,7 +164,8 @@ void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity) gren.bouncefactor = WEP_CVAR(mortar, bouncefactor); gren.bouncestop = WEP_CVAR(mortar, bouncestop); PROJECTILE_MAKETRIGGER(gren); - gren.projectiledeathtype = WEP_MORTAR.m_id; + gren.projectiledeathtype = thiswep.m_id; + gren.weaponentity_fld = weaponentity; setorigin(gren, w_shotorg); setsize(gren, '-3 -3 -3', '3 3 3'); @@ -237,16 +176,18 @@ void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity) settouch(gren, W_Mortar_Grenade_Touch1); gren.takedamage = DAMAGE_YES; - gren.health = WEP_CVAR_PRI(mortar, health); + SetResourceAmountExplicit(gren, RESOURCE_HEALTH, WEP_CVAR_PRI(mortar, health)); gren.damageforcescale = WEP_CVAR_PRI(mortar, damageforcescale); gren.event_damage = W_Mortar_Grenade_Damage; gren.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, gren); gren.missile_flags = MIF_SPLASH | MIF_ARC; W_SetupProjVelocity_UP_PRI(gren, mortar); gren.angles = vectoangles(gren.velocity); gren.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, gren); + IL_PUSH(g_bot_dodge, gren); if(WEP_CVAR_PRI(mortar, type) == 0 || WEP_CVAR_PRI(mortar, type) == 2) CSQCProjectile(gren, true, PROJECTILE_GRENADE, true); @@ -260,9 +201,9 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity gren; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(mortar, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(mortar, ammo), weaponentity); - W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage), thiswep.m_id | HITTYPE_SECONDARY); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -275,7 +216,8 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) gren.bouncefactor = WEP_CVAR(mortar, bouncefactor); gren.bouncestop = WEP_CVAR(mortar, bouncestop); PROJECTILE_MAKETRIGGER(gren); - gren.projectiledeathtype = WEP_MORTAR.m_id | HITTYPE_SECONDARY; + gren.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY; + gren.weaponentity_fld = weaponentity; setorigin(gren, w_shotorg); setsize(gren, '-3 -3 -3', '3 3 3'); @@ -285,16 +227,18 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) settouch(gren, W_Mortar_Grenade_Touch2); gren.takedamage = DAMAGE_YES; - gren.health = WEP_CVAR_SEC(mortar, health); + SetResourceAmountExplicit(gren, RESOURCE_HEALTH, WEP_CVAR_SEC(mortar, health)); gren.damageforcescale = WEP_CVAR_SEC(mortar, damageforcescale); gren.event_damage = W_Mortar_Grenade_Damage; gren.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, gren); gren.missile_flags = MIF_SPLASH | MIF_ARC; W_SetupProjVelocity_UP_SEC(gren, mortar); gren.angles = vectoangles(gren.velocity); gren.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, gren); + IL_PUSH(g_bot_dodge, gren); if(WEP_CVAR_SEC(mortar, type) == 0 || WEP_CVAR_SEC(mortar, type) == 2) CSQCProjectile(gren, true, PROJECTILE_GRENADE, true); @@ -306,13 +250,13 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) .float bot_secondary_grenademooth; -METHOD(Mortar, wr_aim, void(entity thiswep, entity actor)) +METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { PHYS_INPUT_BUTTON_ATCK(actor) = false; PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(actor.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH { - if(bot_aim(actor, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK(actor) = true; if(random() < 0.01) actor.bot_secondary_grenademooth = 1; @@ -320,7 +264,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor)) } else { - if(bot_aim(actor, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.02) actor.bot_secondary_grenademooth = 0; @@ -345,7 +289,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor)) */ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload + if(autocvar_g_balance_mortar_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else if(fire & 1) { @@ -360,15 +304,14 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity if(WEP_CVAR_SEC(mortar, remote_detonateprimary)) { bool nadefound = false; - entity nade; - for(nade = NULL; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == actor) + IL_EACH(g_projectiles, it.realowner == actor && it.classname == "grenade", { - if(!nade.gl_detonate_later) + if(!it.gl_detonate_later) { - nade.gl_detonate_later = true; + it.gl_detonate_later = true; nadefound = true; } - } + }); if(nadefound) sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); } @@ -379,16 +322,16 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor)) +METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo); - ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(mortar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(mortar, ammo); return ammo_amount; } -METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor)) +METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo); - ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(mortar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(mortar, ammo); return ammo_amount; } METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) @@ -423,4 +366,3 @@ METHOD(Mortar, wr_impacteffect, void(entity thiswep, entity actor)) } #endif -#endif