3 void nade_timer_think()
5 self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
7 if(!self.owner || wasfreed(self.owner))
11 void nade_burn_spawn(entity _nade)
13 CSQCProjectile(_nade, true, Nade_ProjectileFromID(_nade.nade_type, true), true);
16 void nade_spawn(entity _nade)
18 entity timer = spawn();
19 setmodel(timer, "models/ok_nade_counter/ok_nade_counter.md3");
20 setattachment(timer, _nade, "");
21 timer.classname = "nade_timer";
22 timer.colormap = _nade.colormap;
23 timer.glowmod = _nade.glowmod;
24 timer.think = nade_timer_think;
25 timer.nextthink = time;
26 timer.wait = _nade.wait;
30 _nade.effects |= EF_LOWPRECISION;
32 CSQCProjectile(_nade, true, Nade_ProjectileFromID(_nade.nade_type, false), true);
35 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
44 RandomSelection_Init();
45 for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
46 if(e.takedamage == DAMAGE_AIM)
47 if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
48 if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
52 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
53 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
54 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
55 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
58 e.fireball_impactvec = p;
59 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
62 if(RandomSelection_chosen_ent)
64 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
65 d = damage + (edgedamage - damage) * (d / dist);
66 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
67 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
68 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
73 void napalm_ball_think()
75 if(round_handler_IsActive())
76 if(!round_handler_IsRoundStarted())
82 if(time > self.pushltime)
88 vector midpoint = ((self.absmin + self.absmax) * 0.5);
89 if(pointcontents(midpoint) == CONTENT_WATER)
91 self.velocity = self.velocity * 0.5;
93 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
94 { self.velocity_z = 200; }
97 self.angles = vectoangles(self.velocity);
99 napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
100 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
102 self.nextthink = time + 0.1;
106 void nade_napalm_ball()
111 spamsound(self, CH_SHOTS, "weapons/fireball_fire.wav", VOL_BASE, ATTEN_NORM);
114 proj.owner = self.owner;
115 proj.realowner = self.realowner;
116 proj.team = self.owner.team;
117 proj.classname = "grenade";
118 proj.bot_dodge = true;
119 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
120 proj.movetype = MOVETYPE_BOUNCE;
121 proj.projectiledeathtype = DEATH_NADE_NAPALM;
122 PROJECTILE_MAKETRIGGER(proj);
123 setmodel(proj, "null");
124 proj.scale = 1;//0.5;
125 setsize(proj, '-4 -4 -4', '4 4 4');
126 setorigin(proj, self.origin);
127 proj.think = napalm_ball_think;
128 proj.nextthink = time;
129 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
130 proj.effects = EF_LOWPRECISION | EF_FLAME;
132 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
133 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
134 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
135 proj.velocity = kick;
137 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
139 proj.angles = vectoangles(proj.velocity);
140 proj.flags = FL_PROJECTILE;
141 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
143 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
147 void napalm_fountain_think()
150 if(round_handler_IsActive())
151 if(!round_handler_IsRoundStarted())
157 if(time >= self.ltime)
163 vector midpoint = ((self.absmin + self.absmax) * 0.5);
164 if(pointcontents(midpoint) == CONTENT_WATER)
166 self.velocity = self.velocity * 0.5;
168 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
169 { self.velocity_z = 200; }
171 UpdateCSQCProjectile(self);
174 napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
175 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
177 self.nextthink = time + 0.1;
178 if(time >= self.nade_special_time)
180 self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
185 void nade_napalm_boom()
189 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
194 fountain.owner = self.owner;
195 fountain.realowner = self.realowner;
196 fountain.origin = self.origin;
197 setorigin(fountain, fountain.origin);
198 fountain.think = napalm_fountain_think;
199 fountain.nextthink = time;
200 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
201 fountain.pushltime = fountain.ltime;
202 fountain.team = self.team;
203 fountain.movetype = MOVETYPE_TOSS;
204 fountain.projectiledeathtype = DEATH_NADE_NAPALM;
205 fountain.bot_dodge = true;
206 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
207 fountain.nade_special_time = time;
208 setsize(fountain, '-16 -16 -16', '16 16 16');
209 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
212 void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
214 frost_target.frozen_by = freezefield.realowner;
215 pointparticles(particleeffectnum("electro_impact"), frost_target.origin, '0 0 0', 1);
216 Freeze(frost_target, 1/freeze_time, 3, false);
217 if(frost_target.ballcarried)
218 if(g_keepaway) { ka_DropEvent(frost_target); }
219 else { DropBall(frost_target.ballcarried, frost_target.origin, frost_target.velocity);}
220 if(frost_target.flagcarried) { ctf_Handle_Throw(frost_target, world, DROP_THROW); }
221 if(frost_target.nade) { toss_nade(frost_target, '0 0 0', time + 0.05); }
223 kh_Key_DropAll(frost_target, false);
226 void nade_ice_think()
229 if(round_handler_IsActive())
230 if(!round_handler_IsRoundStarted())
236 if(time >= self.ltime)
238 if ( autocvar_g_nades_ice_explode )
241 switch(self.realowner.team)
243 case NUM_TEAM_1: expef = "nade_red_explode"; break;
244 case NUM_TEAM_2: expef = "nade_blue_explode"; break;
245 case NUM_TEAM_3: expef = "nade_yellow_explode"; break;
246 case NUM_TEAM_4: expef = "nade_pink_explode"; break;
247 default: expef = "nade_neutral_explode"; break;
249 pointparticles(particleeffectnum(expef), self.origin + '0 0 1', '0 0 0', 1);
250 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
252 RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
253 autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
254 Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
255 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
262 self.nextthink = time+0.1;
267 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
269 randomw = random()*M_PI*2;
271 randomp.x = randomr*cos(randomw);
272 randomp.y = randomr*sin(randomw);
274 pointparticles(particleeffectnum("electro_muzzleflash"), self.origin + randomp, '0 0 0', 1);
276 if(time >= self.nade_special_time)
278 self.nade_special_time = time+0.7;
281 pointparticles(particleeffectnum("electro_impact"), self.origin, '0 0 0', 1);
282 pointparticles(particleeffectnum("icefield"), self.origin, '0 0 0', 1);
286 float current_freeze_time = self.ltime - time - 0.1;
289 for(e = findradius(self.origin, autocvar_g_nades_nade_radius); e; e = e.chain)
291 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, self.realowner) || e == self.realowner))
292 if(e.takedamage && e.deadflag == DEAD_NO)
294 if(!e.revival_time || ((time - e.revival_time) >= 1.5))
296 if(current_freeze_time > 0)
297 nade_ice_freeze(self, e, current_freeze_time);
304 fountain.owner = self.owner;
305 fountain.realowner = self.realowner;
306 fountain.origin = self.origin;
307 setorigin(fountain, fountain.origin);
308 fountain.think = nade_ice_think;
309 fountain.nextthink = time;
310 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
311 fountain.pushltime = fountain.wait = fountain.ltime;
312 fountain.team = self.team;
313 fountain.movetype = MOVETYPE_TOSS;
314 fountain.projectiledeathtype = DEATH_NADE_ICE;
315 fountain.bot_dodge = false;
316 setsize(fountain, '-16 -16 -16', '16 16 16');
317 fountain.nade_special_time = time+0.3;
318 fountain.angles = self.angles;
320 if ( autocvar_g_nades_ice_explode )
322 setmodel(fountain, "models/grenademodel.md3");
323 entity timer = spawn();
324 setmodel(timer, "models/ok_nade_counter/ok_nade_counter.md3");
325 setattachment(timer, fountain, "");
326 timer.classname = "nade_timer";
327 timer.colormap = self.colormap;
328 timer.glowmod = self.glowmod;
329 timer.think = nade_timer_think;
330 timer.nextthink = time;
331 timer.wait = fountain.ltime;
332 timer.owner = fountain;
336 setmodel(fountain, "null");
339 void nade_translocate_boom()
341 if(self.realowner.vehicle)
344 vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
345 tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
346 locout = trace_endpos;
348 makevectors(self.realowner.angles);
350 entity oldself = self;
351 self = self.realowner;
352 MUTATOR_CALLHOOK(PortalTeleport);
353 self.realowner = self;
356 TeleportPlayer(self, self.realowner, locout, self.realowner.mangle, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
359 void nade_spawn_boom()
361 entity spawnloc = spawn();
362 setorigin(spawnloc, self.origin);
363 setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
364 spawnloc.movetype = MOVETYPE_NONE;
365 spawnloc.solid = SOLID_NOT;
366 spawnloc.drawonlytoclient = self.realowner;
367 spawnloc.effects = EF_STARDUST;
368 spawnloc.cnt = autocvar_g_nades_spawn_count;
370 if(self.realowner.nade_spawnloc)
372 remove(self.realowner.nade_spawnloc);
373 self.realowner.nade_spawnloc = world;
376 self.realowner.nade_spawnloc = spawnloc;
379 void nade_heal_think()
381 if(time >= self.ltime)
387 self.nextthink = time;
389 if(time >= self.nade_special_time)
391 self.nade_special_time = time+0.25;
392 self.nade_show_particles = 1;
395 self.nade_show_particles = 0;
398 void nade_heal_touch()
402 if(IS_PLAYER(other) || (other.flags & FL_MONSTER))
403 if(other.deadflag == DEAD_NO)
406 health_factor = autocvar_g_nades_heal_rate*frametime/2;
407 if ( other != self.realowner )
409 if ( SAME_TEAM(other,self) )
410 health_factor *= autocvar_g_nades_heal_friend;
412 health_factor *= autocvar_g_nades_heal_foe;
414 if ( health_factor > 0 )
416 maxhealth = (other.flags & FL_MONSTER) ? other.max_health : g_pickup_healthmega_max;
417 if ( other.health < maxhealth )
419 if ( self.nade_show_particles )
420 pointparticles(particleeffectnum("healing_fx"), other.origin, '0 0 0', 1);
421 other.health = min(other.health+health_factor, maxhealth);
423 other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
425 else if ( health_factor < 0 )
427 Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL,other.origin,'0 0 0');
432 if ( IS_REAL_CLIENT(other) || (other.vehicle_flags & VHF_ISVEHICLE) )
434 entity show_red = (other.vehicle_flags & VHF_ISVEHICLE) ? other.owner : other;
435 show_red.stat_healing_orb = time+0.1;
436 show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime;
440 void nade_heal_boom()
444 healer.owner = self.owner;
445 healer.realowner = self.realowner;
446 setorigin(healer, self.origin);
447 healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
448 healer.ltime = time + healer.healer_lifetime;
449 healer.team = self.realowner.team;
450 healer.bot_dodge = false;
451 healer.solid = SOLID_TRIGGER;
452 healer.touch = nade_heal_touch;
454 setmodel(healer, "models/ctf/shield.md3");
455 healer.healer_radius = autocvar_g_nades_nade_radius;
456 vector size = '1 1 1' * healer.healer_radius / 2;
457 setsize(healer,-size,size);
459 Net_LinkEntity(healer, true, 0, healer_send);
461 healer.think = nade_heal_think;
462 healer.nextthink = time;
463 healer.SendFlags |= 1;
466 void nade_monster_boom()
468 entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
470 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
471 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
472 e.monster_skill = MONSTER_SKILL_INSANE;
478 float nade_blast = 1;
480 switch ( self.nade_type )
482 case NADE_TYPE_NAPALM:
483 nade_blast = autocvar_g_nades_napalm_blast;
484 expef = "explosion_medium";
488 expef = "electro_combo"; // hookbomb_explode electro_combo bigplasma_impact
490 case NADE_TYPE_TRANSLOCATE:
494 case NADE_TYPE_MONSTER:
495 case NADE_TYPE_SPAWN:
497 switch(self.realowner.team)
499 case NUM_TEAM_1: expef = "spawn_event_red"; break;
500 case NUM_TEAM_2: expef = "spawn_event_blue"; break;
501 case NUM_TEAM_3: expef = "spawn_event_yellow"; break;
502 case NUM_TEAM_4: expef = "spawn_event_pink"; break;
503 default: expef = "spawn_event_neutral"; break;
508 expef = "spawn_event_red";
512 case NADE_TYPE_NORMAL:
513 switch(self.realowner.team)
515 case NUM_TEAM_1: expef = "nade_red_explode"; break;
516 case NUM_TEAM_2: expef = "nade_blue_explode"; break;
517 case NUM_TEAM_3: expef = "nade_yellow_explode"; break;
518 case NUM_TEAM_4: expef = "nade_pink_explode"; break;
519 default: expef = "nade_neutral_explode"; break;
524 pointparticles(particleeffectnum(expef), findbetterlocation(self.origin, 8), '0 0 0', 1);
526 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
527 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
529 self.event_damage = func_null; // prevent somehow calling damage in the next call
533 RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
534 autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
535 Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
539 switch ( self.nade_type )
541 case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
542 case NADE_TYPE_ICE: nade_ice_boom(); break;
543 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
544 case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
545 case NADE_TYPE_HEAL: nade_heal_boom(); break;
546 case NADE_TYPE_MONSTER: nade_monster_boom(); break;
554 /*float is_weapclip = 0;
555 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
556 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
557 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
559 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
567 //setsize(self, '-2 -2 -2', '2 2 2');
568 //UpdateCSQCProjectile(self);
569 if(self.health == self.max_health)
571 spamsound(self, CH_SHOTS, strcat("weapons/grenade_bounce", ftos(1 + rint(random() * 5)), ".wav"), VOL_BASE, ATTEN_NORM);
581 sound(self, CH_SHOTS_SINGLE, "overkill/grenadebip.ogg", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
582 self.think = nade_boom;
583 self.nextthink = max(self.wait, time);
586 void nade_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
588 if(ITEM_DAMAGE_NEEDKILL(deathtype))
590 self.takedamage = DAMAGE_NO;
595 if(self.nade_type == NADE_TYPE_TRANSLOCATE || self.nade_type == NADE_TYPE_SPAWN)
598 if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
604 if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
606 force *= 0.5; // too much
610 if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
613 damage = self.max_health * 0.55;
616 if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_HMG))
617 damage = self.max_health * 0.1;
619 if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
620 if(deathtype & HITTYPE_SECONDARY)
622 damage = self.max_health * 0.1;
626 damage = self.max_health * 1.15;
628 self.velocity += force;
629 UpdateCSQCProjectile(self);
631 if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker)))
634 if(self.health == self.max_health)
636 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
637 self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
638 self.think = nade_beep;
641 self.health -= damage;
643 if ( self.nade_type != NADE_TYPE_HEAL || IS_PLAYER(attacker) )
644 self.realowner = attacker;
647 W_PrepareExplosionByDamage(attacker, nade_boom);
649 nade_burn_spawn(self);
652 void toss_nade(entity e, vector _velocity, float _time)
657 entity _nade = e.nade;
663 makevectors(e.v_angle);
665 W_SetupShot(e, false, false, "", CH_WEAPON_A, 0);
667 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
669 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
670 + (v_right * autocvar_g_nades_throw_offset.y)
671 + (v_up * autocvar_g_nades_throw_offset.z);
672 if(autocvar_g_nades_throw_offset == '0 0 0')
675 setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
676 //setmodel(_nade, "models/weapons/v_ok_grenade.md3");
677 //setattachment(_nade, world, "");
678 PROJECTILE_MAKETRIGGER(_nade);
679 setsize(_nade, '-16 -16 -16', '16 16 16');
680 _nade.movetype = MOVETYPE_BOUNCE;
682 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
683 if (trace_startsolid)
684 setorigin(_nade, e.origin);
686 if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH)
687 _nade.velocity = '0 0 100';
688 else if(autocvar_g_nades_nade_newton_style == 1)
689 _nade.velocity = e.velocity + _velocity;
690 else if(autocvar_g_nades_nade_newton_style == 2)
691 _nade.velocity = _velocity;
693 _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true);
695 _nade.touch = nade_touch;
696 _nade.health = autocvar_g_nades_nade_health;
697 _nade.max_health = _nade.health;
698 _nade.takedamage = DAMAGE_AIM;
699 _nade.event_damage = nade_damage;
700 _nade.customizeentityforclient = func_null;
701 _nade.exteriormodeltoclient = world;
702 _nade.traileffectnum = 0;
703 _nade.teleportable = true;
704 _nade.pushable = true;
706 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
707 _nade.damagedbycontents = true;
708 _nade.angles = vectoangles(_nade.velocity);
709 _nade.flags = FL_PROJECTILE;
710 _nade.projectiledeathtype = DEATH_NADE;
711 _nade.toss_time = time;
712 _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
714 if(_nade.nade_type == NADE_TYPE_TRANSLOCATE || _nade.nade_type == NADE_TYPE_SPAWN)
715 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
717 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
723 _nade.think = nade_boom;
724 _nade.nextthink = _time;
727 e.nade_refire = time + autocvar_g_nades_nade_refire;
731 void nades_GiveBonus(entity player, float score)
733 if (autocvar_g_nades)
734 if (autocvar_g_nades_bonus)
735 if (IS_REAL_CLIENT(player))
736 if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
737 if (player.frozen == 0)
738 if (player.deadflag == DEAD_NO)
740 if ( player.bonus_nade_score < 1 )
741 player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
743 if ( player.bonus_nade_score >= 1 )
745 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
746 play2(player,"kh/alarm.wav");
747 player.bonus_nades++;
748 player.bonus_nade_score -= 1;
753 void nades_RemoveBonus(entity player)
755 player.bonus_nades = player.bonus_nade_score = 0;
758 float nade_customize()
760 //if(IS_SPEC(other)) { return false; }
761 if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
763 // somewhat hide the model, but keep the glow
765 if(self.traileffectnum)
766 self.traileffectnum = 0;
771 //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
772 if(!self.traileffectnum)
773 self.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(self.nade_type, false), self.team));
786 remove(self.fake_nade);
788 entity n = spawn(), fn = spawn();
790 n.classname = "nade";
791 fn.classname = "fake_nade";
793 if(self.items & IT_STRENGTH && autocvar_g_nades_bonus_onstrength)
794 n.nade_type = self.nade_type;
795 else if (self.bonus_nades >= 1)
797 n.nade_type = self.nade_type;
798 n.pokenade_type = self.pokenade_type;
799 self.bonus_nades -= 1;
803 n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
804 n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
807 n.nade_type = bound(1, n.nade_type, NADE_TYPE_LAST);
809 setmodel(n, "models/weapons/v_ok_grenade.md3");
810 //setattachment(n, self, "bip01 l hand");
811 n.exteriormodeltoclient = self;
812 n.customizeentityforclient = nade_customize;
813 n.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(n.nade_type, false), self.team));
814 n.colormod = Nade_Color(n.nade_type);
816 n.colormap = self.colormap;
817 n.glowmod = self.glowmod;
818 n.wait = time + autocvar_g_nades_nade_lifetime;
821 n.nextthink = max(n.wait - 3, time);
822 n.projectiledeathtype = DEATH_NADE;
824 setmodel(fn, "models/weapons/h_ok_grenade.iqm");
825 setattachment(fn, self.weaponentity, "");
826 fn.realowner = fn.owner = self;
827 fn.colormod = Nade_Color(n.nade_type);
828 fn.colormap = self.colormap;
829 fn.glowmod = self.glowmod;
830 fn.think = SUB_Remove;
831 fn.nextthink = n.wait;
845 if(self.deadflag != DEAD_NO)
848 if (!autocvar_g_nades)
849 return false; // allow turning them off mid match
851 if(forbidWeaponUse())
854 if (!IS_PLAYER(self))
860 void nades_CheckThrow()
867 if(self.nade_refire < time)
869 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW);
871 self.nade_refire = time + autocvar_g_nades_nade_refire;
876 if(time - self.nade.lifetime >= 1)
878 makevectors(self.v_angle);
879 float _force = time - self.nade.lifetime;
880 _force /= autocvar_g_nades_nade_lifetime;
881 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
882 toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
887 void nades_Clear(entity player)
892 remove(player.fake_nade);
894 player.nade = player.fake_nade = world;
895 player.nade_timer = 0;
898 MUTATOR_HOOKFUNCTION(nades_CheckThrow)
900 if(MUTATOR_RETURNVALUE) { nades_CheckThrow(); }
904 MUTATOR_HOOKFUNCTION(nades_VehicleEnter)
907 toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
912 MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
914 if(!IS_PLAYER(self)) { return false; }
916 float key_pressed = self.BUTTON_HOOK;
919 if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, false, false) || (weaponsInMap & WEPSET_HOOK))
920 key_pressed = self.button16; // if hook is enabled, use an alternate key
924 self.nade_timer = bound(0, (time - self.nade.lifetime) / autocvar_g_nades_nade_lifetime, 1);
925 //print(sprintf("%d %d\n", self.nade_timer, time - self.nade.lifetime));
926 makevectors(self.angles);
927 self.nade.velocity = self.velocity;
929 setorigin(self.nade, self.origin + self.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
930 self.nade.angles_y = self.angles.y;
934 if(self.nade.wait - 0.1 <= time)
935 toss_nade(self, '0 0 0', time + 0.05);
938 if(self.nade_refire < time)
945 else if(time - self.nade.lifetime >= 1)
949 makevectors(self.v_angle);
950 float _force = time - self.nade.lifetime;
951 _force /= autocvar_g_nades_nade_lifetime;
952 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
953 toss_nade(self, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
960 if ( autocvar_g_nades_bonus && autocvar_g_nades )
964 FOR_EACH_KH_KEY(key) if(key.owner == self) { ++key_count; }
966 if(self.flagcarried || self.ballcarried) // this player is important
967 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
969 time_score = autocvar_g_nades_bonus_score_time;
972 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
974 if(autocvar_g_nades_bonus_client_select)
976 self.nade_type = self.cvar_cl_nade_type;
977 self.pokenade_type = self.cvar_cl_pokenade_type;
981 self.nade_type = autocvar_g_nades_bonus_type;
982 self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
985 self.nade_type = bound(1, self.nade_type, NADE_TYPE_LAST);
987 if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
988 nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max);
992 self.bonus_nades = self.bonus_nade_score = 0;
998 if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
1002 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1004 FOR_EACH_PLAYER(other) if(self != other)
1006 if(other.deadflag == DEAD_NO)
1007 if(other.frozen == 0)
1008 if(SAME_TEAM(other, self))
1009 if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
1013 if(self.frozen == 1)
1014 other.reviving = true;
1020 if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
1022 self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1023 self.health = max(1, self.revive_progress * start_health);
1025 if(self.revive_progress >= 1)
1029 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1030 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
1033 FOR_EACH_PLAYER(other) if(other.reviving)
1035 other.revive_progress = self.revive_progress;
1036 other.reviving = false;
1043 MUTATOR_HOOKFUNCTION(nades_PlayerSpawn)
1045 if(autocvar_g_nades_spawn)
1046 self.nade_refire = time + autocvar_g_spawnshieldtime;
1048 self.nade_refire = time + autocvar_g_nades_nade_refire;
1050 if(autocvar_g_nades_bonus_client_select)
1051 self.nade_type = self.cvar_cl_nade_type;
1053 self.nade_timer = 0;
1055 if(self.nade_spawnloc)
1057 setorigin(self, self.nade_spawnloc.origin);
1058 self.nade_spawnloc.cnt -= 1;
1060 if(self.nade_spawnloc.cnt <= 0)
1062 remove(self.nade_spawnloc);
1063 self.nade_spawnloc = world;
1070 MUTATOR_HOOKFUNCTION(nades_PlayerDies)
1072 if(frag_target.nade)
1073 if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade)
1074 toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1076 float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
1078 if(IS_PLAYER(frag_attacker))
1080 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1081 nades_RemoveBonus(frag_attacker);
1082 else if(frag_target.flagcarried)
1083 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1084 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1086 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1087 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1088 switch(frag_attacker.killcount)
1091 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1096 nades_GiveBonus(frag_attacker, killcount_bonus);
1099 nades_RemoveBonus(frag_target);
1104 MUTATOR_HOOKFUNCTION(nades_PlayerDamage)
1106 if(frag_target.frozen)
1107 if(autocvar_g_freezetag_revive_nade)
1108 if(frag_attacker == frag_target)
1109 if(frag_deathtype == DEATH_NADE)
1110 if(time - frag_inflictor.toss_time <= 0.1)
1112 Unfreeze(frag_target);
1113 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1114 pointparticles(particleeffectnum("iceorglass"), frag_target.origin, '0 0 0', 3);
1116 frag_force = '0 0 0';
1117 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1118 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1124 MUTATOR_HOOKFUNCTION(nades_MonsterDies)
1126 if(IS_PLAYER(frag_attacker))
1127 if(DIFF_TEAM(frag_attacker, self))
1128 if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
1129 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1134 MUTATOR_HOOKFUNCTION(nades_RemovePlayer)
1137 nades_RemoveBonus(self);
1141 MUTATOR_HOOKFUNCTION(nades_SpectateCopy)
1143 self.nade_timer = other.nade_timer;
1144 self.nade_type = other.nade_type;
1145 self.pokenade_type = other.pokenade_type;
1146 self.bonus_nades = other.bonus_nades;
1147 self.bonus_nade_score = other.bonus_nade_score;
1148 self.stat_healing_orb = other.stat_healing_orb;
1149 self.stat_healing_orb_alpha = other.stat_healing_orb_alpha;
1153 MUTATOR_HOOKFUNCTION(nades_GetCvars)
1155 GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type");
1156 GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type");
1161 MUTATOR_HOOKFUNCTION(nades_BuildMutatorsString)
1163 ret_string = strcat(ret_string, ":Nades");
1167 MUTATOR_HOOKFUNCTION(nades_BuildMutatorsPrettyString)
1169 ret_string = strcat(ret_string, ", Nades");
1173 void nades_Initialize()
1175 addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer);
1176 addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
1177 addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
1178 addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
1179 addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
1180 addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
1182 precache_model("models/ok_nade_counter/ok_nade_counter.md3");
1183 precache_model("models/weapons/h_ok_grenade.iqm");
1184 precache_model("models/weapons/v_ok_grenade.md3");
1185 precache_model("models/ctf/shield.md3");
1187 precache_sound("weapons/rocket_impact.wav");
1188 precache_sound("weapons/grenade_bounce1.wav");
1189 precache_sound("weapons/grenade_bounce2.wav");
1190 precache_sound("weapons/grenade_bounce3.wav");
1191 precache_sound("weapons/grenade_bounce4.wav");
1192 precache_sound("weapons/grenade_bounce5.wav");
1193 precache_sound("weapons/grenade_bounce6.wav");
1194 precache_sound("overkill/grenadebip.ogg");
1197 MUTATOR_DEFINITION(mutator_nades)
1199 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nades_CheckThrow, CBC_ORDER_LAST);
1200 MUTATOR_HOOK(VehicleEnter, nades_VehicleEnter, CBC_ORDER_ANY);
1201 MUTATOR_HOOK(PlayerPreThink, nades_PlayerPreThink, CBC_ORDER_ANY);
1202 MUTATOR_HOOK(PlayerSpawn, nades_PlayerSpawn, CBC_ORDER_ANY);
1203 MUTATOR_HOOK(PlayerDies, nades_PlayerDies, CBC_ORDER_LAST);
1204 MUTATOR_HOOK(PlayerDamage_Calculate, nades_PlayerDamage, CBC_ORDER_ANY);
1205 MUTATOR_HOOK(MonsterDies, nades_MonsterDies, CBC_ORDER_ANY);
1206 MUTATOR_HOOK(MakePlayerObserver, nades_RemovePlayer, CBC_ORDER_ANY);
1207 MUTATOR_HOOK(ClientDisconnect, nades_RemovePlayer, CBC_ORDER_ANY);
1208 MUTATOR_HOOK(SpectateCopy, nades_SpectateCopy, CBC_ORDER_ANY);
1209 MUTATOR_HOOK(GetCvars, nades_GetCvars, CBC_ORDER_ANY);
1210 MUTATOR_HOOK(reset_map_global, nades_RemovePlayer, CBC_ORDER_ANY);
1211 MUTATOR_HOOK(BuildMutatorsString, nades_BuildMutatorsString, CBC_ORDER_ANY);
1212 MUTATOR_HOOK(BuildMutatorsPrettyString, nades_BuildMutatorsPrettyString, CBC_ORDER_ANY);