Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ewheel.qc File Reference
Include dependency graph for ewheel.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ewheel_draw (entity this)
void ewheel_findtarget (entity this)
void ewheel_move_enemy (entity this)
void ewheel_move_idle (entity this)
void ewheel_move_path (entity this)
 spawnfunc (turret_ewheel)

Variables

float autocvar_g_turrets_unit_ewheel_speed_fast
float autocvar_g_turrets_unit_ewheel_speed_slow
float autocvar_g_turrets_unit_ewheel_speed_slower
float autocvar_g_turrets_unit_ewheel_speed_stop
float autocvar_g_turrets_unit_ewheel_turnrate
const int ewheel_anim_bck_fast = 4
const int ewheel_anim_bck_slow = 3
const int ewheel_anim_fwd_fast = 2
const int ewheel_anim_fwd_slow = 1
const int ewheel_anim_stop = 0

Function Documentation

◆ ewheel_draw()

void ewheel_draw ( entity this)

Definition at line 217 of file ewheel.qc.

218{
219 float dt;
220
221 dt = time - this.move_time;
222 this.move_time = time;
223 if(dt <= 0)
224 return;
225
227 setorigin(this, this.origin + this.velocity * dt);
228 this.tur_head.angles += dt * this.tur_head.avelocity;
229
230 if(GetResource(this, RES_HEALTH) < 127)
231 if(random() < 0.05)
232 te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
233}
void fixedmakevectors(vector a)
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
vector velocity
float time
vector origin
ent angles
Definition ent_cs.qc:121
float random(void)
vector randomvec(void)
float move_time
Definition movetypes.qh:77
entity tur_head
Definition sv_turrets.qh:28

References angles, entity(), fixedmakevectors(), GetResource(), move_time, origin, random(), randomvec(), time, tur_head, and velocity.

◆ ewheel_findtarget()

void ewheel_findtarget ( entity this)

Definition at line 112 of file ewheel.qc.

113{
114 entity e = find(NULL, targetname, this.target);
115 if (!e)
116 {
117 LOG_TRACE("Initital waypoint for ewheel does NOT exist, fix your map!");
118 this.target = "";
119 }
120
121 if (e.classname != "turret_checkpoint")
122 LOG_TRACE("Warning: not a turret path");
123 else
124 {
125
126#ifdef EWHEEL_FANCYPATH
127 this.pathcurrent = pathlib_astar(this, this.origin, e.origin);
128 this.pathgoal = e;
129#else
130 this.pathcurrent = e;
131#endif
132 }
133}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define LOG_TRACE(...)
Definition log.qh:76
entity find(entity start,.string field, string match)
#define NULL
Definition post.qh:14
entity pathlib_astar(entity this, vector from, vector to)
Definition main.qc:353
entity pathcurrent
Definition sv_turrets.qh:86
entity pathgoal
Definition sv_turrets.qh:88
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55

References entity(), find(), LOG_TRACE, NULL, origin, pathcurrent, pathgoal, pathlib_astar(), target, and targetname.

◆ ewheel_move_enemy()

void ewheel_move_enemy ( entity this)

Definition at line 59 of file ewheel.qc.

60{
61 int newframe;
62
63 this.steerto = steerlib_arrive(this, this.enemy.origin,this.target_range_optimal);
64
65 this.moveto = this.origin + this.steerto * 128;
66
67 if (this.tur_dist_enemy > this.target_range_optimal)
68 {
69 if ( this.tur_head.spawnshieldtime < 1 )
70 {
71 newframe = ewheel_anim_fwd_fast;
73 }
74 else if (this.tur_head.spawnshieldtime < 2)
75 {
76 newframe = ewheel_anim_fwd_slow;
78 }
79 else
80 {
81 newframe = ewheel_anim_fwd_slow;
83 }
84 }
85 else if (this.tur_dist_enemy < this.target_range_optimal * 0.5)
86 {
87 newframe = ewheel_anim_bck_slow;
89 }
90 else
91 {
92 newframe = ewheel_anim_stop;
94 }
95
96 turrets_setframe(this, newframe, false);
97}
vector v_forward
const int ewheel_anim_stop
Definition ewheel.qc:11
float autocvar_g_turrets_unit_ewheel_speed_slow
Definition ewheel.qc:6
float autocvar_g_turrets_unit_ewheel_speed_stop
Definition ewheel.qc:8
float autocvar_g_turrets_unit_ewheel_speed_slower
Definition ewheel.qc:7
float autocvar_g_turrets_unit_ewheel_speed_fast
Definition ewheel.qc:5
const int ewheel_anim_fwd_slow
Definition ewheel.qc:12
const int ewheel_anim_fwd_fast
Definition ewheel.qc:13
const int ewheel_anim_bck_slow
Definition ewheel.qc:14
void movelib_brake_simple(entity this, float force)
Definition movelib.qc:167
#define movelib_move_simple(e, newdir, velo, blendrate)
Definition movelib.qh:36
vector steerlib_arrive(entity this, vector point, float maximal_distance)
Pull toward a point, The further away, the stronger the pull.
Definition steerlib.qc:27
vector steerto
Definition steerlib.qh:3
entity enemy
Definition sv_ctf.qh:153
void turrets_setframe(entity this, float _frame, float client_only)
float tur_dist_enemy
Definition sv_turrets.qh:34
vector moveto
Definition zombie.qc:17

