public override void ProcessTriggers(TriggersSet triggersSet)
        {
            if (DBTMod.Instance.energyChargeKey.Current)
            {
                bool canCharge = true;

                for (int i = 0; i < player.buffType.Length; i++)
                {
                    ModBuff modBuff = BuffLoader.GetBuff(player.buffType[i]);
                    if (modBuff == null)
                    {
                        continue;
                    }

                    ICanStopCharging icsc = modBuff as ICanStopCharging;
                    if (icsc == null)
                    {
                        continue;
                    }

                    if (icsc.DoesStopCharging(this))
                    {
                        canCharge = false;
                        break;
                    }
                }

                IsCharging = canCharge;
            }
            else
            {
                IsCharging = false;
            }

            MouseLeftHeld  = triggersSet.MouseLeft;
            MouseRightHeld = triggersSet.MouseRight;

            UpHeld    = triggersSet.Up;
            DownHeld  = triggersSet.Down;
            LeftHeld  = triggersSet.Left;
            RightHeld = triggersSet.Right;

            if (player.whoAmI == Main.myPlayer)
            {
                if (DBTMod.Instance.transformUpKey.JustPressed && SelectedTransformations != null)
                {
                    TryTransforming(SelectedTransformations);
                }

                if (DBTMod.Instance.transformDownKey.JustPressed)
                {
                    ClearTransformations();
                }

                if (DBTMod.Instance.characterMenuKey.JustPressed)
                {
                    DBTMod.Instance.dbtMenu.Visible = !DBTMod.Instance.dbtMenu.Visible;
                }
            }
        }
Exemple #2
0
            public BuffTranslation(ModBuff buff)
            {
                NameTranslation = string.Empty;
                TipTranslation  = string.Empty;

                Name = buff.DisplayName.GetDefault();
                Tip  = buff.Description.GetDefault();
            }
Exemple #3
0
 public virtual void RemoveBuff(ModBuff buff)
 {
     if (buffs.Contains(buff))
     {
         buffs.Remove(buff);
         buffed_mods.Remove(buff.buff_value);
     }
 }
            public BuffTranslation(ModBuff buff)
            {
                NameTranslation = LanguageManager.Instance.ActiveCulture == GameCulture.English ? ""
                                        : Language.GetTextValue(buff.DisplayName.Key);
                TipTranslation = LanguageManager.Instance.ActiveCulture == GameCulture.English ? ""
                                        : Language.GetTextValue(buff.Description.Key);

                Name = buff.DisplayName.GetDefault();
                Tip  = buff.Description.GetDefault();
            }
Exemple #5
0
 private void GetBuffBoost(Player player, Element element)
 {
     buffBoost = new Boost(1, string.Empty);
     for (int i = 0; i < player.buffType.Length; i++)
     {
         ModBuff modBuff = ModContent.GetModBuff(player.buffType[i]);
         if (modBuff != null && modBuff is IPowerupType powerupType)
         {
             buffBoost = powerupType.PowerupType(new PowerupTypeParameters(element, new PlayerWrapper(player))).boost;
         }
     }
 }
        public static void AddBuffMapping(ModBuff buff)
        {
            string qualifiedName = buff.GetType().FullName;
            uint   hashCode      = FNV_1A_32Bit_Hash(qualifiedName);

            if (HashToTypeDict.ContainsKey(hashCode))
            {
                throw new Exception("Buff typename collision for " + qualifiedName);
            }
            HashToTypeDict[hashCode]  = buff.Type;
            TypeToHashDict[buff.Type] = hashCode;
        }
Exemple #7
0
 public EntityTyping CheckBuffModifyType(EntityTyping defTyping)
 {
     for (int i = 0; i < BuffLoader.BuffCount; i++)
     {
         if (NPC.HasBuff(i))
         {
             ModBuff modBuff = ModContent.GetModBuff(i);
             if (modBuff != null && modBuff is IUseModifiedType modifiedType)
             {
                 return(new EntityTyping(modifiedType.MyElement, Element.none, defTyping.offensiveElement));
             }
         }
     }
     return(defTyping);
 }
