Exemplo n.º 1
0
        public static void Heal()
        {
            int num27  = CalculatePriceForHeal();
            int health = Main.player[Main.myPlayer].statLifeMax2 - Main.player[Main.myPlayer].statLife;

            if (health == 0)
            {
                return;
            }

            if (Main.player[Main.myPlayer].BuyItem(num27, -1))
            {
                AchievementsHelper.HandleNurseService(num27);
                Main.PlaySound(SoundID.Item4, -1, -1);
                Main.player[Main.myPlayer].HealEffect(health, true);

                Main.player[Main.myPlayer].statLife += health;
                if (true)
                {
                    for (int i = 0; i < Player.MaxBuffs; i++)
                    {
                        int num9 = Main.player[Main.myPlayer].buffType[i];
                        if (Main.debuff[num9] && Main.player[Main.myPlayer].buffTime[i] > 0 && BuffLoader.CanBeCleared(num9))
                        {
                            Main.player[Main.myPlayer].DelBuff(i);
                            i = -1;
                        }
                    }
                }
                PlayerHooks.PostNurseHeal(Main.player[Main.myPlayer], Main.npc[Main.player[Main.myPlayer].talkNPC], health, true, num27);
            }
        }
Exemplo n.º 2
0
        public override bool NewRightClick(int i, int j)
        {
            int x = i; int y = j;

            while (Main.tile[x, y].frameY % 70 != 0)
            {
                y--;
            }
            while (Main.tile[x, y].frameX % 54 != 0)
            {
                x--;
            }


            int vmID = VendingMachineWorld.GetVendingMachineFromCoordinates(x, y);

            if (vmID < 0)
            {
                Main.NewText("No vending Machine Found...");
                return(false);
            }

            VendingMachineData vm = VendingMachineWorld.vm[vmID];

            if (vm.isItem)
            {
                Main.player[Main.myPlayer].chest = -1;
                Main.npcChatText = "";

                int  type = SoulOfNPC.getTypeFromItemTag(vm.id);
                Item itm  = new Item();
                itm.SetDefaults(type);

                VendingMachineItem vendor = itm.modItem as VendingMachineItem;
                if (vendor != null)
                {
                    if (vendor.replaceRightClick)
                    {
                        vendor.machineRightClick(vm, i, j);
                    }
                    else
                    {
                        Main.npcShop = Main.MaxShopIDs - 1;
                        chooseTalkingNPC(vm);
                        Main.recBigList       = false;
                        Main.playerInventory  = true;
                        Main.InGuideCraftMenu = false;
                        Main.InReforgeMenu    = false;
                        for (int k = 0; k < InvisibleAllShopNPC.shopChest.item.Length; k++)
                        {
                            InvisibleAllShopNPC.shopChest.item[k] = new Item();
                        }
                        vendor.SetupShop(InvisibleAllShopNPC.shopChest);
                        Main.instance.shop[Main.npcShop].SetupShop(ModContent.NPCType <InvisibleAllShopNPC>());
                    }
                }
            }
            else
            {
                int type = SoulOfNPC.getTypeFromNPCTag(vm.id);

                Main.npcShop = NPCToShop(type);

                if (type == NPCID.TravellingMerchant)
                {
                    Main.player[Main.myPlayer].chest = -1;
                    Main.npcChatText = "";
                    for (int k = 0; k < 40; k++)
                    {
                        if (Main.instance.shop[Main.npcShop].item[k] == null)
                        {
                            Main.instance.shop[Main.npcShop].item[k] = new Item();
                        }
                        Main.instance.shop[Main.npcShop].item[k].SetDefaults(Main.travelShop[k]);
                    }
                    Main.InGuideCraftMenu = false;
                    Main.InReforgeMenu    = false;
                    Main.recBigList       = false;
                    Main.playerInventory  = true;
                    chooseTalkingNPC(vm);
                }

                /*Nurse code overrides the normal vending machine shop for the behaviour of the nurse heal option.*/

                else if (type == NPCID.Nurse)
                {
                    int num5 = Main.player[Main.myPlayer].statLifeMax2 - Main.player[Main.myPlayer].statLife;
                    for (int k = 0; k < 22; k++)
                    {
                        int num6 = Main.player[Main.myPlayer].buffType[k];
                        if (Main.debuff[num6] && Main.player[Main.myPlayer].buffTime[k] > 5 && BuffLoader.CanBeCleared(num6))
                        {
                            num5 += 1000;
                        }
                    }

                    if (Main.player[Main.myPlayer].BuyItem(num5))
                    {
                        AchievementsHelper.HandleNurseService(num5);
                        Main.PlaySound(SoundID.Item4, -1, -1);
                        Main.player[Main.myPlayer].HealEffect(Main.player[Main.myPlayer].statLifeMax2 - Main.player[Main.myPlayer].statLife, true);
                        Main.player[Main.myPlayer].statLife = Main.player[Main.myPlayer].statLifeMax2;
                        for (int k = 0; k < 22; k++)
                        {
                            int num23 = Main.player[Main.myPlayer].buffType[k];
                            if (Main.debuff[num23] && Main.player[Main.myPlayer].buffTime[k] > 0 && BuffLoader.CanBeCleared(num23))
                            {
                                Main.player[Main.myPlayer].DelBuff(k);
                                k = -1;
                            }
                        }
                        return(true);
                    }
                }
                else
                {
                    Main.player[Main.myPlayer].chest = -1;
                    Main.npcChatText = "";
                    chooseTalkingNPC(vm);
                    Main.recBigList       = false;
                    Main.playerInventory  = true;
                    Main.InGuideCraftMenu = false;
                    Main.InReforgeMenu    = false;
                    Main.instance.shop[Main.npcShop].SetupShop(Main.npcShop < Main.MaxShopIDs - 1 ? Main.npcShop : type);
                }
            }
            return(true);
        }