Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_nades.qc File Reference
Include dependency graph for sv_nades.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  NadeOffhand

Macros

#define NADE_TYPE_CHECK(nade_ent, nade_cvar)
#define SET_NADE_EFFECT(nade_type, exp_effect, exp_color_min, exp_color_max)
#define SPREE_ITEM(counta, countb, center, normal, gentle)

Functions

bool CanThrowNade (entity this)
 MUTATOR_HOOKFUNCTION (nades, BuildMutatorsPrettyString)
 MUTATOR_HOOKFUNCTION (nades, BuildMutatorsString)
 MUTATOR_HOOKFUNCTION (nades, ClientDisconnect)
 MUTATOR_HOOKFUNCTION (nades, Damage_Calculate)
 MUTATOR_HOOKFUNCTION (nades, DropSpecialItems)
 MUTATOR_HOOKFUNCTION (nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
 MUTATOR_HOOKFUNCTION (nades, MakePlayerObserver)
 MUTATOR_HOOKFUNCTION (nades, MonsterDies)
 MUTATOR_HOOKFUNCTION (nades, PlayerDies, CBC_ORDER_LAST)
 MUTATOR_HOOKFUNCTION (nades, PlayerPreThink)
 MUTATOR_HOOKFUNCTION (nades, PlayerSpawn)
 MUTATOR_HOOKFUNCTION (nades, PutClientInServer)
 MUTATOR_HOOKFUNCTION (nades, reset_map_global)
 MUTATOR_HOOKFUNCTION (nades, SpectateCopy)
 MUTATOR_HOOKFUNCTION (nades, VehicleEnter)
void nade_beep (entity this)
void nade_boom (entity this)
void nade_burn_spawn (entity _nade)
int nade_choose_random ()
bool nade_customize (entity this, entity client)
void nade_damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void nade_pickup (entity this, entity thenade)
void nade_prime (entity this)
void nade_spawn (entity _nade)
void nade_timer_think (entity this)
void nade_touch (entity this, entity toucher)
void nades_CheckThrow (entity this)
Nade nades_CheckTypes (Nade ntype)
void nades_Clear (entity player)
 Remove nades that are being thrown.
Nade Nades_FromString (string ntype)
Nade Nades_GetType (string ntype)
void nades_GiveBonus (entity player, float score)
 Give a bonus grenade to a player.
vector nades_PlayerColor (entity this, bool isPants)
void nades_RemoveBonus (entity player)
 Remove all bonus nades from a player.
void nades_RemovePlayer (entity this)
 Remove nades and bonus nades from a player.
entity nades_spawn_orb (entity this, float orb_lifetime, float orb_rad)
 Spawns an orb for some nade types.
 REGISTER_MUTATOR (nades, autocvar_g_nades)
void spawn_held_nade (entity player, entity nowner, float ntime, string ntype, string pntype)
void toss_nade (entity e, bool set_owner, vector _velocity, float _time)

Variables

bool nade_altbutton
entity nade_spawnloc
float nade_time_primed
NadeOffhand OFFHAND_NADE

Macro Definition Documentation

◆ NADE_TYPE_CHECK

#define NADE_TYPE_CHECK ( nade_ent,
nade_cvar )
Value:
case nade_ent.m_id: \
if (nade_cvar) \
return ntype; \
break

Referenced by nades_CheckTypes().

◆ SET_NADE_EFFECT

#define SET_NADE_EFFECT ( nade_type,
exp_effect,
exp_color_min,
exp_color_max )
Value:
case nade_type: \
expef = exp_effect; \
expcol_min = exp_color_min; \
expcol_max = exp_color_max; \
break

Referenced by nade_boom().

◆ SPREE_ITEM

#define SPREE_ITEM ( counta,
countb,
center,
normal,
gentle )
Value:
case counta: \
nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); \
break;
int autocvar_g_nades_bonus_score_spree
Definition sv_nades.qh:40

Function Documentation

◆ CanThrowNade()

bool CanThrowNade ( entity this)

Definition at line 598 of file sv_nades.qc.

599{
600 return !(this.vehicle || !autocvar_g_nades || IS_DEAD(this) || !IS_PLAYER(this) || weaponLocked(this));
601}
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
bool autocvar_g_nades
Definition sv_nades.qh:5
entity vehicle
bool weaponLocked(entity player)

References autocvar_g_nades, entity(), IS_DEAD, IS_PLAYER, vehicle, and weaponLocked().

Referenced by nade_touch(), nades_CheckThrow(), and NadeOffhand::offhand_think().

◆ MUTATOR_HOOKFUNCTION() [1/15]

MUTATOR_HOOKFUNCTION ( nades ,
BuildMutatorsPrettyString  )

Definition at line 929 of file sv_nades.qc.

930{
931 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Nades");
932}
#define M_ARGV(x, type)
Definition events.qh:17
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [2/15]

MUTATOR_HOOKFUNCTION ( nades ,
BuildMutatorsString  )

Definition at line 934 of file sv_nades.qc.

935{
936 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
937}

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [3/15]

MUTATOR_HOOKFUNCTION ( nades ,
ClientDisconnect  )

Definition at line 907 of file sv_nades.qc.

908{
909 entity player = M_ARGV(0, entity);
910 nades_RemovePlayer(player);
911}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void nades_RemovePlayer(entity this)
Remove nades and bonus nades from a player.
Definition sv_nades.qc:894

References ClientDisconnect, entity(), M_ARGV, and nades_RemovePlayer().

◆ MUTATOR_HOOKFUNCTION() [4/15]

MUTATOR_HOOKFUNCTION ( nades ,
Damage_Calculate  )

Definition at line 856 of file sv_nades.qc.

857{
858 entity frag_inflictor = M_ARGV(0, entity);
859 entity frag_attacker = M_ARGV(1, entity);
861 float frag_deathtype = M_ARGV(3, float);
862
863 if (autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id
864 && time - frag_inflictor.toss_time <= 0.1)
865 {
868 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
869 M_ARGV(4, float) = 0;
870 M_ARGV(6, vector) = '0 0 0';
871 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
872 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
873 }
874}
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float time
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:155
#define STAT(...)
Definition stats.qh:94
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1500
#define NULL
Definition post.qh:14
vector
Definition self.qh:96
entity frag_target
Definition sv_ctf.qc:2315
void freezetag_Unfreeze(entity targ, bool reset_health)
float autocvar_g_freezetag_revive_nade_health
bool autocvar_g_freezetag_revive_nade

References autocvar_g_freezetag_revive_nade, autocvar_g_freezetag_revive_nade_health, entity(), frag_target, freezetag_Unfreeze(), M_ARGV, NULL, Send_Effect(), Send_Notification(), SetResource(), STAT, time, and vector.

◆ MUTATOR_HOOKFUNCTION() [5/15]

MUTATOR_HOOKFUNCTION ( nades ,
DropSpecialItems  )

Definition at line 886 of file sv_nades.qc.

887{
889
890 if (frag_target.nade)
891 toss_nade(frag_target, true, '0 0 0', time + 0.05);
892}
void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
Definition sv_nades.qc:301

References entity(), frag_target, M_ARGV, time, and toss_nade().

◆ MUTATOR_HOOKFUNCTION() [6/15]

MUTATOR_HOOKFUNCTION ( nades ,
ForbidThrowCurrentWeapon ,
CBC_ORDER_LAST  )

Definition at line 695 of file sv_nades.qc.

696{
697 entity player = M_ARGV(0, entity);
698
699 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon)
700 {
701 nades_CheckThrow(player);
702 return true;
703 }
704}
void nades_CheckThrow(entity this)
Definition sv_nades.qc:605
NadeOffhand OFFHAND_NADE
Definition sv_nades.qc:685
bool autocvar_g_nades_override_dropweapon
Definition sv_nades.qh:6
#define WEPSET(id)
Definition all.qh:47

