Example #1
0
        public static void OnDamage(NpcStrikeEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }

            TSPlayer player = TShock.Players[args.Player.whoAmI];

            int index = Plugin.Config.Warrior.FindIndex(p => p.PlayerName == player.Name);

            if (index == -1)
            {
                return;
            }

            Vocation character = Vocation.getVocation(index, Plugin.Config.settings[index].currentVocation);

            // Can only get XP from non-prohibited NPCs
            if (!NoXpTargets.Contains(args.Npc.netID))
            {
                character.XP += Vocation.getDamageXp(args.Damage);
                if (character.XP >= Vocation.getLevelXp(character.Level + 1))
                {
                    character.Level++;
                    character.XP = 0;
                    player.SendInfoMessage(VocationPlugin.Resources.INFO_LEVELUP, character.Level);
                }
            }

            character.InflictDamage(player, args);
        }
Example #2
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            player = TShock.Players[args.Player.whoAmI];
            if (!args.Handled && !(player.TPlayer.FindBuffIndex(130) == -1) && !player.HasPermission("slimydisable.bypass")) //check if player has slimy saddle buff
            {
                timer.Elapsed += ClearStrikes;
#if DEBUG
                Console.WriteLine($"Player {player.Name} has slime buff and hit {args.Npc.netID}");
#endif
                if (args.Npc.netID == 488 || args.Npc.netID == 68) // target dummy and dungeon guardian respectively
                {
                    if ((args.Player.position.Y + 80 > args.Npc.position.Y) && (args.Player.position.Y + 22 < args.Npc.position.Y) && ((args.Player.position.X - args.Npc.position.X < 64) && (args.Npc.position.X - args.Player.position.X < 64)))
                    {
                        strikes++;
#if DEBUG
                        player.SendMessage($"{strikes} strikes were counted", Color.BurlyWood);
                        player.SendMessage($"Player y: {args.Player.position.Y},\nNpc {args.Npc.netID} y: {args.Npc.position.Y}\n Diff y: {args.Player.position.Y - args.Npc.position.Y}", Color.Bisque);
                        player.SendMessage($"Player x: {args.Player.position.X},\nNpc {args.Npc.netID} x: {args.Npc.position.X}\n Diff x: {args.Player.position.X - args.Npc.position.X}", Color.Bisque);
#endif
                        args.Handled = true;
                    }
                    if (strikes >= strikeCap)
                    {
#if DEBUG
                        player.SendMessage("You've been oofed p hard tbh ngl imho.", Color.BurlyWood);
#endif
                        Punishment();
                    }
                }
                timer.Start();
            }
        }
Example #3
0
 public PostNPCStrikeEventArgs(NpcStrikeEventArgs rawArgs, StarverPlayer player, int realDamage, int expGet)
 {
     RawArgs    = rawArgs;
     RealDamage = realDamage;
     ExpGet     = expGet;
     Player     = player;
 }
Example #4
0
 public PreNPCStrikeEventArgs(NpcStrikeEventArgs rawArgs, StarverPlayer player, double dIndexLevel, double dIndexMP)
 {
     RawArgs     = rawArgs;
     Player      = player;
     DIndexLevel = dIndexLevel;
     DIndexMP    = dIndexMP;
 }
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            //Debug.Print($"Banking - OnNpcStrike! Damage: {args.Damage}, Critical: {args.Critical}");

            var item = args.Player.HeldItem;

            //Debug.Print($"Strike NPC with {item.Name}!");
            NpcStrikeTracker.OnNpcStrike(args.Player, args.Npc, args.Damage, args.Critical, item.Name);
        }
Example #6
0
 private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
 {
     if (Config.InfiniteInvasion)
     {
         IncrementKills();
         if (Main.invasionSize < 10)
         {
             Main.invasionSize = 20000000;
         }
     }
 }
Example #7
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            foreach (int i in Config.GetConfig().IgnoreNPCID)
            {
                if (i == args.Npc.netID)
                {
                    return;
                }
            }
            Bank bank = Data.GetBank(args.Player.name);

            bank.Money++;
            bank.Save();
        }
