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