References autocvar_g_nades_override_dropweapon, CBC_ORDER_LAST, entity(), M_ARGV, nades_CheckThrow(), OFFHAND_NADE, STAT, and WEPSET.

◆ MUTATOR_HOOKFUNCTION() [7/15]

MUTATOR_HOOKFUNCTION ( nades ,
MakePlayerObserver  )

Definition at line 902 of file sv_nades.qc.

903{
904 entity player = M_ARGV(0, entity);
905 nades_RemovePlayer(player);
906}

References entity(), M_ARGV, and nades_RemovePlayer().

◆ MUTATOR_HOOKFUNCTION() [8/15]

MUTATOR_HOOKFUNCTION ( nades ,
MonsterDies  )

Definition at line 876 of file sv_nades.qc.

877{
879 entity frag_attacker = M_ARGV(1, entity);
880
881 if (IS_PLAYER(frag_attacker) && DIFF_TEAM(frag_attacker, frag_target)
882 && !(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
884}
const int MONSTERFLAG_SPAWNED
flag for spawned monsters
void nades_GiveBonus(entity player, float score)
Give a bonus grenade to a player.
Definition sv_nades.qc:425
int autocvar_g_nades_bonus_score_minor
Definition sv_nades.qh:36
#define DIFF_TEAM(a, b)
Definition teams.qh:242

References autocvar_g_nades_bonus_score_minor, DIFF_TEAM, entity(), frag_target, IS_PLAYER, M_ARGV, MONSTERFLAG_SPAWNED, and nades_GiveBonus().

◆ MUTATOR_HOOKFUNCTION() [9/15]

MUTATOR_HOOKFUNCTION ( nades ,
PlayerDies ,
CBC_ORDER_LAST  )

Definition at line 816 of file sv_nades.qc.

817{
818 entity frag_attacker = M_ARGV(1, entity);
820
821 if (frag_target.nade
823 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
824
825 if (IS_PLAYER(frag_attacker))
826 {
827 float killcount_bonus = (CS(frag_attacker).killcount >= 1)
830 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
831 nades_RemoveBonus(frag_attacker);
834 else if (autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
835 {
836 #define SPREE_ITEM(counta, countb, center, normal, gentle) \
837 case counta: \
838 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); \
839 break;
840 switch (CS(frag_attacker).killcount)
841 {
843 default:
845 break;
846 }
847 #undef SPREE_ITEM
848 }
849 else
850 nades_GiveBonus(frag_attacker, killcount_bonus);
851 }
852
854}
float bound(float min, float value, float max)
float max(float f,...)
#define KILL_SPREE_LIST
Definition all.qh:486
int killcount
Definition client.qh:315
ClientState CS(Client this)
Definition state.qh:47
void nades_RemoveBonus(entity player)
Remove all bonus nades from a player.
Definition sv_nades.qc:445
int autocvar_g_nades_bonus_score_medium
Definition sv_nades.qh:39
#define GameRules_scoring_is_vip(player)
Definition sv_rules.qh:79
#define SAME_TEAM(a, b)
Definition teams.qh:241

References autocvar_g_freezetag_revive_nade, autocvar_g_nades_bonus_score_medium, autocvar_g_nades_bonus_score_minor, autocvar_g_nades_bonus_score_spree, bound(), CBC_ORDER_LAST, CS(), entity(), frag_target, GameRules_scoring_is_vip, IS_PLAYER, KILL_SPREE_LIST, killcount, M_ARGV, max(), nades_GiveBonus(), nades_RemoveBonus(), SAME_TEAM, STAT, time, and toss_nade().

◆ MUTATOR_HOOKFUNCTION() [10/15]

MUTATOR_HOOKFUNCTION ( nades ,
PlayerPreThink  )

Definition at line 706 of file sv_nades.qc.

707{
708 entity player = M_ARGV(0, entity);
709
710 if (!IS_PLAYER(player))
711 return;
712
713 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK))))
714 OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
715
716 entity held_nade = player.nade;
717 if (held_nade)
718 {
719 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
720 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
721 makevectors(player.angles);
722 held_nade.velocity = player.velocity;
723 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
724 held_nade.angles.y = player.angles.y;
725
726 if (time + 0.1 >= held_nade.wait)
727 {
728 toss_nade(player, false, '0 0 0', time + 0.05);
729 int ntype = STAT(NADE_BONUS_TYPE, held_nade);
730 if (ntype == NADE_TYPE_NORMAL.m_id
731 || ntype == NADE_TYPE_NAPALM.m_id
732 || (ntype == NADE_TYPE_ICE.m_id && !autocvar_g_nades_ice_teamcheck)
733 || ntype == NADE_TYPE_TRANSLOCATE.m_id
734 || (ntype == NADE_TYPE_HEAL.m_id && (autocvar_g_nades_heal_friend < 0 || autocvar_g_nades_heal_armor_rate < 0))
735 || (ntype == NADE_TYPE_ENTRAP.m_id && (autocvar_g_nades_entrap_speed < 1 || autocvar_g_nades_entrap_strength < 1))
736 || (ntype == NADE_TYPE_MONSTER.m_id && !autocvar_g_monsters)
737 || (ntype == NADE_TYPE_AMMO.m_id && autocvar_g_nades_ammo_friend < 0)
738 || (ntype == NADE_TYPE_DARKNESS.m_id && !autocvar_g_nades_darkness_teamcheck))
739 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_THROW);
740 }
741 }
742
743 if (IS_PLAYER(player))
744 {
746 {
747 entity key;
748 int key_count = 0;
749 FOR_EACH_KH_KEY(key)
750 if (key.owner == player)
751 ++key_count;
752
753 float time_score = (GameRules_scoring_is_vip(player))
756
757 if (key_count)
758 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
759
761 {
762 STAT(NADE_BONUS_TYPE, player) = nades_CheckTypes(Nades_FromString(CS_CVAR(player).cvar_cl_nade_type)).m_id;
763 player.pokenade_type = CS_CVAR(player).cvar_cl_pokenade_type;
764 }
765 else
766 {
767 STAT(NADE_BONUS_TYPE, player) = Nades_FromString(autocvar_g_nades_bonus_type).m_id;
768 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
769 }
770
771 if (STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
773 }
774 else
775 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
776
777 nade_veil_Apply(player);
778 }
779}
int m_id
Definition nades.qh:16
float autocvar_g_nades_ammo_friend
Definition ammo.qh:9
vector v_up
vector v_right
vector v_forward
bool autocvar_g_nades_darkness_teamcheck
Definition darkness.qh:8
float autocvar_g_nades_entrap_strength
Definition entrap.qh:7
float autocvar_g_nades_entrap_speed
Definition entrap.qh:8
bool autocvar_g_nades_ice_teamcheck
Definition ice.qh:9
float autocvar_g_nades_heal_friend
Definition heal.qh:10
float autocvar_g_nades_heal_armor_rate
Definition heal.qh:9
string autocvar_g_nades_pokenade_monster_type
Definition monster.qh:8
#define makevectors
Definition post.qh:21
#define CS_CVAR(this)
Definition state.qh:51
#define FOR_EACH_KH_KEY(v)
Definition sv_keyhunt.qh:27
float autocvar_g_monsters
Definition sv_monsters.qh:5
Nade Nades_FromString(string ntype)
Definition sv_nades.qc:493
Nade nades_CheckTypes(Nade ntype)
Definition sv_nades.qc:399
bool autocvar_g_nades_bonus_client_select
Definition sv_nades.qh:29
int autocvar_g_nades_bonus_score_time_flagcarrier
Definition sv_nades.qh:35
bool autocvar_g_nades_bonus
Definition sv_nades.qh:27
int autocvar_g_nades_bonus_score_time
Definition sv_nades.qh:34
string autocvar_g_nades_bonus_type
Definition sv_nades.qh:28
string cvar_cl_nade_type
Definition sv_nades.qh:50
int autocvar_g_nades_bonus_score_max
Definition sv_nades.qh:33
void nade_veil_Apply(entity player)
Definition veil.qc:34

