]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_crylink.c
new gamemode: arena
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_crylink.c
1 void() crylink_ready_01;
2 void() crylink_fire1_01;
3 void() crylink_fire2_01;
4 void() crylink_deselect_01;
5 void() crylink_select_01;
6
7 .float gravity;
8 const vector proj_color = '1 1 1';
9
10 float() crylink_check =
11 {
12         if (self.ammo_cells >= cvar("g_balance_crylink_primary_ammo"))
13                 return TRUE;
14         return FALSE;
15 };
16
17 float() crylink_check2 =
18 {
19         if (self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo"))
20                 return TRUE;
21         return FALSE;
22 };
23
24 void(float req) w_crylink =
25 {
26         if (req == WR_IDLE)
27                 crylink_ready_01();
28         else if (req == WR_FIRE1)
29                 weapon_prepareattack(crylink_check, crylink_check, crylink_fire1_01, cvar("g_balance_crylink_primary_refire"));
30         else if (req == WR_FIRE2)
31                 weapon_prepareattack(crylink_check2, crylink_check2, crylink_fire2_01, cvar("g_balance_crylink_secondary_refire"));
32         else if (req == WR_RAISE)
33                 crylink_select_01();
34         else if (req == WR_UPDATECOUNTS)
35                 self.currentammo = self.ammo_cells;
36         else if (req == WR_DROP)
37                 crylink_deselect_01();
38         else if (req == WR_SETUP)
39                 weapon_setup(WEP_CRYLINK, "w_crylink.zym", IT_CELLS);
40         else if (req == WR_CHECKAMMO)
41                 weapon_hasammo = crylink_check() + crylink_check2();
42 };
43
44 .entity realowner;
45 void W_Crylink_Touch (void)
46 {
47         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
48         {
49                 remove(self);
50                 return;
51         }
52         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage"), cvar("g_balance_crylink_primary_edgedamage"), cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force"), IT_CRYLINK);
53         //te_smallflash(self.origin);
54         if (other.takedamage == DAMAGE_AIM)
55         {
56                 remove (self);
57                 return;
58         }
59         self.owner = world;
60         self.touch = SUB_Null;
61         setmodel (self, "models/plasma.mdl");
62         setsize (self, '0 0 0', '0 0 0');
63         self.gravity = 0;
64         self.glow_size = 0;
65         self.glow_color = 0;
66         self.think = SUB_Remove;
67         self.movetype = MOVETYPE_NONE;
68         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
69         SUB_SetFade(self, time, 1);
70         //remove (self);
71 }
72
73 void W_Crylink_Touch2 (void)
74 {
75         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
76         {
77                 remove(self);
78                 return;
79         }
80         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage"), cvar("g_balance_crylink_secondary_edgedamage"), cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force"), IT_CRYLINK);
81         //te_smallflash(self.origin);
82         if (other.takedamage == DAMAGE_AIM)
83         {
84                 remove (self);
85                 return;
86         }
87         self.owner = world;
88         self.touch = SUB_Null;
89         setmodel (self, "models/plasma.mdl");
90         setsize (self, '0 0 0', '0 0 0');
91         self.gravity = 0;
92         self.glow_size = 0;
93         self.glow_color = 0;
94         self.think = SUB_Remove;
95         self.movetype = MOVETYPE_NONE;
96         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
97         SUB_SetFade(self, time, 1);
98         //remove (self);
99 }
100
101 void W_Crylink_Attack (void)
102 {
103         local float counter, shots;
104         local vector org;
105         local entity proj;
106
107         local vector trueaim;
108         trueaim = W_TrueAim();
109
110         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
111         if (self.items & IT_STRENGTH)
112                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
113
114         if (cvar("g_use_ammunition"))
115                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
116         self.punchangle_x = -2;
117
118         org = W_MuzzleOrigin (self, '24 7 -8');
119         te_smallflash(org);
120
121         shots = cvar("g_balance_crylink_primary_shots");
122         while (counter < shots)
123         {
124                 proj = spawn ();
125                 proj.realowner = proj.owner = self;
126                 proj.classname = "spike";
127
128                 proj.movetype = MOVETYPE_BOUNCE;
129                 proj.solid = SOLID_BBOX;
130                 proj.gravity = 0.001;
131
132                 setmodel (proj, "models/plasmatrail.mdl");
133                 setsize (proj, '0 0 0', '0 0 0');
134                 setorigin (proj, org);
135
136                 proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
137                 proj.touch = W_Crylink_Touch;
138                 proj.think = SUB_Remove;
139                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
140
141                 proj.angles = vectoangles (proj.velocity);
142
143                 //proj.glow_size = 20;
144
145                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
146                 proj.flags = FL_PROJECTILE;
147                 proj.colormod = proj_color;
148                 counter = counter + 1;
149         }
150 }
151
152 void W_Crylink_Attack2 (void)
153 {
154         local float counter, shots;
155         local vector org;
156         local entity proj;
157
158         local vector trueaim;
159         trueaim = W_TrueAim();
160
161         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
162         if (self.items & IT_STRENGTH)
163                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
164
165         if (cvar("g_use_ammunition"))
166                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
167         self.punchangle_x = -2;
168
169         org = W_MuzzleOrigin (self, '20 7 -8');
170         te_smallflash(org);
171
172         shots = cvar("g_balance_crylink_secondary_shots");
173         while (counter < shots)
174         {
175                 proj = spawn ();
176                 proj.realowner = proj.owner = self;
177                 proj.classname = "spike";
178
179                 proj.movetype = MOVETYPE_BOUNCE;
180                 proj.solid = SOLID_BBOX;
181                 proj.gravity = 0.001;
182
183                 setmodel (proj, "models/plasmatrail.mdl");
184                 setsize (proj, '0 0 0', '0 0 0');
185                 setorigin (proj, org);
186
187                 proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
188                 proj.touch = W_Crylink_Touch2;
189                 proj.think = SUB_Remove;
190                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
191
192                 proj.angles = vectoangles (proj.velocity);
193
194                 //proj.glow_size = 20;
195
196                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
197                 proj.flags = FL_PROJECTILE;
198                 proj.colormod = proj_color;
199                 counter = counter + 1;
200         }
201 }
202
203
204 // weapon frames
205 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
206 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
207 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
208 void()  crylink_fire1_01 =
209 {
210         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
211         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
212 };
213 void()  crylink_fire2_01 =
214 {
215         weapon_doattack(crylink_check2, crylink_check2, W_Crylink_Attack2);
216         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), crylink_ready_01);
217 };
218
219 /*
220 // experimental lightning gun
221 void W_Crylink_Attack3 (void)
222 {
223         local vector org, dir;
224
225         local vector trueaim;
226         trueaim = W_TrueAim();
227
228         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
229         if (self.items & IT_STRENGTH) {
230                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
231         }
232
233         if (cvar("g_use_ammunition"))
234                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
235         //self.punchangle_x = -2;
236         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
237
238         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
239         dir = normalize(trueaim - org);
240         traceline_hitcorpse(self, org, org + dir * 1000, FALSE, self);
241
242         te_smallflash(org);
243         te_plasmaburn(trace_endpos);
244         te_lightning2(self, org, trace_endpos);
245
246         if (trace_fraction < 1)
247                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
248 }
249 void()  crylink_fire1_01 =
250 {
251         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack3);
252         if (self.button0)
253                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_fire1_01);
254         else
255                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
256 };
257 */
258