]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/units/unit_plasma.qc
Merge branch 'master' into terencehill/physics_panel_updates
[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, CH_WEAPON_A, "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, CH_WEAPON_A, "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     self.event_damage = SUB_Null;
88     //w_deathtypestring = "ate to much plasma";
89 #ifdef TURRET_DEBUG
90     float d;
91
92     d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_PLASMA, world);
93     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
94     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
95 #else
96     RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_PLASMA, world);
97 #endif
98
99     remove (self);
100 }
101
102 void turret_plasma_std_init()
103 {
104     if (self.netname == "")      self.netname     = "Plasma Cannon";
105
106     // What ammo to use
107     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
108
109     // How to aim
110     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_GROUND2;
111     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MISSILEKILL;
112
113     if (turret_stdproc_init("plasma_std", "models/turrets/base.md3", "models/turrets/plasma.md3", TID_PLASMA) == 0)
114     {
115         remove(self);
116         return;
117     }
118
119     self.damage_flags    |= TFL_DMG_HEADSHAKE;
120     self.firecheck_flags |= TFL_FIRECHECK_AFF;
121
122     // Our fireing routine
123     self.turret_firefunc  = turret_plasma_attack;
124
125     // Custom per turret frame stuff. usualy animation.
126     self.turret_postthink = turret_plasma_postthink;
127     turret_do_updates(self);
128 }
129
130
131 void turret_plasma_dual_init()
132 {
133     if (self.netname == "")      self.netname     = "Dual Plasma Cannon";
134
135     // What ammo to use
136     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
137
138     // How to aim at targets
139     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE  | TFL_AIM_GROUND2 ;
140     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
141
142     if (turret_stdproc_init("plasma_dual", "models/turrets/base.md3", "models/turrets/plasmad.md3", TID_PLASMA_DUAL) == 0)
143     {
144         remove(self);
145         return;
146     }
147
148     self.damage_flags    |= TFL_DMG_HEADSHAKE;
149     self.firecheck_flags |= TFL_FIRECHECK_AFF;
150
151     // Our fireing routine
152     self.turret_firefunc  = turret_plasma_dual_attack;
153
154     // Custom per turret frame stuff. usualy animation.
155     self.turret_postthink = turret_plasma_dual_postthink;
156 }
157
158
159 /*
160 * Basic moderate (std) or fast (dual) fireing, short-mid range energy cannon.
161 * Not too mutch of a therat on its own, but can be rather dangerous in groups.
162 * Regenerates ammo slowly, support with a fusionreactor(s) to do some real damage.
163 */
164
165 /*QUAKED turret_plasma (0 .5 .8) ?
166 */
167 void spawnfunc_turret_plasma()
168 {
169     g_turrets_common_precash();
170     precache_model ("models/turrets/plasma.md3");
171     precache_model ("models/turrets/base.md3");
172
173     self.think = turret_plasma_std_init;
174     self.nextthink = time + 0.5;
175 }
176
177 /*QUAKED turret_plasma_dual (0 .5 .8) ?
178 */
179 void spawnfunc_turret_plasma_dual()
180 {
181
182     precache_model ("models/turrets/plasmad.md3");
183     precache_model ("models/turrets/base.md3");
184
185     self.think = turret_plasma_dual_init;
186     self.nextthink = time + 0.5;
187 }
188