References autocvar_g_monsters, autocvar_g_nades, autocvar_g_nades_ammo_friend, autocvar_g_nades_bonus, autocvar_g_nades_bonus_client_select, autocvar_g_nades_bonus_score_max, autocvar_g_nades_bonus_score_time, autocvar_g_nades_bonus_score_time_flagcarrier, autocvar_g_nades_bonus_type, autocvar_g_nades_darkness_teamcheck, autocvar_g_nades_entrap_speed, autocvar_g_nades_entrap_strength, autocvar_g_nades_heal_armor_rate, autocvar_g_nades_heal_friend, autocvar_g_nades_ice_teamcheck, autocvar_g_nades_pokenade_monster_type, bound(), CS_CVAR, cvar_cl_nade_type, entity(), FOR_EACH_KH_KEY, GameRules_scoring_is_vip, IS_PLAYER, M_ARGV, Nade::m_id, makevectors, nade_veil_Apply(), nades_CheckTypes(), Nades_FromString(), nades_GiveBonus(), OFFHAND_NADE, PlayerPreThink, Send_Notification(), STAT, time, toss_nade(), v_forward, v_right, v_up, and WEPSET.

◆ MUTATOR_HOOKFUNCTION() [11/15]

MUTATOR_HOOKFUNCTION ( nades ,
PlayerSpawn  )

Definition at line 781 of file sv_nades.qc.

782{
783 entity player = M_ARGV(0, entity);
784
785 if (StatusEffects_active(STATUSEFFECT_SpawnShield, player))
786 player.nade_refire = StatusEffects_gettime(STATUSEFFECT_SpawnShield, player);
787 else
788 player.nade_refire = time;
789
791 player.nade_refire += autocvar_g_nades_nade_refire;
792
794 STAT(NADE_BONUS_TYPE, player) = Nades_FromString(CS_CVAR(player).cvar_cl_nade_type).m_id;
795
796 STAT(NADE_TIMER, player) = 0;
797
798 if (!player.offhand)
799 player.offhand = OFFHAND_NADE;
800
801 if (player.nade_spawnloc)
802 {
803 setorigin(player, player.nade_spawnloc.origin);
804 --player.nade_spawnloc.cnt;
805
806 if (player.nade_spawnloc.cnt <= 0)
807 {
808 delete(player.nade_spawnloc);
809 player.nade_spawnloc = NULL;
810 }
811
813 }
814}
void nade_spawn_SetSpawnHealth(entity player)
Definition spawn.qc:22
float StatusEffects_gettime(StatusEffect this, entity actor)
bool StatusEffects_active(StatusEffect this, entity actor)
float autocvar_g_nades_nade_refire
Definition sv_nades.qh:18
bool autocvar_g_nades_onspawn
Definition sv_nades.qh:8

References autocvar_g_nades_bonus_client_select, autocvar_g_nades_nade_refire, autocvar_g_nades_onspawn, CS_CVAR, cvar_cl_nade_type, entity(), M_ARGV, Nade::m_id, nade_spawn_SetSpawnHealth(), Nades_FromString(), NULL, OFFHAND_NADE, STAT, StatusEffects_active(), StatusEffects_gettime(), and time.

◆ MUTATOR_HOOKFUNCTION() [12/15]

MUTATOR_HOOKFUNCTION ( nades ,
PutClientInServer  )

Definition at line 450 of file sv_nades.qc.

451{
452 entity player = M_ARGV(0, entity);
453
454 nades_RemoveBonus(player);
455}

References entity(), M_ARGV, nades_RemoveBonus(), and PutClientInServer.

◆ MUTATOR_HOOKFUNCTION() [13/15]

MUTATOR_HOOKFUNCTION ( nades ,
reset_map_global  )

Definition at line 912 of file sv_nades.qc.

913{
915}
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52

References FOREACH_CLIENT, IS_PLAYER, and nades_RemovePlayer().

◆ MUTATOR_HOOKFUNCTION() [14/15]

MUTATOR_HOOKFUNCTION ( nades ,
SpectateCopy  )

Definition at line 917 of file sv_nades.qc.

918{
919 entity spectatee = M_ARGV(0, entity);
920 entity client = M_ARGV(1, entity);
921
922 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
923 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
924 client.pokenade_type = spectatee.pokenade_type;
925 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
926 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
927}

References entity(), M_ARGV, SpectateCopy(), and STAT.

◆ MUTATOR_HOOKFUNCTION() [15/15]

MUTATOR_HOOKFUNCTION ( nades ,
VehicleEnter  )

Definition at line 647 of file sv_nades.qc.

648{
649 entity player = M_ARGV(0, entity);
650
651 if (player.nade)
652 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
653}

References entity(), M_ARGV, max(), time, and toss_nade().

◆ nade_beep()

void nade_beep ( entity this)

Definition at line 219 of file sv_nades.qc.

220{
221 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 * (ATTEN_LARGE + ATTEN_MAX));
222 setthink(this, nade_boom);
223 this.nextthink = max(this.wait, time);
224}
float wait
Definition items.qc:17
float nextthink
#define setthink(e, f)
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_MAX
Definition sound.qh:34
const int CH_SHOTS_SINGLE
Definition sound.qh:15
#define sound(e, c, s, v, a)
Definition sound.qh:52
const float ATTEN_LARGE
Definition sound.qh:31
void nade_boom(entity this)
Definition sv_nades.qc:94

References ATTEN_LARGE, ATTEN_MAX, CH_SHOTS_SINGLE, entity(), max(), nade_boom(), nextthink, setthink, sound, time, VOL_BASE, and wait.

Referenced by nade_damage(), and spawn_held_nade().

◆ nade_boom()

void nade_boom ( entity this)

Definition at line 94 of file sv_nades.qc.

