X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Ftesla.qc;h=249fe18eb92042465d499a947929c672aee49fa3;hb=e424ba544c41fc40b241b17bd7c1d9c2fc930705;hp=510331c637400fe19586cee4767fff7cffaabd81;hpb=37cf62041a76248472ef6a78feaaed33e35a2260;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/tesla.qc b/qcsrc/common/turrets/turret/tesla.qc index 510331c63..249fe18eb 100644 --- a/qcsrc/common/turrets/turret/tesla.qc +++ b/qcsrc/common/turrets/turret/tesla.qc @@ -1,59 +1,40 @@ -#ifndef TURRET_TESLA_H -#define TURRET_TESLA_H - -#include "tesla_weapon.qh" - -CLASS(TeslaCoil, Turret) -/* spawnflags */ ATTRIB(TeslaCoil, spawnflags, int, TUR_FLAG_HITSCAN | TUR_FLAG_PLAYER | TUR_FLAG_MISSILE); -/* mins */ ATTRIB(TeslaCoil, mins, vector, '-60 -60 0'); -/* maxs */ ATTRIB(TeslaCoil, maxs, vector, '60 60 128'); -/* modelname */ ATTRIB(TeslaCoil, mdl, string, "tesla_base.md3"); -/* model */ ATTRIB_STRZONE(TeslaCoil, model, string, strcat("models/turrets/", this.mdl)); -/* head_model */ ATTRIB_STRZONE(TeslaCoil, head_model, string, strcat("models/turrets/", "tesla_head.md3")); -/* netname */ ATTRIB(TeslaCoil, netname, string, "tesla"); -/* fullname */ ATTRIB(TeslaCoil, turret_name, string, _("Tesla Coil")); - ATTRIB(TeslaCoil, m_weapon, Weapon, WEP_TESLA); -ENDCLASS(TeslaCoil) -REGISTER_TURRET(TESLA, NEW(TeslaCoil)); - -#endif +#include "tesla.qh" #ifdef IMPLEMENTATION #ifdef SVQC -spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(self); } +spawnfunc(turret_tesla) { if (!turret_initialize(this, TUR_TESLA)) delete(this); } METHOD(TeslaCoil, tr_think, void(TeslaCoil thistur, entity it)) { - SELFPARAM(); - if(!self.active) + if(!it.active) { - self.tur_head.avelocity = '0 0 0'; + it.tur_head.avelocity = '0 0 0'; return; } - if(self.ammo < self.shot_dmg) + if(it.ammo < it.shot_dmg) { - self.tur_head.avelocity = '0 45 0' * (self.ammo / self.shot_dmg); + it.tur_head.avelocity = '0 45 0' * (it.ammo / it.shot_dmg); } else { - self.tur_head.avelocity = '0 180 0' * (self.ammo / self.shot_dmg); + it.tur_head.avelocity = '0 180 0' * (it.ammo / it.shot_dmg); - if(self.attack_finished_single[0] > time) + if(it.attack_finished_single[0] > time) return; float f; - f = (self.ammo / self.ammo_max); + f = (it.ammo / it.ammo_max); f = f * f; if(f > random()) if(random() < 0.1) - te_csqc_lightningarc(self.tur_shotorg,self.tur_shotorg + (randomvec() * 350)); + te_csqc_lightningarc(it.tur_shotorg,it.tur_shotorg + (randomvec() * 350)); } } -float turret_tesla_firecheck(); +bool turret_tesla_firecheck(entity this); METHOD(TeslaCoil, tr_setup, void(TeslaCoil this, entity it)) { it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | @@ -70,40 +51,40 @@ METHOD(TeslaCoil, tr_setup, void(TeslaCoil this, entity it)) it.track_flags = TFL_TRACK_NO; } -float turret_tesla_firecheck() -{SELFPARAM(); +bool turret_tesla_firecheck(entity this) +{ // g_turrets_targetscan_maxdelay forces a target re-scan at least this often float do_target_scan = 0; - if((self.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time) + if((this.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time) do_target_scan = 1; // Old target (if any) invalid? - if(self.target_validate_time < time) - if (turret_validate_target(self, self.enemy, self.target_validate_flags) <= 0) + if(this.target_validate_time < time) + if (turret_validate_target(this, this.enemy, this.target_validate_flags) <= 0) { - self.enemy = world; - self.target_validate_time = time + 0.5; + this.enemy = NULL; + this.target_validate_time = time + 0.5; do_target_scan = 1; } // But never more often then g_turrets_targetscan_mindelay! - if (self.target_select_time + autocvar_g_turrets_targetscan_mindelay > time) + if (this.target_select_time + autocvar_g_turrets_targetscan_mindelay > time) do_target_scan = 0; if(do_target_scan) { - self.enemy = turret_select_target(); - self.target_select_time = time; + this.enemy = turret_select_target(this); + this.target_select_time = time; } - if(!turret_firecheck()) - return 0; + if(!turret_firecheck(this)) + return false; - if(self.enemy) - return 1; + if(this.enemy) + return true; - return 0; + return false; } #endif