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