95{
96 entity expef = NULL;
97 vector expcol_min = '0 0 0', expcol_max = '0 0 0';
98
99 Nade ntype = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
100
101 if (!this.takedamage || ntype == NADE_TYPE_Null)
102 {
103 // first condition: nade was destroyed by something (lava, void, etc.), just do a normal explosion
104 // this prevents weird cases like spawn nade setting your spawnpoint on the void, translocate sending you into the void, etc.
105 ntype = NADE_TYPE_NORMAL;
106 }
107
108#define SET_NADE_EFFECT(nade_type, exp_effect, exp_color_min, exp_color_max) \
109 case nade_type: \
110 expef = exp_effect; \
111 expcol_min = exp_color_min; \
112 expcol_max = exp_color_max; \
113 break
114
115 switch (ntype)
116 {
117 SET_NADE_EFFECT(NADE_TYPE_NAPALM, EFFECT_EXPLOSION_MEDIUM, '0 0 0', '0 0 0');
118 SET_NADE_EFFECT(NADE_TYPE_ICE, EFFECT_ELECTRO_COMBO, '0 0 0', '0 0 0');
119 SET_NADE_EFFECT(NADE_TYPE_TRANSLOCATE, NULL, '0 0 0', '0 0 0');
120 SET_NADE_EFFECT(NADE_TYPE_MONSTER, NULL, nades_PlayerColor(this.realowner, false), nades_PlayerColor(this.realowner, true));
121 SET_NADE_EFFECT(NADE_TYPE_SPAWN, EFFECT_SPAWN, nades_PlayerColor(this.realowner, false), nades_PlayerColor(this.realowner, true));
122 SET_NADE_EFFECT(NADE_TYPE_HEAL, EFFECT_SPAWN, '1 0 0', '1 0 0');
123 SET_NADE_EFFECT(NADE_TYPE_ENTRAP, EFFECT_SPAWN, '1 1 0', '1 1 0');
124 SET_NADE_EFFECT(NADE_TYPE_VEIL, EFFECT_SPAWN, '0 0 0', '0 0 0');
125 SET_NADE_EFFECT(NADE_TYPE_AMMO, EFFECT_SPAWN, '0.33 0.33 1', '0.33 0.33 1');
126 SET_NADE_EFFECT(NADE_TYPE_DARKNESS, EFFECT_EXPLOSION_MEDIUM, '0 0 0', '0 0 0');
127 SET_NADE_EFFECT(NADE_TYPE_NORMAL, EFFECT_NADE_EXPLODE, nades_PlayerColor(this.realowner, false), nades_PlayerColor(this.realowner, true));
128 }
129#undef SET_NADE_EFFECT
130
131 if (expef)
132 Send_Effect_Core(expef, findbetterlocation(this.origin, 8), '0 0 0', 1, expcol_min, expcol_max, -1, -1, -1, NULL);
133
134 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
135 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
136
137 this.event_damage = func_null; // prevent somehow calling damage in the next call
138
139 switch (ntype)
140 {
141 case NADE_TYPE_NORMAL: nade_normal_boom(this); break;
142 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
143 case NADE_TYPE_ICE: nade_ice_boom(this); break;
144 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
145 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
146 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
147 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
148 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
149 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
150 case NADE_TYPE_AMMO: nade_ammo_boom(this); break;
151 case NADE_TYPE_DARKNESS: nade_darkness_boom(this); break;
152 }
153
154 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, RemoveHook(it));
155 delete(this);
156}
Definition nades.qh:15
void nade_ammo_boom(entity this)
Definition ammo.qc:70
vector findbetterlocation(vector org, float mindist)
Definition util.qc:116
vector origin
void nade_darkness_boom(entity this)
Definition darkness.qc:66
void Send_Effect_Core(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, float eff_alpha_min, float eff_alpha_max, float eff_alpha_fade, entity ignore)
Definition all.qc:74
void nade_entrap_boom(entity this)
Definition entrap.qc:33
void nade_ice_boom(entity this)
Definition ice.qc:74
#define IL_EACH(this, cond, body)
void nade_monster_boom(entity this)
Definition monster.qc:7
void nade_heal_boom(entity this)
Definition heal.qc:51
void nade_spawn_boom(entity this)
Definition spawn.qc:4
void nade_napalm_boom(entity this)
Definition napalm.qc:144
var void func_null()
void nade_normal_boom(entity this)
Definition normal.qc:4
#define REGISTRY_GET(id, i)
Definition registry.qh:62
void RemoveHook(entity this)
Definition hook.qc:48
IntrusiveList g_projectiles
Definition common.qh:58
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NORM
Definition sound.qh:30
float takedamage
Definition subs.qh:78
#define SET_NADE_EFFECT(nade_type, exp_effect, exp_color_min, exp_color_max)
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:13
entity realowner
void nade_translocate_boom(entity this)
Definition translocate.qc:4
void nade_veil_boom(entity this)
Definition veil.qc:28

References ATTEN_NORM, CH_SHOTS, CH_SHOTS_SINGLE, entity(), findbetterlocation(), func_null(), g_projectiles, IL_EACH, nade_ammo_boom(), nade_darkness_boom(), nade_entrap_boom(), nade_heal_boom(), nade_ice_boom(), nade_monster_boom(), nade_napalm_boom(), nade_normal_boom(), nade_spawn_boom(), nade_translocate_boom(), nade_veil_boom(), nades_PlayerColor(), NULL, origin, realowner, REGISTRY_GET, RemoveHook(), Send_Effect_Core(), SET_NADE_EFFECT, sound, STAT, takedamage, vector, and VOL_BASE.

Referenced by nade_beep(), nade_damage(), nade_touch(), nade_translocate_DestroyDamage(), and toss_nade().

◆ nade_burn_spawn()

void nade_burn_spawn ( entity _nade)

Definition at line 35 of file sv_nades.qc.

36{
37 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[1], true);
38}
void CSQCProjectile(entity e, float clientanimate, int type, float docull)

References CSQCProjectile(), entity(), REGISTRY_GET, and STAT.

Referenced by nade_damage().

◆ nade_choose_random()

int nade_choose_random ( )

Definition at line 482 of file sv_nades.qc.

483{
485 FOREACH(Nades, it != NADE_TYPE_Null,
486 {
487 if (nades_CheckTypes(it) == it) // this nade type is allowed
488 RandomSelection_AddEnt(it, 1, 1);
489 });
490 return RandomSelection_chosen_ent.m_id;
491}
#define FOREACH(list, cond, body)
Definition iter.qh:19
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
#define RandomSelection_AddEnt(e, weight, priority)
Definition random.qh:14
entity RandomSelection_chosen_ent
Definition random.qh:5

References FOREACH, nades_CheckTypes(), RandomSelection_AddEnt, RandomSelection_chosen_ent, and RandomSelection_Init().

Referenced by Nades_GetType().

◆ nade_customize()

bool nade_customize ( entity this,
entity client )

Definition at line 457 of file sv_nades.qc.

458{
459 //if (IS_SPEC(client)) return false;
460 if (client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
461 {
462 // somewhat hide the model, but keep the glow
463 //this.effects = 0;
464 if (this.traileffectnum)
465 this.traileffectnum = 0;
466 this.alpha = -1;
467 }
468 else
469 {
470 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
471 if (!this.traileffectnum)
472 {
473 entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
474 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[0], this.team).eent_eff_name);
475 }
476 this.alpha = 1;
477 }
478
479 return true;
480}
float alpha
Definition items.qc:13
float traileffectnum
entity exteriormodeltoclient
#define nade(name, colormin1, colormax1, colormin2, colormax2)
entity Nade_TrailEffect(int proj, int nade_team)
Definition nades.qc:17
#define IS_SPEC(v)
Definition utils.qh:10

References alpha, entity(), exteriormodeltoclient, IS_SPEC, nade, Nade_TrailEffect(), REGISTRY_GET, STAT, and traileffectnum.

Referenced by spawn_held_nade().

◆ nade_damage()

void nade_damage ( entity this,
entity inflictor,
entity attacker,
float damage,
int deathtype,
.entity weaponentity,
vector hitloc,
vector force )

Definition at line 226 of file sv_nades.qc.

