Exemplo n.º 1
0
        public static void GetGuardianInventoryItem(BinaryReader reader, int WhoAmI)
        {
            byte PlayerID      = reader.ReadByte();
            int  MyGuardianPos = reader.ReadInt32();
            int  Slot          = reader.ReadInt32();
            int  NetID         = reader.ReadInt32();
            byte Prefix        = (byte)(NetID == 0 ? 0 : reader.ReadByte());
            int  Stack         = (NetID == 0 ? 0 : reader.ReadInt32());
            Item i             = new Item();

            i.netDefaults(NetID);
            i.Prefix(Prefix);
            i.stack = Stack;
            ItemIO.ReceiveModData(i, reader);
            Player player = Main.player[PlayerID];

            if (PlayerID == Main.myPlayer)
            {
                return;
            }
            PlayerMod pm = player.GetModPlayer <PlayerMod>();

            if (!pm.MyGuardians.ContainsKey(MyGuardianPos))
            {
                return;
            }
            GuardianData tg = pm.MyGuardians[MyGuardianPos];

            tg.Inventory[Slot] = i;
            if (Main.netMode == 2)
            {
                SendGuardianInventoryItem(pm, MyGuardianPos, Slot, -1, WhoAmI);
            }
        }
Exemplo n.º 2
0
 private static bool CompanionHasFishingGearRequirement(Player player, GuardianData gd)
 {
     for (int i = 0; i < 50; i++)
     {
         if (gd.Inventory[i].fishingPole > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 public override void Action(CommandCaller caller, string input, string[] args)
 {
     if (args.Length < 3)
     {
         caller.Reply("Command parameters are invalid.", Color.Red);
     }
     else
     {
         int    GuardianID;
         string ModID;
         string NewName = "";
         if (!int.TryParse(args[0], out GuardianID))
         {
             caller.Reply("Invalid guardian id. ", Color.Red);
         }
         else
         {
             ModID = args[1];
             //NewName = args[2];
             for (int i = 2; i < args.Length; i++)
             {
                 if (i > 2)
                 {
                     NewName += " ";
                 }
                 NewName += args[i];
             }
             if (NewName.Length < 2 || NewName.Length > 16)
             {
                 caller.Reply("Guardian nickname length must be between 2 and 16 characters.", Color.Red);
             }
             else
             {
                 if (!caller.Player.GetModPlayer <PlayerMod>().HasGuardian(GuardianID, ModID))
                 {
                     caller.Reply("Invalid guardian id.", Color.Red);
                 }
                 else
                 {
                     GuardianData gd = caller.Player.GetModPlayer <PlayerMod>().GetGuardian(GuardianID, ModID);
                     if (gd.CanChangeName)
                     {
                         caller.Reply(gd.Base.Name + "'s nickname changed to " + NewName + ".");
                         gd.Name = NewName;
                     }
                     else
                     {
                         caller.Reply("You can't change " + gd.Name + "'s nickname again, buy a Rename Card from the Dryad and use to allow changing it.");
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public void TryGettingNewRequest(Player player, GuardianData data)
        {
            if (state != RequestState.Ready)
            {
                return;
            }
            List <KeyValuePair <string, int> > RequestToPick = RequestContainer.GetPossibleRequests(data, player);
            KeyValuePair <string, int>         PickedOne     = RequestToPick[Main.rand.Next(RequestToPick.Count)];

            SpawnRequest(PickedOne.Key, PickedOne.Value, player);
            RequestToPick.Clear();
        }
Exemplo n.º 5
0
        public static List <KeyValuePair <string, int> > GetPossibleRequests(GuardianData tg, Player player)
        {
            List <KeyValuePair <string, int> > PossibleRequests = new List <KeyValuePair <string, int> >();

            foreach (string modid in RequestContainers.Keys)
            {
                RequestContainer container = RequestContainers[modid];
                foreach (int id in container.Requests.Keys)
                {
                    if (container.Requests[id].CanGetRequest(player, tg))
                    {
                        PossibleRequests.Add(new KeyValuePair <string, int>(modid, id));
                    }
                }
            }
            return(PossibleRequests);
        }
Exemplo n.º 6
0
        public static RequestReward GetAPossibleReward(Player player, GuardianData gd)
        {
            float TotalChance;
            List <RequestReward> Rewards = GetPossibleRewards(player, gd, out TotalChance);
            float Stack  = 0;
            float Picked = Main.rand.NextFloat() * TotalChance;

            foreach (RequestReward reward in Rewards)
            {
                if (Picked >= Stack && Picked < Stack + reward.AcquisitionChance)
                {
                    return(reward);
                }
                Stack += reward.AcquisitionChance;
            }
            return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Tells if the player has that item on the inventory.
        /// It doesn't tells how many stacks of the item you have.
        /// If you want to get the number of that item, use CountItem instead.
        /// </summary>
        /// <param name="ItemID">ID of the item to check if you have.</param>
        /// <returns>Returns true if you have at least one of that item in the inventory.</returns>
        public static bool GuardianHasItem(int ItemID, int GuardianID, string ModID = "")
        {
            if (ModID == "")
            {
                ModID = MainMod.mod.Name;
            }
            if (!PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianID, ModID))
            {
                return(false);
            }
            GuardianData gd = PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, ModID);

            for (int i = 0; i < 50; i++)
            {
                if (gd.Inventory[i].type == ItemID)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Tells how many of that item you have in the inventory.
        /// </summary>
        /// <param name="ItemID">ID of the item to count from inventory.</param>
        /// <returns>Returns the number of that item you have in the inventory.</returns>
        public static int CountItemFromGuardian(int ItemID, int GuardianID, string ModID = "")
        {
            if (ModID == "")
            {
                ModID = MainMod.mod.Name;
            }
            if (!PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianID, ModID))
            {
                return(0);
            }
            GuardianData gd    = PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, ModID);
            int          Count = 0;

            for (int i = 0; i < 50; i++)
            {
                if (gd.Inventory[i].type == ItemID)
                {
                    Count += gd.Inventory[i].stack;
                }
            }
            return(Count);
        }
Exemplo n.º 9
0
        public void Update(Player player, GuardianData data)
        {
            switch (state)
            {
            case RequestState.Cooldown:
                RequestTimeLeft--;
                if (RequestTimeLeft <= 0)
                {
                    state = RequestState.Ready;
                }
                break;

            case RequestState.Active:
                RequestTimeLeft--;
                Base.UpdateRequest(player, this);
                if (RequestTimeLeft <= 0)
                {
                    SetRequestOnCooldown(false);
                    Main.NewText("You took so long to complete " + data.Name + "'s request, that they forgot about it...", new Microsoft.Xna.Framework.Color(200, 0, 0));
                }
                break;
            }
        }
Exemplo n.º 10
0
        public static List <RequestReward> GetPossibleRewards(Player player, GuardianData gd, out float MaxChance)
        {
            List <RequestReward> rewards = new List <RequestReward>();

            MaxChance = 0;
            foreach (RequestReward r in RequestRewards)
            {
                if (r.CanGetReward(player, gd))
                {
                    MaxChance += r.AcquisitionChance;
                    rewards.Add(r);
                }
            }
            foreach (RequestReward r in gd.Base.RewardsList)
            {
                if (r.CanGetReward(player, gd))
                {
                    MaxChance += r.AcquisitionChance;
                    rewards.Add(r);
                }
            }
            return(rewards);
        }
Exemplo n.º 11
0
 public static bool DefeatedFrostLegionRequirement(Player player, GuardianData tg)
 {
     return(Main.xMas && NPC.downedFrost);
 }
Exemplo n.º 12
0
 public static bool XmasRequirement(Player player, GuardianData tg)
 {
     return(Main.xMas);
 }
Exemplo n.º 13
0
 public static bool MoonlordKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedMoonlord);
 }
Exemplo n.º 14
0
 public static bool GolemKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedGolemBoss);
 }
Exemplo n.º 15
0
 public static bool QueenBeeKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedQueenBee);
 }
Exemplo n.º 16
0
 public static bool AnyFirstBossKillRequirementCrimson(Player player, GuardianData tg)
 {
     return(WorldGen.crimson && (NPC.downedBoss1 || NPC.downedBoss2 || NPC.downedBoss3));
 }
Exemplo n.º 17
0
 public static bool KingSlimeKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedSlimeKing);
 }
