]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_crylink.c
renamed almost all weapon cvars, added distinct cvars for primary/secondary
[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
9 float() crylink_check =
10 {
11         if (self.ammo_cells >= cvar("g_balance_crylink_primary_ammo"))
12                 return TRUE;
13         return FALSE;
14 };
15
16 float() crylink_check2 =
17 {
18         if (self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo"))
19                 return TRUE;
20         return FALSE;
21 };
22
23 void(float req) w_crylink =
24 {
25         if (req == WR_IDLE)
26                 crylink_ready_01();
27         else if (req == WR_FIRE1)
28                 weapon_prepareattack(crylink_check, crylink_check, crylink_fire1_01, cvar("g_balance_crylink_primary_refire"));
29         else if (req == WR_FIRE2)
30                 weapon_prepareattack(crylink_check2, crylink_check2, crylink_fire2_01, cvar("g_balance_crylink_secondary_refire"));
31         else if (req == WR_RAISE)
32                 crylink_select_01();
33         else if (req == WR_UPDATECOUNTS)
34                 self.currentammo = self.ammo_cells;
35         else if (req == WR_DROP)
36                 crylink_deselect_01();
37         else if (req == WR_SETUP)
38                 weapon_setup(WEP_CRYLINK, "w_crylink.zym", IT_CELLS);
39         else if (req == WR_CHECKAMMO)
40                 weapon_hasammo = crylink_check() + crylink_check2();
41 };
42
43 .entity realowner;
44 void W_Crylink_Touch (void)
45 {
46         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);
47         //te_smallflash(self.origin);
48         if (other.takedamage == DAMAGE_AIM)
49         {
50                 remove (self);
51                 return;
52         }
53         self.owner = world;
54         self.touch = SUB_Null;
55         setmodel (self, "models/plasma.mdl");
56         setsize (self, '0 0 0', '0 0 0');
57         self.gravity = 0;
58         self.glow_size = 0;
59         self.glow_color = 0;
60         self.think = SUB_Remove;
61         self.movetype = MOVETYPE_NONE;
62         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
63         SUB_SetFade(self, time, 1);
64         //remove (self);
65 }
66
67 void W_Crylink_Touch2 (void)
68 {
69         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);
70         //te_smallflash(self.origin);
71         if (other.takedamage == DAMAGE_AIM)
72         {
73                 remove (self);
74                 return;
75         }
76         self.owner = world;
77         self.touch = SUB_Null;
78         setmodel (self, "models/plasma.mdl");
79         setsize (self, '0 0 0', '0 0 0');
80         self.gravity = 0;
81         self.glow_size = 0;
82         self.glow_color = 0;
83         self.think = SUB_Remove;
84         self.movetype = MOVETYPE_NONE;
85         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
86         SUB_SetFade(self, time, 1);
87         //remove (self);
88 }
89
90 void W_Crylink_Attack (void)
91 {
92         local float counter, shots;
93         local vector org;
94         local entity proj;
95
96         local vector trueaim;
97         trueaim = W_TrueAim();
98
99         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
100         if (self.items & IT_STRENGTH) {
101                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
102         }
103
104         if (cvar("g_use_ammunition"))
105                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
106         self.punchangle_x = -2;
107         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
108         te_smallflash(org);
109
110         shots = cvar("g_balance_crylink_shots");
111         if (!shots)
112                 shots = 5;
113         while (counter < shots)
114         {
115                 proj = spawn ();
116                 proj.realowner = proj.owner = self;
117                 proj.classname = "spike";
118
119                 proj.movetype = MOVETYPE_BOUNCE;
120                 proj.solid = SOLID_BBOX;
121                 proj.gravity = 0.001;
122
123                 setmodel (proj, "models/plasmatrail.mdl");
124                 setsize (proj, '0 0 0', '0 0 0');
125                 setorigin (proj, org);
126
127                 proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
128                 proj.touch = W_Crylink_Touch;
129                 proj.think = SUB_Remove;
130                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
131
132                 proj.angles = vectoangles (proj.velocity);
133
134                 //proj.glow_size = 20;
135
136                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
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         if (!shots)
163                 shots = 5;
164         while (counter < shots)
165         {
166                 proj = spawn ();
167                 proj.realowner = proj.owner = self;
168                 proj.classname = "spike";
169
170                 proj.movetype = MOVETYPE_BOUNCE;
171                 proj.solid = SOLID_BBOX;
172                 proj.gravity = 0.001;
173
174                 setmodel (proj, "models/plasmatrail.mdl");
175                 setsize (proj, '0 0 0', '0 0 0');
176                 setorigin (proj, org);
177
178                 proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
179                 proj.touch = W_Crylink_Touch2;
180                 proj.think = SUB_Remove;
181                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
182
183                 proj.angles = vectoangles (proj.velocity);
184
185                 //proj.glow_size = 20;
186
187                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
188                 counter = counter + 1;
189         }
190 }
191
192
193 // weapon frames
194 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
195 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
196 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
197 void()  crylink_fire1_01 =
198 {
199         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
200         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
201 };
202 void()  crylink_fire2_01 =
203 {
204         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack2);
205         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), crylink_ready_01);
206 };
207