]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_electro.c
added many g_balance cvars and renamed cl_weapon_ cvars to use the g_viewweapon_...
[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         te_customflash (self.origin, 5000, 10, '0 0 1');
48
49         self.event_damage = nullfunction;
50         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);
51         sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
52
53         remove (self);
54 }
55
56 void W_Plasma_FuseExplode (void)
57 {
58         W_Plasma_Explode (world);
59 }
60
61 void W_Plasma_Touch (void)
62 {
63         if (other.classname == "player" || other.classname == "corpse")
64                 W_Plasma_Explode (other);
65         else
66                 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
67 }
68
69 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
70 {
71         self.health = self.health - damage;
72         if (self.health <= 0)
73                 W_Plasma_FuseExplode ();
74 }
75
76 void W_Plasma_Think ()
77 {
78         self.velocity = self.velocity * 1.2;
79 }
80
81
82 void() W_Electro_Attack
83 {
84         entity  proj;
85         float postion;
86
87         postion = self.electrocount;
88         makevectors(self.v_angle);
89         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
90
91         proj = spawn ();
92         proj.owner = self;
93         proj.classname = "spike";
94
95         proj.movetype = MOVETYPE_FLY;
96         proj.solid = SOLID_BBOX;
97         proj.effects = 1;
98
99         vector org;
100         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
101
102         te_smallflash(org);
103
104         setmodel (proj, "models/elaser.mdl");
105         setsize (proj, '0 0 0', '0 0 0');
106         if (postion == 0)
107         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
108         if (postion == 1)
109         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
110         if (postion == 2)
111         setorigin (proj, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
112
113         proj.velocity = v_forward * cvar("g_balance_electro_speed");
114         proj.touch = W_Plasma_Explode;
115         proj.think = W_Plasma_Think;
116         proj.nextthink = time + 0.1;
117
118         proj.angles = vectoangles (proj.velocity);
119
120         proj.effects = proj.effects | EF_ADDITIVE;
121
122         self.ammo_cells = self.ammo_cells - 2;
123 }
124
125 void() W_Electro_Attack2
126 {
127         entity  Plasma;
128         float postion;
129
130         postion = self.electrocount;
131         makevectors(self.v_angle);
132         sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
133
134         self.punchangle_x = -2;
135
136         Plasma = spawn ();
137         Plasma.owner = self;
138         Plasma.classname = "grenade";
139         Plasma.effects = 1;
140
141         Plasma.movetype = MOVETYPE_BOUNCE;
142         Plasma.solid = SOLID_BBOX;
143
144         vector org;
145         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 7 + v_up * -9;
146         te_smallflash(org);
147
148         Plasma.takedamage = DAMAGE_YES;
149         Plasma.damageforcescale = 4;
150         Plasma.health = 5;
151         Plasma.event_damage = W_Plasma_Damage;
152
153         setmodel (Plasma, "models/ebomb.mdl");
154         setsize (Plasma, '-6 -6 -3', '6 6 3');
155
156         if (postion == 0)
157         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -14);
158         if (postion == 1)
159         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 10 + v_up * -12);
160         if (postion == 2)
161         setorigin (Plasma, self.origin + self.view_ofs + v_forward * 15 + v_right * 15 + v_up * -14);
162
163         Plasma.velocity = v_forward * cvar("g_balance_electro_ballspeed") + v_up * cvar("g_balance_electro_ballspeed_up");
164         //Plasma.angles = vectoangles (Plasma.velocity);
165         //Plasma.avelocity_y = random () * -500 - 500;
166         //Plasma.avelocity_x = random () * -500 - 500;
167         //Plasma.avelocity_z = random () * -500 - 500;
168
169         Plasma.touch = W_Plasma_Touch;
170         Plasma.think = W_Plasma_FuseExplode;
171         Plasma.nextthink = time + 2;
172
173         Plasma.effects = Plasma.effects | EF_ADDITIVE;
174
175         self.ammo_cells = self.ammo_cells - 2;
176
177 }
178
179 // weapon frames
180
181 void()  electro_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, electro_ready_01); self.weaponentity.state = WS_READY;};
182 void()  electro_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
183 void()  electro_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
184 void()  electro_fire1_01 =
185 {
186         weapon_doattack(electro_check, electro_check, W_Electro_Attack);
187
188         self.electrocount = self.electrocount + 1;
189                 if (self.electrocount == 3)
190                         self.electrocount = 0;
191
192         weapon_thinkf(WFRAME_FIRE1, 0.3, electro_ready_01);
193 };
194 void()  electro_fire2_01 =
195 {
196         weapon_doattack(electro_check, electro_check, W_Electro_Attack2);
197
198         self.electrocount = self.electrocount + 1;
199                 if (self.electrocount == 3)
200                         self.electrocount = 0;
201
202         weapon_thinkf(WFRAME_FIRE2, 0.3, electro_ready_01);
203 };