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, 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;
523 pointparticles(particleeffectnum(expef), self.origin + '0 0 1', '0 0 0', 1);
525 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
526 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
528 self.takedamage = DAMAGE_NO;
532 RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
533 autocvar_g_nades_nade_radius, self, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
534 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);
537 switch ( self.nade_type )
539 case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
540 case NADE_TYPE_ICE: nade_ice_boom(); break;
541 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
542 case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
543 case NADE_TYPE_HEAL: nade_heal_boom(); break;
544 case NADE_TYPE_MONSTER: nade_monster_boom(); break;
552 if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
554 //setsize(self, '-2 -2 -2', '2 2 2');
555 //UpdateCSQCProjectile(self);
556 if(self.health == self.max_health)
558 spamsound(self, CH_SHOTS, strcat("weapons/grenade_bounce", ftos(1 + rint(random() * 5)), ".wav"), VOL_BASE, ATTEN_NORM);
568 sound(self, CH_SHOTS_SINGLE, "overkill/grenadebip.ogg", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
569 self.think = nade_boom;
570 self.nextthink = max(self.wait, time);
573 void nade_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
575 if(self.nade_type == NADE_TYPE_TRANSLOCATE || self.nade_type == NADE_TYPE_SPAWN)
578 if(DEATH_ISWEAPON(deathtype, WEP_LASER))
581 if(DEATH_ISWEAPON(deathtype, WEP_NEX) || DEATH_ISWEAPON(deathtype, WEP_MINSTANEX))
584 damage = self.max_health * 0.55;
587 if(DEATH_ISWEAPON(deathtype, WEP_UZI))
588 damage = self.max_health * 0.1;
590 if(DEATH_ISWEAPON(deathtype, WEP_SHOTGUN))
591 if(deathtype & HITTYPE_SECONDARY)
593 damage = self.max_health * 0.1;
597 damage = self.max_health * 1.1;
599 self.velocity += force;
601 if(!damage || (self.flags & FL_ONGROUND && IS_PLAYER(attacker)))
604 if(self.health == self.max_health)
606 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
607 self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
608 self.think = nade_beep;
611 self.health -= damage;
613 if ( self.nade_type != NADE_TYPE_HEAL || IS_PLAYER(attacker) )
614 self.realowner = attacker;
617 W_PrepareExplosionByDamage(attacker, nade_boom);
619 nade_burn_spawn(self);
622 void toss_nade(entity e, vector _velocity, float _time)
627 entity _nade = e.nade;
633 makevectors(e.v_angle);
635 W_SetupShot(e, FALSE, FALSE, "", CH_WEAPON_A, 0);
637 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
639 setorigin(_nade, w_shotorg + (v_right * 25) * -1);
640 //setmodel(_nade, "models/weapons/v_ok_grenade.md3");
641 //setattachment(_nade, world, "");
642 PROJECTILE_MAKETRIGGER(_nade);
643 setsize(_nade, '-16 -16 -16', '16 16 16');
644 _nade.movetype = MOVETYPE_BOUNCE;
646 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, FALSE, _nade);
647 if (trace_startsolid)
648 setorigin(_nade, e.origin);
650 if(self.v_angle_x >= 70 && self.v_angle_x <= 110)
651 _nade.velocity = '0 0 100';
652 else if(autocvar_g_nades_nade_newton_style == 1)
653 _nade.velocity = e.velocity + _velocity;
654 else if(autocvar_g_nades_nade_newton_style == 2)
655 _nade.velocity = _velocity;
657 _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, TRUE);
659 _nade.touch = nade_touch;
660 _nade.health = autocvar_g_nades_nade_health;
661 _nade.max_health = _nade.health;
662 _nade.takedamage = DAMAGE_AIM;
663 _nade.event_damage = nade_damage;
664 _nade.customizeentityforclient = func_null;
665 _nade.exteriormodeltoclient = world;
666 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
667 _nade.traileffectnum = 0;
668 _nade.teleportable = TRUE;
669 _nade.pushable = TRUE;
671 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
672 _nade.damagedbycontents = TRUE;
673 _nade.angles = vectoangles(_nade.velocity);
674 _nade.flags = FL_PROJECTILE;
675 _nade.projectiledeathtype = DEATH_NADE;
676 _nade.toss_time = time;
677 _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
683 _nade.think = nade_boom;
684 _nade.nextthink = _time;
687 e.nade_refire = time + autocvar_g_nades_nade_refire;
691 void nades_GiveBonus(entity player, float score)
693 if (autocvar_g_nades)
694 if (autocvar_g_nades_bonus)
695 if (IS_REAL_CLIENT(player))
696 if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
697 if (player.frozen == 0)
698 if (player.deadflag == DEAD_NO)
700 if ( player.bonus_nade_score < 1 )
701 player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
703 if ( player.bonus_nade_score >= 1 )
705 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
706 play2(player,"kh/alarm.wav");
707 player.bonus_nades++;
708 player.bonus_nade_score -= 1;
713 void nades_RemoveBonus(entity player)
715 player.bonus_nades = player.bonus_nade_score = 0;
718 float nade_customize()
720 //if(IS_SPEC(other)) { return FALSE; }
721 if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
723 // somewhat hide the model, but keep the glow
725 if(self.traileffectnum)
726 self.traileffectnum = 0;
731 //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
732 if(!self.traileffectnum)
733 self.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(self.nade_type, FALSE), self.team));
746 remove(self.fake_nade);
748 entity n = spawn(), fn = spawn();
750 n.classname = "nade";
751 fn.classname = "fake_nade";
753 if(self.items & IT_STRENGTH && autocvar_g_nades_bonus_onstrength)
754 n.nade_type = self.nade_type;
755 else if (self.bonus_nades >= 1)
757 n.nade_type = self.nade_type;
758 n.pokenade_type = self.pokenade_type;
759 self.bonus_nades -= 1;
763 n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
764 n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
767 n.nade_type = bound(1, n.nade_type, NADE_TYPE_LAST);
769 setmodel(n, "models/weapons/v_ok_grenade.md3");
770 //setattachment(n, self, "bip01 l hand");
771 n.exteriormodeltoclient = self;
772 n.customizeentityforclient = nade_customize;
773 n.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(n.nade_type, FALSE), self.team));
774 n.colormod = Nade_Color(n.nade_type);
776 n.colormap = self.colormap;
777 n.glowmod = self.glowmod;
778 n.wait = time + autocvar_g_nades_nade_lifetime;
781 n.nextthink = max(n.wait - 3, time);
782 n.projectiledeathtype = DEATH_NADE;
784 setmodel(fn, "models/weapons/h_ok_grenade.iqm");
785 setattachment(fn, self.weaponentity, "");
786 fn.realowner = fn.owner = self;
787 fn.colormod = Nade_Color(n.nade_type);
788 fn.colormap = self.colormap;
789 fn.glowmod = self.glowmod;
790 fn.think = SUB_Remove;
791 fn.nextthink = n.wait;
805 if(self.deadflag != DEAD_NO)
808 if (!autocvar_g_nades)
809 return FALSE; // allow turning them off mid match
811 if(forbidWeaponUse())
814 if (!IS_PLAYER(self))
820 void nades_CheckThrow()
827 if(self.nade_refire < time)
829 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW);
831 self.nade_refire = time + autocvar_g_nades_nade_refire;
836 if(time - self.nade.lifetime >= 1)
838 makevectors(self.v_angle);
839 float _force = time - self.nade.lifetime;
840 _force /= autocvar_g_nades_nade_lifetime;
841 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
842 toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
847 void nades_Clear(entity player)
852 remove(player.fake_nade);
854 player.nade = player.fake_nade = world;
855 player.nade_timer = 0;
858 MUTATOR_HOOKFUNCTION(nades_CheckThrow)
860 if(MUTATOR_RETURNVALUE) { nades_CheckThrow(); }
864 MUTATOR_HOOKFUNCTION(nades_VehicleEnter)
867 toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
872 MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
874 if(!IS_PLAYER(self)) { return FALSE; }
876 float key_pressed = self.BUTTON_HOOK;
879 if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, FALSE, FALSE) || (weaponsInMap & WEPSET_HOOK) || g_jetpack || self.items & IT_JETPACK)
880 key_pressed = self.button16; // if hook/jetpack is enabled, use an alternate key
884 self.nade_timer = bound(0, (time - self.nade.lifetime) / autocvar_g_nades_nade_lifetime, 1);
885 //print(sprintf("%d %d\n", self.nade_timer, time - self.nade.lifetime));
886 makevectors(self.angles);
887 self.nade.velocity = self.velocity;
889 setorigin(self.nade, self.origin + self.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
890 self.nade.angles_y = self.angles_y;
894 if(self.nade.wait - 0.1 <= time)
895 toss_nade(self, '0 0 0', time + 0.05);
898 if(self.nade_refire < time)
905 else if(time - self.nade.lifetime >= 1)
909 makevectors(self.v_angle);
910 float _force = time - self.nade.lifetime;
911 _force /= autocvar_g_nades_nade_lifetime;
912 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
913 toss_nade(self, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
920 if ( autocvar_g_nades_bonus && autocvar_g_nades )
924 FOR_EACH_KH_KEY(key) if(key.owner == self) { ++key_count; }
926 if(self.flagcarried || self.ballcarried) // this player is important
927 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
929 time_score = autocvar_g_nades_bonus_score_time;
932 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
934 if(autocvar_g_nades_bonus_client_select)
936 self.nade_type = self.cvar_cl_nade_type;
937 self.pokenade_type = self.cvar_cl_pokenade_type;
941 self.nade_type = autocvar_g_nades_bonus_type;
942 self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
945 self.nade_type = bound(1, self.nade_type, NADE_TYPE_LAST);
947 if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
948 nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max);
952 self.bonus_nades = self.bonus_nade_score = 0;
958 if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
962 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
964 FOR_EACH_PLAYER(other) if(self != other)
966 if(other.deadflag == DEAD_NO)
967 if(other.frozen == 0)
968 if(SAME_TEAM(other, self))
969 if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
974 other.reviving = TRUE;
980 if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
982 self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
983 self.health = max(1, self.revive_progress * start_health);
985 if(self.revive_progress >= 1)
989 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
990 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
993 FOR_EACH_PLAYER(other) if(other.reviving)
995 other.revive_progress = self.revive_progress;
996 other.reviving = FALSE;
1003 MUTATOR_HOOKFUNCTION(nades_PlayerSpawn)
1005 if(autocvar_g_nades_spawn)
1006 self.nade_refire = time + autocvar_g_spawnshieldtime;
1008 self.nade_refire = time + autocvar_g_nades_nade_refire;
1010 if(autocvar_g_nades_bonus_client_select)
1011 self.nade_type = self.cvar_cl_nade_type;
1013 self.nade_timer = 0;
1015 if(self.nade_spawnloc)
1017 setorigin(self, self.nade_spawnloc.origin);
1018 self.nade_spawnloc.cnt -= 1;
1020 if(self.nade_spawnloc.cnt <= 0)
1022 remove(self.nade_spawnloc);
1023 self.nade_spawnloc = world;
1030 MUTATOR_HOOKFUNCTION(nades_PlayerDies)
1032 if(frag_target.nade)
1033 if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade)
1034 toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1036 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);
1038 if(IS_PLAYER(frag_attacker))
1040 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1041 nades_RemoveBonus(frag_attacker);
1042 else if(frag_target.flagcarried)
1043 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1044 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1046 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1047 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1048 switch(frag_attacker.killcount)
1051 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1056 nades_GiveBonus(frag_attacker, killcount_bonus);
1059 nades_RemoveBonus(frag_target);
1064 MUTATOR_HOOKFUNCTION(nades_PlayerDamage)
1066 if(frag_target.frozen)
1067 if(autocvar_g_freezetag_revive_nade)
1068 if(frag_attacker == frag_target)
1069 if(frag_deathtype == DEATH_NADE)
1070 if(time - frag_inflictor.toss_time <= 0.1)
1072 Unfreeze(frag_target);
1073 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1074 pointparticles(particleeffectnum("iceorglass"), frag_target.origin, '0 0 0', 3);
1076 frag_force = '0 0 0';
1077 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1078 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1084 MUTATOR_HOOKFUNCTION(nades_MonsterDies)
1086 if(IS_PLAYER(frag_attacker))
1087 if(DIFF_TEAM(frag_attacker, self))
1088 if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
1089 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1094 MUTATOR_HOOKFUNCTION(nades_RemovePlayer)
1097 nades_RemoveBonus(self);
1101 MUTATOR_HOOKFUNCTION(nades_SpectateCopy)
1103 self.nade_timer = other.nade_timer;
1104 self.nade_type = other.nade_type;
1105 self.pokenade_type = other.pokenade_type;
1106 self.bonus_nades = other.bonus_nades;
1107 self.bonus_nade_score = other.bonus_nade_score;
1108 self.stat_healing_orb = other.stat_healing_orb;
1109 self.stat_healing_orb_alpha = other.stat_healing_orb_alpha;
1113 MUTATOR_HOOKFUNCTION(nades_GetCvars)
1115 GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type");
1116 GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type");
1121 MUTATOR_HOOKFUNCTION(nades_BuildMutatorsString)
1123 ret_string = strcat(ret_string, ":Nades");
1127 MUTATOR_HOOKFUNCTION(nades_BuildMutatorsPrettyString)
1129 ret_string = strcat(ret_string, ", Nades");
1133 void nades_Initialize()
1135 addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer);
1136 addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
1137 addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
1138 addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
1139 addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
1140 addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
1142 precache_model("models/ok_nade_counter/ok_nade_counter.md3");
1143 precache_model("models/weapons/h_ok_grenade.iqm");
1144 precache_model("models/weapons/v_ok_grenade.md3");
1145 precache_model("models/ctf/shield.md3");
1147 precache_sound("weapons/rocket_impact.wav");
1148 precache_sound("weapons/grenade_bounce1.wav");
1149 precache_sound("weapons/grenade_bounce2.wav");
1150 precache_sound("weapons/grenade_bounce3.wav");
1151 precache_sound("weapons/grenade_bounce4.wav");
1152 precache_sound("weapons/grenade_bounce5.wav");
1153 precache_sound("weapons/grenade_bounce6.wav");
1154 precache_sound("overkill/grenadebip.ogg");
1157 MUTATOR_DEFINITION(mutator_nades)
1159 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nades_CheckThrow, CBC_ORDER_LAST);
1160 MUTATOR_HOOK(VehicleEnter, nades_VehicleEnter, CBC_ORDER_ANY);
1161 MUTATOR_HOOK(PlayerPreThink, nades_PlayerPreThink, CBC_ORDER_ANY);
1162 MUTATOR_HOOK(PlayerSpawn, nades_PlayerSpawn, CBC_ORDER_ANY);
1163 MUTATOR_HOOK(PlayerDies, nades_PlayerDies, CBC_ORDER_LAST);
1164 MUTATOR_HOOK(PlayerDamage_Calculate, nades_PlayerDamage, CBC_ORDER_ANY);
1165 MUTATOR_HOOK(MonsterDies, nades_MonsterDies, CBC_ORDER_ANY);
1166 MUTATOR_HOOK(MakePlayerObserver, nades_RemovePlayer, CBC_ORDER_ANY);
1167 MUTATOR_HOOK(ClientDisconnect, nades_RemovePlayer, CBC_ORDER_ANY);
1168 MUTATOR_HOOK(SpectateCopy, nades_SpectateCopy, CBC_ORDER_ANY);
1169 MUTATOR_HOOK(GetCvars, nades_GetCvars, CBC_ORDER_ANY);
1170 MUTATOR_HOOK(reset_map_global, nades_RemovePlayer, CBC_ORDER_ANY);
1171 MUTATOR_HOOK(BuildMutatorsString, nades_BuildMutatorsString, CBC_ORDER_ANY);
1172 MUTATOR_HOOK(BuildMutatorsPrettyString, nades_BuildMutatorsPrettyString, CBC_ORDER_ANY);