3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5 #include <common/t_items.qh>
6 #include <common/constants.qh>
7 #include <common/net_linked.qh>
8 #include <common/deathtypes/all.qh>
9 #include <common/notifications/all.qh>
10 #include <common/state.qh>
11 #include <common/util.qh>
12 #include <common/weapons/_all.qh>
13 #include <common/items/_mod.qh>
15 bool W_DualWielding(entity player)
18 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
20 .entity weaponentity = weaponentities[slot];
21 if(player.(weaponentity) && player.(weaponentity).m_switchweapon != WEP_Null)
25 return held_weapons > 1;
28 void W_GiveWeapon(entity e, int wep)
32 e.weapons |= WepSet_FromWeapon(Weapons_from(wep));
35 Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep);
39 void W_PlayStrengthSound(entity player)
41 entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire, but can they have items? TODO
43 if((player.items & ITEM_Strength.m_itemid)
44 && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
45 || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
47 sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
48 store.prevstrengthsound = time;
50 store.prevstrengthsoundattempt = time;
53 float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception)
55 float is_from_contents = (deathtype == DEATH_SLIME.m_id || deathtype == DEATH_LAVA.m_id);
56 float is_from_owner = (inflictor == projowner);
57 float is_from_exception = (exception != -1);
59 //dprint(strcat("W_CheckProjectileDamage: from_contents ", ftos(is_from_contents), " : from_owner ", ftos(is_from_owner), " : exception ", strcat(ftos(is_from_exception), " (", ftos(exception), "). \n")));
61 if(autocvar_g_projectiles_damage <= -2)
63 return false; // no damage to projectiles at all, not even with the exceptions
65 else if(autocvar_g_projectiles_damage == -1)
68 return (exception); // if exception is detected, allow it to override
70 return false; // otherwise, no other damage is allowed
72 else if(autocvar_g_projectiles_damage == 0)
75 return (exception); // if exception is detected, allow it to override
76 else if(!is_from_contents)
77 return false; // otherwise, only allow damage from contents
79 else if(autocvar_g_projectiles_damage == 1)
82 return (exception); // if exception is detected, allow it to override
83 else if(!(is_from_contents || is_from_owner))
84 return false; // otherwise, only allow self damage and damage from contents
86 else if(autocvar_g_projectiles_damage == 2) // allow any damage, but override for exceptions
89 return (exception); // if exception is detected, allow it to override
92 return true; // if none of these return, then allow damage anyway.
95 void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
97 this.takedamage = DAMAGE_NO;
98 this.event_damage = func_null;
100 MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker);
102 if(IS_CLIENT(attacker) && !autocvar_g_projectiles_keep_owner)
104 this.owner = attacker;
105 this.realowner = attacker;
108 // do not explode NOW but in the NEXT FRAME!
109 // because recursive calls to RadiusDamage are not allowed
110 this.nextthink = time;
111 setthink(this, explode);