]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_crylink.qc
game mode "keyhunt", still in testing
[divverent/nexuiz.git] / data / qcsrc / server / w_crylink.qc
1
2 .float gravity;
3 const vector proj_color = '1 1 1';
4
5 .entity realowner;
6 void W_Crylink_Touch (void)
7 {
8         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
9         {
10                 remove(self);
11                 return;
12         }
13         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);
14         te_gunshotquad(self.origin);
15         remove (self);
16         /*
17         //te_smallflash(self.origin);
18         if (other.takedamage == DAMAGE_AIM)
19         {
20                 remove (self);
21                 return;
22         }
23         self.owner = world;
24         self.touch = SUB_Null;
25         setmodel (self, "models/plasma.mdl"); // precision set below
26         setsize (self, '0 0 0', '0 0 0');
27         self.gravity = 0;
28         self.glow_size = 0;
29         self.glow_color = 0;
30         self.think = SUB_Remove;
31         self.movetype = MOVETYPE_NONE;
32         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
33         SUB_SetFade(self, time, 1);
34         //remove (self);
35         */
36 }
37
38 void W_Crylink_Touch2 (void)
39 {
40         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
41         {
42                 remove(self);
43                 return;
44         }
45         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);
46         te_gunshotquad(self.origin);
47         remove (self);
48         /*
49         //te_smallflash(self.origin);
50         if (other.takedamage == DAMAGE_AIM)
51         {
52                 remove (self);
53                 return;
54         }
55         self.owner = world;
56         self.touch = SUB_Null;
57         setmodel (self, "models/plasma.mdl"); // precision set below
58         setsize (self, '0 0 0', '0 0 0');
59         self.gravity = 0;
60         self.glow_size = 0;
61         self.glow_color = 0;
62         self.think = SUB_Remove;
63         self.movetype = MOVETYPE_NONE;
64         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
65         SUB_SetFade(self, time, 1);
66         //remove (self);
67         */
68 }
69
70 void W_Crylink_Attack (void)
71 {
72         local float counter, shots;
73         local entity proj;
74
75         if (cvar("g_use_ammunition"))
76                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
77
78         W_SetupShot (self, '15 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
79         te_smallflash(w_shotorg);
80
81         shots = cvar("g_balance_crylink_primary_shots");
82         while (counter < shots)
83         {
84                 proj = spawn ();
85                 proj.realowner = proj.owner = self;
86                 proj.classname = "spike";
87                 proj.bot_dodge = TRUE;
88                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
89
90                 proj.movetype = MOVETYPE_BOUNCE;
91                 proj.solid = SOLID_BBOX;
92                 proj.gravity = 0.001;
93
94                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
95                 setsize (proj, '0 0 0', '0 0 0');
96                 setorigin (proj, w_shotorg);
97
98                 proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
99                 W_SetupProjectileVelocity(proj);
100                 proj.touch = W_Crylink_Touch;
101                 proj.think = SUB_Remove;
102                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
103
104                 proj.angles = vectoangles (proj.velocity);
105
106                 //proj.glow_size = 20;
107
108                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
109                 proj.flags = FL_PROJECTILE;
110                 proj.colormod = proj_color;
111                 counter = counter + 1;
112         }
113 }
114
115 void W_Crylink_Attack2 (void)
116 {
117         local float counter, shots;
118         local entity proj;
119
120         if (cvar("g_use_ammunition"))
121                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
122
123         W_SetupShot (self, '15 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
124         te_smallflash(w_shotorg);
125
126         shots = cvar("g_balance_crylink_secondary_shots");
127         while (counter < shots)
128         {
129                 proj = spawn ();
130                 proj.realowner = proj.owner = self;
131                 proj.classname = "spike";
132                 proj.bot_dodge = TRUE;
133                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
134
135                 proj.movetype = MOVETYPE_BOUNCE;
136                 proj.solid = SOLID_BBOX;
137                 proj.gravity = 0.001;
138
139                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
140                 setsize (proj, '0 0 0', '0 0 0');
141                 setorigin (proj, w_shotorg);
142
143                 proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
144                 W_SetupProjectileVelocity(proj);
145                 proj.touch = W_Crylink_Touch2;
146                 proj.think = SUB_Remove;
147                 proj.nextthink = time + cvar("g_balance_crylink_secondary_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
161 /*
162 // experimental lightning gun
163 void W_Crylink_Attack3 (void)
164 {
165         if (cvar("g_use_ammunition"))
166                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
167         //W_SetupShot(self, '10 5 -14', TRUE, 0, "weapons/crylink_fire.wav");
168         W_SetupShot (self, '15 7 -8', TRUE, 0, "weapons/crylink_fire.wav");
169
170         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
171         traceline_hitcorpse(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self);
172
173         te_smallflash(w_shotorg);
174         te_plasmaburn(trace_endpos);
175         te_lightning2(self, w_shotorg, trace_endpos);
176
177         if (trace_fraction < 1)
178                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
179 }
180 */
181
182 float(float req) w_crylink =
183 {
184         if (req == WR_AIM)
185         {
186                 if (random() > 0.15)
187                         self.button0 = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_lifetime"), FALSE);
188                 else
189                         self.button3 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_lifetime"), FALSE);
190         }
191         else if (req == WR_THINK)
192         {
193                 if (self.button0)
194                 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
195                 {
196                         W_Crylink_Attack();
197                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
198                 }
199                 if (self.button3)
200                 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
201                 {
202                         W_Crylink_Attack2();
203                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
204                 }
205         }
206         else if (req == WR_SETUP)
207                 weapon_setup(WEP_CRYLINK, "crylink", IT_CELLS);
208         else if (req == WR_CHECKAMMO1)
209                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
210         else if (req == WR_CHECKAMMO2)
211                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
212         return TRUE;
213 };