コード例 #1
0
ファイル: DeathHandler.cs プロジェクト: policeman18/Mirror
        private void HandleDeath(object source, Client client, Client killer)
        {
            AccountUtil.SetPlayerDeath(client, true);
            LevelRanks         levelRanks  = AccountUtil.GetLevelRanks(client);
            LevelRankCooldowns cooldowns   = AccountUtil.GetCooldowns(client);
            DateTime           timeOfDeath = AccountUtil.SetTimeOfDeath(client);

            int downerBonus = 0;

            if (levelRanks.Downer > 0 && cooldowns.IsDownerReady)
            {
                cooldowns.IsDownerReady = false;
                downerBonus             = 5000 * levelRanks.Downer;
                client.SendChatMessage("~r~Downer ~w~You are using your extended downtime for dieing.");
            }

            NotifyPlayersOfDeath(client);

            NAPI.Task.Run(() =>
            {
                if (!AccountUtil.IsPlayerDead(client))
                {
                    return;
                }

                if (timeOfDeath != AccountUtil.GetTimeOfDeath(client))
                {
                    return;
                }

                AccountUtil.SetPlayerDeath(client, false);
            }, 30000 + downerBonus); // 30 Seconds + Bonus
        }
コード例 #2
0
ファイル: Intimidate.cs プロジェクト: policeman18/Mirror
        public static void Use(Client client, Client target)
        {
            if (!target.Exists)
            {
                return;
            }

            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsIntimidateReady || ranks.Intimidate <= 0)
            {
                return;
            }

            if (client.Position.DistanceTo2D(target.Position) > 4)
            {
                return;
            }

            cooldowns.IsIntimidateReady = false;
            Utilities.ForcePlayerCower(target, ranks.Intimidate * 1000);
            client.SendChatMessage($"~r~Intimidate ~w~You look quite intimidating and ~o~{target.Name}~w~ has noticed.");
            target.SendChatMessage($"~r~Intimidate ~o~{client.Name} ~w~looks very intimidating you cower in fear.");
        }
コード例 #3
0
ファイル: Drag.cs プロジェクト: policeman18/Mirror
        public static void Use(Client client, Client target)
        {
            if (!client.Exists)
            {
                return;
            }

            if (!target.Exists)
            {
                return;
            }

            if (client.Position.DistanceTo2D(target.Position) > 5)
            {
                return;
            }

            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (ranks.Drag <= 0)
            {
                return;
            }

            if (!cooldowns.IsDragReady)
            {
                return;
            }

            cooldowns.IsDragReady = false;
            Utilities.ForcePlayerToFollowPlayer(target, client, ranks.Drag * 1500);
            client.SendNotification($"You are dragging ~o~{target.Name}.");
            target.SendNotification($"You are being dragged by ~o~{client.Name}.");
        }
コード例 #4
0
        public static int Use(Client client)
        {
            int damageRollBonus = 0;

            if (!client.Exists)
            {
                return(damageRollBonus);
            }

            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (ranks.DamageRoll <= 0)
            {
                return(damageRollBonus);
            }

            if (!cooldowns.IsDamageRollReady)
            {
                return(damageRollBonus);
            }

            damageRollBonus = ranks.DamageRoll / 2;

            cooldowns.IsDamageRollReady = false;
            client.SendNotification("Your shot hit for a little more damage.");
            return(damageRollBonus);
        }