Exemple #8
0
        public TransformationDefinition GetCurrentTransformation()
        {
            for (int i = 0; i < player.buffType.Length; i++)
            {
                ModBuff            buff      = BuffLoader.GetBuff(player.buffType[i]);
                TransformationBuff transBuff = buff as TransformationBuff;

                if (transBuff != null)
                {
                    return(transBuff.TransformationDefinition);
                }
            }

            return(null);
        }
 private TypeSet BuffType(TypeSet typeSet)
 {
     for (int i = 0; i < player.buffType.Length; i++)
     {
         ModBuff modBuff = ModContent.GetModBuff(player.buffType[i]);
         if (modBuff != null)
         {
             if (modBuff is IBuffModifyType buffModify)
             {
                 buffModify.ModifyType(new Abilities.Buffs.ModifyTypeParameters(typeSet, new PlayerWrapper(this)));
             }
             else if (modBuff is IUseModifiedType)
             {
                 typeSet.Primary   = ModifyType;
                 typeSet.Secondary = Element.none;
             }
         }
     }
     return(typeSet);
 }
Exemple #10
0
        public static ModBuff GetModBuff(string modname, string buffname)
        {
            ModBuff buff = new ModBuff();

            if (ModLoader.GetMod(modname) != null)
            {
                Mod mod = ModLoader.GetMod(modname);
                try
                {
                    buff = mod.GetBuff(buffname);
                }
                catch (Exception)
                {
                    buff = null;
                    throw new Exception("Can't find this buff" + buffname);
                }
            }

            return(buff);
        }
Exemple #11
0
        internal static bool WriteModBuffs(Player player, BinaryWriter writer)
        {
            byte[] data;
            byte   num = 0;

            using (MemoryStream buffer = new MemoryStream())
            {
                using (BinaryWriter customWriter = new BinaryWriter(buffer))
                {
                    byte index = 0;
                    for (int k = 0; k < Player.maxBuffs; k++)
                    {
                        int buff = player.buffType[k];
                        if (!Main.buffNoSave[buff])
                        {
                            if (BuffLoader.IsModBuff(buff))
                            {
                                customWriter.Write(index);
                                ModBuff modBuff = BuffLoader.GetBuff(buff);
                                customWriter.Write(modBuff.mod.Name);
                                customWriter.Write(modBuff.Name);
                                customWriter.Write(player.buffTime[k]);
                                num++;
                            }
                            index++;
                        }
                    }
                    customWriter.Flush();
                    data = buffer.ToArray();
                }
            }
            if (num > 0)
            {
                writer.Write(num);
                writer.Write(data);
                return(true);
            }
            return(false);
        }
Exemple #12
0
        ////////////////

        private void UpdateTransformBuffs()
        {
            bool isTransformed = false;

            for (int i = 0; i < this.player.buffType.Length; i++)
            {
                int buffType = this.player.buffType[i];

                if (buffType <= 0 || this.player.buffTime[i] <= 0)
                {
                    continue;
                }

                ModBuff mybuff = ModContent.GetModBuff(buffType);
                if (mybuff == null || !(mybuff is TransformBuffBase))
                {
                    continue;
                }

                if (isTransformed)
                {
                    this.player.ClearBuff(buffType);

                    if (buffType == ModContent.BuffType <PsychoModeBuff>())
                    {
                        this.PsychoKills = 0;
                    }
                }

                isTransformed = true;
            }

            if (!isTransformed && this.IsTransformed)
            {
                this.ClearTransformation();
            }
        }
