]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/tturrets/units/unit_plasma.qc
renamed src files. to much turrets/turret_something/tturret... ;)
[divverent/nexuiz.git] / data / qcsrc / server / tturrets / units / unit_plasma.qc
1 void spawnfunc_turret_plasma();\r
2 void spawnfunc_turret_plasma_dual();\r
3 \r
4 void turret_plasma_std_init();\r
5 void turret_plasma_dual_init();\r
6 \r
7 void turret_plasma_attack();\r
8 void turret_plasma_projectile_explode();\r
9 \r
10 void turret_plasma_postthink()\r
11 {\r
12     if (self.tur_head.frame != 0)\r
13         self.tur_head.frame = self.tur_head.frame + 1;\r
14 \r
15     if (self.tur_head.frame >= 5)\r
16         self.tur_head.frame = 0;\r
17 \r
18 }\r
19 \r
20 void turret_plasma_dualpostthink()\r
21 {\r
22     if (self.tur_head.frame != 0)\r
23         self.tur_head.frame = self.tur_head.frame + 1;\r
24 \r
25     if (self.tur_head.frame >= 6)\r
26         self.tur_head.frame = 0;\r
27 }\r
28 \r
29 void turret_plasma_attack()\r
30 {\r
31     entity proj;\r
32 \r
33     turret_tag_fire_update();\r
34 \r
35     sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);\r
36     proj                    = spawn ();\r
37     setorigin(proj, self.tur_shotorg_updated);\r
38     setsize(proj, '-0.5 -0.5 -0.5', '0.5 0.5 0.5');\r
39     setmodel(proj, "models/elaser.mdl"); // precision set above\r
40     proj.classname       = "plasmabomb";\r
41     proj.owner           = self;\r
42     proj.bot_dodge       = FALSE;\r
43     //proj.bot_dodgerating = self.shot_dmg;\r
44     proj.think           = turret_plasma_projectile_explode;\r
45     proj.nextthink       = time + 9;\r
46     proj.solid           = SOLID_BBOX;\r
47     proj.movetype        = MOVETYPE_FLYMISSILE;\r
48     proj.velocity        = (self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;\r
49     proj.angles          = vectoangles(proj.velocity);\r
50     proj.touch           = turret_plasma_projectile_explode;\r
51     proj.flags           = FL_PROJECTILE;\r
52     proj.effects         = EF_LOWPRECISION |  EF_BRIGHTFIELD;\r
53     proj.enemy           = self.enemy;\r
54     proj.flags           = FL_PROJECTILE | FL_NOTARGET;\r
55 \r
56     if (self.tur_head.frame == 0)\r
57         self.tur_head.frame = 1;\r
58 \r
59     // Snapback the head\r
60     // self.tur_head.angles_x = self.tur_head.angles_x + min((self.shot_dmg * 0.05),self.aim_maxpitch);\r
61 \r
62 }\r
63 \r
64 void turret_plasma_dual_attack()\r
65 {\r
66     entity proj;\r
67 \r
68     if (self.tur_head.frame > 2)\r
69         self.tur_head.frame = 1;\r
70 \r
71     turret_tag_fire_update();\r
72 \r
73     sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);\r
74     proj                    = spawn ();\r
75     setorigin(proj, self.tur_shotorg_updated);\r
76     setsize(proj, '0 0 0', '0 0 0');\r
77     setmodel(proj, "models/elaser.mdl"); // precision set above\r
78     proj.classname       = "plasmabomb";\r
79     proj.owner           = self;\r
80     proj.bot_dodge       = TRUE;\r
81     proj.bot_dodgerating = self.shot_dmg;\r
82     proj.think           = turret_plasma_projectile_explode;\r
83     proj.nextthink       = time + 9;\r
84     proj.solid           = SOLID_BBOX;\r
85     proj.movetype        = MOVETYPE_FLYMISSILE;\r
86     proj.velocity        = (self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;\r
87     proj.angles          = vectoangles(proj.velocity);\r
88     proj.touch           = turret_plasma_projectile_explode;\r
89     proj.flags           = FL_PROJECTILE;\r
90     proj.effects         = EF_LOWPRECISION |  EF_BRIGHTFIELD;\r
91     proj.enemy           = self.enemy;\r
92     proj.flags           = FL_PROJECTILE | FL_NOTARGET;\r
93 \r
94     if (self.tur_head.frame == 0)\r
95         self.tur_head.frame = 1;\r
96 \r
97     // Snapback the head\r
98     // self.tur_head.angles_x = self.tur_head.angles_x + min((self.shot_dmg * 0.05),self.aim_maxpitch);\r
99 \r
100 }\r
101 \r
102 void turret_plasma_projectile_explode()\r
103 {\r
104     vector org2;\r
105 \r
106     org2 = findbetterlocation (self.origin, 8);\r
107     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);\r
108     WriteByte (MSG_BROADCAST, 79);\r
109     WriteCoord (MSG_BROADCAST, org2_x);\r
110     WriteCoord (MSG_BROADCAST, org2_y);\r
111     WriteCoord (MSG_BROADCAST, org2_z);\r
112     WriteCoord (MSG_BROADCAST, 0);              // SeienAbunae: groan... Useless clutter\r
113     WriteCoord (MSG_BROADCAST, 0);\r
114     WriteCoord (MSG_BROADCAST, 0);\r
115     WriteByte (MSG_BROADCAST, 155);\r
116 \r
117     self.event_damage = SUB_Null;\r
118 \r
119 \r
120 #ifdef TURRET_DEBUG\r
121     float d;\r
122 \r
123     d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET, world);\r
124     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;\r
125     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;\r
126 #else\r
127     RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET, world);\r
128 #endif\r
129     sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", 1, ATTN_NORM);\r
130 \r
131     remove (self);\r
132 }\r
133 \r
134 void turret_plasma_std_init()\r
135 {\r
136     if (self.netname == "")      self.netname     = "Plasma Cannon";\r
137 \r
138     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;\r
139     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_ZEASE | TFL_AIM_GROUND2;\r
140 \r
141     if (turret_stdproc_init("plasma_std") == 0)\r
142     {\r
143         remove(self);\r
144         return;\r
145     }\r
146 \r
147     setmodel(self,"models/turrets/base.md3");\r
148     setmodel(self.tur_head,"models/turrets/plasma.md3");\r
149 \r
150 \r
151     if (!turret_tag_setup(0))\r
152         dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");\r
153 \r
154     // Our fire routine\r
155     self.turret_firefunc  = turret_plasma_dual_attack;\r
156 \r
157     // re-color badge & handle recoil effect\r
158     self.turret_postthink = turret_plasma_dualpostthink;\r
159 }\r
160 \r
161 \r
162 void turret_plasma_dual_init()\r
163 {\r
164     if (self.netname == "")      self.netname     = "Dual Plasma Cannon";\r
165 \r
166     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;\r
167 \r
168     if (turret_stdproc_init("plasma_dual") == 0)\r
169     {\r
170         remove(self);\r
171         return;\r
172     }\r
173 \r
174     setmodel(self,"models/turrets/base.md3");\r
175     setmodel(self.tur_head,"models/turrets/plasmad.md3");\r
176 \r
177     if (!turret_tag_setup(0))\r
178         dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");\r
179 \r
180     // select aim\r
181     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_ZEASE | TFL_AIM_GROUND2;\r
182 \r
183     // Our fire routine\r
184     self.turret_firefunc  = turret_plasma_attack;\r
185 \r
186     // re-color badge & handle recoil effect\r
187     self.turret_postthink = turret_plasma_postthink;\r
188 }\r
189 \r
190 \r
191 /*\r
192 * Basic moderate (std) or fast (dual) fireing, short-mid range energy cannon.\r
193 * Not too mutch of a therat on its own, but can be rather dangerous in groups.\r
194 * Regenerates ammo slowly, support with a fusionreactor(s) to do some real damage.\r
195 */\r
196 \r
197 /*QUAKED turret_plasma (0 .5 .8) ?\r
198 */\r
199 void spawnfunc_turret_plasma()\r
200 {\r
201     //precache_model ("models/turrets/plasma.md3");\r
202     //precache_model ("models/turrets/base.md3");\r
203 \r
204     self.think = turret_plasma_std_init;\r
205     self.nextthink = time + 0.5;\r
206 }\r
207 \r
208 /*QUAKED turret_plasma_dual (0 .5 .8) ?\r
209 */\r
210 void spawnfunc_turret_plasma_dual()\r
211 {\r
212     //precache_model ("models/turrets/plasmad.md3");\r
213     //precache_model ("models/turrets/base.md3");\r
214 \r
215     self.think = turret_plasma_dual_init;\r
216     self.nextthink = time + 0.5;\r
217 }\r
218 \r