X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fhagar.qc;h=684ee75d377540a15de2911269dbf6ccf078d982;hb=5352a65c86ae185b0ff5c412d1eb1208912c17ab;hp=433ceefe2958fedc3a003e921deac6813a03988e;hpb=df2fe9b28cb6210b671bec6d5ae834ff4eb2e2db;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 433ceefe2..684ee75d3 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -1,12 +1,13 @@ +#include "hagar.qh" #ifndef IMPLEMENTATION CLASS(Hagar, Weapon) -/* ammotype */ ATTRIB(Hagar, ammo_field, .int, ammo_rockets) -/* impulse */ ATTRIB(Hagar, impulse, int, 8) +/* ammotype */ ATTRIB(Hagar, ammo_field, .int, ammo_rockets); +/* impulse */ ATTRIB(Hagar, impulse, int, 8); /* flags */ ATTRIB(Hagar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Hagar, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID); /* color */ ATTRIB(Hagar, wpcolor, vector, '1 1 0.5'); /* modelname */ ATTRIB(Hagar, mdl, string, "hagar"); -#ifndef MENUQC +#ifdef GAMEQC /* model */ ATTRIB(Hagar, m_model, Model, MDL_HAGAR_ITEM); #endif /* crosshair */ ATTRIB(Hagar, w_crosshair, string, "gfx/crosshairhagar"); @@ -63,30 +64,30 @@ spawnfunc(weapon_hagar) { weapon_defaultspawnfunc(this, WEP_HAGAR); } // NO bounce protection, as bounces are limited! -void W_Hagar_Explode(entity this) +void W_Hagar_Explode(entity this, entity directhitentity) { this.event_damage = func_null; - RadiusDamage(this, this.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), world, world, WEP_CVAR_PRI(hagar, force), this.projectiledeathtype, other); + RadiusDamage(this, this.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), NULL, NULL, WEP_CVAR_PRI(hagar, force), this.projectiledeathtype, directhitentity); - remove(this); + delete(this); } void W_Hagar_Explode_use(entity this, entity actor, entity trigger) { - W_Hagar_Explode(this); + W_Hagar_Explode(this, trigger); } -void W_Hagar_Explode2(entity this) +void W_Hagar_Explode2(entity this, entity directhitentity) { this.event_damage = func_null; - RadiusDamage(this, this.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), world, world, WEP_CVAR_SEC(hagar, force), this.projectiledeathtype, other); + RadiusDamage(this, this.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), NULL, NULL, WEP_CVAR_SEC(hagar, force), this.projectiledeathtype, directhitentity); - remove(this); + delete(this); } void W_Hagar_Explode2_use(entity this, entity actor, entity trigger) { - W_Hagar_Explode2(this); + W_Hagar_Explode2(this, trigger); } void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) @@ -94,7 +95,7 @@ void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage if(this.health <= 0) return; - float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == this.owner) : true) + float is_linkexplode = ( ((inflictor.owner != NULL) ? (inflictor.owner == this.owner) : true) && (inflictor.projectiledeathtype & HITTYPE_SECONDARY) && (this.projectiledeathtype & HITTYPE_SECONDARY)); @@ -113,34 +114,34 @@ void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage W_PrepareExplosionByDamage(this, attacker, getthink(this)); } -void W_Hagar_Touch(entity this) +void W_Hagar_Touch(entity this, entity toucher) { - PROJECTILE_TOUCH(this); - this.use(this, NULL, NULL); + PROJECTILE_TOUCH(this, toucher); + this.use(this, NULL, toucher); } -void W_Hagar_Touch2(entity this) +void W_Hagar_Touch2(entity this, entity toucher) { - PROJECTILE_TOUCH(this); + PROJECTILE_TOUCH(this, toucher); - if(this.cnt > 0 || other.takedamage == DAMAGE_AIM) { - this.use(this, NULL, NULL); + if(this.cnt > 0 || toucher.takedamage == DAMAGE_AIM) { + this.use(this, NULL, toucher); } else { this.cnt++; Send_Effect(EFFECT_HAGAR_BOUNCE, this.origin, this.velocity, 1); this.angles = vectoangles(this.velocity); - this.owner = world; + this.owner = NULL; this.projectiledeathtype |= HITTYPE_BOUNCE; } } -void W_Hagar_Attack(Weapon thiswep, entity actor) +void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hagar, ammo)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -154,6 +155,7 @@ void W_Hagar_Attack(Weapon thiswep, entity actor) missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale); missile.event_damage = W_Hagar_Damage; missile.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, missile); settouch(missile, W_Hagar_Touch); missile.use = W_Hagar_Explode_use; @@ -164,11 +166,13 @@ void W_Hagar_Attack(Weapon thiswep, entity actor) setorigin(missile, w_shotorg); setsize(missile, '0 0 0', '0 0 0'); - missile.movetype = MOVETYPE_FLY; + set_movetype(missile, MOVETYPE_FLY); W_SetupProjVelocity_PRI(missile, hagar); missile.angles = vectoangles(missile.velocity); missile.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, missile); + IL_PUSH(g_bot_dodge, missile); missile.missile_flags = MIF_SPLASH; CSQCProjectile(missile, true, PROJECTILE_HAGAR, true); @@ -176,13 +180,13 @@ void W_Hagar_Attack(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, missile); } -void W_Hagar_Attack2(Weapon thiswep, entity actor) +void W_Hagar_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -196,6 +200,7 @@ void W_Hagar_Attack2(Weapon thiswep, entity actor) missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale); missile.event_damage = W_Hagar_Damage; missile.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, missile); settouch(missile, W_Hagar_Touch2); missile.cnt = 0; @@ -207,11 +212,13 @@ void W_Hagar_Attack2(Weapon thiswep, entity actor) setorigin(missile, w_shotorg); setsize(missile, '0 0 0', '0 0 0'); - missile.movetype = MOVETYPE_BOUNCEMISSILE; + set_movetype(missile, MOVETYPE_BOUNCEMISSILE); W_SetupProjVelocity_SEC(missile, hagar); missile.angles = vectoangles(missile.velocity); missile.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, missile); + IL_PUSH(g_bot_dodge, missile); missile.missile_flags = MIF_SPLASH; CSQCProjectile(missile, true, PROJECTILE_HAGAR_BOUNCING, true); @@ -234,7 +241,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire)); - W_SetupShot(actor, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); + W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); forward = v_forward; @@ -242,7 +249,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) up = v_up; shots = actor.hagar_load; - missile = world; + missile = NULL; for(counter = 0; counter < shots; ++counter) { missile = new(missile); @@ -255,6 +262,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale); missile.event_damage = W_Hagar_Damage; missile.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, missile); settouch(missile, W_Hagar_Touch); // not bouncy missile.use = W_Hagar_Explode2_use; @@ -264,7 +272,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) missile.projectiledeathtype = WEP_HAGAR.m_id | HITTYPE_SECONDARY; setorigin(missile, w_shotorg); setsize(missile, '0 0 0', '0 0 0'); - missile.movetype = MOVETYPE_FLY; + set_movetype(missile, MOVETYPE_FLY); missile.missile_flags = MIF_SPLASH; // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar) @@ -288,6 +296,8 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) missile.angles = vectoangles(missile.velocity); missile.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, missile); + IL_PUSH(g_bot_dodge, missile); CSQCProjectile(missile, true, PROJECTILE_HAGAR, true); @@ -409,7 +419,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - if(!(fire & 1) || actor.hagar_load || actor.hagar_loadblock) + if(!(fire & 1) || actor.hagar_load || actor.hagar_loadblock || PS(actor).m_switchweapon != WEP_HAGAR) { w_ready(thiswep, actor, weaponentity, fire); return; @@ -423,7 +433,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int return; } - W_Hagar_Attack(thiswep, actor); + W_Hagar_Attack(thiswep, actor, weaponentity); int slot = weaponslot(weaponentity); ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor); @@ -463,19 +473,18 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire))) { - W_Hagar_Attack2(thiswep, actor); + W_Hagar_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready); } } } -METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor)) +METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor, .entity weaponentity)) { // we lost the weapon and want to prepare switching away if(actor.hagar_load) { - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - actor.(weaponentity).state = WS_READY; - W_Hagar_Attack2_Load_Release(actor, weaponentity); + actor.(weaponentity).state = WS_READY; + W_Hagar_Attack2_Load_Release(actor, weaponentity); } } METHOD(Hagar, wr_setup, void(entity thiswep, entity actor)) @@ -504,17 +513,16 @@ METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor)) { actor.hagar_load = 0; } -METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor)) +METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor, .entity weaponentity)) { - .entity weaponentity = weaponentities[0]; // TODO: unhardcode // if we have any rockets loaded when we die, release them if(actor.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath)) - W_Hagar_Attack2_Load_Release(actor, weaponentity); + W_Hagar_Attack2_Load_Release(actor, weaponentity); } METHOD(Hagar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { if(!actor.hagar_load) // require releasing loaded rockets first - W_Reload(actor, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD); } METHOD(Hagar, wr_suicidemessage, Notification(entity thiswep)) {