]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/tturrets/units/unit_checkpoint.qc
Updated pathlib.qc
[divverent/nexuiz.git] / data / qcsrc / server / tturrets / units / unit_checkpoint.qc
1 /**\r
2     turret_checkpoint\r
3     Semi smart pathing system for move capable turrets.\r
4 **/\r
5 \r
6 #define checkpoint_path swampslug\r
7 #define checkpoint_target enemy\r
8 \r
9 #define checkpoint_cache_who flagcarried\r
10 #define checkpoint_cache_from lastrocket\r
11 #define checkpoint_cache_to selected_player\r
12 \r
13 entity path_makeorcache(entity forwho,entity start, entity end)\r
14 {\r
15     entity oldself;\r
16     entity pth;\r
17     oldself = self;\r
18     self = forwho;\r
19 \r
20     pth = pathlib_makepath(start.origin,end.origin,PLF_GROUNDSNAP,500,1.5);\r
21     self = oldself;\r
22     return pth;\r
23 }\r
24 \r
25 void turret_checkpoint_use()\r
26 {\r
27     if(other.checkpoint_path)\r
28         pathlib_deletepath(other.checkpoint_path);\r
29 \r
30     other.checkpoint_path = world;\r
31 \r
32     if(self.checkpoint_target)\r
33         other.checkpoint_path = path_makeorcache(other,self,self.checkpoint_target);\r
34 \r
35 }\r
36 \r
37 /*QUAKED turret_checkpoint (1 0 1) (-32 -32 -32) (32 32 32)\r
38 -----------KEYS------------\r
39 target: .targetname of next waypoint in chain.\r
40 wait:   Pause at this point # seconds.\r
41 -----------SPAWNFLAGS-----------\r
42 ---------NOTES----------\r
43 If a loop is of targets are formed, any unit entering this loop will patrol it indefinitly.\r
44 If the checkpoint chain in not looped, the unit will go "Roaming" when the last point is reached.\r
45 */\r
46 void spawnfunc_turret_checkpoint()\r
47 {\r
48     if(self.target != "")\r
49     {\r
50         self.checkpoint_target = find(world,targetname,self.target);\r
51         if(!self.checkpoint_target)\r
52             dprint("A turret_checkpoint faild to find its target!\n");\r
53     }\r
54 \r
55 }\r
56 \r
57 // Compat.\r
58 void spawnfunc_walker_checkpoint()\r
59 {\r
60     self.classname = "turret_checkpoint";\r
61     spawnfunc_turret_checkpoint();\r
62 }\r