Updated pathlib.qc
[divverent/nexuiz.git] / data / qcsrc / server / tturrets / units / unit_walker.qc
1 #define ANIM_NO 0\r
2 #define ANIM_WALK 1\r
3 #define ANIM_RUN 1.1\r
4 #define ANIM_STRAFE_L 2\r
5 #define ANIM_STRAFE_R 3\r
6 #define ANIM_TURN 2\r
7 #define ANIM_JUMP 4\r
8 #define ANIM_LAND 5\r
9 #define ANIM_PAIN 6\r
10 #define ANIM_MEELE 7\r
11 .float animflag;\r
12 \r
13 .entity wkr_props;\r
14 .entity wkr_spawn;\r
15 \r
16 #define WALKER_MIN '-70 -70 5'\r
17 #define WALKER_MAX '70 70 70'\r
18 \r
19 /*\r
20 .entity goalcurrent, goalstack01, goalstack02, goalstack03;\r
21 .entity goalstack04, goalstack05, goalstack06, goalstack07;\r
22 .entity goalstack08, goalstack09, goalstack10, goalstack11;\r
23 .entity goalstack12, goalstack13, goalstack14, goalstack15;\r
24 .entity goalstack16, goalstack17, goalstack18, goalstack19;\r
25 .entity goalstack20, goalstack21, goalstack22, goalstack23;\r
26 .entity goalstack24, goalstack25, goalstack26, goalstack27;\r
27 .entity goalstack28, goalstack29, goalstack30, goalstack31;\r
28 */\r
29 \r
30 float walker_firecheck()\r
31 {\r
32     if (!turret_stdproc_firecheck()) return 0;\r
33     //if(self.tur_cannon.frame != 0) return 0;\r
34 \r
35     //if(self.walking  == 1) self.walking = 2;\r
36     //if(self.walking != 0)\r
37     //    return 0;\r
38 \r
39     return 1;\r
40 }\r
41 \r
42 void walker_meele_dmg()\r
43 {\r
44     vector where;\r
45     entity e;\r
46 \r
47     makevectors(self.angles);\r
48     where = self.origin + v_forward * 128;\r
49 \r
50     e = findradius(where,80);\r
51     while (e)\r
52     {\r
53         if (turret_validate_target(self,e,self.target_validate_flags))\r
54             if (e != self)\r
55                 Damage(e,self,self,cvar("g_turrets_unit_walker_std_meele_dmg "),DEATH_TURRET,'0 0 0', v_forward * cvar("g_turrets_unit_walker_std_meele_force") );\r
56 \r
57         e = e.chain;\r
58     }\r
59 }\r
60 \r
61 void walker_animate()\r
62 {\r
63 \r
64     if (self.tur_head.frame != 0)\r
65         self.tur_head.frame = self.tur_head.frame +1;\r
66 \r
67     if (self.tur_head.frame > 12)\r
68         self.tur_head.frame = 0;\r
69 \r
70 \r
71     switch (self.animflag)\r
72     {\r
73     case ANIM_NO:\r
74         //if(self.frame != 0)\r
75         //    self.frame = 0;\r
76         break;\r
77 \r
78     case ANIM_WALK:\r
79         self.frame = self.frame + 1;\r
80         if (self.frame > 25)\r
81             self.frame = 5;\r
82         break;\r
83 \r
84     case ANIM_RUN:\r
85         self.frame = self.frame + 2;\r
86         if (self.frame > 25)\r
87             self.frame = 5;\r
88         break;\r
89 \r
90     case ANIM_STRAFE_L:\r
91         if (self.frame < 35) self.frame = 35;\r
92         self.frame = self.frame + 1;\r
93         if (self.frame > 55) self.frame = 35;\r
94         break;\r
95 \r
96     case ANIM_STRAFE_R:\r
97         if (self.frame < 65) self.frame = 65;\r
98         self.frame = self.frame + 1;\r
99         if (self.frame > 85) self.frame = 65;\r
100         break;\r
101 \r
102     case ANIM_JUMP:\r
103         if (self.frame < 95) self.frame = 95;\r
104         if (self.frame > 100)\r
105             self.frame = self.frame + 1;\r
106 \r
107         break;\r
108 \r
109     case ANIM_LAND:\r
110         if (self.frame < 100) self.frame = 100;\r
111         self.frame = self.frame + 1;\r
112         if (self.frame > 107)\r
113             self.animflag = ANIM_NO;\r
114         break;\r
115 \r
116     case ANIM_PAIN:\r
117         if (self.frame < 90) self.frame = 90;\r
118         self.frame = self.frame + 1;\r
119         if (self.frame > 95)\r
120             self.animflag = ANIM_NO;\r
121         break;\r
122 \r
123     case ANIM_MEELE:\r
124         if (self.frame < 123) self.frame = 123;\r
125         self.frame = self.frame + 1;\r
126 \r
127         if (self.frame == 133)\r
128             walker_meele_dmg();\r
129 \r
130         if (self.frame > 140)\r
131             self.animflag = ANIM_NO;\r
132 \r
133     }\r
134 }\r
135 \r
136 void walker_rocket_explode()\r
137 {\r
138     vector org2;\r
139 \r
140     if(self.event_damage != SUB_Null)\r
141     {\r
142         self.event_damage = SUB_Null;\r
143         self.think = walker_rocket_explode;\r
144         self.nextthink = time;\r
145         return;\r
146     }\r
147 \r
148     sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", 1, ATTN_NORM);\r
149     org2 = findbetterlocation (self.origin, 16);\r
150 \r
151     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);\r
152     WriteByte (MSG_BROADCAST, 78);\r
153     WriteCoord (MSG_BROADCAST, org2_x);\r
154     WriteCoord (MSG_BROADCAST, org2_y);\r
155     WriteCoord (MSG_BROADCAST, org2_z);\r
156 \r
157     RadiusDamage (self, self.owner, cvar("g_turrets_unit_walker_std_rocket_dmg"), 0, cvar("g_turrets_unit_walker_std_rocket_radius"), world, cvar("g_turrets_unit_walker_std_rocket_force"), DEATH_TURRET, world);\r
158 \r
159     remove (self);\r
160 }\r
161 \r
162 void walker_rocket_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)\r
163 {\r
164     self.health = self.health - damage;\r
165     self.velocity = self.velocity + vforce;\r
166     if (self.health <= 0) walker_rocket_explode();\r
167 }\r
168 \r
169 \r
170 /*\r
171 g_turrets_unit_walker_std_rocket_refire\r
172 g_turrets_unit_walker_std_rocket_dmg\r
173 g_turrets_unit_walker_std_rocket_radius\r
174 g_turrets_unit_walker_std_rocket_force\r
175 g_turrets_unit_walker_std_rocket_tunrate\r
176 g_turrets_unit_walker_std_rocket_speed\r
177 g_turrets_unit_walker_std_rocket_speed_add\r
178 */\r
179 \r
180 void walker_rocket_loop();\r
181 void walker_rocket_think()\r
182 {\r
183     vector olddir,newdir;\r
184     float edist;\r
185     float itime;\r
186     float m_speed;\r
187 \r
188     self.nextthink          = time + 0.1;\r
189 \r
190     olddir = normalize(self.velocity);\r
191     edist = vlen(self.enemy.origin - self.origin);\r
192 \r
193     // Simulate crude guidance\r
194     if (self.cnt < time)\r
195     {\r
196         if (edist < 1000)\r
197             self.tur_shotorg = randomvec() * min(edist,64);\r
198         else\r
199             self.tur_shotorg = randomvec() * min(edist,256);\r
200         self.cnt = time + 0.5;\r
201     }\r
202     if (edist < 256)\r
203         self.tur_shotorg = '0 0 0';\r
204 \r
205 \r
206     if (self.tur_health < time)\r
207     {\r
208         self.think = walker_rocket_explode;\r
209         self.nextthink = time;\r
210         return;\r
211     }\r
212 \r
213     if ((random() < 0.01) && (self.shot_dmg != 1337))\r
214     {\r
215         walker_rocket_loop();\r
216         return;\r
217     }\r
218 \r
219     olddir = normalize(self.velocity);\r
220 \r
221     // Accelerate\r
222     m_speed = vlen(self.velocity) + cvar("g_turrets_unit_walker_std_rocket_speed_add");\r
223 \r
224     // Enemy dead? just keep on the current heading then.\r
225     if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))\r
226     {\r
227 \r
228         // Make sure we dont return to tracking a respawned player\r
229         self.enemy = world;\r
230 \r
231         // Turn model\r
232         self.angles = vectoangles(self.velocity);\r
233     }\r
234 \r
235     if (self.enemy)\r
236     {\r
237         // Predict enemy position\r
238         itime = max(edist / m_speed,1);\r
239         newdir = normalize((self.enemy.origin + self.tur_shotorg) - self.origin);\r
240     }\r
241     else\r
242     {\r
243         //pre_pos = self.origin + olddir;\r
244         newdir  = olddir;\r
245     }\r
246 \r
247     // Turn\r
248     newdir = normalize(olddir + newdir * cvar("g_turrets_unit_walker_std_rocket_tunrate"));\r
249 \r
250     self.velocity = newdir * m_speed;\r
251 \r
252     // Turn model\r
253     self.angles = vectoangles(self.velocity);\r
254 \r
255     if (time+itime < time+0.1)\r
256     {\r
257         self.think = turret_hellion_missile_explode;\r
258         self.nextthink = time + itime;\r
259     }\r
260 }\r
261 \r
262 void walker_rocket_loop3()\r
263 {\r
264     self.nextthink = time + 0.1;\r
265 \r
266     if (vlen(self.origin - self.tur_shotorg) < 128 )\r
267     {\r
268         self.think = walker_rocket_think;\r
269         return;\r
270     }\r
271 \r
272     vector newdir;\r
273     vector olddir;\r
274     float m_speed;\r
275 \r
276     m_speed = vlen(self.velocity) + cvar("g_turrets_unit_walker_std_rocket_speed_add");\r
277     olddir = normalize(self.velocity);\r
278     newdir = normalize(self.tur_shotorg  - self.origin);\r
279     newdir = normalize(olddir + newdir * cvar("g_turrets_unit_walker_std_rocket_tunrate"));\r
280 \r
281     self.velocity = newdir * m_speed;\r
282     self.angles = vectoangles(self.velocity);\r
283 }\r
284 \r
285 void walker_rocket_loop2()\r
286 {\r
287     self.nextthink = time + 0;\r
288 \r
289     if (vlen(self.origin - self.tur_shotorg) < 128 )\r
290     {\r
291         self.tur_shotorg = self.origin - '0 0 200';\r
292         self.think = walker_rocket_loop3;\r
293         return;\r
294     }\r
295 \r
296     vector newdir;\r
297     vector olddir;\r
298     float m_speed;\r
299 \r
300     m_speed = vlen(self.velocity) + cvar("g_turrets_unit_walker_std_rocket_speed_add");\r
301     olddir = normalize(self.velocity);\r
302     newdir = normalize(self.tur_shotorg  - self.origin);\r
303     newdir = normalize(olddir + newdir * cvar("g_turrets_unit_walker_std_rocket_tunrate"));\r
304     self.velocity = newdir * m_speed;\r
305     self.angles = vectoangles(self.velocity);\r
306 \r
307 }\r
308 \r
309 void walker_rocket_loop()\r
310 {\r
311 \r
312     self.nextthink= time + 0;\r
313     self.tur_shotorg = self.origin + '0 0 400';\r
314     self.think = walker_rocket_loop2;\r
315     self.shot_dmg = 1337;\r
316 }\r
317 \r
318 void walker_fire_rocket(vector org)\r
319 {\r
320 \r
321     entity rocket;\r
322 \r
323 \r
324     //self.angles_x *= -1;\r
325     makevectors(self.angles);\r
326     //self.angles_x *= -1;\r
327 \r
328     rocket = spawn ();\r
329     setorigin(rocket, org);\r
330 \r
331     sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);\r
332     sound (rocket, CHAN_PROJECTILE, "weapons/rocket_fly.wav", 0.4, ATTN_NORM);\r
333     setmodel (rocket, "models/turrets/rocket.md3"); // precision set below\r
334     setsize (rocket, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot\r
335 \r
336     rocket.classname          = "walker_rocket";\r
337     rocket.owner              = self;\r
338     rocket.bot_dodge          = TRUE;\r
339     rocket.bot_dodgerating    = 50;\r
340     rocket.takedamage         = DAMAGE_YES;\r
341 \r
342     rocket.damageforcescale   = 2;\r
343     rocket.health             = 10;\r
344     rocket.tur_shotorg        = randomvec() * 512;\r
345     rocket.cnt                = time + 1;\r
346     rocket.enemy              = self.enemy;\r
347 \r
348     if (random() < 0.01)\r
349         rocket.think          = walker_rocket_loop;\r
350     else\r
351         rocket.think          = walker_rocket_think;\r
352 \r
353     rocket.event_damage       = walker_rocket_damage;\r
354 \r
355     rocket.nextthink          = time + 0.2;\r
356     rocket.solid              = SOLID_BBOX;\r
357     rocket.movetype           = MOVETYPE_FLYMISSILE;\r
358     rocket.effects            = EF_LOWPRECISION;\r
359     rocket.velocity           = ((v_forward + v_up * 0.35) +(randomvec() * 0.15))* cvar("g_turrets_unit_walker_std_rocket_speed");\r
360     rocket.angles             = vectoangles(rocket.velocity);\r
361     rocket.touch              = walker_rocket_explode;\r
362     rocket.flags              = FL_PROJECTILE;\r
363     rocket.solid              = SOLID_BBOX;\r
364     rocket.tur_health         = time + 9;\r
365 \r
366     te_explosion (rocket.origin);\r
367 \r
368 }\r
369 \r
370 #define s_turn 10\r
371 #define s_walk 100\r
372 #define s_run 300\r
373 #define s_accel1 8\r
374 #define s_accel2 16\r
375 #define s_decel 8\r
376 \r
377 void rv_think()\r
378 {\r
379     float f;\r
380     vector org;\r
381 \r
382     self.cnt = self.cnt -1;\r
383 \r
384     if (self.cnt < 0)\r
385     {\r
386         remove(self);\r
387         return;\r
388     }\r
389 \r
390     if (self.cnt > 1)\r
391         f = gettagindex(self.owner,"tag_rocket01");\r
392     else\r
393         f = gettagindex(self.owner,"tag_rocket02");\r
394 \r
395     org = self.owner.origin + gettaginfo(self.owner,f);\r
396 \r
397 \r
398     self.nextthink = time + 0.2;\r
399     self = self.owner;\r
400     walker_fire_rocket(org);\r
401 }\r
402 \r
403 void walker_postthink()\r
404 {\r
405     vector wish_angle;\r
406     vector real_angle;\r
407     float turn_limit;\r
408 \r
409     if ((self.flags & FL_ONGROUND)&&(self.animflag != ANIM_MEELE))\r
410         self.animflag = ANIM_NO;\r
411 \r
412     if (self.enemy)\r
413         if (self.tur_head.attack_finished_single < time)\r
414         {\r
415             entity rv;\r
416             rv = spawn();\r
417             rv.think = rv_think;\r
418             rv.nextthink = time;\r
419             rv.cnt = 4;\r
420             rv.owner = self;\r
421 \r
422             self.tur_head.attack_finished_single = time + cvar("g_turrets_unit_walker_std_rocket_refire");\r
423         }\r
424 \r
425 \r
426     if (self.checkpoint_path)\r
427     {\r
428         if (vlen(self.origin  - self.goalcurrent.origin) < 64)\r
429             if (self.goalcurrent.path_next == world)\r
430             {\r
431 \r
432                 self.checkpoint_path = world; // Path endpoint reached, go roaming.\r
433             }\r
434             else\r
435                 self.goalcurrent = self.goalcurrent.path_next;\r
436 \r
437         self.animflag = ANIM_WALK;\r
438     }\r
439     else // Roaming mode\r
440     {\r
441 \r
442         if (self.enemy)\r
443         {\r
444             wish_angle = angleofs(self,self.enemy); //normalize(self.origin-self.enemy.origin);\r
445 \r
446             if (self.tur_dist_enemy < cvar("g_turrets_unit_walker_std_meele_range"))\r
447             {\r
448 \r
449                 if (fabs(wish_angle_y) < 15)\r
450                     self.animflag = ANIM_MEELE;\r
451             }\r
452             else\r
453             {\r
454                 if (fabs(wish_angle_y) < 15)\r
455                     self.animflag = ANIM_RUN;\r
456                 else if (fabs(wish_angle_y) < 30)\r
457                     self.animflag = ANIM_WALK;\r
458                 else\r
459                     self.animflag = ANIM_TURN;\r
460             }\r
461 \r
462         }\r
463         else\r
464             if(self.animflag != ANIM_MEELE)\r
465                 self.animflag = ANIM_NO;\r
466     }\r
467 \r
468 \r
469     float s_speed;\r
470 \r
471     s_speed = vlen(self.velocity);\r
472 \r
473     // Turn on the spot\r
474     if (self.animflag == ANIM_TURN)\r
475     {\r
476         if (self.enemy)\r
477             wish_angle = normalize(self.enemy.origin - self.origin);\r
478         else\r
479             wish_angle = normalize(self.goalcurrent.origin - self.origin);\r
480 \r
481         wish_angle = vectoangles(wish_angle);\r
482 \r
483         real_angle = wish_angle - self.angles;\r
484 \r
485         if (real_angle_x < 0) real_angle_x += 360;\r
486         if (real_angle_x > 180) real_angle_x -= 360;\r
487 \r
488         if (real_angle_y < 0) real_angle_y += 360;\r
489         if (real_angle_y > 180) real_angle_y -= 360;\r
490 \r
491         turn_limit = cvar("g_turrets_unit_walker_turn_turnrate");\r
492         // Convert from dgr/sec to dgr/tic\r
493         turn_limit  = turn_limit / (1 / self.ticrate);\r
494 \r
495         //real_angle_x = bound((-1 * turn_limit),real_angle_x, turn_limit);\r
496         real_angle_y = bound((-1 * turn_limit),real_angle_y, turn_limit);\r
497 \r
498         self.angles_y = self.angles_y + real_angle_y;\r
499 \r
500         if (self.enemy)\r
501             v_forward = normalize(self.enemy.origin - self.origin);\r
502         else\r
503             v_forward = normalize(self.goalcurrent.origin - self.origin);\r
504 \r
505         makevectors(self.angles);\r
506 \r
507         if (s_speed > s_turn)\r
508             self.velocity = (v_forward * max((s_speed - s_decel),s_turn));\r
509         if (s_speed < s_turn)\r
510             self.velocity = (v_forward * min((s_speed + s_accel1),s_turn));\r
511     }\r
512     else if (self.animflag == ANIM_WALK) // Gg walking\r
513     {\r
514         if (self.goalcurrent)\r
515             wish_angle = normalize(self.goalcurrent.origin - self.origin);\r
516         else\r
517             if (self.enemy)\r
518                 wish_angle = normalize(self.enemy.origin - self.origin);\r
519             else\r
520                 wish_angle = self.angles;\r
521 \r
522 \r
523         wish_angle = vectoangles(wish_angle);                  // And make a angle\r
524         real_angle = wish_angle - self.angles;\r
525 \r
526         if (real_angle_x < 0) real_angle_x += 360;\r
527         if (real_angle_x > 180) real_angle_x -= 360;\r
528 \r
529         if (real_angle_y < 0) real_angle_y += 360;\r
530         if (real_angle_y > 180) real_angle_y -= 360;\r
531 \r
532         turn_limit = cvar("g_turrets_unit_walker_walk_turnrate");\r
533         // Convert from dgr/sec to dgr/tic\r
534         turn_limit  = turn_limit / (1 / self.ticrate);\r
535 \r
536         //real_angle_x = bound((-1 * turn_limit),real_angle_x, turn_limit);\r
537         real_angle_y = bound((-1 * turn_limit),real_angle_y, turn_limit);\r
538 \r
539         self.angles_y = self.angles_y + real_angle_y;\r
540 \r
541         if (self.goalcurrent)\r
542             v_forward = normalize(self.goalcurrent.origin - self.origin);\r
543         else\r
544             if (self.enemy)\r
545                 v_forward = normalize(self.enemy.origin - self.origin);\r
546 \r
547         makevectors(self.angles);\r
548         self.velocity = v_forward * s_walk;\r
549 \r
550         //if(self.flags & FL_ONGROUND)\r
551         /*\r
552         {\r
553             float s_z;\r
554             s_z = self.velocity_z;\r
555             if(s_speed > s_walk)\r
556                 self.velocity = (v_forward * max((s_speed - s_decel),s_walk));\r
557             if(s_speed <= s_walk)\r
558                 self.velocity = (v_forward * min((s_speed + s_accel1),s_walk));\r
559             self.velocity_z = s_z;//s_walk;\r
560         }\r
561         */\r
562 \r
563 \r
564     }\r
565     else if (self.animflag == ANIM_RUN) // Move fast, turn slow\r
566     {\r
567         if (self.goalcurrent)\r
568             wish_angle = normalize(self.goalcurrent.origin - self.origin);\r
569         else\r
570             if (self.enemy)\r
571                 wish_angle = normalize(self.enemy.origin - self.origin);\r
572             else\r
573                 wish_angle = self.angles;\r
574 \r
575         wish_angle = vectoangles(wish_angle);                  // And make a angle\r
576         real_angle = wish_angle - self.angles;\r
577 \r
578         if (real_angle_x < 0) real_angle_x += 360;\r
579         if (real_angle_x > 180) real_angle_x -= 360;\r
580 \r
581         if (real_angle_y < 0) real_angle_y += 360;\r
582         if (real_angle_y > 180) real_angle_y -= 360;\r
583 \r
584         turn_limit = cvar("g_turrets_unit_walker_run_turnrate");\r
585         // Convert from dgr/sec to dgr/tic\r
586         turn_limit  = turn_limit / (1 / self.ticrate);\r
587 \r
588         //real_angle_x = bound((-1 * turn_limit),real_angle_x, turn_limit);\r
589         real_angle_y = bound((-1 * turn_limit),real_angle_y, turn_limit);\r
590 \r
591         self.angles_y = self.angles_y + real_angle_y;\r
592 \r
593 \r
594         if (self.enemy)\r
595             v_forward = normalize(self.enemy.origin - self.origin);\r
596         else\r
597             v_forward = normalize(self.goalcurrent.origin - self.origin);\r
598 \r
599         makevectors(self.angles);\r
600 \r
601         if (self.flags & FL_ONGROUND)\r
602         {\r
603             if (s_speed > s_run)\r
604                 self.velocity = (v_forward * max((s_speed - s_decel),s_run));\r
605             if (s_speed <= s_run)\r
606                 self.velocity = (v_forward * min((s_speed + s_accel2),s_run));\r
607         }\r
608     }\r
609     else\r
610     {\r
611 \r
612         if (self.flags & FL_ONGROUND)\r
613         {\r
614             makevectors(self.angles);\r
615             if (s_speed > 0)\r
616                 self.velocity = min(s_speed - s_decel,0) * v_forward;\r
617         }\r
618     }\r
619 \r
620 \r
621 \r
622     walker_animate();\r
623 \r
624 \r
625 }\r
626 \r
627 void walker_attack()\r
628 {\r
629     entity flash;\r
630 \r
631     //turret_do_updates(self);\r
632 \r
633     self.tur_head.frame = self.tur_head.frame + 1;\r
634 \r
635     sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);\r
636 \r
637 \r
638     fireBullet (self.tur_shotorg_updated, self.tur_shotdir_updated,self.shot_spread, self.shot_dmg, self.shot_force, DEATH_TURRET, FALSE);\r
639 \r
640     te_smallflash(self.tur_shotorg_updated);\r
641 \r
642     if (!(self.uzi_bulletcounter & 3))\r
643     {\r
644 \r
645         trailparticles(self,particleeffectnum("EF_MGTURRETTRAIL"),self.tur_shotorg_updated,trace_endpos);\r
646         // te_lightning1(self,self.tur_shotorg_updated,trace_endpos);\r
647         flash = spawn();\r
648         setmodel(flash, "models/uziflash.md3"); // precision set below\r
649         setattachment(flash, self.tur_head, "tag_fire");\r
650         flash.scale = 3;\r
651         flash.think = W_Uzi_Flash_Go;\r
652         flash.nextthink = time + 0.02;\r
653         flash.frame = 2;\r
654         flash.angles_z = flash.v_angle_z + random() * 180;\r
655         flash.alpha = 1;\r
656         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;\r
657     }\r
658 \r
659     self.uzi_bulletcounter = self.uzi_bulletcounter + 1;\r
660 }\r
661 \r
662 void walker_respawnhook()\r
663 {\r
664     vector vtmp;\r
665     entity e;\r
666 \r
667     self.origin = self.wkr_spawn.origin;\r
668     self.wkr_props.solid = SOLID_BBOX;\r
669     self.wkr_props.alpha = 1;\r
670 \r
671     self.angles = self.wkr_spawn.angles;\r
672     vtmp = self.origin;\r
673     vtmp_z +=self.wkr_spawn.origin_z + self.wkr_spawn.maxs_z;\r
674     setorigin(self,vtmp);\r
675 \r
676     if (self.target != "")\r
677     {\r
678         e = find(world,targetname,self.target);\r
679         if (!e)\r
680         {\r
681             bprint("Warning! initital waypoint for Walker does NOT exsist!\n");\r
682             self.target = "";\r
683 \r
684             //remove(self);\r
685             //return;\r
686         }\r
687 \r
688         if (e.classname != "turret_checkpoint")\r
689             dprint("Warning: not a turrret path\n");\r
690         else\r
691             self.goalcurrent = e;\r
692     }\r
693 }\r
694 void walker_diehook()\r
695 {\r
696 \r
697     self.wkr_props.solid = SOLID_NOT;\r
698     self.wkr_props.alpha = -1;\r
699 }\r
700 \r
701 //.string target_start;\r
702 void turret_walker_dinit()\r
703 {\r
704     entity e;\r
705 \r
706     if (self.netname == "")      self.netname     = "Walker Turret";\r
707 \r
708     /*\r
709     if (self.target != "")\r
710     {\r
711         e = find(world,targetname,self.target);\r
712         if (!e)\r
713         {\r
714             bprint("Warning! initital waypoint for Walker does NOT exsist!\n");\r
715             self.target = "";\r
716         }\r
717 \r
718         if (e.classname != "turret_checkpoint")\r
719             dprint("Warning: not a turrret path\n");\r
720         else\r
721             self.goalcurrent = e;\r
722     }\r
723     */\r
724 \r
725     self.wkr_props = spawn();\r
726     self.wkr_spawn = spawn();\r
727 \r
728     self.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;\r
729     self.turrcaps_flags = TFL_TURRCAPS_HITSCAN | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MOVE | TFL_TURRCAPS_ROAM | TFL_TURRCAPS_LINKED;\r
730     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_ZEASE;\r
731 \r
732     self.turret_respawnhook = walker_respawnhook;\r
733     self.turret_diehook = walker_diehook;\r
734 \r
735     self.ticrate = 0.05;\r
736     if (turret_stdproc_init("walker_std") == 0)\r
737     {\r
738         remove(self);\r
739         return;\r
740     }\r
741     self.damage_flags |= RFL_DMG_DEATH_NOGIBS;\r
742 \r
743     self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;\r
744     self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK;// | TFL_TARGETSELECT_LOS;\r
745 \r
746     //self.flags      = FL_CLIENT;\r
747     self.iscreature = TRUE;\r
748     self.movetype   = MOVETYPE_WALK;\r
749     self.solid      = SOLID_SLIDEBOX;\r
750     self.takedamage = DAMAGE_AIM;\r
751 \r
752     setmodel(self.wkr_props,"models/turrets/walker_props.md3");\r
753     setmodel(self.wkr_spawn,"models/turrets/walker_spawn.md3");\r
754     setorigin(self.wkr_spawn,self.origin);\r
755 \r
756     self.wkr_spawn.angles   = self.angles;\r
757     self.wkr_spawn.solid    = SOLID_NOT;\r
758 \r
759     traceline(self.wkr_spawn.origin + '0 0 10', self.wkr_spawn.origin - '0 0 10000', MOVE_NOMONSTERS, self);\r
760     setorigin(self.wkr_spawn,trace_endpos + '0 0 4');\r
761 \r
762     setmodel(self,"models/turrets/walker_body.md3");\r
763     setmodel(self.tur_head,"models/turrets/walker_head_minigun.md3");\r
764 \r
765     setattachment(self.tur_head,self,"tag_head");\r
766     setattachment(self.wkr_props,self,"tag_head");\r
767 \r
768     vector v;\r
769     float f;\r
770     f = gettagindex(self.tur_head,"tag_fire");\r
771     v = gettaginfo(self.tur_head,f);\r
772     v_y = v_y * -1;\r
773 \r
774     setsize(self,WALKER_MIN,WALKER_MAX);\r
775     //setsize(self,'-70 -70 0','70 70 55');\r
776 \r
777     self.tur_shotorg = v;\r
778     self.tur_aimorg  = v;\r
779 \r
780     self.idle_aim = '0 0 0';\r
781 \r
782 //    self.v_home = self.origin;\r
783 \r
784     self.turret_firecheckfunc   = walker_firecheck;\r
785 \r
786     // Our fire routine\r
787     self.turret_firefunc  = walker_attack;\r
788 \r
789     self.turret_postthink = walker_postthink;\r
790 \r
791 }\r
792 \r
793 \r
794 void spawnfunc_turret_walker()\r
795 {\r
796     precache_model ("models/turrets/walker_head_minigun.md3");\r
797     precache_model ("models/turrets/walker_body.md3");\r
798     precache_model ("models/turrets/walker_props.md3");\r
799     precache_model ("models/turrets/walker_spawn.md3");\r
800     precache_model ( "models/turrets/rocket.md3");\r
801 \r
802     self.think = turret_walker_dinit;\r
803     self.nextthink = time + 0.5;\r
804 }\r