Example #1
0
        public static bool Damage(SvPlayer target, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider)
        {
            if (attacker == null || attacker == target || attacker.IsClientBot() || (Vars.IgnoreDamageToBots && target.player.IsClientBot()))
            {
                return(false);
            }

            Faction attackerFaction, playerFaction;

            {
                var attackerJob = attacker.job.jobIndex;
                attackerFaction = Vars.Factions.Find(x => x.Jobs.Contains(attackerJob));
                playerFaction   = Vars.Factions.Find(x => x.Jobs.Contains(target.player.job.jobIndex));
            }

            if (target.player.wantedLevel >= Vars.MinTargetWantedLevelToIgnoreDamageRules ||
                attackerFaction.CanDamage.Contains(playerFaction.Name) ||
                attackerFaction.CanDamage.Contains("*"))
            {
                if (target.WillDieByDamage(type, amount, collider))
                {
                    if (target.player.wantedLevel >= Vars.MinTargetWantedLevelToIgnoreKillRules ||
                        attackerFaction.CanKill.Contains(playerFaction.Name) ||
                        attackerFaction.CanKill.Contains("*"))
                    {
                        return(false);
                    }

                    attacker.svPlayer.ShowMessageInChat(Vars.CantKillMessage);
                    return(true);
                }
                return(false);
            }
            attacker.svPlayer.ShowMessageInChat(Vars.CantDamageMessage);
            return(true);
        }