Exemple #13
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            if (DBTMod.Instance.energyChargeKey.Current)
            {
                bool canCharge = true;

                for (int i = 0; i < player.buffType.Length; i++)
                {
                    ModBuff modBuff = BuffLoader.GetBuff(player.buffType[i]);
                    if (modBuff == null)
                    {
                        continue;
                    }

                    ICanStopCharging icsc = modBuff as ICanStopCharging;
                    if (icsc == null)
                    {
                        continue;
                    }

                    if (icsc.DoesStopCharging(this))
                    {
                        canCharge = false;
                        break;
                    }
                }

                Charging = canCharge;
            }
            else
            {
                Charging = false;
            }

            //Test code
            //UpdateSynchronizedControls(triggersSet);

            //SyncTriggerSet();

            //_mProgressionSystem.Update(player);

            MouseLeftHeld  = triggersSet.MouseLeft;
            MouseRightHeld = triggersSet.MouseRight;

            UpHeld    = triggersSet.Up;
            DownHeld  = triggersSet.Down;
            LeftHeld  = triggersSet.Left;
            RightHeld = triggersSet.Right;

            if (player.whoAmI == Main.myPlayer)
            {
                if (DBTMod.Instance.transformUpKey.JustPressed && SelectedTransformations != null)
                {
                    TryTransforming(SelectedTransformations);
                }

                if (DBTMod.Instance.transformDownKey.JustPressed)
                {
                    ClearTransformations();
                }

                if (DBTMod.Instance.characterMenuKey.JustPressed)
                {
                    DBTMod.Instance.characterTransformationsMenu.Visible = !DBTMod.Instance.characterTransformationsMenu.Visible;
                }
                if (DBTMod.Instance.techniqueMenuKey.JustPressed)
                {
                    DBTMod.Instance.techniqueMenu.Visible = !DBTMod.Instance.techniqueMenu.Visible;
                }
                if (DBTMod.Instance.flightToggleKey.JustPressed)
                {
                    Flying = !Flying;
                }
            }
        }
        public void QueryModOrigin()
        {
            Point mouseTile = Main.MouseWorld.ToTileCoordinates();

            int   closestNPCIndex    = -1;
            float closestNPCDistance = float.MaxValue;

            for (int l = 0; l < 200; l++)
            {
                if (Main.npc[l].active)
                {
                    float distance = Utils.Distance(Main.npc[l].getRect(), Main.MouseWorld);
                    if (distance < closestNPCDistance)
                    {
                        closestNPCDistance = distance;
                        closestNPCIndex    = l;
                    }
                }
            }

            int   closestItemIndex    = -1;
            float closestItemDistance = float.MaxValue;

            for (int i = 0; i < 400; i++)
            {
                if (Main.item[i].active)
                {
                    float distance = Utils.Distance(Main.item[i].getRect(), Main.MouseWorld);
                    if (distance < closestItemDistance)
                    {
                        closestItemDistance = distance;
                        closestItemIndex    = i;
                    }
                }
            }


            int hoverBuffIndex = -1;
            int hoverBuffID    = -1;

            for (int k = 0; k < 22; k++)
            {
                if (Main.player[Main.myPlayer].buffType[k] > 0)
                {
                    int buffID = Main.player[Main.myPlayer].buffType[k];
                    int buffX  = 32 + k * 38;
                    int buffY  = 76;
                    if (k >= 11)
                    {
                        buffX  = 32 + (k - 11) * 38;
                        buffY += 50;
                    }

                    if (Main.mouseX < buffX + Main.buffTexture[buffID].Width && Main.mouseY <buffY + Main.buffTexture[buffID].Height && Main.mouseX> buffX && Main.mouseY > buffY)
                    {
                        hoverBuffIndex = k;
                        hoverBuffID    = buffID;
                    }
                }
            }

            //Top to Bottom:

            // Hover Buff
            if (hoverBuffIndex > -1 && !Main.playerInventory)
            {
                if (hoverBuffID >= BuffID.Count)
                {
                    ModBuff hoverBuff = BuffLoader.GetBuff(hoverBuffID);
                    Main.NewText("This buff is from: " + hoverBuff.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {hoverBuff.mod.Name}, InternalName: {hoverBuff.Name}, FullName: {hoverBuff.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla buff.");
                }
            }

            // Item in inventory
            else if (Main.HoverItem.type > 0 && Main.HoverItem != null)
            {
                if (Main.HoverItem.modItem != null)
                {
                    Main.NewText("This item is from: " + Main.HoverItem.modItem.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {Main.HoverItem.modItem.mod.Name}, InternalName: {Main.HoverItem.modItem.Name}, FullName: {Main.HoverItem.modItem.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla item.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.HoverItem.type)}, ItemID#: {Main.HoverItem.type}");
                    }
                }
            }

            // NPC
            else if (closestNPCDistance < 30)
            {
                NPC closestNPC = Main.npc[closestNPCIndex];
                if (closestNPC.modNPC != null)
                {
                    Main.NewText("This npc is from: " + closestNPC.modNPC.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {closestNPC.modNPC.mod.Name}, InternalName: {closestNPC.modNPC.Name}, FullName: {closestNPC.modNPC.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla npc.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: NPCID: {NPCID.Search.GetName(closestNPC.type)}, NPCID#: {closestNPC.type}");
                    }
                }
            }

            // Tile
            else if (Main.tile[mouseTile.X, mouseTile.Y].type >= TileID.Count)
            {
                ModTile modTile = TileLoader.GetTile(Main.tile[mouseTile.X, mouseTile.Y].type);
                Main.NewText("This tile is from: " + modTile.mod.DisplayName);
                if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                {
                    Main.NewText($"Developer Info: ModName: {modTile.mod.Name}, InternalName: {modTile.Name}, FullName: {modTile.GetType().FullName}");
                }
                //Main.NewText("This tile is active: " + Main.tile[mouseTile.X, mouseTile.Y].active());
                //Main.NewText("This tile is inactive: " + Main.tile[mouseTile.X, mouseTile.Y].inActive());
                //Main.NewText("This tile is nactive: " + Main.tile[mouseTile.X, mouseTile.Y].nactive());
            }

            // Wall
            else if (Main.tile[mouseTile.X, mouseTile.Y].wall >= WallID.Count)
            {
                ModWall modWall = WallLoader.GetWall(Main.tile[mouseTile.X, mouseTile.Y].wall);
                Main.NewText("This wall is from: " + modWall.mod.DisplayName);
                if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                {
                    Main.NewText($"Developer Info: ModName: {modWall.mod.Name}, InternalName: {modWall.Name}, FullName: {modWall.GetType().FullName}");
                }
            }

            // Item on ground
            else if (closestItemDistance < 5)
            {
                if (Main.item[closestItemIndex].modItem != null)
                {
                    ModItem modItem = Main.item[closestItemIndex].modItem;
                    Main.NewText("This item is from: " + modItem.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {modItem.mod.Name}, InternalName: {modItem.Name}, FullName: {modItem.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla item.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.item[closestItemIndex].type)}, ItemID#: {Main.item[closestItemIndex].type}");
                    }
                }
            }

            // How to Use
            else if (true)
            {
                Main.NewText("Hover over an item, npc, tile, or wall to identify which mod it is from.");
            }
        }
Exemple #15
0
 public static void AddBuffNameTranslation(ModBuff buff, string buffNameTranslation, GameCulture culture)
 {
     buff.DisplayName.AddTranslation(culture, buffNameTranslation);
 }
Exemple #16
0
        public void UpdateDebuffsByID(NPC npc, ref int id, int time, int buffSlot = -1)
        {
            if (npc.buffImmune[id])
            {
                return;
            }
            ModBuff bf = BuffLoader.GetBuff(id);

            if (bf != null)
            {
                if (buffSlot == -1)
                {
                    for (buffSlot = 0; buffSlot < 5; buffSlot++)
                    {
                        if (npc.buffType[buffSlot] <= 0)
                        {
                            npc.buffTime[buffSlot] = time;
                            break;
                        }
                    }
                    if (buffSlot >= 5)
                    {
                        return;
                    }
                }
                bf.Update(npc, ref buffSlot);
                //npc.buffTime[buffSlot] = 0;
                return;
            }

            if (id == 20)
            {
                npc.poisoned = true;
            }
            if (id == 70)
            {
                npc.venom = true;
            }
            if (id == 24)
            {
                npc.onFire = true;
            }
            if (id == 72)
            {
                npc.midas = true;
            }
            if (id == 69)
            {
                npc.ichor = true;
            }
            if (id == 31)
            {
                npc.confused = true;
            }
            if (id == 39)
            {
                npc.onFire2 = true;
            }
            if (id == 44)
            {
                npc.onFrostBurn = true;
            }
            if (id == 103)
            {
                npc.dripping = true;
            }
            if (id == 137)
            {
                npc.drippingSlime = true;
            }
            if (id == 119)
            {
                npc.loveStruck = true;
            }
            if (id == 120)
            {
                npc.stinky = true;
            }
            if (id == 151)
            {
                npc.soulDrain = true;
            }
            if (id == 153)
            {
                npc.shadowFlame = true;
            }
            if (id == 165)
            {
                npc.dryadWard = true;
            }
            if (id == 169)
            {
                npc.javelined = true;
            }
            if (id == 183)
            {
                npc.celled = true;
            }
            if (id == 186)
            {
                npc.dryadBane = true;
            }
            if (id == 189)
            {
                npc.daybreak = true;
            }
            if (id == 203)
            {
                npc.betsysCurse = true;
            }
            if (id == 204)
            {
                npc.oiled = true;
            }
        }
Exemple #17
0
 public static void AddBuffTipTranslation(ModBuff buff, string bufftipTranslation, GameCulture culture)
 {
     buff.Description.AddTranslation(culture, bufftipTranslation);
 }
Exemple #18
0
 public virtual void ApplyBuff(ModBuff buff)
 {
     buffs.Add(buff);
     buffed_mods.Add(buff.buff_value);
 }