X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fhellion_weapon.qc;h=9e737ea6cf12e921fb2e48828b739ef382a5f0e3;hb=fc15d72b041c9a748b605ba28735380fbe5b5b01;hp=2d754e877d0396951cc5173c125bcefe269c3c96;hpb=c51698509e174e343dff48128a1dcfff1527c535;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 2d754e877..9e737ea6c 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -1,15 +1,4 @@ -#ifndef TURRET_HELLION_WEAPON_H -#define TURRET_HELLION_WEAPON_H - -CLASS(HellionAttack, PortoLaunch) -/* flags */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); -/* impulse */ ATTRIB(HellionAttack, impulse, int, 9); -/* refname */ ATTRIB(HellionAttack, netname, string, "turret_hellion"); -/* wepname */ ATTRIB(HellionAttack, message, string, _("Hellion")); -ENDCLASS(HellionAttack) -REGISTER_WEAPON(HELLION, NEW(HellionAttack)); - -#endif +#include "hellion_weapon.qh" #ifdef IMPLEMENTATION @@ -18,19 +7,20 @@ REGISTER_WEAPON(HELLION, NEW(HellionAttack)); float autocvar_g_turrets_unit_hellion_shot_speed_gain; float autocvar_g_turrets_unit_hellion_shot_speed_max; -void turret_hellion_missile_think(); -METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +void turret_hellion_missile_think(entity this); +SOUND(HellionAttack_FIRE, W_Sound("electro_fire")); +METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) - if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { + if (fire & 1) + 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, W_Sound("electro_fire"), CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0); actor.tur_shotdir_updated = w_shotdir; actor.tur_shotorg = w_shotorg; actor.tur_head = actor; actor.shot_radius = 500; - weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } if (!isPlayer) { if (actor.tur_head.frame != 0) @@ -39,9 +29,9 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, b actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2")); } - entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, FALSE, FALSE); + entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false); te_explosion (missile.origin); - missile.think = turret_hellion_missile_think; + setthink(missile, turret_hellion_missile_think); missile.nextthink = time; missile.flags = FL_PROJECTILE; missile.max_health = time + 9; @@ -51,66 +41,66 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, b } } -void turret_hellion_missile_think() -{SELFPARAM(); +void turret_hellion_missile_think(entity this) +{ vector olddir,newdir; vector pre_pos; float itime; - self.nextthink = time + 0.05; + this.nextthink = time + 0.05; - olddir = normalize(self.velocity); + olddir = normalize(this.velocity); - if(self.max_health < time) - turret_projectile_explode(); + if(this.max_health < time) + turret_projectile_explode(this); // Enemy dead? just keep on the current heading then. - if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO)) + if ((this.enemy == NULL) || (IS_DEAD(this.enemy))) { // Make sure we dont return to tracking a respawned player - self.enemy = world; + this.enemy = NULL; // Turn model - self.angles = vectoangles(self.velocity); + this.angles = vectoangles(this.velocity); - if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) ) - turret_projectile_explode(); + if(vdist(this.origin - this.owner.origin, >, (this.owner.shot_radius * 5))) + turret_projectile_explode(this); // Accelerate - self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max)); + this.velocity = olddir * min(vlen(this.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max)); - UpdateCSQCProjectile(self); + UpdateCSQCProjectile(this); return; } // Enemy in range? - if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2) - turret_projectile_explode(); + if(vdist(this.origin - this.enemy.origin, <, this.owner.shot_radius * 0.2)) + turret_projectile_explode(this); // Predict enemy position - itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity); - pre_pos = self.enemy.origin + self.enemy.velocity * itime; + itime = vlen(this.enemy.origin - this.origin) / vlen(this.velocity); + pre_pos = this.enemy.origin + this.enemy.velocity * itime; - pre_pos = (pre_pos + self.enemy.origin) * 0.5; + pre_pos = (pre_pos + this.enemy.origin) * 0.5; // Find out the direction to that place - newdir = normalize(pre_pos - self.origin); + newdir = normalize(pre_pos - this.origin); // Turn newdir = normalize(olddir + newdir * 0.35); // Turn model - self.angles = vectoangles(self.velocity); + this.angles = vectoangles(this.velocity); // Accelerate - self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max)); + this.velocity = newdir * min(vlen(this.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max)); if (itime < 0.05) - self.think = turret_projectile_explode; + setthink(this, turret_projectile_explode); - UpdateCSQCProjectile(self); + UpdateCSQCProjectile(this); } #endif