]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_crylink.qc
handle self/oself CORRECTLY this time
[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_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_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, '11 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
79         te_smallflash(w_shotorg);
80
81         shots = cvar("g_balance_crylink_primary_shots");
82         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg + v_forward * 12, v_forward * 1000, shots);
83         while (counter < shots)
84         {
85                 proj = spawn ();
86                 proj.realowner = proj.owner = self;
87                 proj.classname = "spike";
88                 proj.bot_dodge = TRUE;
89                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
90
91                 proj.movetype = MOVETYPE_BOUNCE;
92                 proj.solid = SOLID_BBOX;
93                 proj.gravity = 0.001;
94
95                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
96                 setsize (proj, '0 0 0', '0 0 0');
97                 setorigin (proj, w_shotorg);
98
99                 proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
100                 W_SetupProjectileVelocity(proj);
101                 proj.touch = W_Crylink_Touch;
102                 proj.think = SUB_Remove;
103                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
104
105                 proj.angles = vectoangles (proj.velocity);
106
107                 //proj.glow_size = 20;
108
109                 proj.effects = EF_LOWPRECISION;
110                 proj.flags = FL_PROJECTILE;
111                 proj.colormod = proj_color;
112                 counter = counter + 1;
113         }
114 }
115
116 void W_Crylink_Attack2 (void)
117 {
118         local float counter, shots;
119         local entity proj;
120
121         if (cvar("g_use_ammunition"))
122                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
123
124         W_SetupShot (self, '11 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
125         //te_smallflash(w_shotorg);
126
127         shots = cvar("g_balance_crylink_secondary_shots");
128         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg + v_forward * 12, v_forward * 1000, shots);
129         while (counter < shots)
130         {
131                 proj = spawn ();
132                 proj.realowner = proj.owner = self;
133                 proj.classname = "spike";
134                 proj.bot_dodge = TRUE;
135                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
136
137                 proj.movetype = MOVETYPE_BOUNCE;
138                 proj.solid = SOLID_BBOX;
139                 proj.gravity = 0.001;
140
141                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
142                 setsize (proj, '0 0 0', '0 0 0');
143                 setorigin (proj, w_shotorg);
144
145                 proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
146                 W_SetupProjectileVelocity(proj);
147                 proj.touch = W_Crylink_Touch2;
148                 proj.think = SUB_Remove;
149                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
150
151                 proj.angles = vectoangles (proj.velocity);
152
153                 //proj.glow_size = 20;
154
155                 proj.effects = EF_LOWPRECISION;
156                 proj.flags = FL_PROJECTILE;
157                 proj.colormod = proj_color;
158                 counter = counter + 1;
159         }
160 }
161
162
163 /*
164 // experimental lightning gun
165 void W_Crylink_Attack3 (void)
166 {
167         if (cvar("g_use_ammunition"))
168                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
169         W_SetupShot (self, '11 8 -8', TRUE, 0, "weapons/crylink_fire.wav");
170
171         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
172         traceline_hitcorpse(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self);
173
174         te_smallflash(w_shotorg);
175         te_plasmaburn(trace_endpos);
176         te_lightning2(self, w_shotorg, trace_endpos);
177
178         if (trace_fraction < 1)
179                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
180 }
181 */
182
183 float(float req) w_crylink =
184 {
185         if (req == WR_AIM)
186         {
187                 if (random() > 0.15)
188                         self.button0 = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_lifetime"), FALSE);
189                 else
190                         self.button3 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_lifetime"), FALSE);
191         }
192         else if (req == WR_THINK)
193         {
194                 if (self.button0)
195                 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
196                 {
197                         W_Crylink_Attack();
198                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
199                 }
200                 if (self.button3)
201                 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
202                 {
203                         W_Crylink_Attack2();
204                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
205                 }
206         }
207         else if (req == WR_PRECACHE)
208         {
209                 precache_model ("models/plasma.mdl");
210                 precache_model ("models/plasmatrail.mdl");
211                 precache_model ("models/weapons/g_crylink.md3");
212                 precache_model ("models/weapons/v_crylink.md3");
213                 precache_model ("models/weapons/w_crylink.zym");
214                 precache_sound ("weapons/crylink_fire.wav");
215         }
216         else if (req == WR_SETUP)
217                 weapon_setup(WEP_CRYLINK, "crylink", IT_CELLS);
218         else if (req == WR_CHECKAMMO1)
219                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
220         else if (req == WR_CHECKAMMO2)
221                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
222         else if (req == WR_REGISTER)
223                 weapon_register(WEP_CRYLINK, min(cvar("g_balance_crylink_primary_ammo"), cvar("g_balance_crylink_secondary_ammo")));
224         return TRUE;
225 };