예제 #1
0
        internal static List <TagCompound> SaveModBuffs(Player player)
        {
            var  list         = new List <TagCompound>();
            byte vanillaIndex = 0;

            for (int k = 0; k < Player.maxBuffs; k++)
            {
                int buff = player.buffType[k];
                if (buff == 0 || Main.buffNoSave[buff])
                {
                    continue;
                }

                if (BuffLoader.IsModBuff(buff))
                {
                    var modBuff = BuffLoader.GetBuff(buff);
                    list.Add(new TagCompound {
                        ["index"] = vanillaIndex,                         //position of the loaded buff if there were no modBuffs before it
                        ["mod"]   = modBuff.mod.Name,
                        ["name"]  = modBuff.Name,
                        ["time"]  = player.buffTime[k]
                    });
                }
                else
                {
                    vanillaIndex++;
                }
            }
            return(list);
        }
예제 #2
0
        internal static List <TagCompound> SaveModBuffs(Player player)
        {
            var list = new List <TagCompound>();

            for (int k = 0; k < Player.MaxBuffs; k++)
            {
                int buff = player.buffType[k];
                if (buff == 0 || Main.buffNoSave[buff])
                {
                    continue;
                }

                if (BuffLoader.IsModBuff(buff))
                {
                    var modBuff = BuffLoader.GetBuff(buff);
                    list.Add(new TagCompound {
                        ["mod"]  = modBuff.Mod.Name,
                        ["name"] = modBuff.Name,
                        ["time"] = player.buffTime[k]
                    });
                }
                else
                {
                    list.Add(new TagCompound {
                        ["mod"]  = "Terraria",
                        ["id"]   = buff,
                        ["time"] = player.buffTime[k]
                    });
                }
            }
            return(list);
        }
예제 #3
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;
                    }
                }

                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;
                }
            }
        }
예제 #4
0
        public override void Load()
        {
            base.Load();

            var buff = BuffLoader.GetBuff(BuffID.Slimed);

            buff.Update
        }
        ////////////////

        /// <summary>
        /// Alias for `Lang.GetBuffName(int)`.
        ///
        /// Credit: Jofairden @ Even More Modifiers
        /// </summary>
        /// <param name="buffType"></param>
        /// <returns></returns>
        public static string GetBuffDisplayName(int buffType)
        {
            if (buffType >= BuffID.Count)
            {
                return(BuffLoader.GetBuff(buffType)?
                       .DisplayName
                       .GetTranslation(LanguageManager.Instance.ActiveCulture)
                       ?? "null");
            }

            return(Lang.GetBuffName(buffType));
        }
예제 #6
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);
        }
예제 #7
0
파일: Test.cs 프로젝트: XiaoRr/LocalizerMod
 public static void TestAddBuffTranslation()
 {
     try
     {
         var type = ModLoader.GetMod("Bluemagic").BuffType("Sunlight");
         if (type > 0)
         {
             TranslateTool.AddBuffNameTranslation(BuffLoader.GetBuff(type), "测试buff名字", GameCulture.Chinese);
             TranslateTool.AddBuffTipTranslation(BuffLoader.GetBuff(type), "测试buff说明", GameCulture.Chinese);
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.Log(ex.ToString());
     }
 }
예제 #8
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);
        }
        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.");
            }
        }
예제 #10
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;
            }
        }
예제 #11
0
        public override void PostSetupContent()
        {
            base.PostSetupContent();


            {
                //ONLY NEEDED BECAUSE IM LAZY AND OLD SAVES WILL BE DESTROYED OTHERWISE
                var modBuffs = new Dictionary <string, List <BuffValue> >();

                for (int i = 0; i < ItemLoader.ItemCount; i++)
                {
                    var mitem = ItemLoader.GetItem(i);


                    if (mitem != null)
                    {
                        if (mitem.item.buffType >= 1)
                        {
                            var buff = BuffLoader.GetBuff(mitem.item.buffType);
                            if (buff != null && !Main.lightPet[mitem.item.buffType] && !Main.vanityPet[mitem.item.buffType] && !Main.debuff[mitem.item.buffType] && !mitem.item.summon)
                            {
                                if (!modBuffs.ContainsKey(mitem.mod.Name))
                                {
                                    modBuffs.Add(mitem.mod.Name, new List <BuffValue>());
                                }

                                var bvalue = new BuffValue(false, mitem.item.buffType, buff.DisplayName.GetDefault(), buff.Description.GetDefault(), mitem.mod.Name, new CostValue[] { new ItemCostValue(mitem.item.type, 30, mitem.DisplayName.GetDefault()) }, null, true);

                                modBuffs[mitem.mod.Name].Add(bvalue);
                            }
                        }
                    }
                }

                foreach (var v in modBuffs)
                {
                    oldSaveModBuffValues.Add(new ModBuffValues(v.Key, v.Value.ToArray()));
                }
            }

            {
                var modBuffs = new Dictionary <string, List <BuffValue> >();

                for (int i = 0; i < ItemLoader.ItemCount; i++)
                {
                    var mitem = ItemLoader.GetItem(i);


                    if (mitem != null)
                    {
                        if (mitem.item.buffType >= 1)
                        {
                            var buff = BuffLoader.GetBuff(mitem.item.buffType);
                            if (buff != null && !Main.lightPet[mitem.item.buffType] && !Main.vanityPet[mitem.item.buffType] && !mitem.item.summon)
                            {
                                if (GetInstance <Config>().AllowDebuff || !Main.debuff[mitem.item.buffType])
                                {
                                    if (!modBuffs.ContainsKey(mitem.mod.Name))
                                    {
                                        modBuffs.Add(mitem.mod.Name, new List <BuffValue>());
                                    }

                                    var bvalue = new BuffValue(false, mitem.item.buffType, buff.DisplayName.GetDefault(), buff.Description.GetDefault(), mitem.mod.Name, new CostValue[] { new ItemCostValue(mitem.item.type, 30, mitem.DisplayName.GetDefault()) }, null, true);

                                    modBuffs[mitem.mod.Name].Add(bvalue);
                                }
                            }
                        }
                    }
                }

                foreach (var v in modBuffs)
                {
                    modBuffValues.Add(new ModBuffValues(v.Key, v.Value.ToArray()));
                }
            }
        }
예제 #12
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;
                }
            }
        }