private bool TryHealFarmer()
        {
            if (this.medkits > 0 && this.player.health < this.player.maxHealth && this.player.health > 0)
            {
                int healthBonus = (this.player.maxHealth / 100) * (this.player.getFriendshipHeartLevelForNPC(this.npc.Name) / 2); // % health bonus based on friendship hearts
                int health      = Math.Max(10, (1 / this.player.health * 10) + Game1.random.Next(0, (int)(this.player.maxHealth * .1f))) + healthBonus;
                this.player.health += health;
                this.healCooldown   = HEAL_COUNTDOWN;
                this.medkits--;

                if (this.player.health > this.player.maxHealth)
                {
                    this.player.health = this.player.maxHealth;
                }

                Game1.drawDialogue(this.npc, DialogueHelper.GetSpecificDialogueText(this.npc, this.player, "heal"));
                Game1.addHUDMessage(new HUDMessage(this.Csm.ContentLoader.LoadString("Strings/Strings:healed", this.npc.displayName, health), HUDMessage.health_type));
                this.hud.GlowSkill("doctor", Color.Lime, HEAL_COUNTDOWN / 60);
                this.Monitor.Log($"{this.npc.Name} healed you! Remaining medkits: {this.medkits}", LogLevel.Info);
                return(true);
            }

            if (this.medkits == 0)
            {
                this.Monitor.Log($"No medkits. {this.npc.Name} can't heal you!", LogLevel.Info);
                Game1.drawDialogue(this.npc, DialogueHelper.GetSpecificDialogueText(this.npc, this.player, "nomedkits"));
                this.medkits = -1;
            }

            return(false);
        }
示例#2
0
        private void ReactOnAsk(NPC companion, Farmer leader, string action)
        {
            switch (action)
            {
            case "dismiss":
                Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetSpecificDialogueText(companion, leader, "companionDismiss"), companion);
                this.dismissalDialogue = dismissalDialogue;
                DialogueHelper.DrawDialogue(dismissalDialogue);
                break;

            case "bag":
                Chest bag = this.StateMachine.Bag;
                this.StateMachine.Companion.currentLocation.playSound("openBox");
                Game1.activeClickableMenu = new ItemGrabMenu(bag.items, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), new ItemGrabMenu.behaviorOnItemSelect(bag.grabItemFromInventory), this.StateMachine.Companion.displayName, new ItemGrabMenu.behaviorOnItemSelect(bag.grabItemFromChest), false, true, true, true, true, 1, null, -1, this.StateMachine.Companion);
                break;
            }
        }
示例#3
0
        private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e)
        {
            this.StateMachine.Companion.clearSchedule();

            if (e.NewTime >= 2200)
            {
                NPC      companion         = this.StateMachine.Companion;
                Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetSpecificDialogueText(companion, this.StateMachine.CompanionManager.Farmer, "companionDismissAuto"), companion);
                this.dismissalDialogue = dismissalDialogue;
                this.StateMachine.Companion.doEmote(24);
                this.StateMachine.Companion.updateEmote(Game1.currentGameTime);
                DialogueHelper.DrawDialogue(dismissalDialogue);
            }

            // Fix spawn ladder if area is infested and all monsters is killed but NPC following us
            if (this.StateMachine.Companion.currentLocation is MineShaft mines && mines.mustKillAllMonstersToAdvance())
            {
                var monsters = from c in mines.characters where c.IsMonster select c;
                if (monsters.Count() == 0)
                {
                    Vector2 vector2 = this.StateMachine.Reflection.GetProperty <Vector2>(mines, "tileBeneathLadder").GetValue();
                    if (mines.getTileIndexAt(Utility.Vector2ToPoint(vector2), "Buildings") == -1)
                    {
                        mines.createLadderAt(vector2, "newArtifact");
                    }
                }
            }

            // Try to push new or change location dialogue randomly until or no location dialogue was pushed
            int until = this.dialoguePushTime + (Game1.random.Next(1, 3) * 10);

            if ((e.NewTime > until || this.currentLocationDialogue == null))
            {
                this.TryPushLocationDialogue(this.StateMachine.Companion.currentLocation);
            }

            // Remove recruited dialogue if this dialogue not spoken until a hour from while companion was recruited
            if (this.recruitedDialogue != null && e.NewTime > this.timeOfRecruit + 100)
            {
                // TODO: Use here Remove old dialogue method when rebased onto branch or merged branch which has this util
                Stack <Dialogue> temp = new Stack <Dialogue>(this.StateMachine.Companion.CurrentDialogue.Count);

                while (this.StateMachine.Companion.CurrentDialogue.Count > 0)
                {
                    Dialogue d = this.StateMachine.Companion.CurrentDialogue.Pop();

                    if (!d.Equals(this.recruitedDialogue))
                    {
                        temp.Push(d);
                    }
                    else
                    {
                        this.monitor.Log($"Recruited dialogue was removed from {this.StateMachine.Name}'s stack due to NPC was recruited a hour ago and dialogue still not spoken.");
                    }
                }

                while (temp.Count > 0)
                {
                    this.StateMachine.Companion.CurrentDialogue.Push(temp.Pop());
                }
            }
        }