How to have different responses given the number of times player repeats action

Hello all! I’m new to making text adventure games. I’ve made a few basic games in RPG maker but that’s about it. Anyway; I’m trying to figure out how to have different printed text that is dependent on the number of times the player repeats the action.

For example:
player kicks rock 1st time: “you hurt your foot. The rock is unfazed”
Player kicks rock 2nd time: “you hurt your foot again. The rock is unfazed”
Player kicks rock 3rd time: “you have broken your toe. You aren’t very smart are you”

If anyone could help me out, I would greatly appreciate it.

Thank you


Hello.

First off, I would create a new command: kick_cmd.

My kick_cmd command would look something like this:

COMMAND PATTERN: kick #object#
NAME: kick_cmd
SCRIPT:

if (not HasAttribute(object, "kick")) {
  msg ("Kicking " + GetDefiniteName(object) + " would serve no purpose.")
}
else {
  do (object, "kick")
}


That way, when you try to kick anything which has no kick script attribute set on it, it will behave like this:

> kick the frob
Kicking the frob would serve no purpose.

Then, I would add a kick script attribute to my rock object with a script like this:

if (not HasAttribute(this, "times_kicked")) {
  this.times_kicked = 0
}
if (this.times_kicked < 4) {
  this.times_kicked = this.times_kicked + 1
}
switch (this.times_kicked) {
  case (1) {
    msg ("You hurt your foot. The rock is unfazed.")
  }
  case (2) {
    msg ("You hurt your foot again. The rock is unfazed.")
  }
  case (3) {
    msg ("You have broken your toe. You aren't very smart, are you?")
  }
  default {
    msg ("You are not allowed to kick the rock anymore!")
  }
}

image


Here is the example game's code:

https://gist.githubusercontent.com/KVonGit/599da0101df5eea7a338c4942290bda4/raw/bf4376ac2d28a6cdd36addf9f8eb004250467e3f/Kick%2520the%2520Rock.aslx

You can click that and view the code, or you can right-click to save the file and open it with Quest (when using the desktop version of Quest) to see it in the GUI.

If you're using Quest online, you'll have to manually enter everything (and probably copy and paste the scripts).


I avoided using a verb because that would be misleading. The player shouldn't be kicking the rock. Therefore adding a visible kick verb to the rock would be dirty pool.

If you'd rather abuse the player by adding "kick" verbs to objects they shouldn't kick (which might be amusing), it wouldn't be hard to change the kick command into a verb.


There are many ways one could do this. If you don't like this method, just say the word.

Happy gaming!


Thank you so much KV!
I plan to use and expand upon this basic function to create a variety of humor occurrences.


You are very welcome.

If you are adding a turn count to your game, you'll probably want to suppress the turn scripts in that command script when the object has no kick attribute.

You'll most likely need to tweak all sorts of other things as you add more stuff to your game, too, but learning how to make it all work the way you want is the fun part.

Have fun!


Here is a lengthy explanation that I copy-pasted from my Quest tutorial “game” that never gets any attention so occasionally I have to offer a shameless plug here and there... and I am quite sure that KVs answer is likely simpler and easier to understand but here it is nonetheless. Hope it helps.

•explain room
This is a frequent problem I see on the forums and one that I struggled with for the longest time. Once I figured this out, it is most likely the most helpful bit of coding I have learned. It really opens up gaming options! So, I will try to make this simple.

You will use something like this whenever you want multiple things to get accomplished before it triggers a new event or singular accomplishment. Want to have multiple keys used to open a door? Or, multiple pieces of a password collected before punching in a code? You want to wear multiple different pieces of clothing before you can sneak in to a top secret lab?? This is your answer.

  1. You will need to add an attribute to an object. Make it an integer attribute and set the integer equal to the number of sub-events. In this room, I added the attribute to the jigsaw puzzle. You need to use four puzzle pieces to complete the puzzle, so I set the integer to 4.
  2. To do so, click on the object, click on the attribute tab. At the bottom box, click on 'Add'. I always name mine [something]Count. In this case, I named it 'MissingPieceCount'.
    3a. Next, click on the 'Add change script'. Under this, I added an 'If' script. Select the 'If object attribute equals' from the drop down.
    3b. Select the object the attribute is set on. In this case, it was the jigsaw puzzle.
    3c. Type in the title of your attribute. Here it was 'MissingPieceCount' and set it to value zero (0).
    3d. For the then, I printed a 'Congratulations, the puzzle is complete' message and set a flag titled 'Complete' on the puzzle. I did this so I could look at the puzzle and get a different response for a complete puzzle and one that wasn't complete.
    4a. Wherever the subevent is completed... in this case it was use puzzle piece with puzzle.... you need to adjust the integer variable on the object in question.
    4b. To do this, I chose the 'set a variable or attribute' script under the heading 'Variables'.
    4c. You need to type into that first box the following: object.attribute - In the second box you need to leave it as 'expression'. In the third box you need to adjust the variable by typing the following: object.attribute - 1
    4d. So, in my example, it looks like this: Set variable: jigsaw puzzle.MissingPieceCount = expression jigsaw puzzle.MissingPieceCount -1
  3. Now, back over to the changedMissingPieceCount script if you choose. I didn't, but you could have added a bunch of Else Ifs to the changedMissingPieceCount attribute. Else If, object has attribute equal to 4 (or 3, or 2, or 1) print a proper message. If you choose to do this, each time a sub-event is comleted, you can send a message to the player that there are three (or two, or one) more events needed to complete it.
  4. Optional: In the look at description, you can add a switch or a bunch of If/Else Ifs to describe the object (puzzle) that is changing.

Hello, XanMag! I have seen several excerpts from your book and they really carry a lot of useful information. But unfortunately, you correctly expressed that your book rarely attracts attention. Most likely it happens because you do not know how to write the text correctly in order to attract the attention of people. To write in such a way as to interest a large category of people, you need to have certain skills. Several services that I have been working with for a long time help me to acquire these skills, pay for essays, and they provide services for writing dissertations.


Without using code ( I can’t do code)
I usually. Set a kick verb on rock
Then under scripts choose first time.
First time print first response
Otherwise first time
First time second response
Otherwise first time
First time third response
You can continue that ad infinitum until you put a final response in otherwise.


@DavidSaine

https://youtu.be/jZOywn1qArI

😂

I think it’s more about how I code and solve problems while using quest - not necessarily my literary skill set.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums