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