public override void OnPlayerPostHurt(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
 {
     if (dotariaPlayer.player.dead || dotariaPlayer.player.statLife / Statistics.TERRARIA_HEALTH_RATIO <= GetHealthThreshold(dotariaPlayer, playerAbility) && !dotariaPlayer.player.HasBuff <BorrowedTimeBuff>())
     {
         dotariaPlayer.player.AddBuff <BorrowedTimeBuff>(GetDuration(dotariaPlayer, playerAbility) * DoTariaMath.TICKS_PER_SECOND);
     }
 }
        private void OnAbilityUpgradeButtonClicked(UIMouseEvent evt, UIElement element)
        {
            DoTariaPlayer   dotariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);
            UIAbilityButton upgradeButton = element as UIAbilityButton;

            if (upgradeButton == null)
            {
                Main.NewText("Upgrade button was null ?");
                return;
            }

            if (!_upgradeButtonsForAbilityDefinitions.ContainsKey(upgradeButton))
            {
                Main.NewText("Upgrade button was clicked when it shouldn't be accessible.");
                return;
            }

            AbilityDefinition ability = _upgradeButtonsForAbilityDefinitions[upgradeButton];

            if (!CanUpgradeAbility(dotariaPlayer, ability))
            {
                Main.NewText("Tried leveling an ability without meeting the requirements.");
                return;
            }

            dotariaPlayer.AcquireOrLevelUp(ability);
        }
示例#3
0
 public override void CastElementModifyWeaponDamage(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, Item item, ref float add, ref float mult, ref float flat)
 {
     if (item.magic)
     {
         flat += GetExtraDamage(dotariaPlayer, playerAbility);
     }
 }
 public override void ModifyWeaponDamage(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, Item item, ref float add, ref float mult, ref float flat)
 {
     if (item.ranged && item.ammo == 0)
     {
         flat += AbilityDefinitionManager.Instance.Necromastery.GetExtraFlatDamage(dotariaPlayer, playerAbility);
     }
 }
        public override bool CastAbility(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, bool casterIsLocalPlayer)
        {
            dotariaPlayer.player.Hurt(PlayerDeathReason.ByPlayer(dotariaPlayer.player.whoAmI), (int)GetSelfDamage(dotariaPlayer, playerAbility), 1);

            if (casterIsLocalPlayer)
            {
                EntitiesHelper.GetLocalHoveredEntity(out Player player, out NPC npc);

                if (player == null && npc == null)
                {
                    return(false);
                }

                int projectileId            = Projectile.NewProjectile(dotariaPlayer.player.position, Vector2.Zero, ModContent.ProjectileType <MistCoilProjectile>(), 0, 0f, dotariaPlayer.player.whoAmI);
                MistCoilProjectile mistCoil = Main.projectile[projectileId].modProjectile as MistCoilProjectile;

                if (player != null)
                {
                    mistCoil.HomeOntoPlayer = player;
                }
                else if (npc != null)
                {
                    mistCoil.HomeOntoNPC = npc;
                }

                mistCoil.DamageOnContact = (int)InternalGetAbilityDamage(dotariaPlayer, playerAbility);


                NetworkPacketManager.Instance.MistCoilFired.SendPacketToAllClients(dotariaPlayer.player.whoAmI, dotariaPlayer.player.whoAmI, (player != null ? MistCoilFiredPacket.TargetType.Player : MistCoilFiredPacket.TargetType.NPC).ToString(),
                                                                                   projectileId, player?.whoAmI ?? NPCsHelper.GetNPCIdFromNPC(npc), (int)mistCoil.DamageOnContact);
            }

            return(true);
        }
示例#6
0
        public override void NPCLoot(NPC npc)
        {
            if (npc.lastInteraction == 255)
            {
                return;                             // Killed by a non-player.
            }
            if (Main.netMode == NetmodeID.Server)
            {
                NetworkPacketManager.Instance.PlayerKilledNPC.SendPacketToAllClients(255, npc.lastInteraction, NPCsHelper.GetNPCIdFromNPC(npc));
            }
            else if (npc.lastInteraction != Main.myPlayer)
            {
                return;                                            // Killed by someone else.
            }
            DoTariaPlayer dotariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);

            if (dotariaPlayer == null)
            {
                return;
            }

            if (npc.lastInteraction == Main.myPlayer)
            {
                dotariaPlayer.OnKilledNPC(npc);
            }
        }