References autocvar_g_turrets_unit_ewheel_speed_fast, autocvar_g_turrets_unit_ewheel_speed_slow, autocvar_g_turrets_unit_ewheel_speed_slower, autocvar_g_turrets_unit_ewheel_speed_stop, enemy, entity(), ewheel_anim_bck_slow, ewheel_anim_fwd_fast, ewheel_anim_fwd_slow, ewheel_anim_stop, movelib_brake_simple(), movelib_move_simple, moveto, origin, steerlib_arrive(), steerto, tur_dist_enemy, tur_head, turrets_setframe(), and v_forward.

◆ ewheel_move_idle()

void ewheel_move_idle ( entity this)

Definition at line 99 of file ewheel.qc.

100{
101 if(this.frame != 0)
102 {
103 this.SendFlags |= TNSF_ANIM;
104 this.anim_start_time = time;
105 }
106
107 this.frame = 0;
108 if(this.velocity)
110}
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
Definition anim.qh:6
float anim_start_time
Definition items.qc:15
int SendFlags
Definition net.qh:118
const int TNSF_ANIM
Definition turret.qh:191

References anim_start_time, autocvar_g_turrets_unit_ewheel_speed_stop, entity(), frame, movelib_brake_simple(), SendFlags, time, TNSF_ANIM, and velocity.

◆ ewheel_move_path()

void ewheel_move_path ( entity this)

Definition at line 17 of file ewheel.qc.

18{
19 // Are we close enough to a path node to switch to the next?
20 if(turret_closetotarget(this, this.pathcurrent.origin, 64))
21 {
22#ifdef EWHEEL_FANCYPATH
23 if (this.pathcurrent.path_next == NULL)
24 {
25 // Path endpoint reached
27 this.pathcurrent = NULL;
28
29 if (this.pathgoal)
30 {
31 if (this.pathgoal.use)
32 this.pathgoal.use(this.pathgoal, NULL, NULL);
33
34 if (this.pathgoal.enemy)
35 {
36 this.pathcurrent = pathlib_astar(this, this.pathgoal.origin,this.pathgoal.enemy.origin);
37 this.pathgoal = this.pathgoal.enemy;
38 }
39 }
40 else
41 this.pathgoal = NULL;
42 }
43 else
44 this.pathcurrent = this.pathcurrent.path_next;
45#else
46 this.pathcurrent = this.pathcurrent.enemy;
47#endif
48 }
49
50 if (this.pathcurrent)
51 {
52 this.moveto = this.pathcurrent.origin;
53 this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95);
54
56 }
57}
void pathlib_deletepath(entity start)
Definition main.qc:10
vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense)
Definition steerlib.qc:45
bool turret_closetotarget(entity this, vector targ, float range)

References autocvar_g_turrets_unit_ewheel_speed_fast, entity(), movelib_move_simple, moveto, NULL, pathcurrent, pathgoal, pathlib_astar(), pathlib_deletepath(), steerlib_attract2(), steerto, turret_closetotarget(), and v_forward.

◆ spawnfunc()

spawnfunc ( turret_ewheel )

Definition at line 135 of file ewheel.qc.

135{ if(!turret_initialize(this, TUR_EWHEEL)) delete(this); }
bool turret_initialize(entity this, Turret tur)

References turret_initialize().

Variable Documentation

◆ autocvar_g_turrets_unit_ewheel_speed_fast

float autocvar_g_turrets_unit_ewheel_speed_fast

Definition at line 5 of file ewheel.qc.

Referenced by ewheel_move_enemy(), and ewheel_move_path().

◆ autocvar_g_turrets_unit_ewheel_speed_slow

float autocvar_g_turrets_unit_ewheel_speed_slow

Definition at line 6 of file ewheel.qc.

Referenced by ewheel_move_enemy().

◆ autocvar_g_turrets_unit_ewheel_speed_slower

float autocvar_g_turrets_unit_ewheel_speed_slower

Definition at line 7 of file ewheel.qc.

Referenced by ewheel_move_enemy().

◆ autocvar_g_turrets_unit_ewheel_speed_stop

float autocvar_g_turrets_unit_ewheel_speed_stop

Definition at line 8 of file ewheel.qc.

Referenced by ewheel_move_enemy(), and ewheel_move_idle().

◆ autocvar_g_turrets_unit_ewheel_turnrate

float autocvar_g_turrets_unit_ewheel_turnrate

Definition at line 9 of file ewheel.qc.

◆ ewheel_anim_bck_fast

const int ewheel_anim_bck_fast = 4

Definition at line 15 of file ewheel.qc.

◆ ewheel_anim_bck_slow

const int ewheel_anim_bck_slow = 3

Definition at line 14 of file ewheel.qc.

Referenced by ewheel_move_enemy().

◆ ewheel_anim_fwd_fast

const int ewheel_anim_fwd_fast = 2

Definition at line 13 of file ewheel.qc.

Referenced by ewheel_move_enemy().

◆ ewheel_anim_fwd_slow

const int ewheel_anim_fwd_slow = 1

Definition at line 12 of file ewheel.qc.

Referenced by ewheel_move_enemy().

◆ ewheel_anim_stop

const int ewheel_anim_stop = 0

Definition at line 11 of file ewheel.qc.

Referenced by ewheel_move_enemy().