Turn-based battle, I don't understand much yet about *if

Hello guys. Let’s see if you can help me.

I am trying to design a battle between the user who reads the story and a monster.
What I did was the following, then I leave examples:

Create 2 permanent variables, one with the health of the user and one with the health of the monster.
Create a third variable which I call “m”, which is to verify that when the user reaches 0 with their health, it will take you to an “end of game” page.
And finally, create another variable with the name of the monster.
What I can’t get is:

I want that if the user manages to leave the monster with 0 health or less than 0, the user can be redirected to another scene.
And if it is the monster who leaves the user with 0 health points or less than 0, he redirects himself to an “end of game” scene.

What I can’t understand is how to compare health variables and make decisions about them.
Greetings and happy new year.

Example:

*create e1 “hipocampo”
*create s “100”
*create s1 “100”
*create m “0”

*label results

choose an attack
*choice
#Lunar ray.

You use the moonbeam.

$!{e1} Use Scale Dance.

*set s - 9
*set s1 - 12
Your health is from $!{s}, and that of the ${e1} is ${s1}.

*if (m = s1)
*goto_scene game_over

*else

Well, you're still alive.
*goto results
*finish
1 Like

if you are using a combat loop, you can use something like:

*label combat_loop
*if ((s <= 0) and (s1 <= 0))
    *goto_scene mutually_assured_destruction
*elseif s <= 0
    *goto_scene game_over
*elseif s1 <= 0
    *goto hipocampo_defeated
*else
    *choice
        #combat option 1
            [some combat events]
            *goto combat_loop
        #combat option 2
            [some different combat events]
            *goto combat_loop

*label hipocampo_defeated

well done ${name} u won, carry on with ur adventure

but there are so many ways you can do combat, its a really complicated thing to code tbh. hth

2 Likes

Have you looked trough the choicescript wiki? You can learn a lot of things there. Whenever i need to toy with coding i just browse trough it to learn new things.

If you want to, the link is Choicescript Wiki

2 Likes