227{
228 if (ITEM_DAMAGE_NEEDKILL(deathtype))
229 {
230 this.takedamage = DAMAGE_NO;
231 W_PrepareExplosionByDamage(this, attacker, nade_boom);
232 return;
233 }
234
235 if (STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
236 return; // can't launch these, to prevent teleporting across the map
237
238 // adjust damage & force to allow specific interactions (e.g. launching nades with Vortex)
239 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage))
240 {}
241 else if (DEATH_ISWEAPON(deathtype, WEP_BLASTER))
242 {
243 force *= 1.5;
244 damage = 0;
245 }
246 else if (DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
247 {
248 force *= 6;
249 damage = this.max_health * 0.55;
250 }
251 else if (DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
252 damage = this.max_health * 0.1;
253 else if (DEATH_ISWEAPON(deathtype, WEP_SHOTGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_SHOTGUN)) // WEAPONTODO
254 {
255 if (!(deathtype & HITTYPE_SECONDARY))
256 damage = this.max_health * 1.15;
257 }
258
259 // melee slaps
260 entity death_weapon = DEATH_WEAPONOF(deathtype);
261 if (death_weapon.spawnflags & ((deathtype & HITTYPE_SECONDARY) ? WEP_TYPE_MELEE_SEC : WEP_TYPE_MELEE_PRI))
262 {
263 force *= 10;
264 damage = this.max_health * 0.1;
265 }
266
267 this.velocity += force;
269
270 if (damage <= 0 || (IS_ONGROUND(this) && IS_PLAYER(attacker)))
271 return;
272
273 float hp = GetResource(this, RES_HEALTH);
274 if (hp == this.max_health)
275 {
276 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 * (ATTEN_LARGE + ATTEN_MAX));
277 this.nextthink = max(time + this.nade_lifetime, time);
278 setthink(this, nade_beep);
279 }
280
281 hp -= damage;
282 SetResource(this, RES_HEALTH, hp);
283
284 if (IS_PLAYER(attacker)
285 && STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_TRANSLOCATE.m_id
286 && STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_SPAWN.m_id)
287 this.realowner = attacker;
288
289 if (hp <= 0)
290 {
291 if (nade_spawn_DestroyDamage(this, attacker)
292 || nade_translocate_DestroyDamage(this, attacker))
293 return;
294
295 W_PrepareExplosionByDamage(this, attacker, nade_boom);
296 }
297 else
298 nade_burn_spawn(this);
299}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
float max_health
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
vector velocity
void UpdateCSQCProjectile(entity e)
#define DEATH_ISWEAPON(t, w)
Definition all.qh:48
#define DEATH_WEAPONOF(t)
Definition all.qh:47
const int HITTYPE_SECONDARY
Definition all.qh:31
#define IS_ONGROUND(s)
Definition movetypes.qh:16
bool nade_spawn_DestroyDamage(entity this, entity attacker)
Definition spawn.qc:28
#define ITEM_DAMAGE_NEEDKILL(dt)
Definition items.qh:123
void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
Definition common.qc:87
const int DAMAGE_NO
Definition subs.qh:79
void nade_burn_spawn(entity _nade)
Definition sv_nades.qc:35
void nade_beep(entity this)
Definition sv_nades.qc:219
float nade_lifetime
Definition sv_nades.qh:45
bool nade_translocate_DestroyDamage(entity this, entity attacker)
const int WEP_TYPE_MELEE_PRI
Definition weapon.qh:262
const int WEP_TYPE_MELEE_SEC
Definition weapon.qh:263

References ATTEN_LARGE, ATTEN_MAX, CH_SHOTS_SINGLE, DAMAGE_NO, DEATH_ISWEAPON, DEATH_WEAPONOF, entity(), GetResource(), HITTYPE_SECONDARY, IS_ONGROUND, IS_PLAYER, ITEM_DAMAGE_NEEDKILL, max(), max_health, MUTATOR_CALLHOOK, nade_beep(), nade_boom(), nade_burn_spawn(), nade_lifetime, nade_spawn_DestroyDamage(), nade_translocate_DestroyDamage(), nextthink, realowner, SetResource(), setthink, sound, STAT, takedamage, time, UpdateCSQCProjectile(), vector, velocity, VOL_BASE, W_PrepareExplosionByDamage(), WEP_TYPE_MELEE_PRI, and WEP_TYPE_MELEE_SEC.

Referenced by toss_nade().

◆ nade_pickup()

void nade_pickup ( entity this,
entity thenade )

Definition at line 159 of file sv_nades.qc.

160{
161 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, thenade)).netname, thenade.pokenade_type);
162
163 // set refire so player can't even
165 STAT(NADE_TIMER, this) = 0;
166
167 if (this.nade)
168 this.nade.nade_time_primed = thenade.nade_time_primed;
169}
string netname
Definition powerups.qc:20
void spawn_held_nade(entity player, entity nowner, float ntime, string ntype, string pntype)
Definition sv_nades.qc:510
float autocvar_g_nades_pickup_time
Definition sv_nades.qh:13
float nade_refire
Definition sv_nades.qh:46

References autocvar_g_nades_nade_refire, autocvar_g_nades_pickup_time, entity(), nade, nade_refire, netname, REGISTRY_GET, spawn_held_nade(), STAT, and time.

Referenced by nade_touch().

◆ nade_prime()

void nade_prime ( entity this)

Definition at line 556 of file sv_nades.qc.

557{
558 if (autocvar_g_nades_bonus_only && !STAT(NADE_BONUS, this))
559 return; // only allow bonus nades
560
561 // TODO: handle old nade if it exists?
562 if (this.nade)
563 delete(this.nade);
564 this.nade = NULL;
565
566 if (this.fake_nade)
567 delete(this.fake_nade);
568 this.fake_nade = NULL;
569
570 Nade ntype;
571 string pntype = this.pokenade_type;
572
573 if (StatusEffects_active(STATUSEFFECT_Strength, this) && autocvar_g_nades_bonus_onstrength)
574 ntype = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
575 else if (STAT(NADE_BONUS, this) >= 1)
576 {
577 ntype = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
578 pntype = this.pokenade_type;
579 --STAT(NADE_BONUS, this);
580 }
581 else
582 {
584 {
586 pntype = CS_CVAR(this).cvar_cl_pokenade_type;
587 }
588 else
589 {
592 }
593 }
594
595 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype.netname, pntype);
596}
string netname
Definition nades.qh:22
string pokenade_type
Definition sv_nades.qh:48
float autocvar_g_nades_nade_lifetime
Definition sv_nades.qh:14
bool autocvar_g_nades_bonus_onstrength
Definition sv_nades.qh:30
bool autocvar_g_nades_bonus_only
Definition sv_nades.qh:31
entity fake_nade
Definition sv_nades.qh:44
bool autocvar_g_nades_client_select
Definition sv_nades.qh:25
string autocvar_g_nades_nade_type
Definition sv_nades.qh:24

References autocvar_g_nades_bonus_only, autocvar_g_nades_bonus_onstrength, autocvar_g_nades_client_select, autocvar_g_nades_nade_lifetime, autocvar_g_nades_nade_type, autocvar_g_nades_pokenade_monster_type, CS_CVAR, cvar_cl_nade_type, entity(), fake_nade, nade, nades_CheckTypes(), Nades_FromString(), Nade::netname, NULL, pokenade_type, REGISTRY_GET, spawn_held_nade(), STAT, and StatusEffects_active().

Referenced by nades_CheckThrow(), and NadeOffhand::offhand_think().

◆ nade_spawn()

void nade_spawn ( entity _nade)

Definition at line 40 of file sv_nades.qc.

41{
42 entity timer = new(nade_timer);
43 setmodel(timer, MDL_NADE_TIMER);
44 setattachment(timer, _nade, "");
45 timer.colormap = _nade.colormap;
46 timer.glowmod = _nade.glowmod;
48 timer.nextthink = time;
49 timer.wait = _nade.wait;
50 timer.nade_lifetime = _nade.nade_lifetime;
51 timer.owner = _nade;
52 timer.skin = 10;
53
54 _nade.effects |= EF_LOWPRECISION;
55
56 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[0], true);
57}
#define setmodel(this, m)
Definition model.qh:26
float EF_LOWPRECISION
float timer
Definition hud.qh:125
void nade_timer_think(entity this)
Definition sv_nades.qc:27

References CSQCProjectile(), EF_LOWPRECISION, entity(), nade_timer_think(), REGISTRY_GET, setmodel, setthink, STAT, time, and timer.

Referenced by toss_nade().

◆ nade_timer_think()

void nade_timer_think ( entity this)

Definition at line 27 of file sv_nades.qc.

28{
29 this.skin = 8 - (this.wait - time) / (this.nade_lifetime / 10);
30 this.nextthink = time;
31 if (!this.owner || wasfreed(this.owner))
32 delete(this);
33}
entity owner
Definition main.qh:87
skin
Definition ent_cs.qc:168

