Discuss Scratch

zikhem
New to Scratch
14 posts

Need to make a multiple-move randomizer

So basically part of the game im making is a sort of pokemon-style level, and for that I need the enemies to select between 4 attacks, but multiple random blocks dont work, how do I do it? (Right now im doing this for one move, but it wont work if multiplied by 4 because multiple results will be made)
when I receive [Enemy turn]
if <(pick random (1) to (4)) = [1]> then
change [your hp] by (((move attack test) + (enemy attack)) - (your defense))
end
<(move attack test) = [-10]>
<(enemy attack) = [3]>
<(your defense) = [3]>

This would make it so that when it picks 1 then it changes your hp by -10 but I cant put multiple of these for other attacks because then the randomizer would pick 4 numbers and it would do 4 attacks.
awesome-llama
Scratcher
1000+ posts

Need to make a multiple-move randomizer

You can use a variable to store the random number. That way, you can use the same number multiple times.

set [num v] to (pick random (1) to (4))
if <(num) = [1]> then
...
else
if <(num) = [2]> then
...
else
if <(num) = [3]> then
...
else
...
end
end
end


zikhem
New to Scratch
14 posts

Need to make a multiple-move randomizer

awesome-llama wrote:

You can use a variable to store the random number. That way, you can use the same number multiple times.

set [num v] to (pick random (1) to (4))
if <(num) = [1]> then
...
else
if <(num) = [2]> then
...
else
if <(num) = [3]> then
...
else
...
end
end
end
thanks lol

Powered by DjangoBB