Exemplo n.º 18
0
 public static bool CrimsonWorldHardmodeRequirement(Player player, GuardianData tg)
 {
     return(Main.hardMode && WorldGen.crimson);
 }
Exemplo n.º 19
0
 public static bool PlanteraKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedPlantBoss);
 }
Exemplo n.º 20
0
 public static bool HardmodeRequirement(Player player, GuardianData tg)
 {
     return(Main.hardMode);
 }
Exemplo n.º 21
0
 public static bool LunaticCultistKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedAncientCultist);
 }
Exemplo n.º 22
0
 public static bool AllMechBossKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3);
 }
Exemplo n.º 23
0
 public static bool HalloweenRequirement(Player player, GuardianData tg)
 {
     return(Main.halloween);
 }
Exemplo n.º 24
0
 public static bool AnyMechBossKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedMechBossAny);
 }
Exemplo n.º 25
0
 public static bool DefeatedMartiansRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedMartians);
 }
Exemplo n.º 26
0
 public static bool EvilBossKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedBoss2);
 }
Exemplo n.º 27
0
 public static bool BugnetRequirement(Player player, GuardianData tg)
 {
     return(player.HasItem(Terraria.ID.ItemID.BugNet) || player.HasItem(Terraria.ID.ItemID.GoldenBugNet));
 }
Exemplo n.º 28
0
 public static bool SkeletronKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedBoss3);
 }
Exemplo n.º 29
0
 public static bool LifeCrystalUsedRequirement(Player player, GuardianData tg)
 {
     return(player.statLifeMax > 100);
 }
Exemplo n.º 30
0
 public static bool AnyFirstBossKillRequirement(Player player, GuardianData tg)
 {
     return(NPC.downedBoss1 || NPC.downedBoss2 || NPC.downedBoss3);
 }