References entity(), nade_lifetime, nextthink, owner, skin, time, and wait.

Referenced by nade_darkness_boom(), nade_ice_boom(), and nade_spawn().

◆ nade_touch()

void nade_touch ( entity this,
entity toucher )

Definition at line 172 of file sv_nades.qc.

173{
174 if (toucher)
176
177 if (toucher == this.realowner)
178 return; // no this impacts
179
181 && time >= this.spawnshieldtime
182 && !toucher.nade && GetResource(this, RES_HEALTH) == this.max_health // no boosted shot pickups, thank you very much
183 && CanThrowNade(toucher) // prevent some obvious things, like dead players
184 && IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
185 {
186 nade_pickup(toucher, this);
187 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 * (ATTEN_LARGE + ATTEN_MAX));
188 delete(this);
189 return;
190 }
191 /*
192 bool is_weapclip = false;
193 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
194 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
195 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
196 is_weapclip = true;
197 */
198 if (ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
199 {
200 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, RemoveHook(it));
201 delete(this);
202 return;
203 }
204
206
207 //setsize(this, '-2 -2 -2', '2 2 2');
208 //UpdateCSQCProjectile(this);
209 if (GetResource(this, RES_HEALTH) == this.max_health)
210 {
212 return;
213 }
214
215 this.enemy = toucher;
216 nade_boom(this);
217}
float spawnshieldtime
Definition damage.qh:61
entity entity toucher
Definition self.qh:76
#define ITEM_TOUCH_NEEDKILL()
Definition items.qh:122
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28
Sound SND_GRENADE_BOUNCE_RANDOM()
Definition all.inc:17
float spamsound(entity e, int chan, Sound samp, float vol, float _atten)
use this one if you might be causing spam (e.g.
Definition all.qc:124
entity enemy
Definition sv_ctf.qh:152
bool CanThrowNade(entity this)
Definition sv_nades.qc:598
void nade_pickup(entity this, entity thenade)
Definition sv_nades.qc:159
bool autocvar_g_nades_pickup
Definition sv_nades.qh:12
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References ATTEN_LARGE, ATTEN_MAX, ATTEN_NORM, autocvar_g_nades_pickup, CanThrowNade(), CH_SHOTS, CH_SHOTS_SINGLE, enemy, entity(), g_projectiles, GetResource(), IL_EACH, IS_REAL_CLIENT, ITEM_TOUCH_NEEDKILL, max_health, nade_boom(), nade_pickup(), PROJECTILE_TOUCH, realowner, RemoveHook(), SND_GRENADE_BOUNCE_RANDOM(), sound, spamsound(), spawnshieldtime, time, toucher, UpdateCSQCProjectile(), and VOL_BASE.

Referenced by toss_nade().

◆ nades_CheckThrow()

void nades_CheckThrow ( entity this)

Definition at line 605 of file sv_nades.qc.

606{
607 if (!CanThrowNade(this))
608 return;
609
610 entity held_nade = this.nade;
611 if (!held_nade)
612 {
613 this.nade_altbutton = true;
614 if (time > this.nade_refire)
615 {
616 nade_prime(this);
618 }
619 }
620 else
621 {
622 this.nade_altbutton = false;
623 if (time >= held_nade.nade_time_primed + 1)
624 {
625 makevectors(this.v_angle);
626 float _force = time - held_nade.nade_time_primed;
629 vector dir = v_forward * 0.75 + v_up * 0.2 + v_right * 0.05;
631 toss_nade(this, true, dir * _force, 0);
632 }
633 }
634}
vector W_CalculateSpread(vector dir, float spread, int spread_style, bool must_normalize)
vector v_angle
Definition player.qh:236
float autocvar_g_nades_spread
Definition nades.qc:7
int dir
Definition impulse.qc:89
bool nade_altbutton
Definition sv_nades.qc:603
void nade_prime(entity this)
Definition sv_nades.qc:556
float autocvar_g_nades_nade_minforce
Definition sv_nades.qh:15
float autocvar_g_nades_nade_maxforce
Definition sv_nades.qh:16
int autocvar_g_projectiles_spread_style
Definition tracing.qh:14

References autocvar_g_nades_nade_lifetime, autocvar_g_nades_nade_maxforce, autocvar_g_nades_nade_minforce, autocvar_g_nades_nade_refire, autocvar_g_nades_spread, autocvar_g_projectiles_spread_style, CanThrowNade(), dir, entity(), makevectors, nade, nade_altbutton, nade_prime(), nade_refire, time, toss_nade(), v_angle, v_forward, v_right, v_up, vector, and W_CalculateSpread().

Referenced by MUTATOR_HOOKFUNCTION().

◆ nades_CheckTypes()

Nade nades_CheckTypes ( Nade ntype)

Definition at line 399 of file sv_nades.qc.

400{
401#define NADE_TYPE_CHECK(nade_ent, nade_cvar) \
402 case nade_ent.m_id: \
403 if (nade_cvar) \
404 return ntype; \
405 break
406
407 switch (ntype.m_id)
408 {
409 case 0: return NADE_TYPE_Null; // use NADE_TYPE_Null to signify a random nade
410 NADE_TYPE_CHECK(NADE_TYPE_NAPALM, autocvar_g_nades_napalm);
412 NADE_TYPE_CHECK(NADE_TYPE_TRANSLOCATE, autocvar_g_nades_translocate);
413 NADE_TYPE_CHECK(NADE_TYPE_SPAWN, autocvar_g_nades_spawn);
414 NADE_TYPE_CHECK(NADE_TYPE_HEAL, autocvar_g_nades_heal);
415 NADE_TYPE_CHECK(NADE_TYPE_MONSTER, autocvar_g_nades_pokenade && autocvar_g_monsters); // if monsters disabled, this nade can't do anything, use instead normal nade
416 NADE_TYPE_CHECK(NADE_TYPE_ENTRAP, autocvar_g_nades_entrap);
417 NADE_TYPE_CHECK(NADE_TYPE_VEIL, autocvar_g_nades_veil);
418 NADE_TYPE_CHECK(NADE_TYPE_AMMO, autocvar_g_nades_ammo);
419 NADE_TYPE_CHECK(NADE_TYPE_DARKNESS, autocvar_g_nades_darkness);
420 }
421 return NADE_TYPE_NORMAL; // default to NADE_TYPE_NORMAL for unknown nade types
422#undef NADE_TYPE_CHECK
423}
bool autocvar_g_nades_ammo
Definition ammo.qh:6
bool autocvar_g_nades_darkness
Definition darkness.qh:6
bool autocvar_g_nades_entrap
Definition entrap.qh:6
bool autocvar_g_nades_ice
Definition ice.qh:6
bool autocvar_g_nades_heal
Definition heal.qh:6
bool autocvar_g_nades_pokenade
Definition monster.qh:7
bool autocvar_g_nades_spawn
Definition spawn.qh:6
bool autocvar_g_nades_napalm
Definition napalm.qh:6
#define NADE_TYPE_CHECK(nade_ent, nade_cvar)
bool autocvar_g_nades_translocate
Definition translocate.qh:6
bool autocvar_g_nades_veil
Definition veil.qh:6

References autocvar_g_monsters, autocvar_g_nades_ammo, autocvar_g_nades_darkness, autocvar_g_nades_entrap, autocvar_g_nades_heal, autocvar_g_nades_ice, autocvar_g_nades_napalm, autocvar_g_nades_pokenade, autocvar_g_nades_spawn, autocvar_g_nades_translocate, autocvar_g_nades_veil, Nade::m_id, and NADE_TYPE_CHECK.

Referenced by MUTATOR_HOOKFUNCTION(), nade_choose_random(), and nade_prime().

◆ nades_Clear()

void nades_Clear ( entity player)

Remove nades that are being thrown.

Definition at line 636 of file sv_nades.qc.

637{
638 if (player.nade)
639 delete(player.nade);
640 if (player.fake_nade)
641 delete(player.fake_nade);
642
643 player.nade = player.fake_nade = NULL;
644 STAT(NADE_TIMER, player) = 0;
645}

References entity(), NULL, and STAT.

Referenced by nades_RemovePlayer().

◆ Nades_FromString()

Nade Nades_FromString ( string ntype)

Definition at line 493 of file sv_nades.qc.

494{
495 FOREACH(Nades, it != NADE_TYPE_Null && (it.netname == ntype || ftos(it.impulse) == ntype), return it);
496 return NADE_TYPE_Null;
497}
string ftos(float f)

References FOREACH, and ftos().

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nade_prime(), and Nades_GetType().

◆ Nades_GetType()

Nade Nades_GetType ( string ntype)

Definition at line 499 of file sv_nades.qc.

500{
501 Nade def;
502 if (ntype == "random" || ntype == "0")
503 def = REGISTRY_GET(Nades, nade_choose_random());
504 else
505 def = Nades_FromString(ntype);
506
507 return (def == NADE_TYPE_Null) ? NADE_TYPE_NORMAL : def;
508}
int nade_choose_random()
Definition sv_nades.qc:482

References nade_choose_random(), Nades_FromString(), and REGISTRY_GET.

Referenced by spawn_held_nade().

◆ nades_GiveBonus()

void nades_GiveBonus ( entity player,
float score )

Give a bonus grenade to a player.

Definition at line 425 of file sv_nades.qc.

426{
428 && IS_REAL_CLIENT(player) && IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max
429 && !IS_DEAD(player) && !STAT(FROZEN, player))
430 {
431 if (STAT(NADE_BONUS_SCORE, player) < 1)
432 STAT(NADE_BONUS_SCORE, player) += score / autocvar_g_nades_bonus_score_max;
433
434 if (STAT(NADE_BONUS_SCORE, player) >= 1)
435 {
436 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
437 play2(player, SND(NADE_BONUS));
438 ++STAT(NADE_BONUS, player);
439 --STAT(NADE_BONUS_SCORE, player);
440 }
441 }
442}
void play2(entity e, string filename)
Definition all.qc:116
#define SND(id)
Definition all.qh:35
int autocvar_g_nades_bonus_max
Definition sv_nades.qh:32

