How to set a timer for a status effect

Hello, been coming here a lot. Apologies if this is flooding the forum posts. I searched through old posts and I did find someone going through something similar, but I didn’t exactly understand the explanation given.

It’s quite simple, I’m just looking for a way to have a status effect, i.e bleed, poison, rooted, etc end after a certain ‘timer’ has passed, in this case turns.

I.E, the longest a Bleed status effect would last 3 turns. I’ve been wracking my head for a way to make this happen, but I just can’t figure it out. Thanks again.

1 Like

Maybe create a variable called “bleed” and set it as the number of turns you want it to be active. Create a check to see if the “bleed” is positive and and a *set -1 at the end of each turn.

*gosub bleed
*Create bleed 0
You have been hit with a sharp sword and have begun to bleed!
*set bleed 3
*goto battle
*if bleed >0
     *set hp -1
blah blah blah
*set bleed -1

Note, this is very rudimentary and I haven’t checked if it even works but I think something like this could.


Maybe you can add another variable for the timer and then set timer_bleed + 1 for every turn completed, and then do a gosub to count the timer. Maybe something like

*set timer_bleed + 1
*gosub timer_bleed_check

And then in the gosub: check the timer counter, set the timer back to 0 (if more than counter), and then remove the Bleed status effect

*label timer_bleed_check
*if timer_bleed > 2
*set timer_bleed 0
*set bleed false

(edit: there should be a tab before both sets in the gosub but I can’t figure out how to mark whole paragraphs as code in mobile :sweat_smile:)

I’m merely a code-diver though so I’m not sure if that *if operation is free of errors

Maybe something like that, I don’t know how’s the code you’re using, if I knew I could insert the timer there, or make another suggestion. I don’t find it difficult though, just play with it.

*set turns 4

*label battle_start
*set turns -1
*if turns = 0
  *goto continue
  *if poison >= 1
    *set hp -2
    The poison consumes your hp!
    *goto battle_1
    *goto battle_1

*label battle_1
story, fight, whatever
  #something more
  #try something and it doesn't work.
    *set poison 3
    you are poisoned!
    *goto battel_2

*label battle_2
battle here, choices, etc etc.
*goto battle_3

*label battle_3
more battle
*goto battle_start

*label battle_4......

*label continue
here continues the story

Hey, just wanted to notify that you might want to use the #game-development:choicescript-help category. This is the place if you want to go specific. If you notice the category of your topic being moved around, that’s me.

To me, it seems you’re struggling with the implementation and writing down the code rather than the general, big picture of the mechanics.

As for the code itself, I think this is something best if you came up with the solution yourself.
You might want to familiarize yourself with *label, *goto, *gosub, and *params commands to get started, as well as understanding the importance of having separate .txt files to manage your combat system.

Feel free to return here if you have questions or things to discuss. We can give examples, but who knows if the examples are not going to be compatible with the entirety of your code structure.

Ah, my bad. Didn’t know I was posting in the wrong category, my bad. As for the help, trust me, the examples go a LONG WAY. Having a general idea of what I’d like the code to be like helps me so much, so it’s okay if it’s all just examples. Right now my code is pretty spaghetti’d up (just using a small test demo project for now), I’ll clean it all up before showing it here.