Turret should now work in ONS.
[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", 1, 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"))\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", 1, ATTN_NORM);\r
313     sound (rocket, CHAN_PROJECTILE, "weapons/rocket_fly.wav", 0.4, ATTN_NORM);\r
314     setmodel (rocket, "models/turrets/rocket.md3"); // precision set below\r
315     setsize (rocket, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot\r
316 \r
317     rocket.classname          = "walker_rocket";\r
318     rocket.owner              = self;\r
319     rocket.bot_dodge          = TRUE;\r
320     rocket.bot_dodgerating    = 50;\r
321     rocket.takedamage         = DAMAGE_YES;\r
322 \r
323     rocket.damageforcescale   = 2;\r
324     rocket.health             = 10;\r
325     rocket.tur_shotorg        = randomvec() * 512;\r
326     rocket.cnt                = time + 1;\r
327     rocket.enemy              = self.enemy;\r
328 \r
329     if (random() < 0.01)\r
330         rocket.think          = walker_rocket_loop;\r
331     else\r
332         rocket.think          = walker_rocket_think;\r
333 \r
334     rocket.event_damage       = walker_rocket_damage;\r
335 \r
336     rocket.nextthink          = time + 0.25;\r
337     rocket.solid              = SOLID_BBOX;\r
338     rocket.movetype           = MOVETYPE_FLYMISSILE;\r
339     rocket.effects            = EF_LOWPRECISION;\r
340     rocket.velocity           = ((v_forward + v_up * 0.25) +(randomvec() * 0.1))* cvar("g_turrets_unit_walker_std_rocket_speed");\r
341     rocket.angles             = vectoangles(rocket.velocity);\r
342     rocket.touch              = walker_rocket_explode;\r
343     rocket.flags              = FL_PROJECTILE;\r
344     rocket.solid              = SOLID_BBOX;\r
345     rocket.tur_health         = time + 9;\r
346 \r
347     te_explosion (rocket.origin);\r
348 \r
349 }\r
350 \r
351 /*\r
352 #define s_turn 10\r
353 #define s_walk 100\r
354 #define s_run 300\r
355 #define s_accel1 8\r
356 #define s_accel2 16\r
357 #define s_decel 8\r
358 */\r
359 \r
360 void rv_think()\r
361 {\r
362     float f;\r
363     vector org;\r
364     entity oldself;\r
365 \r
366     if(self.owner.deadflag != DEAD_NO)\r
367     {\r
368         remove(self);\r
369         return;\r
370     }\r
371 \r
372     self.cnt = self.cnt -1;\r
373 \r
374     if (self.cnt < 0)\r
375     {\r
376         remove(self);\r
377         return;\r
378     }\r
379 \r
380     if (self.cnt > 1)\r
381         f = gettagindex(self.owner,"tag_rocket01");\r
382     else\r
383         f = gettagindex(self.owner,"tag_rocket02");\r
384 \r
385     org = self.owner.origin + gettaginfo(self.owner,f);\r
386 \r
387 \r
388 \r
389     self.nextthink = time + 0.2;\r
390     oldself = self;\r
391     self = self.owner;\r
392     walker_fire_rocket(org);\r
393     self=oldself;\r
394 }\r
395 \r
396 /*\r
397 void acb_run()\r
398 {\r
399     //bprint("run\n");\r
400     animation_set(self,5,25,40,AF_ENDCALLBACK,5);\r
401 }\r
402 void acb_walk()\r
403 {\r
404     bprint("walk\n");\r
405     animation_set(self,5,25,20,AF_ENDCALLBACK,5);\r
406 }\r
407 void acb_meele()\r
408 {\r
409     walker_do_meele();\r
410 }\r
411 \r
412 void set_acb(void() acb_func)\r
413 {\r
414     self.animator_callback = acb_func;\r
415     if(animation_query(self) != AS_RUNNING)\r
416     {\r
417         bprint("Not running\n");\r
418         acb_func();\r
419     }\r
420     else\r
421     {\r
422         if not(self.animator.anim_flags & AF_ENDCALLBACK)\r
423             self.animator.anim_flags = self.animator.anim_flags | AF_ENDCALLBACK;\r
424     }\r
425 }\r
426 */\r
427 \r
428 void walker_postthink()\r
429 {\r
430     vector wish_angle;\r
431     vector real_angle;\r
432     vector steer;\r
433     float vel;\r
434 \r
435     //if (self.flags & FL_ONGROUND)\r
436     //if (self.animflag != ANIM_MEELE)\r
437     //    self.animflag = ANIM_NO;\r
438 \r
439     if (self.tur_head.attack_finished_single < time)\r
440     if (self.enemy)\r
441     {\r
442         entity rv;\r
443 \r
444         rv = spawn();\r
445         rv.think = rv_think;\r
446         rv.nextthink = time;\r
447         rv.cnt = 4;\r
448         rv.owner = self;\r
449 \r
450         self.tur_head.attack_finished_single = time + cvar("g_turrets_unit_walker_std_rocket_refire");\r
451     }\r
452 \r
453     // Do we have a path?\r
454     if (self.pathcurrent)\r
455     {\r
456         //set_acb(acb_walk);\r
457         self.animflag = ANIM_WALK;\r
458 \r
459         // Are we close enougth to a path node to switch to the next?\r
460         if (vlen(self.origin  - self.pathcurrent.origin) < 64)\r
461             if (self.pathcurrent.path_next == world)\r
462             {\r
463                 // Path endpoint reached\r
464                 pathlib_deletepath(self.pathcurrent.owner);\r
465                 self.pathcurrent = world;\r
466 \r
467                 if(self.pathgoal)\r
468                 {\r
469                     if(self.pathgoal.use)\r
470                         self.pathgoal.use();\r
471 \r
472                     if(self.pathgoal.enemy)\r
473                     {\r
474                         self.pathcurrent = pathlib_makepath(self.pathgoal.origin,self.pathgoal.enemy.origin,PLF_GROUNDSNAP,1500,2,PT_QUICKBOX);\r
475                         self.pathgoal = self.pathgoal.enemy;\r
476                     }\r
477                 }\r
478                 else\r
479                     self.pathgoal = world;\r
480             }\r
481             else\r
482                 self.pathcurrent = self.pathcurrent.path_next;\r
483 \r
484         steer = steerlib_attract2(self.pathcurrent.origin,0.5,2000,0.95);\r
485         vel = 150;\r
486     }\r
487     else // Roaming mode\r
488     {\r
489         if (self.enemy)\r
490         {\r
491             wish_angle = angleofs(self,self.enemy);\r
492             steer = steerlib_pull(self.enemy.origin);\r
493 \r
494             if (self.tur_dist_enemy < cvar("g_turrets_unit_walker_std_meele_range"))\r
495             {\r
496                 if (fabs(wish_angle_y) < 15)\r
497                 {\r
498                     vel = 0;\r
499                     //set_acb(acb_meele);\r
500                     //walker_do_meele();\r
501                     self.animflag = ANIM_MEELE;\r
502                     return;\r
503                 }\r
504             }\r
505             else\r
506             {\r
507                 if (fabs(wish_angle_y) < 15)\r
508                 {\r
509                     //set_acb(acb_run);\r
510                     self.animflag = ANIM_RUN;\r
511                     vel = 300;\r
512                 }\r
513                 else if (fabs(wish_angle_y) < 30)\r
514                 {\r
515                     //set_acb(acb_walk);\r
516                     self.animflag = ANIM_WALK;\r
517                     vel = 150;\r
518                 }\r
519                 else\r
520                 {\r
521                     //set_acb(acb_walk);\r
522                     self.animflag = ANIM_WALK;\r
523                     vel = 50;\r
524                 }\r
525             }\r
526         }\r
527         else\r
528         {\r
529             vel = 0;\r
530 \r
531             if(self.animflag != ANIM_MEELE)\r
532                 self.animflag = ANIM_NO;\r
533         }\r
534     }\r
535 \r
536     // Align the walker to the ground\r
537 \r
538     self.angles_x = self.angles_x  * -1;\r
539     makevectors(self.angles);\r
540     self.angles_x = self.angles_x  * -1;\r
541 \r
542     traceline(self.origin + '0 0 15', self.origin - '0 0 150' ,MOVE_WORLDONLY,self);\r
543     wish_angle = (trace_endpos);\r
544     traceline(self.origin  + v_forward * 10 + '0 0 15', self.origin + v_forward * 10 - '0 0 150' ,MOVE_WORLDONLY,self);\r
545     real_angle = vectoangles(normalize( trace_endpos - wish_angle));\r
546 \r
547     self.angles_x = real_angle_x;\r
548     self.angles_z = real_angle_z;\r
549 \r
550     if(vel == 0)\r
551     {\r
552         self.velocity = '0 0 0';\r
553         //animator_remove(self);\r
554     }\r
555     else\r
556     {\r
557         steer  = steer * 0.5  + steerlib_traceavoid(0.3,256);\r
558         float vz;\r
559         vz = self.velocity_z;\r
560         movelib_move_simple(steer * 200,vel,0.5);\r
561         self.velocity_z = vz;\r
562 \r
563         wish_angle = vectoangles(self.velocity);\r
564 \r
565         real_angle = wish_angle - self.angles;\r
566 \r
567         real_angle_y = shortangle_f(real_angle_y,self.angles_y);\r
568 \r
569         self.angles_y = self.angles_y + bound(-5,real_angle_y,5);\r
570     }\r
571     walker_animate();\r
572 \r
573     if (self.tur_head.frame != 0)\r
574         self.tur_head.frame = self.tur_head.frame +1;\r
575 \r
576     if (self.tur_head.frame > 12)\r
577         self.tur_head.frame = 0;\r
578 \r
579 \r
580 }\r
581 \r
582 void walker_attack()\r
583 {\r
584     entity flash;\r
585 \r
586     //turret_do_updates(self);\r
587 \r
588     self.tur_head.frame = self.tur_head.frame + 1;\r
589 \r
590     sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);\r
591 \r
592 \r
593     fireBullet (self.tur_shotorg_updated, self.tur_shotdir_updated,self.shot_spread, self.shot_dmg, self.shot_force, DEATH_TURRET, FALSE);\r
594 \r
595     te_smallflash(self.tur_shotorg_updated);\r
596 \r
597     if (!(self.uzi_bulletcounter & 3))\r
598     {\r
599 \r
600         trailparticles(self,particleeffectnum("EF_MGTURRETTRAIL"),self.tur_shotorg_updated,trace_endpos);\r
601         // te_lightning1(self,self.tur_shotorg_updated,trace_endpos);\r
602         flash = spawn();\r
603         setmodel(flash, "models/uziflash.md3"); // precision set below\r
604         setattachment(flash, self.tur_head, "tag_fire");\r
605         flash.scale = 3;\r
606         flash.think = W_Uzi_Flash_Go;\r
607         flash.nextthink = time + 0.02;\r
608         flash.frame = 2;\r
609         flash.angles_z = flash.v_angle_z + random() * 180;\r
610         flash.alpha = 1;\r
611         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;\r
612     }\r
613 \r
614     self.uzi_bulletcounter = self.uzi_bulletcounter + 1;\r
615 }\r
616 \r
617 \r
618 void walker_respawnhook()\r
619 {\r
620     vector vtmp;\r
621     entity e;\r
622 \r
623     //load_unit_settings(self.rocket_rack,"walker_std_rocket",1);\r
624 \r
625     self.origin = self.wkr_spawn.origin;\r
626     self.wkr_props.solid = SOLID_BBOX;\r
627     self.wkr_props.alpha = 1;\r
628 \r
629     self.angles = self.wkr_spawn.angles;\r
630     vtmp = self.origin;\r
631     vtmp_z +=self.wkr_spawn.origin_z + self.wkr_spawn.maxs_z;\r
632     setorigin(self,vtmp);\r
633 \r
634     if (self.target != "")\r
635     {\r
636         e = find(world,targetname,self.target);\r
637         if (!e)\r
638         {\r
639             bprint("Warning! initital waypoint for Walker does NOT exsist!\n");\r
640             self.target = "";\r
641         }\r
642 \r
643         if (e.classname != "turret_checkpoint")\r
644             dprint("Warning: not a turrret path\n");\r
645         else\r
646         {\r
647             self.pathcurrent = pathlib_makepath(self.origin,e.origin,PLF_GROUNDSNAP,500,2,PT_QUICKBOX);\r
648             self.pathgoal = e;\r
649         }\r
650     }\r
651 }\r
652 void walker_diehook()\r
653 {\r
654     //animator_remove(self);\r
655 \r
656     if(self.pathcurrent)\r
657         pathlib_deletepath(self.pathcurrent.owner);\r
658 \r
659     self.pathcurrent = world;\r
660 \r
661     self.wkr_props.solid = SOLID_NOT;\r
662     self.wkr_props.alpha = -1;\r
663 \r
664     if(self.damage_flags & TFL_DMG_DEATH_NORESPAWN)\r
665     {\r
666 \r
667         remove(self.wkr_props);\r
668         //remove(self.rocket_rack);\r
669         remove(self.wkr_spawn);\r
670     }\r
671 \r
672 }\r
673 \r
674 //.string target_start;\r
675 void turret_walker_dinit()\r
676 {\r
677 \r
678     entity e;\r
679 \r
680     if (self.netname == "")      self.netname     = "Walker Turret";\r
681 \r
682 \r
683     self.wkr_props = spawn();\r
684     self.wkr_spawn = spawn();\r
685 \r
686     self.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;\r
687     self.turrcaps_flags = TFL_TURRCAPS_HITSCAN | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MOVE | TFL_TURRCAPS_ROAM | TFL_TURRCAPS_LINKED;\r
688     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_ZEASE;\r
689 \r
690     self.turret_respawnhook = walker_respawnhook;\r
691     self.turret_diehook = walker_diehook;\r
692 \r
693     self.ticrate = 0.05;\r
694     if (turret_stdproc_init("walker_std") == 0)\r
695     {\r
696         remove(self);\r
697         return;\r
698     }\r
699     self.damage_flags |= RFL_DMG_DEATH_NOGIBS;\r
700 \r
701     self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;\r
702     self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK;// | TFL_TARGETSELECT_LOS;\r
703 \r
704     //self.flags      = FL_CLIENT;\r
705     self.iscreature = TRUE;\r
706     self.movetype   = MOVETYPE_WALK;\r
707     self.solid      = SOLID_SLIDEBOX;\r
708     self.takedamage = DAMAGE_AIM;\r
709 \r
710     setmodel(self.wkr_props,"models/turrets/walker_props.md3");\r
711     setmodel(self.wkr_spawn,"models/turrets/walker_spawn.md3");\r
712     setorigin(self.wkr_spawn,self.origin);\r
713 \r
714     self.wkr_spawn.angles   = self.angles;\r
715     self.wkr_spawn.solid    = SOLID_NOT;\r
716 \r
717 \r
718     traceline(self.wkr_spawn.origin + '0 0 10', self.wkr_spawn.origin - '0 0 10000', MOVE_NOMONSTERS, self);\r
719     setorigin(self.wkr_spawn,trace_endpos + '0 0 4');\r
720 \r
721     setmodel(self,"models/turrets/walker_body.md3");\r
722     setmodel(self.tur_head,"models/turrets/walker_head_minigun.md3");\r
723 \r
724     setattachment(self.tur_head,self,"tag_head");\r
725     setattachment(self.wkr_props,self,"tag_head");\r
726 \r
727     vector v;\r
728     float f;\r
729     f = gettagindex(self.tur_head,"tag_fire");\r
730     v = gettaginfo(self.tur_head,f);\r
731     v_y = v_y * -1;\r
732 \r
733     setsize(self,WALKER_MIN,WALKER_MAX);\r
734     //setsize(self,'-70 -70 0','70 70 55');\r
735 \r
736     self.tur_shotorg = v;\r
737     self.tur_aimorg  = v;// + '0 0 10';\r
738 \r
739     self.idle_aim = '0 0 0';\r
740 \r
741 //    self.v_home = self.origin;\r
742 \r
743     self.turret_firecheckfunc   = walker_firecheck;\r
744 \r
745     // Our fire routine\r
746     self.turret_firefunc  = walker_attack;\r
747 \r
748     self.turret_postthink = walker_postthink;\r
749 \r
750     if (self.target != "")\r
751     {\r
752         e = find(world,targetname,self.target);\r
753         if (!e)\r
754         {\r
755             bprint("Warning! initital waypoint for Walker does NOT exsist!\n");\r
756             self.target = "";\r
757         }\r
758 \r
759         if (e.classname != "turret_checkpoint")\r
760             dprint("Warning: not a turrret path\n");\r
761         else\r
762         {\r
763             self.pathcurrent = pathlib_makepath(self.origin,e.origin,PLF_GROUNDSNAP,500,2,PT_QUICKBOX);\r
764             self.pathgoal = e;\r
765         }\r
766     }\r
767 \r
768     //self.solid    = SOLID_NOT;\r
769 \r
770 }\r
771 \r
772 \r
773 void spawnfunc_turret_walker()\r
774 {\r
775     precache_model ("models/turrets/walker_head_minigun.md3");\r
776     precache_model ("models/turrets/walker_body.md3");\r
777     precache_model ("models/turrets/walker_props.md3");\r
778     precache_model ("models/turrets/walker_spawn.md3");\r
779     precache_model ( "models/turrets/rocket.md3");\r
780 \r
781     self.think = turret_walker_dinit;\r
782     self.nextthink = time + 0.5;\r
783 }\r