Coding a battle system, help with math operations

mhnnn… that’s what I meant though…
go into the scene file, exit it, go back in at a specific label below.

Maybe you should try creating temp variables before *gosub_scene?
*gosub_scene, however, essentially (if briefly) loads the indicated file behind-the-scenes and does not actually “unload” the current scene file in the process, meaning that unlike for a *goto_scene, all of the current scene’s *temp variables and #option _reuse states are retained in memory and will still apply after the subroutine has been used.

i think i’ll work with a melee/distance variable for the texts
thank you

If you use fairmath for this, the damage will be different for characters with different fortitude.
For example, let’s take two characters: one has fortitude 80, another has only 10. They receive 4 critical hits from the same enemy with strength 10, so hurt will be str*4 = 40.
For our resilient character with 80, damage would be 32, leaves 48.
Second hit to this already weakened character will be only 19, leaves 29.
The 3rd hit - 11, leaves 18.
The 4th hit - 7, leaves 11.
This at least could be explained: the enemy is tired after previous attack and can deal less damage.
But what about squishy character with 10 fortitude? Logically, they should be dead after the first hit from the same enemy, but, because of how fairmath works, they receive only 4 damage. Then 2, then 1, and one again.
Wouldn’t this cause some logical problems in combat?

I’ll be honest. I outrigt forgot I could do plain math there too… and make a

*if fort <0
  *set fort 0
  *set outcome 10

(I have a list for the outcomes)

Well, that should fix it.
By the way, are you planning to use the same file with this script for every battle?

If it proves itself. The var (except fort) would be resetted after every battle.

This means the reader will see the same non-specific lines like “Enemy attacks you and misses” again and again. Or are you planning to do something about that, too?

Yes. As there’s a limited number of opponents I’ll go with some ifs and vars for the respective fight here.

Understood. Good luck.

1 Like