]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_electro.qc
make projectiles SOLID_TRIGGER for a test
[divverent/nexuiz.git] / data / qcsrc / server / w_electro.qc
1
2 void W_Plasma_Explode (void)
3 {
4         if(other.takedamage == DAMAGE_AIM)
5                 if(other.classname == "player")
6                         if(IsDifferentTeam(self.owner, other))
7                                 if(other.deadflag == DEAD_NO)
8                                         if(IsFlying(other))
9                                                 announce(self.owner, "announcer/male/electrobitch.wav");
10
11         self.event_damage = SUB_Null;
12         if (self.movetype == MOVETYPE_BOUNCE)
13         {
14                 RadiusDamage (self, self.owner, cvar("g_balance_electro_secondary_damage"), cvar("g_balance_electro_secondary_edgedamage"), cvar("g_balance_electro_secondary_radius"), world, cvar("g_balance_electro_secondary_force"), self.projectiledeathtype, other);
15         }
16         else
17         {
18                 RadiusDamage (self, self.owner, cvar("g_balance_electro_primary_damage"), cvar("g_balance_electro_primary_edgedamage"), cvar("g_balance_electro_primary_radius"), world, cvar("g_balance_electro_primary_force"), self.projectiledeathtype, other);
19         }
20
21         remove (self);
22 }
23
24 void W_Plasma_Explode_Combo (void) {
25         self.event_damage = SUB_Null;
26         RadiusDamage (self, self.owner, cvar("g_balance_electro_combo_damage"), cvar("g_balance_electro_combo_edgedamage"), cvar("g_balance_electro_combo_radius"), world, cvar("g_balance_electro_combo_force"), WEP_ELECTRO | HITTYPE_BOUNCE, other); // use THIS type for a combo because primary can't bounce
27         remove (self);
28 }
29
30 void W_Plasma_Touch (void)
31 {
32         PROJECTILE_TOUCH;
33         if (other.takedamage == DAMAGE_AIM) {
34                 W_Plasma_Explode ();
35         } else {
36                 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
37                 self.projectiledeathtype |= HITTYPE_BOUNCE;
38         }
39 }
40
41 void W_Plasma_TouchExplode (void)
42 {
43         PROJECTILE_TOUCH;
44         W_Plasma_Explode ();
45 }
46
47 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
48 {
49         if(self.health <= 0)
50                 return;
51         self.health = self.health - damage;
52         if (self.health <= 0)
53         {
54                 self.takedamage = DAMAGE_NO;
55                 self.nextthink = time;
56                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
57                 {
58                         // change owner to whoever caused the combo explosion
59                         self.owner = inflictor.owner;
60                         self.classname = "plasma_chain";
61                         self.think = W_Plasma_Explode_Combo;
62                         self.nextthink = time + vlen(self.origin - inflictor.origin) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
63                 }
64                 else
65                         self.think = W_Plasma_Explode;
66         }
67 }
68
69 void W_Electro_Attack()
70 {
71         local entity proj;
72
73         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", cvar("g_balance_electro_primary_damage"));
74
75         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
76
77         proj = spawn ();
78         proj.classname = "plasma_prim";
79         proj.owner = self;
80         proj.bot_dodge = TRUE;
81         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
82         proj.use = W_Plasma_Explode;
83         proj.think = adaptor_think2use;
84         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
85         PROJECTILE_MAKETRIGGER(proj);
86         proj.projectiledeathtype = WEP_ELECTRO;
87         setorigin(proj, w_shotorg);
88
89         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
90                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
91         proj.movetype = MOVETYPE_FLY;
92         proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
93         W_SetupProjectileVelocity(proj);
94         proj.angles = vectoangles(proj.velocity);
95         proj.touch = W_Plasma_TouchExplode;
96         setsize(proj, '0 0 -3', '0 0 -3');
97         proj.flags = FL_PROJECTILE;
98
99         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
100         //sounds bad
101
102         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
103 }
104
105 void W_Electro_Attack2()
106 {
107         local entity proj;
108
109         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire2.wav", cvar("g_balance_electro_secondary_damage"));
110         w_shotdir = v_forward; // no TrueAim for grenades please
111
112         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
113
114         proj = spawn ();
115         proj.classname = "plasma";
116         proj.owner = self;
117         proj.use = W_Plasma_Explode;
118         proj.think = adaptor_think2use;
119         proj.bot_dodge = TRUE;
120         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
121         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
122         PROJECTILE_MAKETRIGGER(proj);
123         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
124         setorigin(proj, w_shotorg);
125
126         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
127                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
128         //proj.glow_size = 50;
129         //proj.glow_color = 45;
130         proj.movetype = MOVETYPE_BOUNCE;
131         proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_electro_secondary_spread")) * cvar("g_balance_electro_secondary_speed") + v_up * cvar("g_balance_electro_secondary_speed_up");
132         W_SetupProjectileVelocity(proj);
133         proj.touch = W_Plasma_Touch;
134         setsize(proj, '0 0 -3', '0 0 -3');
135         proj.takedamage = DAMAGE_YES;
136         proj.damageforcescale = cvar("g_balance_electro_secondary_damageforcescale");
137         proj.health = cvar("g_balance_electro_secondary_health");
138         proj.event_damage = W_Plasma_Damage;
139         proj.flags = FL_PROJECTILE;
140
141 #if 0
142         entity p2;
143         p2 = spawn();
144         copyentity(proj, p2);
145         setmodel(p2, "models/ebomb.mdl");
146         setsize(p2, proj.mins, proj.maxs);
147 #endif
148
149         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
150 }
151
152 void spawnfunc_weapon_electro (void)
153 {
154         weapon_defaultspawnfunc(WEP_ELECTRO);
155 }
156
157 .float bot_secondary_electromooth;
158 float w_electro(float req)
159 {
160         if (req == WR_AIM)
161         {
162                 self.BUTTON_ATCK=FALSE;
163                 self.BUTTON_ATCK2=FALSE;
164                 if(vlen(self.origin-self.enemy.origin) > 1000)
165                         self.bot_secondary_electromooth = 0;
166                 if(self.bot_secondary_electromooth == 0)
167                 {
168                         if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
169                         {
170                                 self.BUTTON_ATCK = TRUE;
171                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
172                         }
173                 }
174                 else
175                 {
176                         if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
177                         {
178                                 self.BUTTON_ATCK2 = TRUE;
179                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
180                         }
181                 }
182         }
183         else if (req == WR_THINK)
184         {
185                 if (self.BUTTON_ATCK)
186                 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
187                 {
188                         W_Electro_Attack();
189                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
190                 }
191                 if (self.BUTTON_ATCK2)
192                 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
193                 {
194                         W_Electro_Attack2();
195                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_ready);
196                 }
197         }
198         else if (req == WR_PRECACHE)
199         {
200                 precache_model ("models/weapons/g_electro.md3");
201                 precache_model ("models/weapons/v_electro.md3");
202                 precache_model ("models/weapons/h_electro.dpm");
203                 precache_sound ("weapons/electro_bounce.wav");
204                 precache_sound ("weapons/electro_fire.wav");
205                 precache_sound ("weapons/electro_fire2.wav");
206                 precache_sound ("weapons/electro_impact.wav");
207                 precache_sound ("weapons/electro_impact_combo.wav");
208         }
209         else if (req == WR_SETUP)
210                 weapon_setup(WEP_ELECTRO);
211         else if (req == WR_CHECKAMMO1)
212                 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
213         else if (req == WR_CHECKAMMO2)
214                 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
215         else if (req == WR_SUICIDEMESSAGE)
216         {
217                 if(w_deathtype & HITTYPE_SECONDARY)
218                         w_deathtypestring = "could not remember where he put plasma";
219                 else
220                         w_deathtypestring = "played with plasma";
221         }
222         else if (req == WR_KILLMESSAGE)
223         {
224                 if(w_deathtype & HITTYPE_SECONDARY)
225                 {
226                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
227                                 w_deathtypestring = "just noticed #'s blue ball";
228                         else // unchecked: BOUNCE
229                                 w_deathtypestring = "got in touch with #'s blue ball";
230                 }
231                 else
232                 {
233                         if(w_deathtype & HITTYPE_BOUNCE) // combo
234                                 w_deathtypestring = "felt the electrifying air of #'s combo";
235                         else if(w_deathtype & HITTYPE_SPLASH)
236                                 w_deathtypestring = "got too close to #'s blue beam";
237                         else
238                                 w_deathtypestring = "was blasted by #'s blue beam";
239                 }
240         }
241         return TRUE;
242 };