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); } }
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); }
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 bool PreAI() { if (Owner == null) { Owner = DoTariaPlayer.Get(Main.player[projectile.owner]); } projectile.netUpdate = true; return(base.PreAI()); }
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)); }
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); }
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)); }
private void DrawDescription(SpriteBatch spriteBatch, AbilityDefinition ability) { DoTariaPlayer doTariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer); PlayerAbility currentPlayerAbility; if (doTariaPlayer.HasAbility(ability)) { currentPlayerAbility = doTariaPlayer.GetPlayerAbility(ability); } else { currentPlayerAbility = new PlayerAbility(ability, 1, 0); } int panelWidth = 300, panelHeight = 34; Vector2 position = Main.MouseWorld + new Vector2(Main.cursorTextures[0].Width, Main.cursorTextures[0].Height * 2) - Main.screenPosition; StringBuilder description = new StringBuilder("Ability: "); if (ability.AbilityTargetType == AbilityTargetType.NoTarget && ability.AbilityType == AbilityType.Passive) { description.Append(ability.AbilityType); } else { description.Append(ability.AbilityTargetType.ToString().AddSpaceBeforeCapitals()); } description.AppendLine(); if (ability.AbilityTargetUnitType != AbilityTargetUnitType.None) { description.Append("Affects: "); if (!(ability.AbilityTargetUnitFaction == AbilityTargetFaction.Self || ability.AbilityTargetUnitFaction == (AbilityTargetFaction.Enemies & AbilityTargetFaction.Allies))) { description.Append(ability.AbilityTargetUnitFaction).Append(" "); } description.Append(ability.AbilityTargetUnitType.ToString().AddSpaceBeforeCapitals()).AppendLine(); } description.Append(ability.GetAbilityTooltip(doTariaPlayer, currentPlayerAbility)); DispelType dispelType = ability.GetDispelType(doTariaPlayer, currentPlayerAbility); if (dispelType != DispelType.None) { description.AppendLine().Append("Dispel type: ").Append(dispelType.ToString()).Append(" Dispel"); } description.AppendLine(); string finaliziedDescription = SpliceText(description.ToString(), 34); panelHeight += finaliziedDescription.Split('\n').Length * 26; spriteBatch.Draw(Main.magicPixel, position, new Rectangle(0, 0, panelWidth, panelHeight), Color.Black * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); spriteBatch.Draw(Main.magicPixel, position + new Vector2(2, 2), new Rectangle(0, 0, panelWidth - 4, 32), Color.Gray * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); spriteBatch.DrawString(Main.fontMouseText, ability.DisplayName, position + new Vector2(6, 8), Color.White); spriteBatch.DrawString(Main.fontMouseText, "Level: " + CurrentLevel, position + new Vector2(panelWidth - 56, 12), Color.White, 0, Vector2.Zero, 0.75f, SpriteEffects.None, 1f); spriteBatch.DrawString(Main.fontMouseText, finaliziedDescription, position + new Vector2(10, 40), Color.Gray, 0, Vector2.Zero, 0.85f, SpriteEffects.None, 1f); Texture2D manacostTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/ManacostIcon"); Texture2D cooldownTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/CooldownIcon"); Func <DoTariaPlayer, PlayerAbility, float> cooldownGetter = (player, playerAbility) => (float)Math.Round((double)playerAbility.Ability.InternalGetCooldown(player, playerAbility), 2); List <float> differentCooldowns = AbilitiesHelper.GetDifferentValues(cooldownGetter, doTariaPlayer, ability); if (!(differentCooldowns.Count == 1 && differentCooldowns[0] == 0f)) { spriteBatch.Draw(cooldownTexture, position + new Vector2(10, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); spriteBatch.DrawString(Main.fontMouseText, AbilitiesHelper.GenerateCleanSlashedString(AbilitiesHelper.GetAllValues((player, pAbility) => (float)Math.Round((double)pAbility.Ability.InternalGetCooldown(player, pAbility), 2), doTariaPlayer, ability), differentCooldowns), position + new Vector2(30, panelHeight - 24), Color.Gray); } if (ability.AbilityType == AbilityType.Active) { spriteBatch.Draw(manacostTexture, position + new Vector2(panelWidth / 2, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); spriteBatch.DrawString(Main.fontMouseText, AbilitiesHelper.GenerateCleanSlashedString((player, playerAbility) => (float)Math.Ceiling(playerAbility.Ability.InternalGetManaCost(player, playerAbility)), doTariaPlayer, ability), position + new Vector2(panelWidth / 2 + 20, panelHeight - 24), Color.Gray); } }
public override void Update(GameTime gameTime) { base.Update(gameTime); _mainPanel.BackgroundColor = ModContent.GetInstance <DoTariaClientConfiguration>().AbilityPanelBackgroundColor; _mainPanel.BorderColor = ModContent.GetInstance <DoTariaClientConfiguration>().AbilityPanelBorderColor; DoTariaPlayer dotariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer); foreach (KeyValuePair <UIAbilityButton, UIImage> kvp in _abilityNotLearnedMasks) { if (!_definitionsForAbilityButton.ContainsKey(kvp.Key) || _definitionsForAbilityButton[kvp.Key] == null || dotariaPlayer.HasAbility(_definitionsForAbilityButton[kvp.Key])) { kvp.Value.ImageScale = 0f; } else { kvp.Value.ImageScale = 1f; } } foreach (var button in _upgradeButtonsForAbilityButtons) { ChangeUpgradeButton(button.Value, false); } foreach (AbilityDefinition ability in dotariaPlayer.DisplayedAbilities) { UIAbilityButton upgradeButton = GetUpgradeButtonForAbility(ability); UIAbilityButton abilityButton = GetAbilityButtonForAbility(ability); abilityButton.Ability = ability; if (dotariaPlayer.AcquiredAbilities.Count > 0) { if (dotariaPlayer.AcquiredAbilities.ContainsKey(ability)) { float percent = (float)(dotariaPlayer.AcquiredAbilities[ability].Cooldown / (ability.GetCooldown(dotariaPlayer, dotariaPlayer.AcquiredAbilities[ability]) * DoTariaMath.TICKS_PER_SECOND)); abilityButton.Percent = percent; abilityButton.CurrentLevel = dotariaPlayer.AcquiredAbilities[ability].Level; abilityButton.Ability = ability; if (dotariaPlayer.AcquiredAbilities[ability].Cooldown > 0) { abilityButton.Seconds = dotariaPlayer.AcquiredAbilities[ability].Cooldown / DoTariaMath.TICKS_PER_SECOND + 1; } else { abilityButton.Seconds = 0; } abilityButton.SetVisibility(COOLDOWN_VISIBILITY, COOLDOWN_VISIBILITY); } else { abilityButton.SetVisibility(ACTIVE_VISIBILITY, INACTIVE_VISIBILITY); } } if (upgradeButton == null) { continue; } bool shouldDisplay = dotariaPlayer.HasSpareLevels && ability.CanUnlock(dotariaPlayer) && (!dotariaPlayer.HasAbility(ability) || ability.InternalCanLevelUp(dotariaPlayer)); ChangeUpgradeButton(upgradeButton, shouldDisplay); } }
public override void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit) { DoTariaPlayer.Get(player).OnHitNPCWithItem(npc, player, item, damage, knockback, crit); }
public override void Action(CommandCaller caller, string input, string[] args) { DoTariaPlayer.Get(caller.Player).Level += int.Parse(args[0]); }