Example #8
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            var playerIndex = args.Player.whoAmI;
            var npc         = args.Npc;
            var npcId       = npc.whoAmI;

            //if (!_npcName?.Equals(npc.GivenOrTypeName, StringComparison.OrdinalIgnoreCase) ?? false)
            if (args.Handled || (!AnyNcpType && !npcTypes.Contains(MiscFunctions.StripTags(npc.GivenOrTypeName))))
            {
                return;
            }

            if (partyMembers.All(m => m.Player.Index != playerIndex))
            {
                return;
            }

            Debug.Print($"NpcStruck name: {npc.GivenOrTypeName}");
            Debug.Print($"NpcStruck id: {npc.whoAmI}");

            LastStrucks[npcId] = playerIndex;

            Debug.Print($"Strike Player index: {playerIndex}");

            //DISABLED becuase the bottom clause is removing all registered strikes, and thus kills are failing.
            //no idea why this stuff is here, other than the commit that said "Fix KillNpcs"...
            //var defense = npc.defense;
            //         if (npc.ichor)
            //         {
            //             defense -= 20;
            //         }
            //         if (npc.betsysCurse)
            //         {
            //             defense -= 40;
            //         }
            //         defense = Math.Max(0, defense);
            //         var damage = Main.CalculateDamage(args.Damage, defense);
            //         if (args.Critical)
            //         {
            //             damage *= 2.0;
            //         }
            //         damage *= Math.Max(1.0, npc.takenDamageMultiplier);

            //         var actualNpc = npc.realLife >= 0 ? Main.npc[npc.realLife] : npc;
            //         if (actualNpc.life - damage <= 0)
            //         {
            //             LastStrucks.Remove(npcId);
            //             --_amount;
            //         }
        }
Example #9
0
        public void InflictDamage(TSPlayer player, NpcStrikeEventArgs args)
        {
            int bonusdmg = Level / 5;

            if (player.SelectedItem.melee)
            {
                melee.XP++;
                bonusdmg += melee.Level;

                if (melee.XP >= melee.getAttackLevelXp(MeleeAttackMultiplier, XpFormat.Integer))
                {
                    melee.XP = 0;
                    melee.Level++;
                    player.SendInfoMessage(VocationPlugin.Resources.INFO_LEVELUP_ATTACK, "melee", melee.Level);
                }
            }
            else if (player.SelectedItem.magic)
            {
                magic.XP++;
                bonusdmg += magic.Level;

                if (magic.XP >= magic.getAttackLevelXp(MagicAttackMultiplier, XpFormat.Integer))
                {
                    magic.XP = 0;
                    magic.Level++;
                    player.SendInfoMessage(VocationPlugin.Resources.INFO_LEVELUP_ATTACK, "magic", magic.Level);
                }
            }
            else if (player.SelectedItem.ranged)
            {
                ranged.XP++;
                bonusdmg += ranged.Level;

                if (ranged.XP >= ranged.getAttackLevelXp(RangedAttackMultiplier, XpFormat.Integer))
                {
                    ranged.XP = 0;
                    ranged.Level++;
                    player.SendInfoMessage(VocationPlugin.Resources.INFO_LEVELUP_ATTACK, "ranged", ranged.Level);
                }
            }

            if (bonusdmg > 0)
            {
                args.Damage += bonusdmg;
                var color   = Convert.ToInt32(Color.Gold.PackedValue);
                var msgType = Convert.ToInt32(PacketTypes.CreateCombatText);
                NetMessage.SendData(msgType, -1, -1, "+" + bonusdmg, color, args.Npc.position.X, args.Npc.position.Y);
            }
        }
Example #10
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            var ply  = TSPlayer.FindByNameOrID(args.Player.name)[0];
            var item = ply.TPlayer.inventory[ply.TPlayer.selectedItem];
            var job  = Data.Job.GetJob(ply.Name);

            NetMessage.SendData((int)PacketTypes.Status, -1, -1, Terraria.Localization.NetworkText.FromLiteral("Status 测试            "), 100, 2);
            if (item.magic && job.jobType == Data.Job.JobType.法师 ||
                item.melee && job.jobType == Data.Job.JobType.战士 ||
                item.ranged && job.jobType == Data.Job.JobType.射手)
            {
                args.Damage += args.Damage * (int)job.Level * Data.Config.GetConfig().Player.DamageAdd / 100;
            }
            args.Damage = args.Damage + args.Damage / (Data.Config.GetConfig().NPC.Level + 1) / 10;
        }
Example #11
0
 public static void NpcStrike(NpcStrikeEventArgs args)
 {
     if (UserManager.TryGetEPlayeFromName(args.Player.name, out EPlayer eplr))
     {
         if (EternalLand.IsGameMode)
         {
             eplr.Statistic.Damage_NPC += args.Damage;
             if (args.Critical)
             {
                 eplr.Statistic.CritCount++;
             }
         }
         else
         {
             //Bank.OnStrike(args.Npc, tsp, args.Damage);
         }
     }
 }
