NPC Creation: Events (part 2)

Okay! So first and foremost… Cameron isn’t going to mysteriously suddenly appear in town, she’s going to arrive by bus, and she’s going to move into the Boarding House while she completes her research.

This allows scope for another event, the Introduction (0 heart) event.

Now, here’s the tricky bit… We could have her arrive by bus, but what happens if the farmer leaves the farm by the north or south entrance? Then the farmer could run into her before seeing the introduction event! And if we set the introduction event to happen before she actually spawns in town, she’s going to be invisible for the remainder of the day!

Easiest option? Have her turn up on the farmer’s doorstep. There is still a chance the player might leave their house by another route (ie: warp totem), but most players will walk out their front door!

Here’s the code to set up the event:

{   "Action": "EditData", 

    "Target": "Data/Events/Farm",

    "Entries":{ ....

Now we need an ID# for this event. Since a lot of custom NPCs and other mods exist, it’s important that you choose a unique number: 7 to 8 digits is recommended. It is recommended to use your 4-digit Nexus ID followed by 3-4 other numbers. NOTE THESE DOWN SOMEWHERE!

Since Jasper’s mod is “5599” and Cameron will likely be an extension of that, let’s start with “55991001”.

You can add other pre-conditions too, but overall, I think it’s probably safest to have this event trigger No Matter What.

"55991001":

Next step is to set up your scene. Farm events are almost always the same. In fact, changing the positions of the actors actually won’t work and they will revert to the below. General set-up goes:

"music/viewport/actors' positions/skippable/pause 500/<event continues>"

The list of musical tracks can be found on the Great ID Spreadsheet, and you can play them through the links there, or by typing “debug music <trackname>” into the Smapi console (it does not like spaces though). You can also use “continue” or “none” but you cannot leave it blank.

Viewport is the co-ordinates the screen will be centered on.

"55991001": "continue/64 15/farmer 64 16 2 Peasbody 64 18 0/skippable/pause 1500/..."

(“skippable” should be included in most scenes, because it means if they crash, the player will be able to escape from them. You do not want the player to have to restart the game. The only time you would not include it would be: if the character had to give the player something, the information was essential, or you needed the scene to end with the character invisible. Non skippable scenes on the doorstep are generally OK, since the characters don’t move and they tend to be short.)

The next part I like to think of as running a play: you get to determine which way the character’s will face, what they will say, and what emotions they will display.

...speak Peasbody \"Oh hi there! I was wondering if you might be able to help me?#$b#I've just arrived from Zuzu City, and I'm afraid I'm lost.\"/emote farmer 8/pause 1000/speak Peasbody \"Oh, sorry! My name's Peasbody, Professor Cameron Peasbody.$1#$b#I was wondering if you'd be able to point me in the direction of the museum?$2\"/pause 500/emote farmer 16/pause 1000/...

(emote 8 = ?, emote 16 = !)

Why this reaction? Because Cameron isn’t going to load into the game until the farmer knows their name and has already drawn some conclusions about them, possibly negative conclusions.

So the next option should be a choice: to direct Cameron to the museum, or to put her in her place. For this we are going to use a question fork. There are two ways to do this, but this is the easiest, so we’ll start here.

...question fork0 \"...#Follow the path into town, it's just over the stream.#You should go back to Zuzu. We don't want you here.\"/fork HelpCameron/pause 500/emote Peasbody 60/pause 1500/speak Peasbody \"I thought village folk were meant to be friendly.$5\"/pause 500/emote farmer 12/pause 2500/faceDirection farmer 0/warp farmer -100 -100/viewport 64 15/playSound doorClose/pause 1000/emote Peasbody 28/pause 500/faceDirection Peasbody 2/speak Peasbody \"Okay... I suppose I deserved that.$2#$b#But...$2\"/pause 1000/faceDirection Peasbody 0/pause 1500/speak Peasbody \"This might be harder than I thought...$2\"/pause 2000/end",

Now, we need the alternate fork for if you do choose to not let your prejudice against Peasbody influence you (or perhaps you are just naturally helpful). This begins with the Key “HelpCameron”:

"HelpCameron": "pause 500/speak Peasbody \"Thanks! I hope to see you around sometime. I might be here for a while.\"/pause 500/faceDirection Peasbody 2/pause 1500/faceeDirection Peasbody 0/speak Peasbody \"Oh, hey, I hear there's a saloon in town. We could meet up for a drink there sometime.#$b#If you wanted to, that is?$2\"/pause 500/emote farmer 40/pause 1500/speak Peasbody \"Hey, no need to answer now. Don't be a stranger, okay? Later!$1\"/pause 1500/faceDirection Peasbody 2/pause 1500/end"

Now, how to test your event? For the above, it’s quite easy – all I have to do is exit the house. For other events, however, the easiest way to test them is to enter

debug ebi 55991001

into your Smapi console (that’s the black box that pops up when you load a modded game and shows what the mods are doing). For this to work, the mod Console Commands must be on your list. It’s added automatically with Smapi, so if you don’t have it, just install Smapi again.

There’s another neat debug command too. If you need to make adjustments to your event because it crashes, or the character walks in the wrong direction, or whatever, you can fix the code, save the file, and enter this into your Smapi console:

patch reload <unique ID>

Unique ID being what your mod is called in the manifest. Standard set up for these is: ModCreator Name.Mod Name(.Framework).

So: LemurKat.CameronNPC

This will reload the mod, and allow you to replay the event with your adjustments. Note that really bad crashes (lots of red text) will require a complete restart, and sometimes things may behalf a little differently after a patch reload (specifically, I’ve found, strings dialogue).

But what if we wanted the way you chose to answer the question to influence the way Peasbody acts towards you? In the next post, we will look at a slightly more complicated way to code a question fork, one that can be used to influence friendship, and also to flavor future dialogue.

Trouble shooting:

Events can require a lot of debugging! Before testing your event, I recommend you enable Debug Mode, this provides a pop up cursor box in which you can watch the steps of the event, and if it crashes, you can determine approximately where.

Common errors:

  • “Input string was not in the correct format”: Often means you’ve made an error with your actors’ positions, usually an additional space or you’ve forgotten to include the direction for the character to face. Can also mean extra space, you’re missing part of the command, or another typo (ie, spelt Elliott’s name wrong).
  • Invalid Command: <something>“: there’s something wrong with that line. Whether it’s that you’ve entered a musical track that doesn’t exist, or written a command wrong.

There are numerous ways to make a mistake in an event, and the more events you make, the smoother the first play through will get.

The SDV Discord is very helpful with finding the errors, so don’t be afraid to share. A lot of us love problem solving (and you can PM me there if you like: @lemurkat#3754)