How to script specific text each turn for several

Thickar
26 Mar 2018, 22:19

Hi so what I want to do is start an event like as a fight. The event will last a certain amount of terms, for example ten. The player has lets say three actions they can make, punch, bob, or block. Now what actions they choose per each ten turns has not change in the fights out come, but each turn each action gets a different response scripted for that specific turn. So turn one has a different answer for all they actions, as does two and so on. But its always the same responses per action on a specific turn. beacuse I want each turn to reflect the progress of the fight which will end at ten turns.
How do I go about doing this?
I assume I would use the show menu each turn with a split for each action. And probably a variable or something that counts from 1-10, with code like if turn = 2 then do this answer, turn now = 3 or something. Now idea how to code this though?


Io
26 Mar 2018, 22:34

Uh... I'm having some trouble following what you're trying to accomplish. Could you try again with better grammar, or post an example of what you'd like your game to do?


Thickar
26 Mar 2018, 22:53

Well I can put it the fight last ten turns of the game. and the player has three actions to make one of per turn and each turn those three actions have a different answer specific to that turn.
So,
Turn 1
Answers tier 1

Turn 2
Answers tier 2

At the end of ten turns the fight is over and the out come is not affected by which choices each turn the player made.


Io
27 Mar 2018, 00:35

So... let me see if I understand it.

Turn 1
Player inputs an action.
If Action 1, run Action1-Turn1
If Action2, run Action2-Turn1

Turn 2
Player inputs an action
If Action1, run Action1-Turn2
If Action2, run Action2-Turn2

And etc?


DarkLizerd
27 Mar 2018, 03:30

Io... I think you got it...
Thickar... You have your idea, and I bet you have it pictured of what you want, but just haven't put the two together yet...
One easy way would be to make 10 "rooms", called Round_1... Round_2... Round_3... and so on...
after the player enters his command, say what the player did, then move the player to the next "room".
After Round_10, move the player to Round_End, and describe weighter (I still can't spell that %%$@#%^ word!!!)
the player won or lost, and how badly they got beat up...


Thickar
27 Mar 2018, 03:34

Ya I think you got it Io, is there a way to do it with out making a room for each turn, I want to use this process quite a few time and having that many rooms would make organization tough


Io
27 Mar 2018, 03:41

Thickar yes, there is. I know there is, because I did a similar thing in my game.

This is my method, adapted for what you want. There may be simpler ones:

First, create a room. Let's call it FightRoom. Fight room has NO text in it. Zero. Nada. Zip.

Turn 1 comes. Move the player to FightRoom. Whatever text we want for Turn 1, we'll use print to insert it! Have the player input an action, and depending on what it is, print more text.

Now Turn 2. How do we do this?

First, in FightRoom, go to 'Before entering' and add 'Clear the screen'. Now, we call a function called 'ResetRoom'. It moves the player super-fast to a textless empty room called Empty, then BACK to FightRoom.

Now we're ready to begin Turn 2. Once Turn 2's text-action-text is done, ResetRoom, and call Turn 3. Turn 4. Etc.

Edit: Actually, in retrospect, my game needed ResetRoom but yours from the sound of it doesn't. You can just call 'Clear the screen' without worrying about other rooms.


Thickar
27 Mar 2018, 04:01

Thanks thats a good idea, but I still need a way to keep track of the changing of the turns relative to when the fight started. So since the turn count can vary when the feet started, how should I do this?
A variable that increases with each passing turn maybe?


Io
27 Mar 2018, 04:07

Thickar that's the simplest way: Player.Turn as an integer, and whenever a turn ends, Player.Turn=Player.Turn+1.

If you have multiple encounters, and either each turn is different or you START at different turns, then I recommend some additional variable to keep track of that. Call it Player.Fight, it can be a string or an integer.

So example: We have two encounters. In one we fight a zombie, in another we fight a skeleton. For the zombie we start an earlier turn, and the skeleton we start a later turn; as we fight the zombie we knock its flesh off and turn it into a skeleton.

When starting the fight:

If Player.Fight=Zombie, Player.Turn=1
else if Player.Fight=Skeleton, Player.Turn=5 (Note, if you have a LOT of fights, Switch is preferable to a giant stack of if/else)

And if you want the Zombie's turn 7 to vary from the Skeleton's turn 7, then that's a simple case too if 'If Player.Fight=Skeleton' and such.


mrangel
27 Mar 2018, 09:47

If you just want to display messages, I wouldn't bother with a fight room. I'd just set it up as a function. For example, call the function DoFight; it could look something like this:

if (not HasInt(game, "fightTurn")) {
  game.fightTurn = 0
  game.fightResults = NewDictionary()
  dictionary add (game.fightResults, "punch", Split("turn 1 response;turn 2 response;turn 3 response;etc"))
  dictionary add (game.fightResults, "bob", Split("turn 1 response;turn 2 response;turn 3 response;etc"))
  dictionary add (game.fightResults, "block", Split("turn 1 response;turn 2 response;turn 3 response;etc"))
}
msg ("Fight! Round "+game.fightTurn)
ShowMenu("What do you do?", Split("punch;bob;block"). false) {
  fightResults = DictionaryItem(game.fightResults, result)
  msg (ListItem (fightResults, game.fightTurn))
  game.fightTurn = game.fightTurn + 1
  if (game.fightTurn < ListCount(fightResults)) {
    DoFight
  }
  else {
    game.fightTurn = null
    game.fightResults = null
    msg ("Congratulations! You won!")
    // If you want to do anything else after the fight, put it here
  }
}