示例#7
0
 public override void VerifyAndApplyBuffs(DoTariaPlayer dotariaPlayer)
 {
     if (dotariaPlayer.HasAbility(AbilityDefinitionManager.Instance.Necromastery) && !dotariaPlayer.player.HasBuff <NecromasteryBuff>())
     {
         dotariaPlayer.player.AddBuff <NecromasteryBuff>(int.MaxValue);
     }
 }
        public override void ModifyBuffTip(ref string tip, ref int rare)
        {
            base.ModifyBuffTip(ref tip, ref rare);

            DoTariaPlayer dotariaPlayer = Main.LocalPlayer.GetModPlayer <DoTariaPlayer>();

            tip += $"\n\nYou currently have {dotariaPlayer.Souls} souls, giving you an extra {AbilityDefinitionManager.Instance.Necromastery.GetExtraFlatDamage(dotariaPlayer)} damage to ranged attacks.";
        }
示例#9
0
        public override bool CastAbility(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, bool casterIsLocalPlayer)
        {
            CombatText.NewText(new Rectangle((int)dotariaPlayer.player.position.X, (int)dotariaPlayer.player.position.Y,
                                             (int)(dotariaPlayer.player.width), (int)(dotariaPlayer.player.height)), AbilityColor, DisplayName);

            dotariaPlayer.CastInvokerElement(this);
            return(true);
        }
        public int GetMaxSouls(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility)
        {
            if (!dotariaPlayer.HasAbility(this))
            {
                return(0);
            }

            return(4 + playerAbility.Level * 8 + (dotariaPlayer.HasAghanims() ? 10 : 0));
        }
        public override void OnPlayerKilledNPC(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, NPC npc)
        {
            dotariaPlayer.Souls += 1;

            if (npc.boss)
            {
                dotariaPlayer.Souls += 15;
            }
        }
示例#12
0
        public virtual int GetRequiredLevelForNextUpgrade(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility)
        {
            if (AbilitySlot == AbilitySlot.Ultimate)
            {
                return((playerAbility.Level + 1) * 6);
            }

            return((playerAbility.Level * 2) + 1);
        }
示例#13
0
        public override void ModifyWeaponDamage(DoTariaPlayer dotariaPlayer, Item item, ref float add, ref float mult, ref float flat)
        {
            base.ModifyWeaponDamage(dotariaPlayer, item, ref add, ref mult, ref flat);

            foreach (InvokerElementAbility ability in dotariaPlayer.CurrentElements)
            {
                ability.CastElementModifyWeaponDamage(dotariaPlayer, dotariaPlayer.AcquiredAbilities[ability], item, ref add, ref mult, ref flat);
            }
        }
示例#14
0
        public override void ModifyBuffTip(ref string tip, ref int rare)
        {
            DoTariaPlayer dotariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);
            int           elementCount  = dotariaPlayer.CountInvokerElement(InvokerElementAbility);

            tip += $"You currently have {elementCount} {InvokerElementAbility.DisplayName} element(s)";

            ExtraModifyTooltip(dotariaPlayer, elementCount, ref tip, ref rare);
        }
        public override void OnPlayerHitNPCWithItem(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, NPC npc, Player player, Item item, int damage, float knockback, bool crit)
        {
            if (!item.melee)
            {
                return;
            }

            //npc.GetGlobalNPC<DoTariaGlobalInstanciatedNPC>().AddCurseofAvernus();
        }
示例#16
0
        public bool InternalCastAbility(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, bool casterIsLocalPlayer)
        {
            if (CastAbility(dotariaPlayer, playerAbility, casterIsLocalPlayer))
            {
                playerAbility.Cooldown = playerAbility.Ability.InternalGetCooldown(dotariaPlayer) * DoTariaMath.TICKS_PER_SECOND;
                return(true);
            }

            return(false);
        }
示例#17
0
 public override void OnAbilityLeveledUp(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility)
 {
     for (int i = 0; i < shadowrazes.Length; i++)
     {
         if (shadowrazes[i] != this)
         {
             dotariaPlayer.AcquireOrLevelUp(shadowrazes[i], false);
         }
     }
 }
        public override bool OnPlayerPreHurt(DoTariaPlayer dotariaPlayer, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
        {
            if (dotariaPlayer.player.HasBuff <BorrowedTimeBuff>())
            {
                dotariaPlayer.player.HealEffect(damage);
                dotariaPlayer.player.statLife += damage;
                return(false);
            }

            return(true);
        }
示例#19
0
        public override bool PreAI()
        {
            if (Owner == null)
            {
                Owner = DoTariaPlayer.Get(Main.player[projectile.owner]);
            }

            projectile.netUpdate = true;

            return(base.PreAI());
        }
        public override float UseTimeMultiplier(Item item, Player player)
        {
            if (item.melee || item.ranged)
            {
                DoTariaPlayer dotariaPlayer = player.GetModPlayer <DoTariaPlayer>();

                return(1 - Attributes.AttackSpeedFromAgility(dotariaPlayer.Hero.BaseAttributes.Agility) / MAX_ATTACK_SPEED);
            }

            return(1f);
        }
示例#21
0
        public static void ExecuteAuraPlayer <T>(int auraRange, DoTariaPlayer dotariaPlayer, int linger) where T : ModBuff
        {
            for (int i = 0; i < Main.player.Length; i++)
            {
                Player player = Main.player[i];

                if (Vector2.Distance(player.Center, dotariaPlayer.player.Center) <= auraRange)
                {
                    player.AddBuff <T>(linger);
                }
            }
        }
        public int GetExtraFlatDamage(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility)
        {
            // TODO Add support for talent.
            int actualSouls = dotariaPlayer.Souls;
            int maxSouls    = AbilityDefinitionManager.Instance.Necromastery.GetMaxSouls(dotariaPlayer, playerAbility);

            if (actualSouls > maxSouls)
            {
                actualSouls = maxSouls;
            }

            return(actualSouls * 2);
        }
示例#23
0
        public override bool CanExecuteRule(DoTariaPlayer dotariaPlayer, NPC npc, bool executedBefore)
        {
            if (!npc.boss || executedBefore)
            {
                return(false);
            }

            bool componentFound = false;

            for (int i = 0; i < RequiresNPCsToBeDead.Length; i++)
            {
                if (RequiresNPCsToBeDead[i] == npc.type)
                {
                    componentFound = true;
                    break;
                }
            }

            if (!componentFound)
            {
                return(false);
            }

            bool anyComponentLeftAlive = false;

            for (int i = 0; i < Main.npc.Length; i++)
            {
                for (int j = 0; j < RequiresNPCsToBeDead.Length; j++)
                {
                    NPC jNPC = Main.npc[i];

                    if (jNPC.type == RequiresNPCsToBeDead[j] && jNPC.active && npc != jNPC)
                    {
                        anyComponentLeftAlive = true;
                        break;
                    }
                }

                if (anyComponentLeftAlive)
                {
                    break;
                }
            }

            if (anyComponentLeftAlive)
            {
                return(false);
            }

            return(true);
        }
示例#24
0
        public override void ModifyTooltips(List <TooltipLine> tooltips)
        {
            base.ModifyTooltips(tooltips);

            DoTariaPlayer dotariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);
            string        tooltip       = dotariaPlayer.Hero.GetAghanimsUpgrade(dotariaPlayer);

            if (string.IsNullOrWhiteSpace(tooltip))
            {
                tooltip = "This hero has no Aghanim's upgrade";
            }

            tooltips.Add(new TooltipLine(mod, AghanimsScepter.TOOLTIP_AGHANIMS_UPGRADE, tooltip));
        }