Example #12
0
        private void OnNPCStrike(NpcStrikeEventArgs args)
        {
            Config config = Config.GetConfig();

            foreach (int i in config.IgnoreNPCs)
            {
                if (i == args.Npc.netID)
                {
                    return;
                }
            }
            if (config.AllNPC)
            {
                args.Damage = (int)((float)args.Damage * config.StrongerPercent);
            }
            else if (config.OnlyBoss && args.Npc.boss)
            {
                args.Damage = (int)((float)args.Damage * config.StrongerPercent);
            }
        }
Example #13
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }

            var npc       = args.Npc;
            var customNpc = GetCustomNpc(npc);

            if (customNpc == null)
            {
                return;
            }

            var definition = customNpc.Definition;
            var player     = TShock.Players[args.Player.whoAmI];

            if (!definition.ShouldTallyKills)
            {
                // Don't tally kills.
                npc.playerInteraction[player.Index] = false;
            }
            if (definition.ShouldUpdateOnHit)
            {
                customNpc.SendNetUpdate = true;
            }

            try
            {
                CustomIDFunctions.CurrentID = definition.Name;
                var result = definition.OnStrike?.Invoke(customNpc, player, args.Damage, args.KnockBack, args.Critical);
                args.Handled = result == true;
            }
            catch (Exception ex)
            {
                Utils.LogScriptRuntimeError(ex);
                definition.OnStrike = null;
            }
        }
Example #14
0
        private void OnNpc(NpcStrikeEventArgs args)
        {
            List <int> a = AddHP;

            foreach (var i in a)
            {
                if (i == args.Npc.netID)
                {
                    AddHP.Remove(i);
                    var npc  = args.Npc;
                    int life = Config.GetConfig().Num;
                    npc.lifeMax *= life;
                    npc.life    *= life;
                    for (int _i = 0; _i < Main.npc.Count(); _i++)
                    {
                        if (Main.npc[i] == args.Npc)
                        {
                            npc.UpdateNPCDirect(i);
                        }
                    }
                    npc.StrikeNPC(1, 0, 0);
                }
            }
        }
Example #15
0
 public override void OnStrikeNpc(NpcStrikeEventArgs args)
 {
     args.Handled = true;
 }