References autocvar_g_nades, autocvar_g_nades_bonus, autocvar_g_nades_bonus_max, autocvar_g_nades_bonus_score_max, entity(), IS_DEAD, IS_PLAYER, IS_REAL_CLIENT, play2(), Send_Notification(), SND, and STAT.

Referenced by ctf_Handle_Capture(), ctf_Handle_Pickup(), ctf_Handle_Return(), kh_WinnerTeam(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ nades_PlayerColor()

vector nades_PlayerColor ( entity this,
bool isPants )

Definition at line 13 of file sv_nades.qc.

14{
15 if (teamplay)
16 return Team_ColorRGB(this.team);
17
18 // logic copied from Scoreboard_GetName
19 int col = (this.colormap >= 1024)
20 ? this.colormap - 1024
22 return (isPants)
23 ? colormapPaletteColor(col % 16, true)
24 : colormapPaletteColor(floor(col / 16), false);
25}
int team
Definition main.qh:188
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
float colormap
#define false
Definition csprogsdefs.qh:6
float clientcolors
float floor(float f)
entity this
Definition self.qh:76
vector Team_ColorRGB(int teamid)
Definition teams.qh:76
bool teamplay
Definition teams.qh:59

References clientcolors, colormap, colormapPaletteColor, entity(), floor(), team, Team_ColorRGB(), teamplay, and vector.

Referenced by nade_boom(), nade_darkness_think(), and nade_ice_think().

◆ nades_RemoveBonus()

void nades_RemoveBonus ( entity player)

Remove all bonus nades from a player.

Definition at line 445 of file sv_nades.qc.

446{
447 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
448}

References entity(), and STAT.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and nades_RemovePlayer().

◆ nades_RemovePlayer()

void nades_RemovePlayer ( entity this)

Remove nades and bonus nades from a player.

Definition at line 894 of file sv_nades.qc.

895{
896 nades_Clear(this);
897 nades_RemoveBonus(this);
898 delete(this.nade_spawnloc);
899 this.nade_spawnloc = NULL;
900}
void nades_Clear(entity player)
Remove nades that are being thrown.
Definition sv_nades.qc:636
entity nade_spawnloc
Definition sv_nades.qc:11

References entity(), nade_spawnloc, nades_Clear(), nades_RemoveBonus(), and NULL.

Referenced by CA_CheckWinner(), freezetag_CheckWinner(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), Onslaught_CheckWinner(), and Surv_CheckWinner().

◆ nades_spawn_orb()

entity nades_spawn_orb ( entity this,
float orb_lifetime,
float orb_rad )

Spawns an orb for some nade types.

Definition at line 60 of file sv_nades.qc.

61{
62 // NOTE: this function merely places an orb
63 // you must add a custom touch function to the returned entity if desired
64 entity orb = new(nades_spawn_orb);
65 orb.owner = this.owner;
66 orb.realowner = this.realowner;
67 setorigin(orb, this.origin);
68
69 orb.lifetime = orb_lifetime; // required for timers
70 orb.ltime = time + orb.lifetime;
71 orb.bot_dodge = false;
72 orb.team = this.realowner.team;
73 orb.solid = SOLID_TRIGGER;
74
75 setmodel(orb, MDL_NADE_ORB);
76 orb.skin = 1;
77 orb.radius = orb_rad; // required for fading
78 vector size = '0.5 0.5 0.5' * orb.radius;
79 setsize(orb, -size, size);
80
81 STAT(NADE_BONUS_TYPE, orb) = STAT(NADE_BONUS_TYPE, this);
82 orb.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, orb)).m_color;
83
84 Net_LinkEntity(orb, true, 0, orb_send);
85
86 orb.reset = SUB_Remove;
87 setthink(orb, SUB_Remove);
88 orb.nextthink = orb.ltime;
89
90 return orb;
91}
const float SOLID_TRIGGER
vector size
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:12
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:167
bool orb_send(entity this, entity to, int sf)
Definition net.qc:101
entity nades_spawn_orb(entity this, float orb_lifetime, float orb_rad)
Spawns an orb for some nade types.
Definition sv_nades.qc:60

References entity(), nades_spawn_orb(), Net_LinkEntity(), orb_send(), origin, owner, realowner, REGISTRY_GET, setmodel, setthink, size, SOLID_TRIGGER, STAT, SUB_Remove(), time, and vector.

Referenced by nade_ammo_boom(), nade_entrap_boom(), nade_heal_boom(), nade_veil_boom(), and nades_spawn_orb().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( nades ,
autocvar_g_nades  )

Definition at line 686 of file sv_nades.qc.

687{
689 {
691 }
692 return 0;
693}
#define MUTATOR_ONADD
Definition base.qh:309
#define NEW(cname,...)
Definition oo.qh:120

References autocvar_g_nades, MUTATOR_ONADD, NEW, OFFHAND_NADE, and REGISTER_MUTATOR.

◆ spawn_held_nade()

void spawn_held_nade ( entity player,
entity nowner,
float ntime,
string ntype,
string pntype )

Definition at line 510 of file sv_nades.qc.

