]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_electro.c
major tweaks to ammo pickups, item respawn times, and all weapons are now parameteriz...
[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_Electro_Touch (void)
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);          // Sajt: Yeah.. I agree with him
51         WriteCoord (MSG_BROADCAST, 0);
52         WriteByte (MSG_BROADCAST, 155);
53         self.event_damage = nullfunction;
54         RadiusDamage (self, self.owner, cvar("g_balance_electro_shot_damage"), cvar("g_balance_electro_shot_edgedamage"), cvar("g_balance_electro_shot_radius"), world, cvar("g_balance_electro_shot_force"), IT_ELECTRO);
55         sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
56         remove (self);
57 }
58
59 void() W_Electro_Attack
60 {
61         entity  proj;
62         float postion;
63
64         postion = self.electrocount;
65         makevectors(self.v_angle);
66         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
67
68         proj = spawn ();
69         proj.owner = self;
70         proj.classname = "spike";
71
72         proj.movetype = MOVETYPE_FLY;
73         proj.solid = SOLID_BBOX;
74         proj.effects = 1;
75
76         vector org;
77         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
78
79         te_smallflash(org);
80
81         setmodel (proj, "models/elaser.mdl");
82         setsize (proj, '0 0 0', '0 0 0');
83         if (postion == 0)
84         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
85         if (postion == 1)
86         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
87         if (postion == 2)
88         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
89
90         proj.velocity = v_forward * cvar("g_balance_electro_shot_speed");
91         proj.touch = W_Electro_Touch;
92         proj.think = SUB_Remove;
93         proj.nextthink = time + 1.5;
94
95         proj.angles = vectoangles (proj.velocity);
96
97         proj.effects = proj.effects | EF_ADDITIVE;
98
99         self.attack_finished = time + 0.4;
100         self.ammo_cells = self.ammo_cells - 1;
101 }
102
103 void W_Plasma_Explode (entity ignore)
104 {
105         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
106         WriteByte (MSG_BROADCAST, 79);
107         WriteCoord (MSG_BROADCAST, self.origin_x);
108         WriteCoord (MSG_BROADCAST, self.origin_y);
109         WriteCoord (MSG_BROADCAST, self.origin_z);
110         WriteCoord (MSG_BROADCAST, 0);          // SeienAbunae: groan... Useless clutter
111         WriteCoord (MSG_BROADCAST, 0);
112         WriteCoord (MSG_BROADCAST, 0);
113         WriteByte (MSG_BROADCAST, 155);
114
115         te_customflash (self.origin, 5000, 10, '0 0 1');
116
117         self.event_damage = nullfunction;
118         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);
119         sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
120
121         remove (self);
122 }
123
124 void W_Plasma_FuseExplode (void)
125 {
126         W_Plasma_Explode (world);
127 }
128
129 void W_Plasma_Touch (void)
130 {
131         if (other.classname == "player" || other.classname == "corpse")
132                 W_Plasma_Explode (other);
133         else
134                 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
135 }
136
137 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
138 {
139         self.health = self.health - damage;
140         if (self.health <= 0)
141                 W_Plasma_FuseExplode ();
142 }
143
144 void() W_Electro_Attack2
145 {
146         entity  Plasma;
147         float postion;
148
149         postion = self.electrocount;
150         makevectors(self.v_angle);
151         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
152
153         self.punchangle_x = -4;
154
155         Plasma = spawn ();
156         Plasma.owner = self;
157         Plasma.classname = "grenade";
158         Plasma.effects = 1;
159
160         Plasma.movetype = MOVETYPE_BOUNCE;
161         Plasma.solid = SOLID_BBOX;
162
163         vector org;
164         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
165         te_smallflash(org);
166
167         Plasma.takedamage = DAMAGE_YES;
168         Plasma.damageforcescale = 4;
169         Plasma.health = 5;
170         Plasma.event_damage = W_Plasma_Damage;
171
172         setmodel (Plasma, "models/ebomb.mdl");
173         setsize (Plasma, '-6 -6 -3', '6 6 3');
174
175         if (postion == 0)
176         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
177         if (postion == 1)
178         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
179         if (postion == 2)
180         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
181
182         Plasma.velocity = v_forward * cvar("g_balance_electro_grenade_speed") + v_up * cvar("g_balance_electro_grenade_speed_up");
183         Plasma.angles = vectoangles (Plasma.velocity);
184         Plasma.avelocity_y = random () * -500 - 500;
185         Plasma.avelocity_x = random () * -500 - 500;
186         Plasma.avelocity_z = random () * -500 - 500;
187
188         Plasma.touch = W_Plasma_Touch;
189         Plasma.think = W_Plasma_FuseExplode;
190         Plasma.nextthink = time + 2;
191
192         Plasma.effects = Plasma.effects | EF_ADDITIVE;
193
194         self.attack_finished = time + 1;
195         self.ammo_cells = self.ammo_cells - 2;
196
197 }
198
199 // weapon frames
200
201 void()  electro_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, electro_ready_01); self.weaponentity.state = WS_READY;};
202 void()  electro_select_01 =     {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
203 void()  electro_deselect_01 =   {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
204 void()  electro_fire1_01 =
205 {
206         weapon_doattack(electro_check1, electro_check1, W_Electro_Attack);
207
208         self.electrocount = self.electrocount + 1;
209                 if (self.electrocount == 3)
210                         self.electrocount = 0;
211
212         weapon_thinkf(WFRAME_FIRE1, 0.3, electro_ready_01);
213 };
214 void()  electro_fire2_01 =
215 {
216         weapon_doattack(electro_check1, electro_check2, W_Electro_Attack2);
217
218         self.electrocount = self.electrocount + 1;
219                 if (self.electrocount == 3)
220                         self.electrocount = 0;
221
222         weapon_thinkf(WFRAME_FIRE2, 0.3, electro_ready_01);
223 };