X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fmortar.qc;h=1f019ac81518dba3738504addb97606de345b7dd;hb=393022c0e9b00481e68d1db786e96e4ffb7f37e0;hp=5f56f19db19b2080d7255318562d150ee2be1787;hpb=edf01df130d0d1877461561178b8833a9ab6051c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 5f56f19db..1f019ac81 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -1,12 +1,13 @@ +#include "mortar.qh" #ifndef IMPLEMENTATION CLASS(Mortar, Weapon) -/* ammotype */ ATTRIB(Mortar, ammo_field, .int, ammo_rockets) -/* impulse */ ATTRIB(Mortar, impulse, int, 4) +/* 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 +#ifdef GAMEQC /* model */ ATTRIB(Mortar, m_model, Model, MDL_MORTAR_ITEM); #endif /* crosshair */ ATTRIB(Mortar, w_crosshair, string, "gfx/crosshairgrenadelauncher"); @@ -64,54 +65,54 @@ REGISTER_WEAPON(MORTAR, mortar, NEW(Mortar)); spawnfunc(weapon_mortar) { weapon_defaultspawnfunc(this, WEP_MORTAR); } spawnfunc(weapon_grenadelauncher) { spawnfunc_weapon_mortar(this); } -void W_Mortar_Grenade_Explode(entity this) +void W_Mortar_Grenade_Explode(entity this, entity directhitentity) { - if(other.takedamage == DAMAGE_AIM) - if(IS_PLAYER(other)) - if(DIFF_TEAM(this.realowner, other)) - if(!IS_DEAD(other)) - if(IsFlying(other)) + if(directhitentity.takedamage == DAMAGE_AIM) + if(IS_PLAYER(directhitentity)) + if(DIFF_TEAM(this.realowner, directhitentity)) + if(!IS_DEAD(directhitentity)) + if(IsFlying(directhitentity)) Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); this.event_damage = func_null; this.takedamage = DAMAGE_NO; - if(this.movetype == MOVETYPE_NONE) + 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, 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, directhitentity); - remove(this); + delete(this); } void W_Mortar_Grenade_Explode_use(entity this, entity actor, entity trigger) { - W_Mortar_Grenade_Explode(this); + W_Mortar_Grenade_Explode(this, trigger); } -void W_Mortar_Grenade_Explode2(entity this) +void W_Mortar_Grenade_Explode2(entity this, entity directhitentity) { - if(other.takedamage == DAMAGE_AIM) - if(IS_PLAYER(other)) - if(DIFF_TEAM(this.realowner, other)) - if(!IS_DEAD(other)) - if(IsFlying(other)) + if(directhitentity.takedamage == DAMAGE_AIM) + if(IS_PLAYER(directhitentity)) + if(DIFF_TEAM(this.realowner, directhitentity)) + if(!IS_DEAD(directhitentity)) + if(IsFlying(directhitentity)) Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); this.event_damage = func_null; this.takedamage = DAMAGE_NO; - if(this.movetype == MOVETYPE_NONE) + 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, 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, directhitentity); - remove(this); + delete(this); } void W_Mortar_Grenade_Explode2_use(entity this, entity actor, entity trigger) { - W_Mortar_Grenade_Explode2(this); + 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) @@ -133,21 +134,20 @@ void W_Mortar_Grenade_Think1(entity this) this.nextthink = time; if(time > this.cnt) { - other = NULL; this.projectiledeathtype |= HITTYPE_BOUNCE; - W_Mortar_Grenade_Explode(this); + W_Mortar_Grenade_Explode(this, NULL); return; } if(this.gl_detonate_later && this.gl_bouncecnt >= WEP_CVAR_PRI(mortar, remote_minbouncecnt)) - W_Mortar_Grenade_Explode(this); + W_Mortar_Grenade_Explode(this, NULL); } -void W_Mortar_Grenade_Touch1(entity this) +void W_Mortar_Grenade_Touch1(entity this, entity toucher) { - 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 + PROJECTILE_TOUCH(this, toucher); + if(toucher.takedamage == DAMAGE_AIM || WEP_CVAR_PRI(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile { - this.use(this, NULL, NULL); + this.use(this, NULL, toucher); } else if(WEP_CVAR_PRI(mortar, type) == 1) // bounce { @@ -156,14 +156,14 @@ void W_Mortar_Grenade_Touch1(entity this) 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 + 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); // let it stick whereever it is this.oldvelocity = this.velocity; this.velocity = '0 0 0'; - this.movetype = MOVETYPE_NONE; // also disables gravity + set_movetype(this, MOVETYPE_NONE); // also disables gravity this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO UpdateCSQCProjectile(this); @@ -174,12 +174,12 @@ void W_Mortar_Grenade_Touch1(entity this) } } -void W_Mortar_Grenade_Touch2(entity this) +void W_Mortar_Grenade_Touch2(entity this, entity toucher) { - 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 + PROJECTILE_TOUCH(this, toucher); + if(toucher.takedamage == DAMAGE_AIM || WEP_CVAR_SEC(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile { - this.use(this, NULL, NULL); + this.use(this, NULL, toucher); } else if(WEP_CVAR_SEC(mortar, type) == 1) // bounce { @@ -192,14 +192,14 @@ void W_Mortar_Grenade_Touch2(entity this) 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 + 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); // let it stick whereever it is this.oldvelocity = this.velocity; this.velocity = '0 0 0'; - this.movetype = MOVETYPE_NONE; // also disables gravity + set_movetype(this, MOVETYPE_NONE); // also disables gravity this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO UpdateCSQCProjectile(this); @@ -210,22 +210,20 @@ void W_Mortar_Grenade_Touch2(entity this) } } -void W_Mortar_Attack(Weapon thiswep, entity actor) +void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - entity gren; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(mortar, ammo)); - W_SetupShot_ProjectileSize(actor, '-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)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - gren = new(grenade); + entity gren = new(grenade); gren.owner = gren.realowner = actor; gren.bot_dodge = true; gren.bot_dodgerating = WEP_CVAR_PRI(mortar, damage); - gren.movetype = MOVETYPE_BOUNCE; + set_movetype(gren, MOVETYPE_BOUNCE); gren.bouncefactor = WEP_CVAR(mortar, bouncefactor); gren.bouncestop = WEP_CVAR(mortar, bouncestop); PROJECTILE_MAKETRIGGER(gren); @@ -244,11 +242,14 @@ void W_Mortar_Attack(Weapon thiswep, entity actor) 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); @@ -258,13 +259,13 @@ void W_Mortar_Attack(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, gren); } -void W_Mortar_Attack2(Weapon thiswep, entity actor) +void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity gren; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(mortar, ammo)); - W_SetupShot_ProjectileSize(actor, '-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)); w_shotdir = v_forward; // no TrueAim for grenades please Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -273,7 +274,7 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor) gren.owner = gren.realowner = actor; gren.bot_dodge = true; gren.bot_dodgerating = WEP_CVAR_SEC(mortar, damage); - gren.movetype = MOVETYPE_BOUNCE; + set_movetype(gren, MOVETYPE_BOUNCE); gren.bouncefactor = WEP_CVAR(mortar, bouncefactor); gren.bouncestop = WEP_CVAR(mortar, bouncestop); PROJECTILE_MAKETRIGGER(gren); @@ -291,11 +292,14 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor) 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); @@ -352,7 +356,7 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire))) { - W_Mortar_Attack(thiswep, actor); + W_Mortar_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); } } @@ -375,7 +379,7 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire))) { - W_Mortar_Attack2(thiswep, actor); + W_Mortar_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); } } @@ -394,7 +398,7 @@ METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor)) } 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 + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO } METHOD(Mortar, wr_suicidemessage, Notification(entity thiswep)) {