X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fmortar.qc;h=5f56f19db19b2080d7255318562d150ee2be1787;hb=fc15d72b041c9a748b605ba28735380fbe5b5b01;hp=36a3c0c9e66f9c5ee515ad17d057cf8bff2dc4d6;hpb=43eba8ca70f00458db385630f86009f6d7fa849a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 36a3c0c9e..5f56f19db 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -14,43 +14,46 @@ CLASS(Mortar, Weapon) /* 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, NEW(Mortar)); - -#define MORTAR_SETTINGS(w_cvar,w_prop) MORTAR_SETTINGS_LIST(w_cvar, w_prop, MORTAR, mortar) -#define MORTAR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \ - w_cvar(id, sn, BOTH, ammo) \ - w_cvar(id, sn, BOTH, animtime) \ - w_cvar(id, sn, NONE, bouncefactor) \ - w_cvar(id, sn, NONE, bouncestop) \ - w_cvar(id, sn, BOTH, damage) \ - w_cvar(id, sn, BOTH, damageforcescale) \ - w_cvar(id, sn, BOTH, edgedamage) \ - w_cvar(id, sn, BOTH, force) \ - w_cvar(id, sn, BOTH, health) \ - w_cvar(id, sn, BOTH, lifetime) \ - w_cvar(id, sn, SEC, lifetime_bounce) \ - w_cvar(id, sn, BOTH, lifetime_stick) \ - w_cvar(id, sn, BOTH, radius) \ - w_cvar(id, sn, BOTH, refire) \ - w_cvar(id, sn, SEC, remote_detonateprimary) \ - w_cvar(id, sn, PRI, remote_minbouncecnt) \ - w_cvar(id, sn, BOTH, speed) \ - w_cvar(id, sn, BOTH, speed_up) \ - w_cvar(id, sn, BOTH, speed_z) \ - w_cvar(id, sn, BOTH, spread) \ - w_cvar(id, sn, BOTH, type) \ - w_prop(id, sn, float, reloading_ammo, reload_ammo) \ - w_prop(id, sn, float, reloading_time, reload_time) \ - w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \ - w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \ - w_prop(id, sn, string, weaponreplace, weaponreplace) \ - w_prop(id, sn, float, weaponstart, weaponstart) \ - w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \ - w_prop(id, sn, float, weaponthrowable, weaponthrowable) +REGISTER_WEAPON(MORTAR, mortar, NEW(Mortar)); + #ifdef SVQC -MORTAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .float gl_detonate_later; .float gl_bouncecnt; #endif @@ -61,156 +64,165 @@ MORTAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) spawnfunc(weapon_mortar) { weapon_defaultspawnfunc(this, WEP_MORTAR); } spawnfunc(weapon_grenadelauncher) { spawnfunc_weapon_mortar(this); } -void W_Mortar_Grenade_Explode() -{SELFPARAM(); +void W_Mortar_Grenade_Explode(entity this) +{ if(other.takedamage == DAMAGE_AIM) if(IS_PLAYER(other)) - if(DIFF_TEAM(self.realowner, other)) - if(other.deadflag == DEAD_NO) + if(DIFF_TEAM(this.realowner, other)) + if(!IS_DEAD(other)) if(IsFlying(other)) - Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); + Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); - self.event_damage = func_null; - self.takedamage = DAMAGE_NO; + this.event_damage = func_null; + this.takedamage = DAMAGE_NO; - if(self.movetype == MOVETYPE_NONE) - self.velocity = self.oldvelocity; + if(this.movetype == MOVETYPE_NONE) + this.velocity = this.oldvelocity; - RadiusDamage(self, self.realowner, WEP_CVAR_PRI(mortar, damage), WEP_CVAR_PRI(mortar, edgedamage), WEP_CVAR_PRI(mortar, radius), world, world, WEP_CVAR_PRI(mortar, force), self.projectiledeathtype, other); + 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, other); + + remove(this); +} - remove(self); +void W_Mortar_Grenade_Explode_use(entity this, entity actor, entity trigger) +{ + W_Mortar_Grenade_Explode(this); } -void W_Mortar_Grenade_Explode2() -{SELFPARAM(); +void W_Mortar_Grenade_Explode2(entity this) +{ if(other.takedamage == DAMAGE_AIM) if(IS_PLAYER(other)) - if(DIFF_TEAM(self.realowner, other)) - if(other.deadflag == DEAD_NO) + if(DIFF_TEAM(this.realowner, other)) + if(!IS_DEAD(other)) if(IsFlying(other)) - Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); + Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); - self.event_damage = func_null; - self.takedamage = DAMAGE_NO; + this.event_damage = func_null; + this.takedamage = DAMAGE_NO; - if(self.movetype == MOVETYPE_NONE) - self.velocity = self.oldvelocity; + if(this.movetype == MOVETYPE_NONE) + this.velocity = this.oldvelocity; - RadiusDamage(self, self.realowner, WEP_CVAR_SEC(mortar, damage), WEP_CVAR_SEC(mortar, edgedamage), WEP_CVAR_SEC(mortar, radius), world, world, WEP_CVAR_SEC(mortar, force), self.projectiledeathtype, other); + 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, other); - remove(self); + remove(this); } +void W_Mortar_Grenade_Explode2_use(entity this, entity actor, entity trigger) +{ + W_Mortar_Grenade_Explode2(this); +} -void W_Mortar_Grenade_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); - if(self.health <= 0) +void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{ + if(this.health <= 0) return; - if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions + if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions return; // g_projectiles_damage says to halt - self.health = self.health - damage; + this.health = this.health - damage; - if(self.health <= 0) - W_PrepareExplosionByDamage(attacker, self.use); + if(this.health <= 0) + W_PrepareExplosionByDamage(this, attacker, adaptor_think2use); } -void W_Mortar_Grenade_Think1() -{SELFPARAM(); - self.nextthink = time; - if(time > self.cnt) +void W_Mortar_Grenade_Think1(entity this) +{ + this.nextthink = time; + if(time > this.cnt) { - other = world; - self.projectiledeathtype |= HITTYPE_BOUNCE; - W_Mortar_Grenade_Explode(); + other = NULL; + this.projectiledeathtype |= HITTYPE_BOUNCE; + W_Mortar_Grenade_Explode(this); return; } - if(self.gl_detonate_later && self.gl_bouncecnt >= WEP_CVAR_PRI(mortar, remote_minbouncecnt)) - W_Mortar_Grenade_Explode(); + if(this.gl_detonate_later && this.gl_bouncecnt >= WEP_CVAR_PRI(mortar, remote_minbouncecnt)) + W_Mortar_Grenade_Explode(this); } -void W_Mortar_Grenade_Touch1() -{SELFPARAM(); - PROJECTILE_TOUCH; +void W_Mortar_Grenade_Touch1(entity this) +{ + PROJECTILE_TOUCH(this); if(other.takedamage == DAMAGE_AIM || WEP_CVAR_PRI(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile { - self.use(); + this.use(this, NULL, NULL); } else if(WEP_CVAR_PRI(mortar, type) == 1) // bounce { - spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTN_NORM); - Send_Effect(EFFECT_HAGAR_BOUNCE, self.origin, self.velocity, 1); - self.projectiledeathtype |= HITTYPE_BOUNCE; - self.gl_bouncecnt += 1; + 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 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick { - spamsound(self, 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 - self.oldvelocity = self.velocity; - self.velocity = '0 0 0'; - self.movetype = MOVETYPE_NONE; // also disables gravity - self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO - UpdateCSQCProjectile(self); + this.oldvelocity = this.velocity; + this.velocity = '0 0 0'; + this.movetype = MOVETYPE_NONE; // also disables gravity + this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO + UpdateCSQCProjectile(this); // do not respond to any more touches - self.solid = SOLID_NOT; + this.solid = SOLID_NOT; - self.nextthink = min(self.nextthink, time + WEP_CVAR_PRI(mortar, lifetime_stick)); + this.nextthink = min(this.nextthink, time + WEP_CVAR_PRI(mortar, lifetime_stick)); } } -void W_Mortar_Grenade_Touch2() -{SELFPARAM(); - PROJECTILE_TOUCH; +void W_Mortar_Grenade_Touch2(entity this) +{ + PROJECTILE_TOUCH(this); if(other.takedamage == DAMAGE_AIM || WEP_CVAR_SEC(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile { - self.use(); + this.use(this, NULL, NULL); } else if(WEP_CVAR_SEC(mortar, type) == 1) // bounce { - spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTN_NORM); - Send_Effect(EFFECT_HAGAR_BOUNCE, self.origin, self.velocity, 1); - self.projectiledeathtype |= HITTYPE_BOUNCE; - self.gl_bouncecnt += 1; + 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; - if(WEP_CVAR_SEC(mortar, lifetime_bounce) && self.gl_bouncecnt == 1) - self.nextthink = time + WEP_CVAR_SEC(mortar, lifetime_bounce); + if(WEP_CVAR_SEC(mortar, lifetime_bounce) && this.gl_bouncecnt == 1) + this.nextthink = time + WEP_CVAR_SEC(mortar, lifetime_bounce); } else if(WEP_CVAR_SEC(mortar, type) == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick { - spamsound(self, 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 - self.oldvelocity = self.velocity; - self.velocity = '0 0 0'; - self.movetype = MOVETYPE_NONE; // also disables gravity - self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO - UpdateCSQCProjectile(self); + this.oldvelocity = this.velocity; + this.velocity = '0 0 0'; + this.movetype = MOVETYPE_NONE; // also disables gravity + this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO + UpdateCSQCProjectile(this); // do not respond to any more touches - self.solid = SOLID_NOT; + this.solid = SOLID_NOT; - self.nextthink = min(self.nextthink, time + WEP_CVAR_SEC(mortar, lifetime_stick)); + this.nextthink = min(this.nextthink, time + WEP_CVAR_SEC(mortar, lifetime_stick)); } } -void W_Mortar_Attack(Weapon thiswep) -{SELFPARAM(); +void W_Mortar_Attack(Weapon thiswep, entity actor) +{ entity gren; - W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(mortar, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(mortar, ammo)); - W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); + W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); gren = new(grenade); - gren.owner = gren.realowner = self; + gren.owner = gren.realowner = actor; gren.bot_dodge = true; gren.bot_dodgerating = WEP_CVAR_PRI(mortar, damage); gren.movetype = MOVETYPE_BOUNCE; @@ -223,9 +235,9 @@ void W_Mortar_Attack(Weapon thiswep) gren.cnt = time + WEP_CVAR_PRI(mortar, lifetime); gren.nextthink = time; - gren.think = W_Mortar_Grenade_Think1; - gren.use = W_Mortar_Grenade_Explode; - gren.touch = W_Mortar_Grenade_Touch1; + setthink(gren, W_Mortar_Grenade_Think1); + gren.use = W_Mortar_Grenade_Explode_use; + settouch(gren, W_Mortar_Grenade_Touch1); gren.takedamage = DAMAGE_YES; gren.health = WEP_CVAR_PRI(mortar, health); @@ -243,22 +255,22 @@ void W_Mortar_Attack(Weapon thiswep) else CSQCProjectile(gren, true, PROJECTILE_GRENADE_BOUNCING, true); - MUTATOR_CALLHOOK(EditProjectile, self, gren); + MUTATOR_CALLHOOK(EditProjectile, actor, gren); } -void W_Mortar_Attack2(Weapon thiswep) -{SELFPARAM(); +void W_Mortar_Attack2(Weapon thiswep, entity actor) +{ entity gren; - W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(mortar, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(mortar, ammo)); - W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); + W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); gren = new(grenade); - gren.owner = gren.realowner = self; + gren.owner = gren.realowner = actor; gren.bot_dodge = true; gren.bot_dodgerating = WEP_CVAR_SEC(mortar, damage); gren.movetype = MOVETYPE_BOUNCE; @@ -270,9 +282,9 @@ void W_Mortar_Attack2(Weapon thiswep) setsize(gren, '-3 -3 -3', '3 3 3'); gren.nextthink = time + WEP_CVAR_SEC(mortar, lifetime); - gren.think = adaptor_think2use_hittype_splash; - gren.use = W_Mortar_Grenade_Explode2; - gren.touch = W_Mortar_Grenade_Touch2; + setthink(gren, adaptor_think2use_hittype_splash); + gren.use = W_Mortar_Grenade_Explode2_use; + settouch(gren, W_Mortar_Grenade_Touch2); gren.takedamage = DAMAGE_YES; gren.health = WEP_CVAR_SEC(mortar, health); @@ -290,135 +302,126 @@ void W_Mortar_Attack2(Weapon thiswep) else CSQCProjectile(gren, true, PROJECTILE_GRENADE_BOUNCING, true); - MUTATOR_CALLHOOK(EditProjectile, self, gren); + MUTATOR_CALLHOOK(EditProjectile, actor, gren); } .float bot_secondary_grenademooth; - METHOD(Mortar, wr_aim, void(entity thiswep)) - { - self.BUTTON_ATCK = false; - self.BUTTON_ATCK2 = false; - if(self.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH - { - if(bot_aim(WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true)) - { - self.BUTTON_ATCK = true; - if(random() < 0.01) self.bot_secondary_grenademooth = 1; - } - } - else - { - if(bot_aim(WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true)) - { - self.BUTTON_ATCK2 = true; - if(random() < 0.02) self.bot_secondary_grenademooth = 0; - } - } - } - /*case WR_CALCINFO: - { - wepinfo_pri_refire = max3(sys_frametime, WEP_CVAR_PRI(mortar, refire), WEP_CVAR_PRI(mortar, animtime)); - wepinfo_pri_dps = (WEP_CVAR_PRI(mortar, damage) * (1 / wepinfo_pri_refire)); - wepinfo_pri_speed = (1 / max(1, (10000 / max(1, WEP_CVAR_PRI(mortar, speed))))); - - // for the range calculation, closer to 1 is better - wepinfo_pri_range_max = 2000 * wepinfo_pri_speed; - wepinfo_pri_range = wepinfo_pri_speed * WEP_CVAR_PRI(mortar, - - wepinfo_sec_refire = max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)); - wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / wepinfo_sec_refire)); - - wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)))); - wepinfo_ter_dps = 0; - */ - 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 - Weapon w = get_weaponinfo(actor.weapon); - w.wr_reload(w); - } else if(fire & 1) - { - if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire))) - { - W_Mortar_Attack(thiswep); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); - } - } - else if(fire & 2) - { - if(WEP_CVAR_SEC(mortar, remote_detonateprimary)) - { - bool nadefound = false; - entity nade; - for(nade = world; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == actor) - { - if(!nade.gl_detonate_later) - { - nade.gl_detonate_later = true; - nadefound = true; - } - } - if(nadefound) - sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); - } - else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire))) - { - W_Mortar_Attack2(thiswep); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); - } - } - } - METHOD(Mortar, wr_init, void(entity thiswep)) - { - MORTAR_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP); - } - METHOD(Mortar, wr_checkammo1, bool(entity thiswep)) - { - float ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_PRI(mortar, ammo); - ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo); - return ammo_amount; - } - METHOD(Mortar, wr_checkammo2, bool(entity thiswep)) - { - float ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_SEC(mortar, ammo); - ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo); - return ammo_amount; - } - METHOD(Mortar, wr_config, void(entity thiswep)) - { - MORTAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); - } - METHOD(Mortar, wr_reload, void(entity thiswep)) - { - W_Reload(self, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND(RELOAD)); // WEAPONTODO - } - METHOD(Mortar, wr_suicidemessage, int(entity thiswep)) - { - if(w_deathtype & HITTYPE_SECONDARY) - return WEAPON_MORTAR_SUICIDE_BOUNCE; - else - return WEAPON_MORTAR_SUICIDE_EXPLODE; - } - METHOD(Mortar, wr_killmessage, int(entity thiswep)) - { - if(w_deathtype & HITTYPE_SECONDARY) - return WEAPON_MORTAR_MURDER_BOUNCE; - else - return WEAPON_MORTAR_MURDER_EXPLODE; - } +METHOD(Mortar, wr_aim, void(entity thiswep, entity actor)) +{ + 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)) + { + PHYS_INPUT_BUTTON_ATCK(actor) = true; + if(random() < 0.01) actor.bot_secondary_grenademooth = 1; + } + } + else + { + if(bot_aim(actor, 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; + } + } +} +/*case WR_CALCINFO: +{ + wepinfo_pri_refire = max3(sys_frametime, WEP_CVAR_PRI(mortar, refire), WEP_CVAR_PRI(mortar, animtime)); + wepinfo_pri_dps = (WEP_CVAR_PRI(mortar, damage) * (1 / wepinfo_pri_refire)); + wepinfo_pri_speed = (1 / max(1, (10000 / max(1, WEP_CVAR_PRI(mortar, speed))))); + + // for the range calculation, closer to 1 is better + wepinfo_pri_range_max = 2000 * wepinfo_pri_speed; + wepinfo_pri_range = wepinfo_pri_speed * WEP_CVAR_PRI(mortar, + + wepinfo_sec_refire = max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)); + wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / wepinfo_sec_refire)); + + wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)))); + wepinfo_ter_dps = 0; + */ +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 + thiswep.wr_reload(thiswep, actor, weaponentity); + } else if(fire & 1) + { + if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire))) + { + W_Mortar_Attack(thiswep, actor); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); + } + } + else if(fire & 2) + { + if(WEP_CVAR_SEC(mortar, remote_detonateprimary)) + { + bool nadefound = false; + entity nade; + for(nade = NULL; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == actor) + { + if(!nade.gl_detonate_later) + { + nade.gl_detonate_later = true; + nadefound = true; + } + } + if(nadefound) + sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); + } + else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire))) + { + W_Mortar_Attack2(thiswep, actor); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); + } + } +} +METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor)) +{ + 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); + return ammo_amount; +} +METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor)) +{ + 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); + return ammo_amount; +} +METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) +{ + W_Reload(actor, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO +} +METHOD(Mortar, wr_suicidemessage, Notification(entity thiswep)) +{ + if(w_deathtype & HITTYPE_SECONDARY) + return WEAPON_MORTAR_SUICIDE_BOUNCE; + else + return WEAPON_MORTAR_SUICIDE_EXPLODE; +} +METHOD(Mortar, wr_killmessage, Notification(entity thiswep)) +{ + if(w_deathtype & HITTYPE_SECONDARY) + return WEAPON_MORTAR_MURDER_BOUNCE; + else + return WEAPON_MORTAR_MURDER_EXPLODE; +} #endif #ifdef CSQC - METHOD(Mortar, wr_impacteffect, void(entity thiswep)) - { - vector org2; - org2 = w_org + w_backoff * 12; - pointparticles(EFFECT_GRENADE_EXPLODE, org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTN_NORM); - } +METHOD(Mortar, wr_impacteffect, void(entity thiswep, entity actor)) +{ + vector org2; + org2 = w_org + w_backoff * 12; + pointparticles(EFFECT_GRENADE_EXPLODE, org2, '0 0 0', 1); + if(!w_issilent) + sound(actor, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTN_NORM); +} #endif #endif