X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fewheel.qc;h=c0a0b177ee2d179afb99aeb774203521daf5eeeb;hp=d2feb0823c44933e89fe013cf66daf41864c2af0;hb=f8fe0e4aa8dad544f243ae997dfeb9cdccd55ee2;hpb=63841ddfb9349787f6380b9e9e2606e6d7ed9eb6 diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index d2feb0823c..c0a0b177ee 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -1,7 +1,5 @@ #include "ewheel.qh" -#ifdef IMPLEMENTATION - #ifdef SVQC float autocvar_g_turrets_unit_ewheel_speed_fast; @@ -19,7 +17,7 @@ const int ewheel_anim_bck_fast = 4; void ewheel_move_path(entity this) { // Are we close enough to a path node to switch to the next? - if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + if(turret_closetotarget(this, this.pathcurrent.origin)) { #ifdef EWHEEL_FANCYPATH if (this.pathcurrent.path_next == NULL) @@ -51,7 +49,6 @@ void ewheel_move_path(entity this) if (this.pathcurrent) { - this.moveto = this.pathcurrent.origin; this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95); @@ -113,14 +110,36 @@ void ewheel_move_idle(entity this) movelib_brake_simple(this, (autocvar_g_turrets_unit_ewheel_speed_stop)); } +void ewheel_findtarget(entity this) +{ + entity e = find(NULL, targetname, this.target); + if (!e) + { + LOG_TRACE("Initital waypoint for ewheel does NOT exist, fix your map!"); + this.target = ""; + } + + if (e.classname != "turret_checkpoint") + LOG_TRACE("Warning: not a turret path"); + else + { + +#ifdef EWHEEL_FANCYPATH + this.pathcurrent = pathlib_astar(this, this.origin, e.origin); + this.pathgoal = e; +#else + this.pathcurrent = e; +#endif + } +} + spawnfunc(turret_ewheel) { if(!turret_initialize(this, TUR_EWHEEL)) delete(this); } METHOD(EWheel, tr_think, void(EWheel thistur, entity it)) { - float vz; vector wish_angle, real_angle; - vz = it.velocity_z; + float vz = it.velocity_z; it.angles_x = anglemods(it.angles_x); it.angles_y = anglemods(it.angles_y); @@ -162,8 +181,6 @@ METHOD(EWheel, tr_death, void(EWheel this, entity it)) METHOD(EWheel, tr_setup, void(EWheel this, entity it)) { - entity e; - if(it.move_movetype == MOVETYPE_WALK) { it.velocity = '0 0 0'; @@ -172,33 +189,14 @@ METHOD(EWheel, tr_setup, void(EWheel this, entity it)) setorigin(it, it.pos1); if (it.target != "") - { - e = find(NULL, targetname, it.target); - if (!e) - { - LOG_TRACE("Initital waypoint for ewheel does NOT exist, fix your map!"); - it.target = ""; - } - - if (e.classname != "turret_checkpoint") - LOG_TRACE("Warning: not a turret path"); - else - { - -#ifdef EWHEEL_FANCYPATH - it.pathcurrent = pathlib_astar(it, it.origin, e.origin); - it.pathgoal = e; -#else - it.pathcurrent = e; -#endif - } - } + InitializeEntity(it, ewheel_findtarget, INITPRIO_FINDTARGET); } it.iscreature = true; it.teleportable = TELEPORT_NORMAL; - it.damagedbycontents = true; - IL_PUSH(g_damagedbycontents, it); + if(!it.damagedbycontents) + IL_PUSH(g_damagedbycontents, it); + it.damagedbycontents = true; set_movetype(it, MOVETYPE_WALK); it.solid = SOLID_SLIDEBOX; it.takedamage = DAMAGE_AIM; @@ -230,18 +228,17 @@ void ewheel_draw(entity this) setorigin(this, this.origin + this.velocity * dt); this.tur_head.angles += dt * this.tur_head.avelocity; - if (this.health < 127) + if(GetResourceAmount(this, RESOURCE_HEALTH) < 127) if(random() < 0.05) te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16); } - METHOD(EWheel, tr_setup, void(EWheel this, entity it)) - { - it.gravity = 1; - set_movetype(it, MOVETYPE_BOUNCE); - it.move_time = time; - it.draw = ewheel_draw; - } +METHOD(EWheel, tr_setup, void(EWheel this, entity it)) +{ + it.gravity = 1; + set_movetype(it, MOVETYPE_BOUNCE); + it.move_time = time; + it.draw = ewheel_draw; +} #endif // CSQC -#endif