示例#25
0
        public override bool CanExecuteRule(DoTariaPlayer dotariaPlayer, NPC npc, bool executedBefore)
        {
            if (executedBefore)
            {
                return(false);
            }

            if (npc.type == NPCID.BrainofCthulhu)
            {
                return(true);
            }

            return(base.CanExecuteRule(dotariaPlayer, npc, executedBefore));
        }
        public override bool CastAbility(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility, bool casterIsLocalPlayer)
        {
            if (!casterIsLocalPlayer)
            {
                return(true);
            }

            InvokableAbility invokableAbility = InvokableAbilities.InvokableAbilities.GetAbilityForCombination(dotariaPlayer.currentInvokerElements.ToArray());

            if (invokableAbility == null)
            {
                return(false);
            }

            return(dotariaPlayer.TryActivateAbility(invokableAbility));
        }
示例#27
0
        public override void OnHitByProjectile(NPC npc, Projectile projectile, int damage, float knockback, bool crit)
        {
            if (projectile.owner == 255)
            {
                return;
            }

            Player player = Main.player[projectile.owner];

            if (player.name == "")
            {
                return;
            }

            DoTariaPlayer.Get(player).OnHitNPCWithProjectile(npc, projectile, damage, knockback, crit);
        }
示例#28
0
        public override void VerifyAndApplyBuffs(DoTariaPlayer dotariaPlayer)
        {
            if (dotariaPlayer.HasAbility(AbilityDefinitionManager.Instance.Quas) && !dotariaPlayer.player.HasBuff <QuasBuff>())
            {
                dotariaPlayer.player.AddBuff <QuasBuff>(int.MaxValue);
            }

            if (dotariaPlayer.HasAbility(AbilityDefinitionManager.Instance.Wex) && !dotariaPlayer.player.HasBuff <WexBuff>())
            {
                dotariaPlayer.player.AddBuff <WexBuff>(int.MaxValue);
            }

            if (dotariaPlayer.HasAbility(AbilityDefinitionManager.Instance.Exort) && !dotariaPlayer.player.HasBuff <ExortBuff>())
            {
                dotariaPlayer.player.AddBuff <ExortBuff>(int.MaxValue);
            }
        }
示例#29
0
        public static void ExecuteAuraNPC <T>(int auraRange, DoTariaPlayer dotariaPlayer, int linger) where T : ModBuff
        {
            for (int i = 0; i < Main.npc.Length; i++)
            {
                NPC npc = Main.npc[i];

                if (!npc.active)
                {
                    continue;
                }

                if (Vector2.Distance(npc.Center, dotariaPlayer.player.Center) <= auraRange)
                {
                    npc.AddBuff <T>(linger);
                }
            }
        }
        public override void Update(NPC npc, ref int buffIndex)
        {
            PresenceoftheDarkLordAbility ability = AbilityDefinitionManager.Instance.PresenceoftheDarkLord;

            IEnumerable <DoTariaPlayer> players = Main.player.Where(p =>
            {
                if (p.name == "")
                {
                    return(false);
                }

                DoTariaPlayer player = DoTariaPlayer.Get(p);
                bool hasPotDL        = player.HasAbility(ability);

                if (hasPotDL)
                {
                    return(Vector2.Distance(p.Center, npc.Center) <=
                           ability.InternalGetCastRange(player));
                }

                return(false);
            }).Select(p => DoTariaPlayer.Get(p));

            PlayerAbility highestPlayerAbility      = null;
            DoTariaPlayer highestLevelDoTariaPlayer = null;

            foreach (DoTariaPlayer dotariaPlayer in players)
            {
                if (highestPlayerAbility == null || dotariaPlayer.AcquiredAbilities[ability].Level > highestPlayerAbility.Level)
                {
                    highestPlayerAbility      = dotariaPlayer.AcquiredAbilities[ability];
                    highestLevelDoTariaPlayer = dotariaPlayer;
                }
            }

            if (highestPlayerAbility == null)
            {
                return;
            }


            npc.defense = npc.defDefense - (int)(npc.defDefense * ability.GetDefenseReduction(highestLevelDoTariaPlayer, highestPlayerAbility));
        }