Limit how often the Grabber's beam effect is sent (lightning bolt from the weapon...
[voretournament/voretournament.git] / data / qcsrc / server / tturrets / units / unit_phaser.qc
1 void spawnfunc_turret_phaser();\r
2 void turret_phaser_dinit();\r
3 void turret_phaser_attack();\r
4 \r
5 .float fireflag;\r
6 \r
7 float turret_phaser_firecheck()\r
8 {\r
9     if (self.fireflag != 0) return 0;\r
10     return turret_stdproc_firecheck();\r
11 }\r
12 \r
13 void turret_phaser_postthink()\r
14 {\r
15     if (self.tur_head.frame == 0)\r
16         return;\r
17 \r
18     if (self.fireflag == 1)\r
19     {\r
20         if (self.tur_head.frame == 10)\r
21             self.tur_head.frame = 1;\r
22         else\r
23             self.tur_head.frame = self.tur_head.frame +1;\r
24     }\r
25     else if (self.fireflag == 2 )\r
26     {\r
27         self.tur_head.frame = self.tur_head.frame +1;\r
28         if (self.tur_head.frame == 15)\r
29         {\r
30             self.tur_head.frame = 0;\r
31             self.fireflag = 0;\r
32         }\r
33     }\r
34 }\r
35 \r
36 void beam_think()\r
37 {\r
38     if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))\r
39     {\r
40         self.owner.attack_finished_single = time + self.owner.shot_refire;\r
41         self.owner.fireflag = 2;\r
42         self.owner.tur_head.frame = 10;\r
43         sound (self, CHAN_PROJECTILE, "", VOL_BASE, ATTN_NORM);\r
44         remove(self);\r
45         return;\r
46     }\r
47 \r
48     turret_do_updates(self.owner);\r
49 \r
50     if (time - self.shot_spread > 0)\r
51     {\r
52         self.shot_spread = time + 2;\r
53         sound (self, CHAN_VOICE, "turrets/phaser.wav", VOL_BASE, ATTN_NORM);\r
54     }\r
55 \r
56 \r
57     self.nextthink = time + self.ticrate;\r
58 \r
59     self.owner.attack_finished_single = time + frametime;\r
60     entity oldself;\r
61     oldself = self;\r
62     self = self.owner;\r
63     //w_deathtypestring = "was phased out of existence";\r
64     FireImoBeam (   self.tur_shotorg,\r
65                     self.tur_shotorg + self.tur_shotdir_updated * self.target_range,\r
66                     '-1 -1 -1' * self.shot_radius,\r
67                     '1 1 1' * self.shot_radius,\r
68                     self.shot_force,\r
69                     oldself.shot_dmg,\r
70                     0.75,\r
71                     DEATH_TURRET);\r
72     self = oldself;\r
73     self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;\r
74 \r
75 }\r
76 \r
77 void turret_phaser_attack()\r
78 {\r
79     entity beam;\r
80 \r
81     beam = spawn();\r
82     beam.ticrate = cvar("sys_ticrate");\r
83     setmodel(beam,"models/turrets/phaser_beam.md3");\r
84     beam.effects = EF_LOWPRECISION;\r
85     beam.solid = SOLID_NOT;\r
86     beam.think = beam_think;\r
87     beam.cnt = time + self.shot_speed;\r
88     beam.shot_spread = time + 2;\r
89     beam.nextthink = time;\r
90     beam.owner = self;\r
91     beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate);\r
92     beam.scale = self.target_range / 256;\r
93     beam.movetype = MOVETYPE_NONE;\r
94     beam.enemy = self.enemy;\r
95     beam.bot_dodge = TRUE;\r
96     beam.bot_dodgerating = beam.shot_dmg;\r
97     sound (beam, CHAN_PROJECTILE, "turrets/phaser.wav", VOL_BASE, ATTN_NORM);\r
98     self.fireflag = 1;\r
99 \r
100     beam.attack_finished_single = self.attack_finished_single;\r
101     self.attack_finished_single = time + cvar("sys_ticrate");\r
102 \r
103     setattachment(beam,self.tur_head,"tag_fire");\r
104 \r
105     soundat (self, trace_endpos, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);\r
106 \r
107     if (self.tur_head.frame == 0)\r
108         self.tur_head.frame = 1;\r
109 }\r
110 \r
111 void turret_phaser_dinit()\r
112 {\r
113     if (self.netname == "")      self.netname  = "Phaser Cannon";\r
114 \r
115     self.turrcaps_flags = TFL_TURRCAPS_SNIPER|TFL_TURRCAPS_HITSCAN|TFL_TURRCAPS_PLAYERKILL;\r
116     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;\r
117     self.aim_flags = TFL_AIM_ZEASE | TFL_AIM_LEAD;\r
118 \r
119     if (turret_stdproc_init("phaser_std",0,"models/turrets/base.md3","models/turrets/phaser.md3") == 0)\r
120     {\r
121         remove(self);\r
122         return;\r
123     }\r
124 \r
125     if (!turret_tag_setup())\r
126         dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");\r
127 \r
128     self.turret_firecheckfunc = turret_phaser_firecheck;\r
129     self.turret_firefunc  = turret_phaser_attack;\r
130     self.turret_postthink = turret_phaser_postthink;\r
131 \r
132 }\r
133 \r
134 /*QUAKED turret_phaser(0 .5 .8) ?\r
135 */\r
136 void spawnfunc_turret_phaser()\r
137 {\r
138     precache_sound ("turrets/phaser.wav");\r
139     precache_model ("models/turrets/phaser.md3");\r
140     precache_model ("models/turrets/phaser_beam.md3");\r
141     precache_model ("models/turrets/base.md3");\r
142 \r
143     self.think = turret_phaser_dinit;\r
144     self.nextthink = time + 0.5;\r
145 }\r
146 \r