]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_electro.c
Added a massive push when shot with the Nex
[divverent/nexuiz.git] / qcsrc / gamec / w_electro.c
1 void() electro_ready_01;
2 void() electro_fire1_01;
3 void() electro_fire2_01;
4 void() electro_deselect_01;
5 void() electro_select_01;
6
7 float() electro_check1 =
8 {
9         if (self.ammo_cells > 1)
10                 return TRUE;
11         return FALSE;
12 };
13
14 float() electro_check2 =
15 {
16         if (self.ammo_cells > 2)
17                 return TRUE;
18         return FALSE;
19 };
20
21 void(float req) w_electro =
22 {
23         if (req == WR_IDLE)
24                 electro_ready_01();
25         else if (req == WR_FIRE1)
26                 weapon_prepareattack(electro_check1, electro_check1, electro_fire1_01, 0.4);
27         else if (req == WR_FIRE2)
28                 weapon_prepareattack(electro_check1, electro_check2, electro_fire2_01, 2);
29         else if (req == WR_RAISE)
30                 electro_select_01();
31         else if (req == WR_UPDATECOUNTS)
32                 self.currentammo = self.ammo_cells;
33         else if (req == WR_DROP)
34                 electro_deselect_01();
35         else if (req == WR_SETUP)
36                 weapon_setup(WEP_ELECTRO, "w_electro.zym", IT_CELLS);
37         else if (req == WR_CHECKAMMO)
38                 weapon_hasammo = electro_check1();
39 };
40
41
42 void W_Plasma_Explode (entity ignore)
43 {
44         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
45         WriteByte (MSG_BROADCAST, 79);
46         WriteCoord (MSG_BROADCAST, self.origin_x);
47         WriteCoord (MSG_BROADCAST, self.origin_y);
48         WriteCoord (MSG_BROADCAST, self.origin_z);
49         WriteCoord (MSG_BROADCAST, 0);          // SeienAbunae: groan... Useless clutter
50         WriteCoord (MSG_BROADCAST, 0);
51         WriteCoord (MSG_BROADCAST, 0);
52         WriteByte (MSG_BROADCAST, 155);
53
54         te_customflash (self.origin, 5000, 10, '0 0 1');
55
56         self.event_damage = nullfunction;
57         RadiusDamage (self, self.owner, cvar("g_balance_electro_grenade_damage"), cvar("g_balance_electro_grenade_edgedamage"), cvar("g_balance_electro_grenade_radius"), world, cvar("g_balance_electro_grenade_force"), IT_ELECTRO);
58         sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
59
60         remove (self);
61 }
62
63 void W_Plasma_FuseExplode (void)
64 {
65         W_Plasma_Explode (world);
66 }
67
68 void W_Plasma_Touch (void)
69 {
70         if (other.classname == "player" || other.classname == "corpse")
71                 W_Plasma_Explode (other);
72         else
73                 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
74 }
75
76 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
77 {
78         self.health = self.health - damage;
79         if (self.health <= 0)
80                 W_Plasma_FuseExplode ();
81 }
82
83 void W_Plasma_Think ()
84 {
85         self.velocity = self.velocity * 1.2;
86 }
87
88
89 void() W_Electro_Attack
90 {
91         entity  proj;
92         float postion;
93
94         postion = self.electrocount;
95         makevectors(self.v_angle);
96         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
97
98         proj = spawn ();
99         proj.owner = self;
100         proj.classname = "spike";
101
102         proj.movetype = MOVETYPE_FLY;
103         proj.solid = SOLID_BBOX;
104         proj.effects = 1;
105
106         vector org;
107         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
108
109         te_smallflash(org);
110
111         setmodel (proj, "models/elaser.mdl");
112         setsize (proj, '0 0 0', '0 0 0');
113         if (postion == 0)
114         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
115         if (postion == 1)
116         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
117         if (postion == 2)
118         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
119
120         proj.velocity = v_forward * cvar("g_balance_electro_shot_speed");
121         proj.touch = W_Plasma_Explode;
122         proj.think = W_Plasma_Think;
123         proj.nextthink = time + 0.1;
124
125         proj.angles = vectoangles (proj.velocity);
126
127         proj.effects = proj.effects | EF_ADDITIVE;
128
129         self.attack_finished = time + 0.4;
130         self.ammo_cells = self.ammo_cells - 1;
131 }
132
133 void() W_Electro_Attack2
134 {
135         entity  Plasma;
136         float postion;
137
138         postion = self.electrocount;
139         makevectors(self.v_angle);
140         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
141
142         self.punchangle_x = -4;
143
144         Plasma = spawn ();
145         Plasma.owner = self;
146         Plasma.classname = "grenade";
147         Plasma.effects = 1;
148
149         Plasma.movetype = MOVETYPE_BOUNCE;
150         Plasma.solid = SOLID_BBOX;
151
152         vector org;
153         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
154         te_smallflash(org);
155
156         Plasma.takedamage = DAMAGE_YES;
157         Plasma.damageforcescale = 4;
158         Plasma.health = 5;
159         Plasma.event_damage = W_Plasma_Damage;
160
161         setmodel (Plasma, "models/ebomb.mdl");
162         setsize (Plasma, '-6 -6 -3', '6 6 3');
163
164         if (postion == 0)
165         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
166         if (postion == 1)
167         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
168         if (postion == 2)
169         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
170
171         Plasma.velocity = v_forward * cvar("g_balance_electro_grenade_speed") + v_up * cvar("g_balance_electro_grenade_speed_up");
172         Plasma.angles = vectoangles (Plasma.velocity);
173         Plasma.avelocity_y = random () * -500 - 500;
174         Plasma.avelocity_x = random () * -500 - 500;
175         Plasma.avelocity_z = random () * -500 - 500;
176
177         Plasma.touch = W_Plasma_Touch;
178         Plasma.think = W_Plasma_FuseExplode;
179         Plasma.nextthink = time + 2;
180
181         Plasma.effects = Plasma.effects | EF_ADDITIVE;
182
183         self.attack_finished = time + 1;
184         self.ammo_cells = self.ammo_cells - 2;
185
186 }
187
188 // weapon frames
189
190 void()  electro_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, electro_ready_01); self.weaponentity.state = WS_READY;};
191 void()  electro_select_01 =     {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
192 void()  electro_deselect_01 =   {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
193 void()  electro_fire1_01 =
194 {
195         weapon_doattack(electro_check1, electro_check1, W_Electro_Attack);
196
197         self.electrocount = self.electrocount + 1;
198                 if (self.electrocount == 3)
199                         self.electrocount = 0;
200
201         weapon_thinkf(WFRAME_FIRE1, 0.3, electro_ready_01);
202 };
203 void()  electro_fire2_01 =
204 {
205         weapon_doattack(electro_check1, electro_check2, W_Electro_Attack2);
206
207         self.electrocount = self.electrocount + 1;
208                 if (self.electrocount == 3)
209                         self.electrocount = 0;
210
211         weapon_thinkf(WFRAME_FIRE2, 0.3, electro_ready_01);
212 };