Discuss Scratch

EeveeMaster20
Scratcher
2 posts

How do I create an Ai in an RPG

I am just learning to code and having been taking classes, so I am sorry if the code is a bit clumsy, but I need help to determine when the enemy's turn is.
I have established a system where the player can attack on their turn when they click attack (with random damage and animations), but I cannot figure out how to make it even and odd.
I want to make it so that on even turns the player moves and on odd turns the enemy moves. However, any forums I could find would have blocks not on the online version. I really need help sorting…
If anyone has an alternate solution, that would be totally cool too!


Also, the game is no where finished, but I have to share it so that other people can view it.
https://scratch.mit.edu/projects/748864189
legendary34678
Scratcher
1000+ posts

How do I create an Ai in an RPG

You can check if something is even or odd with the modulo (or mod for short) block like so:

ifnumbermod2=0then. . .Number is evenelse. . .Number is oddIf number is divisible by 2

Basically, the mod block takes the first number divided by the second number and returns the remainder, so it's super useful for things that repeat such as turn order.
EeveeMaster20
Scratcher
2 posts

How do I create an Ai in an RPG

Thank you so much!
ROBLOXMYGUY
Scratcher
16 posts

How do I create an Ai in an RPG

I need help trying to make an ai for my rpg. there nothing i can figure out.

if theres anything, pls let me know.

Powered by DjangoBB