I need help with arithmetic and set variables

I have read the choicescript wiki even rounds and loops But I don’t understand anything I am terribly with everything related with numbers. so the thing is I have the system on paper I have planed all and absolutely no single idea how make simple mathematics works on code so I am about to skip combat dynamics. So this is my last hope so i would go for basics first
An example I want set a stat called strength that is result of another stat called fight / 3.

Then with strength made the variable attack that is result of d5 (a throw rand die) plus the strength.

I have more difficult variables but If I have no idea basics I will not trying add more.

1 Like

From what I understand you want something kind of like this? This is sort of how it would be the attacking turn for the player from what you’ve described.

EDIT: Corrected a few mistakes.

``````*create str 0
*create fight 42
*create random 0
*create damage 0
*create enemy_1_health 150
*create turn 1

*label attack_loop

Turn #\${turn}

*gosub attack

*set enemy_1_health - damage

The enemy takes \${damage} points of damage!

*if (enemy_1_health <= 0)
You've defeated the enemy!
*finish
*else
The enemy still has \${enemy_1_health} HP left.
*page_break Attack again!
*set turn +1
*goto attack_loop

*comment --------ATTACK----------
*label attack

*set str (fight/3)
*rand random 1 5
*set damage str + random

*return

``````
1 Like

No it was the actual mathematical code. The problem was a cultural one not a mathematical onw. Lol I am so dummy. In Spanish we use for decimals 1’5 instead 1.5 so Of course my rounds and code doesn’t work… lol.

Why I am so terribly with maths is beyond me. To my defence here is almost 2:00 am and I am in Nanowrimo tired mood

You can also use:

``````*set str round((fight/3))
``````

To round decimals into full numbers.

Light night/Early morning writing grind.

Yeah That was starting check right now and loop it was the damn cultural writing decimal error made me lost like one hour and my sanity … So far for now is working as it should… At least it reads like similar to a dungeon and dragons dice combat so I am okay…