First of all: Much of this code may be unnecessarily complicated. I’m still new at coding, so sorry for that. I tried to make a sort of turnset, a “if roll is 1 it’s the players’ turn but if it’s 2 it’s the companion’s turn”. The idea is to add more companions later on.
I get no bugs on quicktest, but it freezes when I run it on Node, after the first choice I make. Why does it freeze?
My code looks like this:
*label turnset
*rand d4 1 2
*comment This ^^ should say "rand d4 1 4" but just Jura has stats as of now, so
*if d4 = 1
*goto player
*if (d4 = 2) and (juraalive)
*set Juraturnvar true
*goto juraturn
*else
*goto player
*label player
A wolf attacks!
*label fight
*if wolfturn
The wolf attacks!
*rand d20 0 20
*if d4 = 1
*set minushealth phealth - (wolfattack + d20)
*set wolfturn false
*if phealth <= 0
*goto death
*if phealth > 0
The wolf bits you!
*goto player
*if d4 = 2
*set minushealth jhealth - (wolfattack + d20)
*set wolfturn false
*if jhealth <= 0
*goto jdeath
*if jhealth > 0
The wolf bits Jura!
*goto turnset
Your health: ${phealth}
Jura's health (placeholder): ${jhealth}
It's health: ${wolfhealth}
What do you choose?
*label juraturn
*if juraturnvar and juraalive
It's Jura's turn.
*fake_choice
*if (sword = true) #Attack it with my sword!
*rand d20 0 20
*set totalattack addstrenght + (swordat + d20)
You rolled ${totalattack}!
*if totalattack >= 20
*set wolfhealth -30
You hit!
*if (wolfhealth <= 0)
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 15) and (totalattack < 20)
*set wolfhealth -20
You hit!
*if wolfhealth <= 0
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 10) and (totalattack < 15)
You don't hit!
*set wolfturn true
*goto fight
*else
You don't hit!
*set wolfturn true
*goto fight
*if (jsword = true) #He'll attack with a sword!
*set juraturnvar false
*rand d20 0 20
*set totalattack addstrenght + (swordat + d20)
You rolled ${totalattack}!
*if totalattack >= 20
*set wolfhealth -30
You hit!
*if (wolfhealth <= 0)
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 15) and (totalattack < 20)
*set wolfhealth -20
You hit!
*if wolfhealth <= 0
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 10) and (totalattack < 15)
You don't hit!
*set wolfturn true
*goto fight
*else
You don't hit!
*set wolfturn true
*goto fight
*if (ironsword = true) #Attack it with my ironsword!
*rand d20 0 20
*set totalattack jaddstrenght + (jswordat + d20)
You rolled ${totalattack}!
*if totalattack >= 20
*set wolfhealth -30
You hit!
*if (wolfhealth <= 0)
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 15) and (totalattack < 20)
*set wolfhealth -20
You hit!
*if wolfhealth <= 0
*goto win
*elseif (wolfhealth > 0) and (phealth > 0)
*set wolfturn true
*goto fight
*if (totalattack > 10) and (totalattack < 15)
You don't hit!
*set wolfturn true
*goto fight
*else
You don't hit!
*set wolfturn true
*goto fight
#Flee
*goto flee
*label win
You win
*ending
*label flee
You flee
*ending
*label death
You die
*ending
*label jdeath
Jura died! Dang it!
*set juraalive false
*goto turnset