X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fhk_weapon.qc;h=dffe83c8283d135b220e0cd4509269de57be9458;hb=c0da80fe6125a43ee99a90808ac6f9d0ddcf88c8;hp=b083c6830eda791bcaa7de0f43cd3a44c4cfa08c;hpb=317ec3eb27ada1c4668876e9499136125acb7984;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index b083c6830..dffe83c82 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -1,15 +1,4 @@ -#ifndef TURRET_HK_WEAPON_H -#define TURRET_HK_WEAPON_H - -CLASS(HunterKillerAttack, PortoLaunch) -/* flags */ ATTRIB(HunterKillerAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); -/* impulse */ ATTRIB(HunterKillerAttack, impulse, int, 9); -/* refname */ ATTRIB(HunterKillerAttack, netname, string, "turret_hk"); -/* wepname */ ATTRIB(HunterKillerAttack, m_name, string, _("Hunter-Killer")); -ENDCLASS(HunterKillerAttack) -REGISTER_WEAPON(HK, NEW(HunterKillerAttack)); - -#endif +#include "hk_weapon.qh" #ifdef IMPLEMENTATION @@ -22,7 +11,7 @@ float autocvar_g_turrets_unit_hk_shot_speed_decel; float autocvar_g_turrets_unit_hk_shot_speed_max; float autocvar_g_turrets_unit_hk_shot_speed_turnrate; -void turret_hk_missile_think(); +void turret_hk_missile_think(entity this); SOUND(HunterKillerAttack_FIRE, W_Sound("electro_fire")); METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { @@ -31,16 +20,16 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); - W_SetupShot_Dir(actor, v_forward, false, 0, SND(HunterKillerAttack_FIRE), CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, v_forward, false, 0, SND_HunterKillerAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, FALSE, FALSE); + entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false); te_explosion (missile.origin); - missile.think = turret_hk_missile_think; + setthink(missile, turret_hk_missile_think); missile.nextthink = time + 0.25; missile.movetype = MOVETYPE_BOUNCEMISSILE; missile.velocity = actor.tur_shotdir_updated * (actor.shot_speed * 0.75); @@ -56,8 +45,8 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity } bool hk_is_valid_target(entity e_target); -void turret_hk_missile_think() -{SELFPARAM(); +void turret_hk_missile_think(entity this) +{ vector vu, vd, vf, vl, vr, ve; // Vector (direction) float fu, fd, ff, fl, fr, fe; // Fraction to solid vector olddir,wishdir,newdir; // Final direction @@ -74,7 +63,7 @@ void turret_hk_missile_think() //if (self.cnt < time) // turret_hk_missile_explode(); - if (self.enemy.deadflag != DEAD_NO) + if (IS_DEAD(self.enemy)) self.enemy = world; // Pick the closest valid target. @@ -88,7 +77,7 @@ void turret_hk_missile_think() if (!self.enemy) self.enemy = e; else - if (vlen(self.origin - e.origin) < vlen(self.origin - self.enemy.origin)) + if (vlen2(self.origin - e.origin) < vlen2(self.origin - self.enemy.origin)) self.enemy = e; } e = e.chain; @@ -106,7 +95,7 @@ void turret_hk_missile_think() // Close enougth to do decent damage? if ( edist <= (self.owner.shot_radius * 0.25) ) { - turret_projectile_explode(); + turret_projectile_explode(self); return; } @@ -276,7 +265,7 @@ bool hk_is_valid_target(entity e_target) if (self.owner.target_select_playerbias < 0) return 0; - if (e_target.deadflag != DEAD_NO) + if (IS_DEAD(e_target)) return 0; }