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