X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fewheel.qc;h=fd85e68decfac5a33accfbb5e001be40d9a75111;hb=57b530590b56a3306703456c2434d8f267216cfd;hp=0a633c78446431fdb0f0c841d67c5d70e49da369;hpb=e1bfe1d1d43ac7adedba945d692b37e0aafc453b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index 0a633c784..fd85e68de 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -10,17 +10,18 @@ float autocvar_g_turrets_unit_ewheel_speed_slower; float autocvar_g_turrets_unit_ewheel_speed_stop; float autocvar_g_turrets_unit_ewheel_turnrate; -const float ewheel_anim_stop = 0; -const float ewheel_anim_fwd_slow = 1; -const float ewheel_anim_fwd_fast = 2; -const float ewheel_anim_bck_slow = 3; -const float ewheel_anim_bck_fast = 4; +const int ewheel_anim_stop = 0; +const int ewheel_anim_fwd_slow = 1; +const int ewheel_anim_fwd_fast = 2; +const int ewheel_anim_bck_slow = 3; +const int ewheel_anim_bck_fast = 4; void ewheel_move_path(entity this) { -#ifdef EWHEEL_FANCYPATH - // Are we close enougth to a path node to switch to the next? + // Are we close enough to a path node to switch to the next? if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + { +#ifdef EWHEEL_FANCYPATH if (this.pathcurrent.path_next == NULL) { // Path endpoint reached @@ -43,11 +44,10 @@ void ewheel_move_path(entity this) } else this.pathcurrent = this.pathcurrent.path_next; - #else - if(vdist(this.origin - this.pathcurrent.origin, <, 64)) this.pathcurrent = this.pathcurrent.enemy; #endif + } if (this.pathcurrent) { @@ -61,11 +61,11 @@ void ewheel_move_path(entity this) void ewheel_move_enemy(entity this) { - float newframe; + int newframe; this.steerto = steerlib_arrive(this, this.enemy.origin,this.target_range_optimal); - this.moveto = this.origin + this.steerto * 128; + this.moveto = this.origin + this.steerto * 128; if (this.tur_dist_enemy > this.target_range_optimal) { @@ -113,6 +113,29 @@ 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)) @@ -162,8 +185,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 +193,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 exsist, fix your map!"); - it.target = ""; - } - - if (e.classname != "turret_checkpoint") - LOG_TRACE("Warning: not a turrret path"); - else - { - -#ifdef EWHEEL_FANCYPATH - it.pathcurrent = WALKER_PATH(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;