]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/units/unit_plasma.qc
a372ad19f47b1b960c16ceb2eb1926bceb9da0d6
[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", "models/turrets/base.md3", "models/turrets/plasma.md3", TID_PLASMA) == 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     // Our fireing routine
137     self.turret_firefunc  = turret_plasma_attack;
138
139     // Custom per turret frame stuff. usualy animation.
140     self.turret_postthink = turret_plasma_postthink;
141     turret_do_updates(self);
142 }
143
144
145 void turret_plasma_dual_init()
146 {
147     if (self.netname == "")      self.netname     = "Dual Plasma Cannon";
148
149     // What ammo to use
150     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
151
152     // How to aim at targets
153     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE  | TFL_AIM_GROUND2 ;
154     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
155
156     if (turret_stdproc_init("plasma_dual", "models/turrets/base.md3", "models/turrets/plasmad.md3", TID_PLASMA_DUAL) == 0)
157     {
158         remove(self);
159         return;
160     }
161
162     self.damage_flags    |= TFL_DMG_HEADSHAKE;
163     self.firecheck_flags |= TFL_FIRECHECK_AFF;
164
165     // Our fireing routine
166     self.turret_firefunc  = turret_plasma_dual_attack;
167
168     // Custom per turret frame stuff. usualy animation.
169     self.turret_postthink = turret_plasma_dual_postthink;
170 }
171
172
173 /*
174 * Basic moderate (std) or fast (dual) fireing, short-mid range energy cannon.
175 * Not too mutch of a therat on its own, but can be rather dangerous in groups.
176 * Regenerates ammo slowly, support with a fusionreactor(s) to do some real damage.
177 */
178
179 /*QUAKED turret_plasma (0 .5 .8) ?
180 */
181 void spawnfunc_turret_plasma()
182 {
183     g_turrets_common_precash();
184     precache_model ("models/turrets/plasma.md3");
185     precache_model ("models/turrets/base.md3");
186
187     self.think = turret_plasma_std_init;
188     self.nextthink = time + 0.5;
189 }
190
191 /*QUAKED turret_plasma_dual (0 .5 .8) ?
192 */
193 void spawnfunc_turret_plasma_dual()
194 {
195
196     precache_model ("models/turrets/plasmad.md3");
197     precache_model ("models/turrets/base.md3");
198
199     self.think = turret_plasma_dual_init;
200     self.nextthink = time + 0.5;
201 }
202