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