Help with Hub game + random events [structuring variables]

Story Format: Sugarcube

(Plase keep in mind that english is not my native language)

The game will be like this:

In the Hub passage:

------> 1. Morning: Player wakes up.

----- > 2. Morning: Group events with friends.

Every morning will have a different group event, there will be 10 group-events in total, once player has seen all 10 this session is skipped.

The 10 group-events will have a separate passage each, but how do I show them in order (they’re not random events, they have an order) every morning until all 10 are shown? And then skip the morning for the player go directly to the afternoon.

----- > 3. Afternoon: Player choose between go on missions or go explore. Exploring costs action points. There will be 3 AP and every ending of mission resets the AP.

:black_small_square:︎Go to a mission.

There will always be 3 main missions per “chapter” plus some sidequests, once the three are done the story continues and add 3 new main missions. Each mission will have diferent sets of passages. I want the hub to always show:

  • Choose mission 1

  • Choose mission 2

  • Choose mission 3

  • Sidequest 1

  • Sidequest 2

(The missions dont need to be done in order)

Then:

<<if mission 1 is true>>Mission 1 completed<>

  • Choose mission 2
  • Choose mission 3

(Same thing for sidequests)

Once player has done all 3, the main story advances and 3 new missions will be shown. The hub will also have some changes and some new characters in it (I guess I can make a different hub here? Ir is best to have just one hub?)

  • Choose mission 4
  • Choose mission 5
  • Choose mission 6

New sidequests will be added too.

:black_small_square:︎Go explore the hub. (Costs Action Points)

There will be different rooms, each time that room will have a random npc.

  • Go to library
  • Go to main hall
    … And other locations

Every main npc have relationship events (like stardew valley). So for example, if player meet Ana in the library, they will see Ana first event. If they meet Jack there instead they will see Jack first event. If they encounter Ana again in the library or in another location, they will see Ana second event. And so on. Every character event will be in different passages.

The npc appearing in the locations are random but the character events have an order.

:black_small_square:︎Go explore the city (Costs Action Points)

To buy stuff in different shops. If possible, I wanted to add random events here as well, like be attacked by thiefs in the streets, between the hub and the shop. I also wanted to set “open/closed” days for the shops (see more bellow).

(Actions points are earned doing missions)

------ > 4. Go back to Hub.

Is there an easy way to keep track of the time so, for example, if the player returns from a mission very late at night they won’t be able to go explore?

Specifically to keep track of just hours, not minutes. So I could set the initial time to 7AM and use <> to add hours depending of the action taked. Then when the players go to sleep the time resets to 7AM. This, I can do.

I will also keep track of the days of the week and of the months too, for birthday events and for shop open/closed days. This, I dont know how to do.

(The game will last only 1 year I think)

------ > 5. Nigh: Sleep.

------ > 6. Repeat.


So… How is the best way to approach all that? I know this is probably a difficult system. Please if possible give me very detailed instructions, the more details the better.

Advices for this type of game will be appreciated too!

I know you asked for details, but I can at least give an overview. There may be a Twine expert who can give more specific details.

In general to run the type of game you’re describing, you need to get familiar with variables. (If your flavor of Twine has a built-in “visited” count for passages that can also be used.)

Essentially each task or quest should have a variable associated with it such as $mission1 or $sidequest1. You can make them as simple as true/false if you just want them to show up, or you can associate a number with them to keep track like
=0 not offered yet
=1 offered and displayed to player
=2 mission in progress, show different text
=3 mission completed and not shown

You may have more numbers depending on what you’re doing.

So on the main hub screen you’ll need to have a large array of your missions which will display to the player based the variable associated using if/else statements. (The following is not actual code, but just structure - I am used to AXMA which is mostly like Sugarcube but might be different.)

<<if $mission1 = 1>>You can go for a walk with Bob[link].<<elseif $mission1 = 2>>Take another walk with Bob. [link].<<elseif $mission1 = 3>>You're all tired out and don't want to go for a walk.<<endif>>

If the player meets a person somewhere in the game to go for a walk with:

<<if $mission1 = 0>>"Hey," says Bob. "Would you like to go for a walk some afternoon? If so, select it from your mission screen!"<<set $mission1 = 1>><<endif>>

That moves the variable so the $mission1 associated link text will show on the hub screen. You change the variable based on what the player has seen and what you’ve set up to show from the hub.

In the mission screen:

You go for a walk with Bob and enjoy the afternoon. <<set $mission1 = $mission1 + 1>><<set $actionpoints = $actionpoints +1>>

That increments the variable so the hub will show the mission is “in progress” or partially completed as you set up. It also gives the player an action point if that’s what they use to explore. In the case here, if the player goes on two walks, the variable will eventually hit 3 and tell them they are too tired to go on a walk.

Setting up an in-game clock can be done similarly with variables but is a bit more complicated. Unless you really want to go by hours and minutes, you might instead opt to segment your game-days with a $time variable that advances when you tell it to, such as after missions or when the player returns to the hub screen. So in this case, $time
=0 Morning
=1 Afternoon
=2 Evening
=3 Nighttime

You would also gate your choices with time variables. Say if the walks are only available in the afternoon period…

<set $time = $time +1>> (this makes time go forward when the player visits the hub)
<<if $time >= 4>><<set $time = 0>> (this resets from night time to morning if it's past night)

<<if $time = 1>> (checking if the time period is afternoon)
   <<if $mission1 = 1>>You can go for a walk with Bob[link].
   <<elseif $mission1 = 2>>Take another walk with Bob. [link].
   <<elseif $mission1 = 3>>You're all tired out and don't want to go for a walk.
   <<endif>>
<<endif>>
<<if $actionpoints > 0>> Go explore. [link]<<endif>>

<<if $time = 3>>Go to sleep. [link] <<endif>>

With the nested if-statements, the Mission 1 “walk” option only shows if the current time period is also afternoon - $time = 1 - even if the event is available.

That’s just the basics of how it works. It can get more complicated, and the actual code will depend on your Twine version. (I don’t remember if Sugarcube requires variable checking with eq for equals/= or gt for greater than/>.)

OH MY GOD, THANK YOU SO MUCH!!! Your answer is perfect and easy do understand!! Seriously, I will love you forever now hahaha

1 Like