5 float autocvar_g_turrets_unit_walker_melee_damage;
6 float autocvar_g_turrets_unit_walker_melee_force;
7 float autocvar_g_turrets_unit_walker_melee_range;
8 float autocvar_g_turrets_unit_walker_rocket_damage;
9 float autocvar_g_turrets_unit_walker_rocket_radius;
10 float autocvar_g_turrets_unit_walker_rocket_force;
11 float autocvar_g_turrets_unit_walker_rocket_speed;
12 float autocvar_g_turrets_unit_walker_rocket_range;
13 float autocvar_g_turrets_unit_walker_rocket_range_min;
14 float autocvar_g_turrets_unit_walker_rocket_refire;
15 float autocvar_g_turrets_unit_walker_rocket_turnrate;
16 float autocvar_g_turrets_unit_walker_speed_stop;
17 float autocvar_g_turrets_unit_walker_speed_walk;
18 float autocvar_g_turrets_unit_walker_speed_run;
19 float autocvar_g_turrets_unit_walker_speed_jump;
20 float autocvar_g_turrets_unit_walker_speed_swim;
21 float autocvar_g_turrets_unit_walker_speed_roam;
22 float autocvar_g_turrets_unit_walker_turn;
23 float autocvar_g_turrets_unit_walker_turn_walk;
24 float autocvar_g_turrets_unit_walker_turn_strafe;
25 float autocvar_g_turrets_unit_walker_turn_swim;
26 float autocvar_g_turrets_unit_walker_turn_run;
28 const int ANIM_NO = 0;
29 const int ANIM_TURN = 1;
30 const int ANIM_WALK = 2;
31 const int ANIM_RUN = 3;
32 const int ANIM_STRAFE_L = 4;
33 const int ANIM_STRAFE_R = 5;
34 const int ANIM_JUMP = 6;
35 const int ANIM_LAND = 7;
36 const int ANIM_PAIN = 8;
37 const int ANIM_MELEE = 9;
38 const int ANIM_SWIM = 10;
39 const int ANIM_ROAM = 11;
44 bool walker_firecheck(
entity this)
46 if (this.animflag == ANIM_MELEE)
52 void walker_melee_do_dmg(
entity this)
60 e = findradius(where,32);
64 if (e !=
this && e.owner !=
this)
65 Damage(e,
this,
this, (autocvar_g_turrets_unit_walker_melee_damage), DEATH_TURRET_WALK_MELEE.m_id,
DMG_NOWEP,
'0 0 0', v_forward * (autocvar_g_turrets_unit_walker_melee_force));
71 void walker_setnoanim(
entity this)
74 this.animflag = this.
frame;
76 void walker_rocket_explode(
entity this)
78 RadiusDamage (
this, this.
owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius),
this,
NULL, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id,
DMG_NOWEP,
NULL);
84 walker_rocket_explode(
this);
96 #define WALKER_ROCKET_MOVE(s) movelib_move_simple((s), newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(s) 97 void walker_rocket_loop(
entity this);
98 void walker_rocket_think(
entity this)
107 edist =
vlen(this.
enemy.origin -
this.origin);
125 setthink(
this, walker_rocket_explode);
130 if (this.shot_dmg != 1337 &&
random() < 0.01)
132 walker_rocket_loop(
this);
144 itime =
max(edist / m_speed, 1);
150 WALKER_ROCKET_MOVE(
this);
153 void walker_rocket_loop3(
entity this)
159 setthink(
this, walker_rocket_explode);
165 setthink(
this, walker_rocket_think);
170 WALKER_ROCKET_MOVE(
this);
175 void walker_rocket_loop2(
entity this)
181 setthink(
this, walker_rocket_explode);
188 setthink(
this, walker_rocket_loop3);
193 WALKER_ROCKET_MOVE(
this);
196 void walker_rocket_loop(
entity this)
200 setthink(
this, walker_rocket_loop2);
201 this.shot_dmg = 1337;
210 entity rocket =
new(walker_rocket);
214 setsize (rocket,
'-3 -3 -3',
'3 3 3');
217 rocket.bot_dodge =
true;
218 rocket.bot_dodgerating = 50;
220 rocket.damageforcescale = 2;
223 rocket.cnt =
time + 1;
224 rocket.enemy = this.
enemy;
227 setthink(rocket, walker_rocket_loop);
229 setthink(rocket, walker_rocket_think);
231 rocket.event_damage = walker_rocket_damage;
233 rocket.nextthink =
time;
235 rocket.velocity =
normalize((v_forward +
v_up * 0.5) + (
randomvec() * 0.2)) * (autocvar_g_turrets_unit_walker_rocket_speed);
237 settouch(rocket, walker_rocket_touch);
238 rocket.flags = FL_PROJECTILE;
242 rocket.max_health =
time + 9;
248 .vector enemy_last_loc;
249 .float enemy_last_time;
250 void walker_move_to(
entity this,
vector _target,
float _dist)
256 this.animflag = ANIM_RUN;
258 this.animflag = ANIM_WALK;
261 if (this.animflag != ANIM_SWIM)
262 this.animflag = ANIM_WALK;
264 this.animflag = ANIM_SWIM;
267 this.animflag = ANIM_SWIM;
270 this.moveto = _target;
275 this.enemy_last_loc = _target;
276 this.enemy_last_time =
time;
280 void walker_move_path(
entity this)
282 #ifdef WALKER_FANCYPATHING 312 walker_move_to(
this, this.moveto, 0);
323 walker_move_to(
this, this.moveto, 0);
327 void walker_findtarget(
entity this)
332 LOG_TRACE(
"Initital waypoint for walker does NOT exist, fix your map!");
336 if (e.classname !=
"turret_checkpoint")
337 LOG_TRACE(
"Warning: not a turrret path");
340 #ifdef WALKER_FANCYPATHING 358 walker_move_path(it);
359 else if (it.enemy ==
NULL)
362 walker_move_path(it);
365 if(it.enemy_last_time != 0)
367 if(
vdist(it.origin - it.enemy_last_loc, <, 128) ||
time - it.enemy_last_time > 10)
368 it.enemy_last_time = 0;
370 walker_move_to(it, it.enemy_last_loc, 0);
374 if(it.animflag != ANIM_NO)
376 traceline(it.origin +
'0 0 64', it.origin +
'0 0 64' + v_forward * 128,
MOVE_NORMAL, it);
379 it.tur_head.idletime = -1337;
384 it.tur_head.idletime = -1337;
387 if(it.tur_head.idletime == -1337)
389 it.moveto = it.origin +
randomvec() * 256;
390 it.tur_head.idletime = 0;
393 it.moveto = it.moveto * 0.9 + ((it.origin + v_forward * 500) +
randomvec() * 400) * 0.1;
394 it.moveto_z = it.origin_z + 64;
395 walker_move_to(it, it.moveto, 0);
398 if(it.idletime <
time)
403 it.moveto = it.origin;
404 it.animflag = ANIM_NO;
408 it.animflag = ANIM_WALK;
410 it.moveto = it.origin +
randomvec() * 256;
411 it.tur_head.moveto = it.moveto;
412 it.tur_head.idletime = 0;
420 if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_melee_range) && it.animflag != ANIM_MELEE)
424 wish_angle =
angleofs(it, it.enemy);
425 if (it.animflag != ANIM_SWIM)
426 if (
fabs(wish_angle_y) < 15)
428 it.moveto = it.enemy.origin;
430 it.animflag = ANIM_MELEE;
433 else if (it.tur_head.attack_finished_single[0] <
time)
435 if(it.tur_head.shot_volly)
437 it.animflag = ANIM_NO;
439 it.tur_head.shot_volly = it.tur_head.shot_volly -1;
440 if(it.tur_head.shot_volly == 0)
441 it.tur_head.attack_finished_single[0] =
time + (autocvar_g_turrets_unit_walker_rocket_refire);
443 it.tur_head.attack_finished_single[0] =
time + 0.2;
445 if(it.tur_head.shot_volly > 1)
452 if (it.tur_dist_enemy > (autocvar_g_turrets_unit_walker_rocket_range_min))
453 if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_rocket_range))
454 it.tur_head.shot_volly = 4;
459 if (it.animflag != ANIM_MELEE)
460 walker_move_to(it, it.enemy.origin, it.tur_dist_enemy);
466 float turny = 0, turnx = 0;
475 movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
479 turny = (autocvar_g_turrets_unit_walker_turn);
480 movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
484 turny = (autocvar_g_turrets_unit_walker_turn_walk);
485 movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6);
489 turny = (autocvar_g_turrets_unit_walker_turn_run);
490 movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6);
494 turny = (autocvar_g_turrets_unit_walker_turn_strafe);
495 movelib_move_simple(it,
v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
499 turny = (autocvar_g_turrets_unit_walker_turn_strafe);
500 movelib_move_simple(it,
v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8);
504 it.velocity +=
'0 0 1' * (autocvar_g_turrets_unit_walker_speed_jump);
511 if(it.frame != ANIM_PAIN)
512 defer(it, 0.25, walker_setnoanim);
517 if(it.frame != ANIM_MELEE)
519 defer(it, 0.41, walker_setnoanim);
520 defer(it, 0.21, walker_melee_do_dmg);
523 movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop));
527 turny = (autocvar_g_turrets_unit_walker_turn_swim);
528 turnx = (autocvar_g_turrets_unit_walker_turn_swim);
531 movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3);
532 vz = it.velocity_z +
sin(
time * 4) * 8;
536 turny = (autocvar_g_turrets_unit_walker_turn_walk);
537 movelib_move_simple(it, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5);
544 it.angles_y += turny;
550 it.angles_x += turnx;
557 if(it.origin != it.oldorigin)
560 it.oldorigin = it.origin;
565 #ifdef WALKER_FANCYPATHING 569 it.pathcurrent =
NULL;
590 it.iscreature =
true;
592 if(!it.damagedbycontents)
594 it.damagedbycontents =
true;
600 tracebox(it.origin +
'0 0 128', it.mins, it.maxs, it.origin -
'0 0 10000',
MOVE_NORMAL, it);
606 it.idle_aim =
'0 0 0';
607 it.turret_firecheckfunc = walker_firecheck;
618 void walker_draw(
entity this)
623 this.move_time =
time;
642 it.draw = walker_draw;
const float SOLID_SLIDEBOX
float turret_validate_target(entity e_turret, entity e_target, float validate_flags)
void movelib_groundalign4point(entity this, float spring_length, float spring_up, float blendrate, float _max)
const int WATERLEVEL_SUBMERGED
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
const int TELEPORT_NORMAL
entity pathlib_astar(entity this, vector from, vector to)
IntrusiveList g_damagedbycontents
int target_validate_flags
bool turret_initialize(entity this, Turret tur)
spawnfunc(info_player_attacker)
void turrets_setframe(entity this, float _frame, float client_only)
#define METHOD(cname, name, prototype)
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
const int TFL_AMMO_RECHARGE
IntrusiveList g_bot_dodge
const int WATERLEVEL_NONE
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
const int TFL_TARGETSELECT_PLAYERS
const int TFL_TARGETSELECT_LOS
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define angleofs(from, to)
const int PROJECTILE_ROCKET
const int TFL_AMMO_BULLETS
void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
bool turret_firecheck(entity this)
ERASEABLE float shortangle_f(float ang1, float ang2)
const int TFL_AMMO_RECIEVE
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
const int TSF_NO_PATHBREAK
const int WATERLEVEL_WETFEET
vector(float skel, float bonenum) _skel_get_boneabs_hidden
IntrusiveList g_projectiles
const int TFL_TARGETSELECT_TEAMCHECK
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void InitializeEntity(entity e, void(entity this) func, int order)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense)
bool turret_closetotarget(entity this, vector targ)
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
const int WATERLEVEL_SWIMMING
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
const int MIF_GUIDED_HEAT
#define sound(e, c, s, v, a)
#define steerlib_pull(ent, point)
Uniform pull towards a point.
void pathlib_deletepath(entity start)
void set_movetype(entity this, int mt)
const int TUR_FLAG_HITSCAN
const int TFL_TARGETSELECT_RANGELIMITS