511{
512 entity n = new(nade), fn = new(fake_nade);
513
514 Nade def = Nades_GetType(ntype);
515
516 n.pokenade_type = pntype;
517
518 STAT(NADE_BONUS_TYPE, n) = def.m_id;
519
520 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
521
522 setmodel(n, MDL_PROJECTILE_NADE);
523 //setattachment(n, player, "bip01 l hand");
524 n.exteriormodeltoclient = player;
526 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(def.m_projectile[0], player.team).eent_eff_name);
527 n.colormod = def.m_color;
528 n.realowner = nowner;
529 n.colormap = player.colormap;
530 n.glowmod = player.glowmod;
531 n.wait = time + max(0, ntime);
532 n.nade_time_primed = time;
534 n.nextthink = max(n.wait - 3, time);
535 n.projectiledeathtype = DEATH_NADE.m_id;
536 n.weaponentity_fld = weaponentity;
537 n.nade_lifetime = ntime;
538 n.alpha = def.m_alpha;
539
540 setmodel(fn, MDL_NADE_VIEW);
541 //setattachment(fn, player.(weaponentity), "");
542 fn.viewmodelforclient = player;
543 fn.realowner = fn.owner = player;
544 fn.colormod = def.m_color;
545 fn.colormap = player.colormap;
546 fn.glowmod = player.glowmod;
547 setthink(fn, SUB_Remove);
548 fn.nextthink = n.wait;
549 fn.weaponentity_fld = weaponentity;
550 fn.alpha = def.m_alpha;
551
552 player.nade = n;
553 player.fake_nade = fn;
554}
float m_alpha
Definition nades.qh:20
vector m_color
Definition nades.qh:17
int m_projectile[2]
Definition nades.qh:42
#define setcefc(e, f)
bool nade_customize(entity this, entity client)
Definition sv_nades.qc:457
Nade Nades_GetType(string ntype)
Definition sv_nades.qc:499
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

References entity(), fake_nade, Nade::m_alpha, Nade::m_color, Nade::m_id, Nade::m_projectile, max(), nade, nade_beep(), nade_customize(), Nade_TrailEffect(), Nades_GetType(), setcefc, setmodel, setthink, STAT, SUB_Remove(), time, and weaponentities.

Referenced by nade_pickup(), and nade_prime().

◆ toss_nade()

void toss_nade ( entity e,
bool set_owner,
vector _velocity,
float _time )

Definition at line 301 of file sv_nades.qc.

302{
303 if (e.nade == NULL)
304 return;
305
306 entity _nade = e.nade;
307 e.nade = NULL;
308
309 if (e.fake_nade)
310 delete(e.fake_nade);
311 e.fake_nade = NULL;
312
313 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
314
315 makevectors(e.v_angle);
316
317 // NOTE: always throw from first weapon entity?
318 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
319
323
324 setorigin(_nade, w_shotorg + offset);
325 //setmodel(_nade, MDL_PROJECTILE_NADE);
326 //setattachment(_nade, NULL, "");
328 float size;
329 if (STAT(NADES_SMALL, e))
330 size = 16;
331 else
332 size = 32;
333 setsize(_nade, '0.5 0.5 0.5' * -size, '0.5 0.5 0.5' * size);
335
336 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
338 setorigin(_nade, e.origin);
339
340 if (e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
341 _nade.velocity = '0 0 100';
343 _nade.velocity = e.velocity + _velocity;
345 _nade.velocity = _velocity;
346 else
347 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
348
349 if (set_owner)
350 _nade.realowner = e;
351
352 settouch(_nade, nade_touch);
353 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
354 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
355 _nade.max_health = GetResource(_nade, RES_HEALTH);
356 _nade.takedamage = DAMAGE_AIM;
357 _nade.event_damage = nade_damage;
358 setcefc(_nade, func_null);
359 _nade.exteriormodeltoclient = NULL;
360 _nade.traileffectnum = 0;
361 _nade.teleportable = true;
362 _nade.pushable = true;
363 _nade.gravity = 1;
364 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
365 _nade.damagedbycontents = true;
367 _nade.angles = vectoangles(_nade.velocity);
368 _nade.flags = FL_PROJECTILE;
369 IL_PUSH(g_projectiles, _nade);
370 IL_PUSH(g_bot_dodge, _nade);
371 _nade.projectiledeathtype = DEATH_NADE.m_id;
372 _nade.toss_time = time;
373 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
374
375 switch (STAT(NADE_BONUS_TYPE, _nade))
376 {
377 case NADE_TYPE_TRANSLOCATE.m_id:
378 case NADE_TYPE_SPAWN.m_id:
379 case NADE_TYPE_MONSTER.m_id:
380 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
381 break;
382 default:
383 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
384 break;
385 }
386
387 nade_spawn(_nade);
388
389 if (_time)
390 {
391 setthink(_nade, nade_boom);
392 _nade.nextthink = _time;
393 }
394
395 e.nade_refire = time + autocvar_g_nades_nade_refire;
396 STAT(NADE_TIMER, e) = 0;
397}
IntrusiveList g_bot_dodge
Definition api.qh:150
#define PHYS_INPUT_BUTTON_CROUCH(s)
Definition player.qh:156
const int FL_PROJECTILE
Definition constants.qh:77
const float MOVE_NOMONSTERS
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
const float SOLID_CORPSE
float DPCONTENTS_BODY
float DPCONTENTS_PLAYERCLIP
float trace_startsolid
IntrusiveList g_damagedbycontents
Definition damage.qh:143
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
vector vectoangles(vector v)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_BOUNCE
Definition movetypes.qh:143
void Kill_Notification(NOTIF broadcast, entity client, MSG net_type, CPID net_cpid)
Definition all.qc:1464
#define settouch(e, f)
Definition self.qh:77
const int MIF_SPLASH
Definition common.qh:46
const int MIF_ARC
Definition common.qh:47
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
const int CH_WEAPON_A
Definition sound.qh:7
const int DAMAGE_AIM
Definition subs.qh:81
void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition sv_nades.qc:226
void nade_touch(entity this, entity toucher)
Definition sv_nades.qc:172
void nade_spawn(entity _nade)
Definition sv_nades.qc:40
int autocvar_g_nades_nade_newton_style
Definition sv_nades.qh:23
float autocvar_g_nades_nade_health
Definition sv_nades.qh:17
vector autocvar_g_nades_throw_offset
Definition sv_nades.qh:7
vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute)
Definition tracing.qc:174
vector w_shotorg
Definition tracing.qh:19
#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:34

References autocvar_g_nades_nade_health, autocvar_g_nades_nade_newton_style, autocvar_g_nades_nade_refire, autocvar_g_nades_throw_offset, CH_WEAPON_A, DAMAGE_AIM, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, entity(), FL_PROJECTILE, func_null(), g_bot_dodge, g_damagedbycontents, g_projectiles, GetResource(), IL_PUSH(), Kill_Notification(), makevectors, MIF_ARC, MIF_SPLASH, MOVE_NOMONSTERS, MOVETYPE_BOUNCE, nade_boom(), nade_damage(), nade_spawn(), nade_touch(), NULL, PHYS_INPUT_BUTTON_CROUCH, PROJECTILE_MAKETRIGGER, set_movetype(), setcefc, SetResource(), setthink, settouch, size, SOLID_CORPSE, STAT, time, trace_startsolid, v_forward, v_right, v_up, vectoangles(), vector, W_CalculateProjectileVelocity(), W_SetupShot, and w_shotorg.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and nades_CheckThrow().

Variable Documentation

◆ nade_altbutton

bool nade_altbutton

Definition at line 603 of file sv_nades.qc.

Referenced by nades_CheckThrow().

◆ nade_spawnloc

entity nade_spawnloc

Definition at line 11 of file sv_nades.qc.

Referenced by nades_RemovePlayer().

◆ nade_time_primed

float nade_time_primed

Definition at line 9 of file sv_nades.qc.

◆ OFFHAND_NADE