Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Twine 2.1.1][SugarCube 2.14] Traversing to a passage when a condition is met

edited April 2017 in Help! with 2.0
Hey there!

I'm in the process of creating a way to automatically travel to a location without entering an infinite loop. Now, I've seen two methods of doing this. There's a topic about this, but I can't seem to find it (not even with google, the title must've been confusing). That concept showed using 'PassageHeader' (?, probably not, no idea...) and a boolean to send the player to somewhere else when an event is triggered.

I also remember TME posted a code, which enables one to override the next passage when a certain time has passed in game (event occurs):
This can be found here:
https://twinery.org/forum/discussion/8533/sugarcube-2-16-0-how-to-display-links-based-on-player-action-without-a-page-reload#latest

Does anyone know more methods of doing this?
Say, I have multiple quests going and I want to go to a passage when a quest is complete (an enemy is slain, a sword was picked up, you lost all your health and died, etc.). How do I manage these without conflicting?

I setup a quest system the following way:
<<set $equipEnchantedSilverSwordQuest =
{
	item: { name:"Enchanted Silver Sword", id: "enchanted.silver.sword" },
	character: $player
}>>
<<set $slayingCoboldSkeletonQuest =
{
	numEnemies: 8,
	enemyTypes: ["Cobold", "Skeleton"]
}>>
<<set $beThereOnTimeQuest =
{
        date: "20.12.428",
        time: "22:00"
}>>
<<set $silversword_log = 
{
	name: "Silver Sword Equip Quest Name",
	startPassage: "Quest - Equip Your Enchanted Silver Sword",
	onSuccess: {passage: "Battlegrounds", message: "Now go and slay some cobolds and skeletons"},
	questType: $equipEnchantedSilverSwordQuest,
	description: "This is a description for Quest - Equip Your Enchanted Silver Sword"
}>>
<<set $quest1_log =
{
	name: "Quest 1 Name",
	startPassage: "Quest 1 - Your Castle",
	onSuccess: {passage: "Party House", message: "congratulations for completing quest 1"},
	questType: $slayingCoboldSkeletonQuest,
	description: "This is a description for Quest 1"
}>>
<<set $returnBeforeNightfall
{
        name: "Quest - Return before nightfall",
	startPassage: "Quest 1 - Your Castle",
	onSuccess: {passage: "Couch - Resting", message: "You return your castle to rest until the morning."},
        onFailure:  {passage: "Graveyard - Game Over", message: "You've failed to return to your sanctuary before nightfall, your reward is death by cobolts and skeletons!"},
	questType: $beThereOnTimeQuest ,
	description: "This is a description for Quest - Return before nightfall"
}>>

// now of course you'd put these into an array and loop through them 

My question is, which special passage or Task Object would you use and how?

Comments

  • Disane wrote: »
    I'm in the process of creating a way to automatically travel to a location without entering an infinite loop. Now, I've seen two methods of doing this. There's a topic about this, but I can't seem to find it (not even with google, the title must've been confusing). That concept showed using 'PassageHeader' (?, probably not, no idea...) and a boolean to send the player to somewhere else when an event is triggered.
    This has been discussed in several threads recently, however, the best coverage is probably this post of mine from the (SugarCube 2) Monitor a global variable and override content when it gets too high thread.

    Disane wrote: »
    I also remember TME posted a code, which enables one to override the next passage when a certain time has passed in game (event occurs):
    This can be found here:
    https://twinery.org/forum/discussion/8533/sugarcube-2-16-0-how-to-display-links-based-on-player-action-without-a-page-reload#latest
    The linked thread does not discuss what you seem to think it does.

    Disane wrote: »
    Does anyone know more methods of doing this?
    Say, I have multiple quests going and I want to go to a passage when a quest is complete (an enemy is slain, a sword was picked up, you lost all your health and died, etc.). How do I manage these without conflicting?
    You could simply process them in order in the override callback. The first one whose success conditions are true wins that turn. Next turn would be the next and so on. Random selection from multiple events is also a possibility.


    PS: To search these forums with Google, add the special site: term to your search terms:
    site:http://twinery.org/forum/
    
    For example, if you wanted to search for Config.navigation.override your Google search should look something like the following:
    site:http://twinery.org/forum/ Config.navigation.override
    
  • A quest/event system is one of the more complex RPG elements to design, but three of the main parts are:

    1. How to determine the conditions of a quest/event's success or failure:

    This is generally done using a conditional expression (eg. $player.sword is "longsword"). When testing if a quest was successful or not you may need to used two expressions because failure is not always the negative of success.

    eg. You have to kill 10 skeleton before leaving the current area ('here')

    The success expression could be as simple as $dead_skeletons >= 10 and $area is 'here' but that expression returning false would not indicate failure as it would be false while in 'here' and the number of $dead_skeletons < 10. The related failure expression would be something like $dead_skeletons < 10 and $area isnot 'here'

    2. When to evaluate the quest/event conditional expressions:

    There are two main times to do these evaluations are:

    2a. After the user has interacted with the game by selecting a link.

    Not all links result in passage traversal (eg. an in-passage combat or equipment system) which means you may need to attach code that accesses your event system to the code that is executed when the related link is selected.

    2b. After the game has traversed from one passage to another.

    Not all passage traversals are the result of a user interaction (eg. timer based) which means you may need to attach code to a Task Object targeting the target passage.

    3. What to do when a quest/event finishes (either success or failure):

    Some care needs to be taken when automatically moving the user to another passage because doing so can result in them not seeing (all / some of) the contents of the passage, especially if that traversal is done within a Task Object.

    This is why I would generally recommend either displaying the success/failure message in the current passage, or adding a link to the current passage which would allow the user to move to the relevant target passage after they have finished reading the content of the current one.

    eg. You swing your mighty sword and hit Hogger for 99 points of damage, and he dies. You have successfully killed Hogger!!!! End of Kill Hogger Quest Passage)

    note: You will notice I have not supplied any solutions, this is because based on the quest examples you supplied I would need to understand how your existing Equipment, Combat, and Travel systems worked and if any of them are in-passage based. Your exiting User-Interface layout could also influence the implementation of a possible quest/event system.
  • Another idea on the quest front:

    The dialog api is very useful for displaying messages to the player without having to worry too much about your navigation. Just set up your conditionals for quests in the target passage, change whatever variables you need to, and then just throw up a dialog to let the player known what happened.
  • Chapel wrote: »
    Another idea on the quest front:

    The dialog api is very useful for displaying messages to the player without having to worry too much about your navigation. Just set up your conditionals for quests in the target passage, change whatever variables you need to, and then just throw up a dialog to let the player known what happened.

    Interesting, I have not thought about using this. I might need to research this. I'll come back with questions and code pieces soon. Thank you!
  • greyelf wrote: »
    note: You will notice I have not supplied any solutions, this is because based on the quest examples you supplied I would need to understand how your existing Equipment, Combat, and Travel systems worked and if any of them are in-passage based. Your exiting User-Interface layout could also influence the implementation of a possible quest/event system.

    Thank you, your explanation is very useful. So far I've only completed my inventory system and now I'm slowly thinking about moving onto quest management.
  • edited April 2017
    For example, if you wanted to search for Config.navigation.override your Google search should look something like the following
    I wish I knew what I was looking for at that time. Thank you anyway :)
Sign In or Register to comment.