Example #16
0
        public static void run(NpcStrikeEventArgs e)
        {
            if (e.Handled == true)
            {
                return;
            }
            if (e.Player == null)
            {
                return;
            }
            if (!(Variables.playersData.ContainsKey(e.Player.name)))
            {
                return;
            }
            if (Variables.blockedNPCs.ContainsKey(e.Npc.netID))
            {
                if (Variables.blockedNPCs[e.Npc.netID] == true)
                {
                    return;
                }
            }
            Color c = new Color(255, 120, 0);

            if (Variables.playersData[e.Player.name].ActualClass == "warrior")
            {
                int neededExpForLevelUp = Variables.playersData[e.Player.name].Warrior.level * (896 + (896 * 43 / 100));
                int addedExp            = ((e.Damage * 147 / 100) / 2);
                Variables.playersData[e.Player.name].Warrior.exprience += ((e.Damage * 147 / 100) / 2);
                if (Variables.playersData[e.Player.name].Warrior.exprience >= neededExpForLevelUp)
                {
                    Variables.playersData[e.Player.name].Warrior.level++;
                    Variables.playersData[e.Player.name].Warrior.exprience = 0;
                    Variables.playersData[e.Player.name].Warrior.statsPoints++;
                    string levelUp = Variables.levelUp.Replace("%level%", Variables.playersData[e.Player.name].Warrior.level + "");
                    NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral(levelUp), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                }
                else
                {
                    int change = new Random().Next(0, 100);
                    if (change <= Variables.Chance)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("[" + Variables.playersData[e.Player.name].Warrior.level + "LVL] " + Variables.playersData[e.Player.name].Warrior.exprience + "|" + neededExpForLevelUp + "] " + ((Variables.playersData[e.Player.name].Warrior.exprience * 100) / neededExpForLevelUp) + "%    +[" + addedExp + "xp]"), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                    }
                }
            }
            if (Variables.playersData[e.Player.name].ActualClass == "paladin")
            {
                int neededExpForLevelUp = Variables.playersData[e.Player.name].Paladin.level * (896 + (896 * 43 / 100));
                int addedExp            = ((e.Damage * 147 / 100) / 2);
                Variables.playersData[e.Player.name].Paladin.exprience += ((e.Damage * 147 / 100) / 2);
                if (Variables.playersData[e.Player.name].Paladin.exprience >= neededExpForLevelUp)
                {
                    Variables.playersData[e.Player.name].Paladin.level++;
                    Variables.playersData[e.Player.name].Paladin.exprience = 0;
                    Variables.playersData[e.Player.name].Paladin.statsPoints++;
                    string levelUp = Variables.levelUp.Replace("%level%", Variables.playersData[e.Player.name].Warrior.level + "");
                    NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral(levelUp), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                }
                else
                {
                    int change = new Random().Next(0, 100);
                    if (change <= Variables.Chance)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("[" + Variables.playersData[e.Player.name].Paladin.level + "LVL] " + Variables.playersData[e.Player.name].Paladin.exprience + "|" + neededExpForLevelUp + "] " + ((Variables.playersData[e.Player.name].Paladin.exprience * 100) / neededExpForLevelUp) + "%    +[" + addedExp + "xp]"), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                    }
                }
            }
            if (Variables.playersData[e.Player.name].ActualClass == "wizard")
            {
                int neededExpForLevelUp = Variables.playersData[e.Player.name].Wizard.level * (896 + (896 * 43 / 100));
                int addedExp            = ((e.Damage * 147 / 100) / 2);
                Variables.playersData[e.Player.name].Wizard.exprience += ((e.Damage * 147 / 100) / 2);
                if (Variables.playersData[e.Player.name].Wizard.exprience >= neededExpForLevelUp)
                {
                    Variables.playersData[e.Player.name].Wizard.level++;
                    Variables.playersData[e.Player.name].Wizard.exprience = 0;
                    Variables.playersData[e.Player.name].Wizard.statsPoints++;
                    string levelUp = Variables.levelUp.Replace("%level%", Variables.playersData[e.Player.name].Warrior.level + "");
                    NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral(levelUp), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                }
                else
                {
                    int change = new Random().Next(0, 100);
                    if (change <= Variables.Chance)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("[" + Variables.playersData[e.Player.name].Wizard.level + "LVL] " + Variables.playersData[e.Player.name].Wizard.exprience + "|" + neededExpForLevelUp + "] " + ((Variables.playersData[e.Player.name].Wizard.exprience * 100) / neededExpForLevelUp) + "%    +[" + addedExp + "xp]"), (int)c.PackedValue, TShock.Players[e.Player.whoAmI].X, TShock.Players[e.Player.whoAmI].Y, 0, 0, 0, 0);
                    }
                }
            }
            if (TShock.Players[e.Player.whoAmI].SelectedItem.melee)
            {
                if (Variables.playersData[e.Player.name].ActualClass == "warrior")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Warrior.statMeleeDamage * 3);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
                if (Variables.playersData[e.Player.name].ActualClass == "paladin")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Paladin.statMeleeDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
                if (Variables.playersData[e.Player.name].ActualClass == "wizard")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Wizard.statMeleeDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
            }
            if (TShock.Players[e.Player.whoAmI].SelectedItem.ranged)
            {
                if (Variables.playersData[e.Player.name].ActualClass == "warrior")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Warrior.statRangedDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
                if (Variables.playersData[e.Player.name].ActualClass == "paladin")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Paladin.statRangedDamage * 3);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
                if (Variables.playersData[e.Player.name].ActualClass == "wizard")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Wizard.statRangedDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
            }
            if (TShock.Players[e.Player.whoAmI].SelectedItem.magic)
            {
                if (Variables.playersData[e.Player.name].ActualClass == "warrior")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Warrior.statMagicDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
                if (Variables.playersData[e.Player.name].ActualClass == "paladin")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Paladin.statMagicDamage);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }

                if (Variables.playersData[e.Player.name].ActualClass == "wizard")
                {
                    if (e.Damage >= e.Npc.life)
                    {
                        return;
                    }
                    int Damage = (Variables.playersData[e.Player.name].Wizard.statMagicDamage * 3);
                    if (Damage > 0)
                    {
                        NetMessage.SendData(119, -1, -1, Terraria.Localization.NetworkText.FromLiteral("+" + Damage), (int)c.PackedValue, e.Npc.position.X, e.Npc.position.Y, 0, 0, 0, 0);
                    }
                    e.Damage = e.Damage + Damage;
                    return;
                }
            }
        }
Example #17
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            var player = Players[args.Player.whoAmI];

            player.OnStrikeNpc(args);
        }