コード例 #5
0
        public static bool Weapon(Client client, string name)
        {
            LevelRanks levelRanks = AccountUtil.GetLevelRanks(client);
            WeaponHash hash       = NAPI.Util.WeaponNameToModel(name);

            if (Array.IndexOf(WeaponNamesData.AssaultWeapons, name.ToLower()) >= 0)
            {
                if (levelRanks.MediumWeaponry <= 0)
                {
                    client.SendChatMessage("~o~You are unable to wield this weapon type: ~y~Medium");
                    Utilities.PlaySoundFrontend(client, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    return(false);
                }
            }

            if (Array.IndexOf(WeaponNamesData.ShotgunWeapons, name.ToLower()) >= 0)
            {
                if (levelRanks.MediumWeaponry <= 0)
                {
                    client.SendChatMessage("~o~You are unable to wield this weapon type: ~y~Medium");
                    Utilities.PlaySoundFrontend(client, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    return(false);
                }
            }

            if (Array.IndexOf(WeaponNamesData.SmgWeapons, name.ToLower()) >= 0)
            {
                if (levelRanks.LightWeaponry <= 0)
                {
                    client.SendChatMessage("~o~You are unable to wield this weapon type: ~y~Light");
                    Utilities.PlaySoundFrontend(client, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    return(false);
                }
            }

            if (Array.IndexOf(WeaponNamesData.HeavyWeapons, name.ToLower()) >= 0)
            {
                if (levelRanks.HeavyWeaponry <= 0)
                {
                    client.SendChatMessage("~o~You are unable to wield this weapon type: ~y~Heavy");
                    Utilities.PlaySoundFrontend(client, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    return(false);
                }
            }

            // Try adding the weapon to the player.
            if (!AccountUtil.AddPlayerWeapon(client, hash))
            {
                return(false);
            }

            Utilities.PlaySoundFrontend(client, "PICK_UP_WEAPON", "HUD_FRONTEND_CUSTOM_SOUNDSET");
            client.SendNotification("A weapon may be unequipped into your inventory by pressing ~o~R~w~.");
            return(true);
        }
コード例 #6
0
        public static int Use(Client client, int number)
        {
            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsQuickReady || ranks.Quick <= 0)
            {
                return(number);
            }

            cooldowns.IsQuickReady = false;
            client.SendNotification("You used your increased dodge chance.");
            return(number += ranks.Quick);
        }
コード例 #7
0
        public static bool Use(Client client)
        {
            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsCalculatedReady || ranks.Calculated <= 0)
            {
                return(false);
            }

            client.SendNotification("Your shot hit with 100% accuracy.");
            cooldowns.IsCalculatedReady = false;
            return(true);
        }
コード例 #8
0
        public static int Use(Client client, int number)
        {
            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsConcentrateReady || ranks.Concentrate <= 0)
            {
                return(number);
            }

            cooldowns.IsConcentrateReady = false;
            client.SendNotification("Your shot hit for double damage.");
            return(number * 2);
        }
コード例 #9
0
        public static bool Use(Client client)
        {
            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsDeadeyeReady || ranks.Deadeye <= 0)
            {
                return(false);
            }

            cooldowns.IsDeadeyeReady = false;
            client.SendNotification("Your shot had increased accuracy.");
            return(true);
        }
コード例 #10
0
        public static void Use(Client client, Vehicle vehicle)
        {
            if (!vehicle.Exists)
            {
                return;
            }

            LevelRankCooldowns cooldowns = AccountUtil.GetCooldowns(client);
            LevelRanks         ranks     = AccountUtil.GetLevelRanks(client);

            if (!cooldowns.IsSmashReady || ranks.Smash <= 0)
            {
                return;
            }

            if (client.Position.DistanceTo2D(vehicle.Position) > 2.5)
            {
                return;
            }

            if (!vehicle.Locked)
            {
                return;
            }

            cooldowns.IsSmashReady = false;

            bool didPlayerSucceed = Skillcheck.SkillCheckPlayer(client, Skillcheck.Skills.strength, new Random().Next(15, 28), clientModifier: ranks.Smash, impact: -1);

            if (!didPlayerSucceed)
            {
                client.SendNotification("You try to smash the vehicle window but end up hurting your fist.");
                return;
            }

            vehicle.Locked = false;
            client.SendNotification("You successfully smash the vehicle window.");
            Utilities.BreakVehicleWindow(client, vehicle);
        }
