using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using StardustCore.Events.Preconditions; using StardustCore.Events.Preconditions.TimeSpecific; using StardewValley; namespace StardustCore.Events { /// ///TODO: Figure out forked dialogue /// /// Helps in creating events based in code for stardew valley. /// https://stardewvalleywiki.com/Modding:Event_data /// /// A lot of the function comments were taken from the SDV wiki. /// public class EventHelper { /// /// Nexus user id for Omegasis (aka me). /// protected int nexusUserId = 32171640; /// /// Wraps SDV facing direction. /// public enum FacingDirection { Up, Right, Down, Left } public enum Layers { Back, Paths, Buildings, Front, AlwaysFront } public enum FestivalItemType { Pan, Sculpture, Rod, Sword, Hero, Joja, SlimeEgg } protected StringBuilder eventData; protected StringBuilder eventPreconditionData; protected List eventPreconditions; protected int eventID; public string eventName; public EventHelper() { this.eventData = new StringBuilder(); this.eventPreconditionData = new StringBuilder(); this.eventPreconditions = new List(); } public EventHelper(string EventName,int ID, LocationPrecondition Location, TimePrecondition Time, EventDayExclusionPrecondition NotTheseDays, EventStartData StartData) { this.eventName = EventName; this.eventData = new StringBuilder(); this.eventPreconditionData = new StringBuilder(); this.eventPreconditions = new List(); this.eventID = ID; this.add(Location); this.add(Time); this.add(NotTheseDays); this.add(StartData.ToString()); } public EventHelper(string EventName,int ID,List Conditions, EventStartData StartData) { this.eventName = EventName; this.eventID = ID; this.eventData = new StringBuilder(); this.eventPreconditions = new List(); this.eventPreconditionData = new StringBuilder(); foreach (var v in Conditions) { this.add(v); } this.add(StartData.ToString()); } /// /// Adds in the event precondition data to the string builder and appends seperators as necessary. /// /// public virtual void add(EventPrecondition Data) { this.eventPreconditions.Add(Data); if (this.eventPreconditionData.Length > 0) { this.eventPreconditionData.Append(this.getSeperator()); } this.eventPreconditionData.Append(Data.ToString()); } /// /// Adds in the data to the event data.Aka what happens during the event. /// /// public virtual void add(string Data) { if (this.eventData.Length > 0) { this.eventData.Append(this.getSeperator()); } this.eventData.Append(Data); } /// /// Adds in the data to the event data. Aka what happens during the event. /// /// public virtual void add(StringBuilder Builder) { this.add(Builder.ToString()); } /// /// Converts the direction to enum. /// /// /// protected virtual int getFacingDirectionNumber(FacingDirection Dir) { return (int)Dir; } /// /// Gets the layer string from the Layer enum. /// /// /// protected virtual string getLayerName(Layers Layer) { if (Layer == Layers.AlwaysFront) return "AlwaysFront"; if (Layer == Layers.Back) return "Back"; if (Layer == Layers.Buildings) return "Buildings"; if (Layer == Layers.Front) return "Front"; if (Layer == Layers.Paths) return "Paths"; return ""; } /// /// Gets the even parsing seperator. /// /// protected virtual string getSeperator() { return "/"; } /// /// Gets the starting event numbers based off of my nexus user id. /// /// protected virtual string getUniqueEventStartID() { string s = this.nexusUserId.ToString(); return s.Substring(0, 4); } /// /// Gets the id for the event. /// /// public virtual int getEventID() { return Convert.ToInt32(this.getUniqueEventStartID() + this.eventID.ToString()); } /// /// Checks to ensure I don't create a id value that is too big for nexus. /// /// /// protected virtual bool isIdValid(int IDToCheck) { if (IDToCheck > 2147483647 || IDToCheck < 0) return false; else return true; } /// /// Checks to ensure I don't create a id value that is too big for nexus. /// /// /// protected virtual bool isIdValid(string IDToCheck) { if (Convert.ToInt32(IDToCheck) > 2147483647 || Convert.ToInt32(IDToCheck) < 0) return false; else return true; } /// /// Gets the string representation for the event's data. /// /// public virtual string getEventString() { return this.eventData.ToString(); } /// /// Creates the Stardew Valley event from the given event data. /// /// /// protected virtual StardewValley.Event getEvent(Farmer PlayerActor = null) { return new StardewValley.Event(this.getEventString(), Convert.ToInt32(this.getEventID()), PlayerActor); } /// /// Checks to see if all of the event preconditions have been met and starts the event if so. /// public virtual void startEventAtLocationifPossible() { if (this.canEventOccur()) { //Game1.player.currentLocation.currentEvent = this.getEvent(); Game1.player.currentLocation.startEvent(this.getEvent()); } } //~~~~~~~~~~~~~~~~// // Validation // //~~~~~~~~~~~~~~~~// /// /// Checks to see if the event can occur. /// /// public virtual bool canEventOccur() { foreach (EventPrecondition eve in this.eventPreconditions) { if (eve.meetsCondition() == false) return false; } return true; } //~~~~~~~~~~~~~~~~// // Actions // //~~~~~~~~~~~~~~~~// /// /// Adds an object at the specified tile from the TileSheets\Craftables.png sprite sheet /// /// /// /// protected virtual void addBigProp(int xTile, int yTile, int ID) { StringBuilder b = new StringBuilder(); b.Append("addBigProp "); b.Append(xTile.ToString()); b.Append(" "); b.Append(yTile.ToString()); b.Append(" "); b.Append(ID.ToString()); this.add(b); } /// /// Starts an active dialogue event with the given ID and a length of 4 days. /// /// protected virtual void addConversationTopic(string ID) { StringBuilder b = new StringBuilder(); b.Append("addBigProp "); b.Append(ID); this.add(b); } /// /// Adds the specified cooking recipe to the player. /// /// protected virtual void addCookingRecipe(string Recipe) { StringBuilder b = new StringBuilder(); b.Append("addCookingRecipe "); b.Append(Recipe); this.add(b); } /// /// Adds the specified crafting recipe to the player. /// /// protected virtual void addCraftingRecipe(string Recipe) { StringBuilder b = new StringBuilder(); b.Append("addCraftingRecipe "); b.Append(Recipe); this.add(b); } /// /// Add a non-solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height. /// protected virtual void addFloorProp(int PropIndex, int XTile, int YTile, int SolidWidth, int SolidHeight, int DisplayHeight) { StringBuilder b = new StringBuilder(); b.Append("addFloorProp "); b.Append(PropIndex.ToString()); b.Append(" "); b.Append(XTile.ToString()); b.Append(" "); b.Append(YTile.ToString()); b.Append(" "); b.Append(SolidWidth.ToString()); b.Append(" "); b.Append(SolidHeight.ToString()); b.Append(" "); b.Append(DisplayHeight.ToString()); this.add(b); } /// /// Adds a glowing temporary sprite at the specified tile from the Maps\springobjects.png sprite sheet. A light radius of 0 just places the sprite. /// /// /// /// /// protected virtual void addLantern(int ItemID, int XPosition, int YPosition, float LightRadius) { StringBuilder b = new StringBuilder(); b.Append("addLantern "); b.Append(ItemID.ToString()); b.Append(" "); b.Append(XPosition.ToString()); b.Append(" "); b.Append(YPosition.ToString()); b.Append(" "); b.Append(LightRadius.ToString()); this.add(b); } /// /// Set a letter as received. /// /// protected virtual void addMailReceived(string ID) { StringBuilder b = new StringBuilder(); b.Append("addMailReceived "); b.Append(ID); this.add(b); } /// /// Adds a temporary sprite at the specified tile from the Maps\springobjects.png sprite sheet. /// /// /// /// /// protected virtual void addObject(int XTile, int YTile, int ParentSheetIndex, string Layer) { StringBuilder b = new StringBuilder(); b.Append("addObject "); b.Append(XTile.ToString()); b.Append(" "); b.Append(YTile.ToString()); b.Append(" "); b.Append(Layer); this.add(b); } /// /// Adds a temporary sprite at the specified tile from the Maps\springobjects.png sprite sheet. /// /// /// /// /// protected virtual void addObject(int XTile, int YTile, int ParentSheetIndex, Layers Layer) { StringBuilder b = new StringBuilder(); b.Append("addObject "); b.Append(XTile.ToString()); b.Append(" "); b.Append(YTile.ToString()); b.Append(" "); b.Append(this.getLayerName(Layer)); this.add(b); } /// /// Add a solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height. /// /// /// /// /// /// /// protected virtual void addProp(int Index, int XTile, int YTile, int SolidWidth, int SolidHeight, int DisplayHeight) { StringBuilder b = new StringBuilder(); b.Append("addProp "); b.Append(Index.ToString()); b.Append(" "); b.Append(XTile.ToString()); b.Append(" "); b.Append(YTile.ToString()); b.Append(" "); b.Append(SolidWidth.ToString()); b.Append(" "); b.Append(SolidHeight.ToString()); b.Append(" "); b.Append(DisplayHeight.ToString()); this.add(b); } /// /// Add the specified quest to the quest log. /// /// public virtual void addQuest(int QuestID) { StringBuilder b = new StringBuilder(); b.Append("addQuest "); b.Append(QuestID.ToString()); this.add(b); } /// /// Add a temporary actor. 'breather' is boolean. The category determines where the texture will be loaded from, default is Character. Animal name only applies to animal. /// /// /// /// /// /// /// /// public virtual void addTemporaryActor_NPC(NPC npc, int SpriteWidth, int SpriteHeight, int TileX, int TileY, FacingDirection Direction, bool Breather) { StringBuilder b = new StringBuilder(); b.Append("addTemporaryActor "); b.Append(npc.Name); b.Append(" "); b.Append(SpriteWidth.ToString()); b.Append(" "); b.Append(SpriteHeight.ToString()); b.Append(" "); b.Append(TileX.ToString()); b.Append(" "); b.Append(TileY.ToString()); b.Append(" "); b.Append(Direction); b.Append(" "); b.Append("Character"); this.add(b); } /// /// Add a temporary actor. 'breather' is boolean. The category determines where the texture will be loaded from, default is Character. Animal name only applies to animal. /// /// /// /// /// /// /// /// /// public virtual void addTemporaryActor_Animal(string character, int SpriteWidth, int SpriteHeight, int TileX, int TileY, FacingDirection Direction, bool Breather, string AnimalName) { StringBuilder b = new StringBuilder(); b.Append("addTemporaryActor "); b.Append(character); b.Append(" "); b.Append(SpriteWidth.ToString()); b.Append(" "); b.Append(SpriteHeight.ToString()); b.Append(" "); b.Append(TileX.ToString()); b.Append(" "); b.Append(TileY.ToString()); b.Append(" "); b.Append(Direction); b.Append(" "); b.Append("Animal"); b.Append(" "); b.Append(AnimalName); this.add(b); } /// /// Add a temporary actor. 'breather' is boolean. The category determines where the texture will be loaded from, default is Character. Animal name only applies to animal. /// /// /// /// /// /// /// /// public virtual void addTemporaryActor_Monster(string character, int SpriteWidth, int SpriteHeight, int TileX, int TileY, FacingDirection Direction, bool Breather) { StringBuilder b = new StringBuilder(); b.Append("addTemporaryActor "); b.Append(character); b.Append(" "); b.Append(SpriteWidth.ToString()); b.Append(" "); b.Append(SpriteHeight.ToString()); b.Append(" "); b.Append(TileX.ToString()); b.Append(" "); b.Append(TileY.ToString()); b.Append(" "); b.Append(Direction); b.Append(" "); b.Append("Monster"); this.add(b); } /// /// Places on object on the furniture at a position. If the location is FarmHouse, then it will always be placed on the initial table. /// /// /// /// public virtual void addToTable(int XPosition, int YPosition, int ObjectParentSheetIndex) { StringBuilder b = new StringBuilder(); b.Append("addToTable "); b.Append(XPosition); b.Append(" "); b.Append(YPosition); b.Append(" "); b.Append(ObjectParentSheetIndex); this.add(b); } /// /// Adds the Return Scepter to the player's inventory. /// public virtual void addTool_ReturnScepter() { StringBuilder b = new StringBuilder(); b.Append("addTool Wand"); this.add(b); } /// /// Set multiple movements for an NPC. You can set True to have NPC walk the path continuously. Example: /advancedMove Robin false 0 3 2 0 0 2 -2 0 0 -2 2 0/ /// /// /// /// public virtual void advanceMove(NPC npc, bool Loop, List TilePoints) { StringBuilder b = new StringBuilder(); b.Append("advancedMove "); b.Append(npc.Name); b.Append(" "); b.Append(Loop.ToString()); b.Append(" "); for (int i = 0; i < TilePoints.Count; i++) { b.Append(TilePoints[i].X); b.Append(" "); b.Append(TilePoints[i].Y); if (i != TilePoints.Count - 1) { b.Append(" "); } } this.add(b); } /// /// Modifies the ambient light level, with RGB values from 0 to 255. Note that it works by removing colors from the existing light ambience, so ambientLight 1 80 80 would reduce green and blue and leave the light with a reddish hue. /// /// /// /// public virtual void setAmbientLight(int r, int g, int b) { StringBuilder builder = new StringBuilder(); builder.Append("ambientLight "); builder.Append(r); builder.Append(" "); builder.Append(g); builder.Append(" "); builder.Append(b); this.add(builder); } /// /// Modifies the ambient light level, with RGB values from 0 to 255. Note that it works by removing colors from the existing light ambience, so ambientLight 1 80 80 would reduce green and blue and leave the light with a reddish hue. /// /// public virtual void setAmbientLight(Color color) { this.setAmbientLight(color.R, color.G, color.B); } //animalNaming public virtual void animalNaming() { StringBuilder b = new StringBuilder(); b.Append("animalNaming"); this.add(b); } /// /// Animate a named actor, using one or more from their sprite sheet, for milliseconds per frame. indicates whether to flip the sprites along the Y axis; indicates whether to repeat the animation until stopAnimation is used. /// /// /// /// /// In milliseconds /// public virtual void animate(string ActorName, bool Flip, bool Loop, int FrameDuration, List Frames) { StringBuilder b = new StringBuilder(); b.Append("animate "); b.Append(ActorName); b.Append(" "); b.Append(Flip); b.Append(" "); b.Append(Loop); b.Append(" "); b.Append(FrameDuration); b.Append(" "); for (int i = 0; i < Frames.Count; i++) { b.Append(Frames[i]); if (i != Frames.Count - 1) { b.Append(" "); } } this.add(b); } /// /// Attach an actor to the most recent temporary sprite. /// /// public virtual void attachCharacterToTempSprite(string Actor) { StringBuilder b = new StringBuilder(); b.Append("attachCharacterToTempSprite "); b.Append(Actor); this.add(b); } /// /// Awards the festival prize to the winner for the easter egg hunt and ice fishing contest. /// public virtual void awardFestivalPrize() { StringBuilder b = new StringBuilder(); b.Append("awardFestivalPrize"); this.add(b); } /// /// Awards the specified item to the player. Possible item types are "pan", "sculpture", "rod", "sword", "hero", "joja", and "slimeegg". /// /// public virtual void awardFestivalPrize(FestivalItemType ItemType) { StringBuilder b = new StringBuilder(); b.Append("awardFestivalPrize "); if (ItemType == FestivalItemType.Hero) { b.Append("hero"); } else if (ItemType == FestivalItemType.Joja) { b.Append("joja"); } else if (ItemType == FestivalItemType.Pan) { b.Append("pan"); } else if (ItemType == FestivalItemType.Rod) { b.Append("rod"); } else if (ItemType == FestivalItemType.Sculpture) { b.Append("sculpture"); } else if (ItemType == FestivalItemType.SlimeEgg) { b.Append("slimeegg"); } else if (ItemType == FestivalItemType.Sword) { b.Append("sword"); } this.add(b); } /// /// Causes the event to be seen by all players when triggered. /// public virtual void broadcastEvent() { StringBuilder b = new StringBuilder(); b.Append("broadcastEvent"); this.add(b); } /// /// Trigger question about adopting your pet. /// public virtual void petAdoptionQuestion() { StringBuilder b = new StringBuilder(); b.Append("catQuestion"); this.add(b); } /// /// Trigger the question for the farm cave type. This will work again later, however changing from bats to mushrooms will not remove the mushroom spawning objects. /// public virtual void farmCaveTypeQuestion() { StringBuilder b = new StringBuilder(); b.Append("cave"); this.add(b); } /// /// Change to another location and run the remaining event script there. /// /// public virtual void changeLocation(GameLocation location) { StringBuilder b = new StringBuilder(); b.Append("changeLocation "); b.Append(location.NameOrUniqueName); this.add(b); } /// /// Change to another location and run the remaining event script there. /// /// public virtual void changeLocation(string location) { StringBuilder b = new StringBuilder(); b.Append("changeLocation "); b.Append(location); this.add(b); } /// /// Change the specified tile to a particular value. /// /// /// /// /// public virtual void changeMapTile(Layers l, int X, int Y, int TileIndex) { StringBuilder b = new StringBuilder(); b.Append("changeMapTile "); b.Append(this.getLayerName(l)); b.Append(" "); b.Append(X); b.Append(" "); b.Append(Y); b.Append(" "); b.Append(TileIndex); this.add(b); } /// /// Change the NPC's portrait to be from "Portraits/_". /// /// /// public virtual void changePortrait(string npc, string Portrait) { StringBuilder b = new StringBuilder(); b.Append("changePortrait "); b.Append(npc); b.Append(" "); b.Append(Portrait); this.add(b); } /// /// Change the actor's sprite to be from "Characters/_". /// /// /// public virtual void changeSprite(string npc, string Sprite) { StringBuilder b = new StringBuilder(); b.Append("changeSprite "); b.Append(npc); b.Append(" "); b.Append(Sprite); this.add(b); } /// /// Change the location to a temporary one loaded from the map file specified by . The [pan] argument indicates the tile coordinates to pan to (defaults to 0, 0). /// /// public virtual void changeToTemporaryMap(string Map) { StringBuilder b = new StringBuilder(); b.Append("changeToTemporaryMap "); b.Append(Map); this.add(b); } /// /// Change the location to a temporary one loaded from the map file specified by . The [pan] argument indicates the tile coordinates to pan to (defaults to 0, 0). /// /// /// public virtual void changeToTemporaryMap(string Map, Point PanPosition) { StringBuilder b = new StringBuilder(); b.Append("changeToTemporaryMap "); b.Append(Map); b.Append(" "); b.Append(PanPosition.X); b.Append(" "); b.Append(PanPosition.Y); this.add(b); } /// /// Changes the NPC's vertical texture offset. Example: changeYSourceRectOffset Abigail 96 will offset her sprite sheet, showing her looking left instead of down. This persists for the rest of the event. This is only used in Emily's Clothing Therapy event to display the various outfits properly. /// /// /// public virtual void changeYSourceRectOffset(string NPC, int YOffset) { StringBuilder b = new StringBuilder(); b.Append("changeYSourceRectOffset "); b.Append(NPC); b.Append(" "); b.Append(YOffset); this.add(b); } /// /// Acts as if the player had clicked the specified x/y coordinate and triggers any relevant action. It is commonly used to open doors from inside events, but it can be used for other purposes. If you use it on an NPC you will talk to them, and if the player is holding an item they will give that item as a gift. doAction activates objects in the main game world (their actual location outside of the event), so activating NPCs like this is very tricky, and their reaction varies depending on what the player is holding. /// /// /// public virtual void doAction(int x, int y) { StringBuilder b = new StringBuilder(); b.Append("doAction "); b.Append(x); b.Append(" "); b.Append(y); this.add(b); } /// /// Make the given NPC name perform an emote, which is a little icon shown above the NPC's head. Emotes are stored in Content\TileSheets\emotes.xnb (see list of emotes). /// /// /// public virtual void emote(string Actor, int EmoteID) { StringBuilder b = new StringBuilder(); b.Append("emote "); b.Append(Actor); b.Append(" "); b.Append(EmoteID); this.add(b); } /// /// Ends the current event by fading out, then resumes the game world and places the player on the square where they entered the zone. All end parameters do this by default unless otherwise stated. /// public virtual void end() { StringBuilder b = new StringBuilder(); b.Append("end"); this.add(b); } /// /// Same as end, and additionally clears the existing NPC dialogue for the day and replaces it with the line(s) specified at the end of the command. Example usage: end dialogue Abigail "It was fun talking to you today.$h" /// /// /// public virtual void endDialogue(NPC npc, string Dialogue) { StringBuilder b = new StringBuilder(); b.Append("end dialogue "); b.Append(npc.Name); b.Append(" "); b.Append(Dialogue); this.add(b); } /// /// Ends the event, sets npc dialogue, and warps the player out of the location. /// /// /// public virtual void endDialogueWarpOut(NPC npc, string Dialogue) { StringBuilder b = new StringBuilder(); b.Append("end dialogueWarpOut "); b.Append(npc.Name); b.Append(" "); b.Append(Dialogue); this.add(b); } /// /// Same as end, and additionally turns the specified NPC invisible (cannot be interacted with until the next day). /// /// public virtual void endInvisible(NPC npc) { StringBuilder b = new StringBuilder(); b.Append("end invisible "); b.Append(npc.Name); b.Append(" "); this.add(b); } public virtual void endInvisibleWarpOut(NPC npc) { StringBuilder b = new StringBuilder(); b.Append("end invisibleWarpOut "); b.Append(npc.Name); b.Append(" "); this.add(b); } /// /// Ends both the event and the day (warping player to their bed, saving the game, selling everything in the shipping box, etc). /// public virtual void endNewDay() { StringBuilder b = new StringBuilder(); b.Append("end newDay"); this.add(b); } /// /// Same as end, and additionally warps the player to the map coordinates specified in x y. /// /// /// public virtual void endPosition(int xTile, int yTile) { StringBuilder b = new StringBuilder(); b.Append("end position"); b.Append(xTile); b.Append(" "); b.Append(yTile); this.add(b); } public virtual void endWarpOut() { StringBuilder b = new StringBuilder(); b.Append("end warpOut"); this.add(b); } public virtual void playerFaceDirection(FacingDirection Dir) { StringBuilder b = new StringBuilder(); b.Append("faceDirection farmer "); b.Append(this.getFacingDirectionNumber(Dir).ToString()); b.Append(" "); b.Append(true); this.add(b); } public virtual void npcFaceDirection(NPC NPC, FacingDirection Dir) { StringBuilder b = new StringBuilder(); b.Append("faceDirection "); b.Append(NPC.Name); b.Append(" "); b.Append(this.getFacingDirectionNumber(Dir).ToString()); b.Append(" "); b.Append(true); this.add(b); } /// /// Fades out the screen. /// public virtual void fadeOut() { StringBuilder b = new StringBuilder(); b.Append("fade true"); this.add(b); } public virtual void fadeIn() { StringBuilder b = new StringBuilder(); b.Append("fade"); this.add(b); } /// /// Makes the farmer eat an object. /// /// public virtual void farmerEatObject(int ID) { StringBuilder b = new StringBuilder(); b.Append("farmerEat "); b.Append(ID); this.add(b); } //TODO: Support event forking. /// /// Add the given number of friendship points with the named NPC. (There are 250 points per heart.) /// /// /// public virtual void addFriendship(NPC NPC, int Amount) { StringBuilder b = new StringBuilder(); b.Append("friendship "); b.Append(NPC.Name); b.Append(" "); b.Append(Amount); this.add(b); } /// /// Fade to black at a particular speed (default 0.007). If no speed is specified, the event will continue immediately; otherwise, it will continue after the fade is finished. The fade effect disappears when this command is done; to avoid that, use the viewport command to move the camera off-screen. /// /// public virtual void globalFadeOut(double speed=0.007) { StringBuilder b = new StringBuilder(); b.Append("globalFade "); b.Append(speed); this.add(b); } public virtual void globalFadeIn(double speed=0.007) { StringBuilder b = new StringBuilder(); b.Append("globalFadeToClear "); b.Append(speed); this.add(b); } /// /// Fade to clear (unfade?) at a particular speed (default 0.007). If no speed is specified, the event will continue immediately; otherwise, it will continue after the fade is finished. /// /// public virtual void globalFadeToClear(double speed) { StringBuilder b = new StringBuilder(); b.Append("globalFadeToClear "); b.Append(speed); this.add(b); } /// /// Make the screen glow once, fading into and out of the values over the course of a second. If is true it will fade to and hold that color until stopGlowing is used. /// /// /// public virtual void glow(Color color, bool Hold) { StringBuilder b = new StringBuilder(); b.Append("glow "); b.Append(color.R); b.Append(" "); b.Append(color.G); b.Append(" "); b.Append(color.B); b.Append(" "); b.Append(Hold); this.add(b); } /// /// Stops npc movement /// public virtual void stopNPCMovement() { StringBuilder b = new StringBuilder(); b.Append("halt"); this.add(b); } /// /// Stops npc movement. /// public virtual void halt() { this.stopNPCMovement(); } /// /// Make a the named NPC jump. The default intensity is 8. /// /// /// public virtual void actorJump(string ActorName, int Intensity=8) { StringBuilder b = new StringBuilder(); b.Append("jump "); b.Append(Intensity); this.add(b); } /// /// Queue a letter to be received tomorrow (see Content\Data\mail.xnb for available mail). /// /// public virtual void addMailForTomorrow(string LetterID) { StringBuilder b = new StringBuilder(); b.Append("mail "); b.Append(LetterID); this.add(b); } /// /// Show a dialogue box (no speaker). See dialogue format for the format. /// /// public virtual void showMessage(string Message) { StringBuilder b = new StringBuilder(); b.Append("message "); b.Append("\\\""); b.Append(Message); b.Append("\""); this.add(b); } /// /// Make a named NPC move by the given tile offset from their current position (along one axis only), and face the given direction when they're done. To move along multiple axes, you must specify multiple move commands. By default the event pauses while a move command is occurring, but if is set to true the movement is asynchronous and will run simultaneously with other event commands. /// /// /// /// /// /// public virtual void moveNPC(NPC npc, int xOffset, int yOffset, FacingDirection Dir, bool Continue) { StringBuilder b = new StringBuilder(); b.Append("move "); b.Append(npc.Name); b.Append(" "); b.Append(xOffset); b.Append(" "); b.Append(yOffset); b.Append(" "); b.Append(this.getFacingDirectionNumber(Dir)); b.Append(" "); b.Append(Continue); this.add(b); } public virtual void moveNPCUp(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection,bool EventDoesntPause) { this.moveNPC(npc, 0, -TileAmount, FinishingFacingDirection, EventDoesntPause); } public virtual void moveNPCDown(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveNPC(npc, 0, TileAmount, FinishingFacingDirection, EventDoesntPause); } public virtual void moveNPCLeft(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveNPC(npc, TileAmount,0,FinishingFacingDirection, EventDoesntPause); } public virtual void moveNPCRight(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveNPC(npc,-TileAmount,0,FinishingFacingDirection, EventDoesntPause); } public virtual void moveFarmer(int xOffset, int yOffset, FacingDirection Dir, bool Continue) { StringBuilder b = new StringBuilder(); b.Append("move "); b.Append("farmer"); b.Append(" "); b.Append(xOffset); b.Append(" "); b.Append(yOffset); b.Append(" "); b.Append(this.getFacingDirectionNumber(Dir)); b.Append(" "); b.Append(Continue); this.add(b); } public virtual void moveFarmerUp(int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveFarmer(0, -TileAmount, FinishingFacingDirection, EventDoesntPause); } public virtual void moveFarmerDown(int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveFarmer(0, TileAmount, FinishingFacingDirection, EventDoesntPause); } public virtual void moveFarmerLeft(int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveFarmer(-TileAmount,0,FinishingFacingDirection, EventDoesntPause); } public virtual void moveFarmerRight(int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) { this.moveFarmer(TileAmount, 0,FinishingFacingDirection, EventDoesntPause); } /// /// Pause the game for the given number of milliseconds. /// /// public virtual void pauseGame(int Milliseconds) { StringBuilder b = new StringBuilder(); b.Append("pause "); b.Append(Milliseconds); this.add(b); } /// /// Play the specified music track ID. If the track is 'samBand', the track played will change depend on certain dialogue answers (76-79). /// /// public virtual void playMusic(string id) { StringBuilder b = new StringBuilder(); b.Append("playMusic "); b.Append(id); this.add(b); } /// /// Play a given sound ID from the game's sound bank. /// /// public virtual void playSound(string id) { StringBuilder b = new StringBuilder(); b.Append("playSound "); b.Append(id); this.add(b); } /// /// Give the player control back. /// public virtual void givePlayerControl() { StringBuilder b = new StringBuilder(); b.Append("playSound "); this.add(b); } /// /// Offset the position of the named NPC by the given number of pixels. This happens instantly, with no walking animation. /// /// /// /// public virtual void positionOffset(string ActorName,int PixelsX, int PixelsY) { StringBuilder b = new StringBuilder(); b.Append("positionOffset "); b.Append(PixelsX); b.Append(" "); b.Append(PixelsY); this.add(b); } /// /// Show a dialogue box with some answers and an optional question. When the player chooses an answer, the event script continues with no other effect. /// /// /// /// public virtual void questionNoFork(string Question, string Answer1, string Answer2) { StringBuilder b = new StringBuilder(); b.Append("question null "); b.Append(Question); b.Append("#"); b.Append(Answer1); b.Append("#"); b.Append(Answer2); this.add(b); } /// /// Remove the first of an object from a player's inventory. /// /// public virtual void removeItem(int ParentSheetIndex) { StringBuilder b = new StringBuilder(); b.Append("removeItem "); b.Append(ParentSheetIndex); this.add(b); } /// /// /// /// /// public virtual void removeObject(int TileX, int TileY) { StringBuilder b = new StringBuilder(); b.Append("removeObject "); b.Append(TileX); b.Append(" "); b.Append(TileY); this.add(b); } /// /// Remove the specified quest from the quest log. /// /// public virtual void removeQuest(int ID) { StringBuilder b = new StringBuilder(); b.Append("removeQuest "); b.Append(ID); this.add(b); } /// /// Remove the temporary sprite at a position. /// /// /// public virtual void removeSprite(int XTile, int YTile) { StringBuilder b = new StringBuilder(); b.Append("removeSprite "); b.Append(" "); b.Append(XTile); b.Append(" "); b.Append(YTile); this.add(b); } /// /// Remove all temporary sprites. /// public virtual void removeTemporarySprites() { StringBuilder b = new StringBuilder(); b.Append("removeTemporarySprites"); this.add(b); } /// /// Flashes the screen white for an instant. An alpha value from 0 to 1 adjusts the brightness, and values from 1 and out flashes pure white for x seconds. /// /// public virtual void screenFlash(float Alpha) { StringBuilder b = new StringBuilder(); b.Append("screenFlash "); b.Append(Alpha); this.add(b); } public virtual void setPlayerRunning() { StringBuilder b = new StringBuilder(); b.Append("setRunning"); this.add(b); } public virtual void shakeNPC(NPC npc,int Milliseconds) { StringBuilder b = new StringBuilder(); b.Append("shake "); b.Append(npc.Name); b.Append(" "); b.Append(Milliseconds); this.add(b); } public virtual void shakeFarmer(int Milliseconds) { StringBuilder b = new StringBuilder(); b.Append("shake "); b.Append("farmer"); b.Append(" "); b.Append(Milliseconds); this.add(b); } /// /// Set the named NPC's current frame in their Content\Characters\*.xnb spritesheet. Note that setting the farmer's sprite only changes parts of the sprite (some times arms, some times arms and legs and torso but not the head, etc). To rotate the whole sprite, use faceDirection farmer <0/1/2/3> first before modifying the sprite with showFrame. Frame ID starts from 0. If farmer is the one whose frame is being set, "farmer" can be eliminated, i.e. both showFrame farmer and showFrame would work. /// /// /// public virtual void showNPCFrame(NPC npc, int FrameIndex) { StringBuilder b = new StringBuilder(); b.Append("showFrame "); b.Append(npc.Name); b.Append(" "); b.Append(FrameIndex); this.add(b); } /// /// Shows the given frame for the farmer. Forces the farmer to rotate first as specified by the wiki, /// /// /// public virtual void showFrameFarmer(FacingDirection Direction,int FrameIndex) { this.playerFaceDirection(Direction); StringBuilder b = new StringBuilder(); b.Append("showFrame "); b.Append(FrameIndex); this.add(b); } //Skippable is enabled by default. /// /// Show dialogue text from a named NPC; see dialogue format. /// /// /// public virtual void speak(NPC npc, string Message) { StringBuilder b = new StringBuilder(); b.Append("speak "); b.Append(npc.Name); b.Append(" "); b.Append(Message); this.add(b); } /// /// Make the player start jittering. /// public virtual void playerJitter() { StringBuilder b = new StringBuilder(); b.Append("startJittering"); this.add(b); } /// /// Stop movement from advancedMove. /// public virtual void stopAdvancedMoves() { StringBuilder b = new StringBuilder(); b.Append("stopAdvancedMoves"); this.add(b); } /// /// Stop the farmer's current animation. /// public virtual void stopFarmerAnimation() { StringBuilder b = new StringBuilder(); b.Append("stopAnimation farmer"); this.add(b); } /// /// Stop the named NPC's current animation. Not applicable to the farmer. /// /// /// public virtual void stopNPCAnimation(NPC npc, int EndFrame) { StringBuilder b = new StringBuilder(); b.Append("stopAnimation "); b.Append(npc.Name); b.Append(" "); b.Append(EndFrame); this.add(b); } /// /// Make the screen stop glowing. /// public virtual void stopGlowing() { StringBuilder b = new StringBuilder(); b.Append("stopGlowing"); this.add(b); } /// /// Make the player stop jittering. /// public virtual void stopJittering() { StringBuilder b = new StringBuilder(); b.Append("stopJittering"); this.add(b); } /// /// Stop any currently playing music. /// public virtual void stopMusic() { StringBuilder b = new StringBuilder(); b.Append("stopMusic"); this.add(b); } /// /// Make the farmer stop running. /// public virtual void stopRunning() { StringBuilder b = new StringBuilder(); b.Append("stopRunning"); this.add(b); } /// /// Make the farmer stop swimming. /// public virtual void stopFarmerSwimming() { StringBuilder b = new StringBuilder(); b.Append("stopSwimming farmer"); this.add(b); } /// /// Make the npc stop swimming. /// public virtual void stopNPCSwimming(NPC npc) { StringBuilder b = new StringBuilder(); b.Append("stopSwimming "); b.Append(npc.Name); this.add(b); } /// /// Make the farmer start swimming. /// public virtual void startFarmerSwimming() { StringBuilder b = new StringBuilder(); b.Append("swimming farmer"); this.add(b); } /// /// Make the npc start swimming. /// /// public virtual void startNPCSwimming(NPC npc) { StringBuilder b = new StringBuilder(); b.Append("swimming "); b.Append(npc.Name); this.add(b); } /// /// Changes the current event (ie. event commands) to another event in the same location. /// /// public virtual void switchEvent(int ID) { StringBuilder b = new StringBuilder(); b.Append("switchEvent "); b.Append(ID); this.add(b); } /// /// Create a temporary sprite with the given parameters. /// /// /// /// /// /// /// /// public virtual void temporarySprite(int XPos, int YPos, int Index, int AnimationLength, int AnimationInterval, bool Looped, int LoopCount) { StringBuilder b = new StringBuilder(); b.Append("temporarySprite "); b.Append(XPos); b.Append(" "); b.Append(YPos); b.Append(" "); b.Append(Index); b.Append(" "); b.Append(AnimationLength); b.Append(" "); b.Append(AnimationInterval); b.Append(" "); b.Append(Looped); b.Append(" "); b.Append(LoopCount); this.add(b); } /// /// Show a small text bubble over the named NPC's head with the given text; see dialogue format. /// /// /// public virtual void showSpeechBubble(NPC npc, string Message) { StringBuilder b = new StringBuilder(); b.Append("textAboveHead "); b.Append(npc.Name); b.Append(" "); b.Append(Message); this.add(b); } /// /// Pan the the camera in the direction (and with the velocity) defined by x/y for the given duration in milliseconds. Example: "viewport move 2 -1 5000" moves the camera 2 pixels right and 1 pixel up for 5 seconds. /// /// /// /// public virtual void panViewport(int xPixelAmount, int yPixelAmount, int MillisecondDuration) { StringBuilder b = new StringBuilder(); b.Append("viewport move "); b.Append(xPixelAmount); b.Append(" "); b.Append(yPixelAmount); b.Append(" "); b.Append(MillisecondDuration); this.add(b); } /// /// Instantly reposition the camera to center on the given X, Y tile position. TODO: explain other parameters. /// /// /// public virtual void setViewportPosition(int XPosition, int YPosition) { StringBuilder b = new StringBuilder(); b.Append("viewport "); b.Append(XPosition); b.Append(" "); b.Append(YPosition); b.Append(" "); b.Append("true"); this.add(b); } /// /// Wait for other players (vanilla MP). /// public virtual void waitForAllPlayers() { StringBuilder b = new StringBuilder(); b.Append("waitForOtherPlayers"); this.add(b); } /// /// Warp the named NPC to a position to the given X, Y tile coordinate. This can be used to warp characters off-screen. /// /// /// public virtual void warpPlayer(int x, int y) { StringBuilder b = new StringBuilder(); b.Append("warp farmer "); b.Append(x); b.Append(" "); b.Append(y); this.add(b); } /// /// Warp the named NPC to a position to the given X, Y tile coordinate. This can be used to warp characters off-screen. /// /// /// /// public virtual void warpActor(string ActorName,int x, int y) { StringBuilder b = new StringBuilder(); b.Append("warp "); b.Append(ActorName); b.Append(" "); b.Append(x); b.Append(" "); b.Append(y); this.add(b); } public virtual void warpNPC(NPC NPC, int x, int y) { StringBuilder b = new StringBuilder(); b.Append("warp "); b.Append(NPC.Name); b.Append(" "); b.Append(x); b.Append(" "); b.Append(y); this.add(b); } } }