GameMaker Random attacks

D

deem93

Guest
Hello.
I am working on my turn based combat system and I have a bit of a problem.
All the weapons in the game can deal either slash, stab or blunt damage.
While attacking, the system randomly picks which attack, of the three, will be performed by the character.
Right now I am using a simple choose() function for this. And here is my problem.
How do I take attacks that yield 0 damage out of this equation?
For example, a morning star deals only blunt damage, slash and stab are set to 0.
Is there a way to make the system omit attacks that will always deal 0 damage without copy-pasting the formula 7 times like so:
if attack1 = 0 then choose attack2 and attack3, if attack1 and attack2 = 0 then choose attack3 etc.
Thanks!
 
V

VagrantWhaleGames

Guest
what about somethin like this? hard to know without context but...this is not one line but also not a bunch of ifs...

Code:
SLASH=10;
STAB=11;
BLUNT=12;

type=SLASH;

switch(type)
{
case slash:
choose(atk1,atk2);
break;
case stab:
choose(atk3,atk4);
break;
case blunt:
choose(atk5,atk6);
break;
}
 
I would recommend using arrays. I can't post links currently, but I can send you a tutorial, or you could google one like "weapon system using arrays"
 

FrostyCat

Redemption Seeker
Either use a do-until loop to keep choosing until you get a nonzero result, or add the non-zero entries into a list or array and pick a random entry from that.
 
Top