]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/server/gamec/w_crylink.c
Added a basic singleplayer campaign as an example... needs to be extended and a
[divverent/nexuiz.git] / 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_gunshotquad(self.origin);
54         remove (self);
55         /*
56         //te_smallflash(self.origin);
57         if (other.takedamage == DAMAGE_AIM)
58         {
59                 remove (self);
60                 return;
61         }
62         self.owner = world;
63         self.touch = SUB_Null;
64         setmodel (self, "models/plasma.mdl");
65         setsize (self, '0 0 0', '0 0 0');
66         self.gravity = 0;
67         self.glow_size = 0;
68         self.glow_color = 0;
69         self.think = SUB_Remove;
70         self.movetype = MOVETYPE_NONE;
71         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
72         SUB_SetFade(self, time, 1);
73         //remove (self);
74         */
75 }
76
77 void W_Crylink_Touch2 (void)
78 {
79         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
80         {
81                 remove(self);
82                 return;
83         }
84         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);
85         te_gunshotquad(self.origin);
86         remove (self);
87         /*
88         //te_smallflash(self.origin);
89         if (other.takedamage == DAMAGE_AIM)
90         {
91                 remove (self);
92                 return;
93         }
94         self.owner = world;
95         self.touch = SUB_Null;
96         setmodel (self, "models/plasma.mdl");
97         setsize (self, '0 0 0', '0 0 0');
98         self.gravity = 0;
99         self.glow_size = 0;
100         self.glow_color = 0;
101         self.think = SUB_Remove;
102         self.movetype = MOVETYPE_NONE;
103         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
104         SUB_SetFade(self, time, 1);
105         //remove (self);
106         */
107 }
108
109 void W_Crylink_Attack (void)
110 {
111         local float counter, shots;
112         local vector org;
113         local entity proj;
114
115         local vector trueaim;
116         trueaim = W_TrueAim();
117
118         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
119         if (self.items & IT_STRENGTH)
120                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
121
122         if (cvar("g_use_ammunition"))
123                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
124         self.punchangle_x = -2;
125
126         org = W_MuzzleOrigin (self, '24 7 -8');
127         te_smallflash(org);
128
129         shots = cvar("g_balance_crylink_primary_shots");
130         while (counter < shots)
131         {
132                 proj = spawn ();
133                 proj.realowner = proj.owner = self;
134                 proj.classname = "spike";
135
136                 proj.movetype = MOVETYPE_BOUNCE;
137                 proj.solid = SOLID_BBOX;
138                 proj.gravity = 0.001;
139
140                 setmodel (proj, "models/plasmatrail.mdl");
141                 setsize (proj, '0 0 0', '0 0 0');
142                 setorigin (proj, org);
143
144                 proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
145                 proj.touch = W_Crylink_Touch;
146                 proj.think = SUB_Remove;
147                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
148
149                 proj.angles = vectoangles (proj.velocity);
150
151                 //proj.glow_size = 20;
152
153                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
154                 proj.flags = FL_PROJECTILE;
155                 proj.colormod = proj_color;
156                 counter = counter + 1;
157         }
158 }
159
160 void W_Crylink_Attack2 (void)
161 {
162         local float counter, shots;
163         local vector org;
164         local entity proj;
165
166         local vector trueaim;
167         trueaim = W_TrueAim();
168
169         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
170         if (self.items & IT_STRENGTH)
171                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
172
173         if (cvar("g_use_ammunition"))
174                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
175         self.punchangle_x = -2;
176
177         org = W_MuzzleOrigin (self, '20 7 -8');
178         te_smallflash(org);
179
180         shots = cvar("g_balance_crylink_secondary_shots");
181         while (counter < shots)
182         {
183                 proj = spawn ();
184                 proj.realowner = proj.owner = self;
185                 proj.classname = "spike";
186
187                 proj.movetype = MOVETYPE_BOUNCE;
188                 proj.solid = SOLID_BBOX;
189                 proj.gravity = 0.001;
190
191                 setmodel (proj, "models/plasmatrail.mdl");
192                 setsize (proj, '0 0 0', '0 0 0');
193                 setorigin (proj, org);
194
195                 proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
196                 proj.touch = W_Crylink_Touch2;
197                 proj.think = SUB_Remove;
198                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
199
200                 proj.angles = vectoangles (proj.velocity);
201
202                 //proj.glow_size = 20;
203
204                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
205                 proj.flags = FL_PROJECTILE;
206                 proj.colormod = proj_color;
207                 counter = counter + 1;
208         }
209 }
210
211
212 // weapon frames
213 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
214 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
215 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
216 void()  crylink_fire1_01 =
217 {
218         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
219         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
220 };
221 void()  crylink_fire2_01 =
222 {
223         weapon_doattack(crylink_check2, crylink_check2, W_Crylink_Attack2);
224         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), crylink_ready_01);
225 };
226
227 /*
228 // experimental lightning gun
229 void W_Crylink_Attack3 (void)
230 {
231         local vector org, dir;
232
233         local vector trueaim;
234         trueaim = W_TrueAim();
235
236         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
237         if (self.items & IT_STRENGTH) {
238                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
239         }
240
241         if (cvar("g_use_ammunition"))
242                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
243         //self.punchangle_x = -2;
244         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
245
246         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
247         dir = normalize(trueaim - org);
248         traceline_hitcorpse(self, org, org + dir * 1000, FALSE, self);
249
250         te_smallflash(org);
251         te_plasmaburn(trace_endpos);
252         te_lightning2(self, org, trace_endpos);
253
254         if (trace_fraction < 1)
255                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
256 }
257 void()  crylink_fire1_01 =
258 {
259         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack3);
260         if (self.button0)
261                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_fire1_01);
262         else
263                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
264 };
265 */
266