コード例 #11
0
        private void RecieveClientAttackData(object source, Client client, Client target, string weaponName)
        {
            // Basic Failures. Just make sure there's a weapon and such.
            if (!client.Exists || !target.Exists || weaponName == "")
            {
                return;
            }

            WeaponHash hash = NAPI.Util.WeaponNameToModel(weaponName);

            if (!AccountUtil.DoesPlayerHaveWeapon(client, hash))
            {
                PlayerEvents.CancelAttack(client);
                return;
            }



            if (client == target)
            {
                PlayerEvents.CancelAttack(client);
                return;
            }

            if (weaponName.ToLower() != "unarmed")
            {
                if (!client.IsAiming)
                {
                    return;
                }
            }

            int   WeaponRange            = Weapons.GetWeaponRange(weaponName);
            float DistanceBetweenTargets = client.Position.DistanceTo(target.Position);

            // If it's too far there's no point in rolling.
            if (DistanceBetweenTargets > WeaponRange + 20)
            {
                return;
            }

            // Ternary Op - If the distance is greater than the weapon range return the distance between the targets. If they're in range set the penalty to zero.
            int RangePenalty = (DistanceBetweenTargets > WeaponRange) ? Convert.ToInt32((DistanceBetweenTargets - WeaponRange)) : 0;

            Account    account          = AccountUtil.RetrieveAccount(client);
            Account    targetAccount    = AccountUtil.RetrieveAccount(target);
            LevelRanks clientLevelRanks = AccountUtil.GetLevelRanks(client);

            LevelRankCooldowns levelRankCooldowns = AccountUtil.GetCooldowns(client);
            bool skipCheck    = false;
            int  deadeyeBonus = 0;

            // The target player's defense bonus.
            int targetDefenseBonus = 0;

            targetDefenseBonus = Quick.Use(target, targetDefenseBonus);

            if (account.IsDead || targetAccount.IsDead)
            {
                client.SendNotification("That player is already downed. Focus on someone else.");
                PlayerEvents.CancelAttack(client);
                return;
            }

            // Calculated Skill Check
            if (Calculated.Use(client))
            {
                skipCheck = true;
            }

            // Use Deadeye if Calculated wasn't triggered.
            if (Deadeye.Use(client) && !skipCheck)
            {
                deadeyeBonus = clientLevelRanks.Deadeye;
            }

            // Check if the player beats the other's score.
            if (!skipCheck)
            {
                if (!Skillcheck.SkillCheckPlayers(client, target, Skillcheck.Skills.endurance, clientModifier: (RangePenalty + deadeyeBonus), targetModifier: targetDefenseBonus) && weaponName != "unarmed")
                {
                    Utilities.NotifyPlayersOfTargetDamage(client, target, 0);
                    return;
                }
            }

            // Get the weapon dice and roll count for the damage calculation.
            int weaponDie       = Weapons.GetWeaponDamageDie(weaponName.ToLower()) + DamageRoll.Use(client);
            int weaponRollCount = Weapons.GetWeaponRollCount(weaponName.ToLower());

            // Roll for damage.
            int amountOfDamage = 0;

            for (int i = 0; i < weaponRollCount; i++)
            {
                amountOfDamage += Skills.Utility.RollDamage(weaponDie);
            }

            // Double damage if concentrate is available.
            amountOfDamage = Concentrate.Use(client, amountOfDamage);

            // Add fisticuffs damage if they're unarmed.
            amountOfDamage += weaponName.ToLower() == "unarmed" ? clientLevelRanks.Fisticuffs : 0;

            // Double Damage Skill
            if (clientLevelRanks.Concentrate > 0)
            {
                if (levelRankCooldowns.IsConcentrateReady)
                {
                    amountOfDamage *= 2;
                    levelRankCooldowns.IsConcentrateReady = false;
                    client.SendChatMessage("~g~Concentrate ~w~Your shot hit for ~r~DOUBLE ~w~damage.");
                }
            }

            if (target.Health - amountOfDamage <= 0)
            {
                target.Health = 1;
            }
            else
            {
                target.Health -= amountOfDamage;
            }

            // Update Health
            Account.PlayerUpdateEvent.Trigger(target, targetAccount);


            Utilities.NotifyPlayersOfTargetDamage(client, target, amountOfDamage);

            if (target.Health > 2)
            {
                return;
            }

            PlayerEvents.CancelAttack(client);
            DeathHandler.DeathEvent.Trigger(target, client); // Raise Death Event
        }