Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Creator on Sat 23/12/2006 05:21:41

Title: Random Attacks
Post by: Creator on Sat 23/12/2006 05:21:41
How do you make random attacks?

eg.

PlaySound(1);
Display("You attack NPC");
GiveScore(-2);
PlaySound(2);
Display(NPC throws fireball");
SetglobalInt(2,GetGlobalInt(2)-2);
//I have my comaprisons for health here


Now how can i make this:
PlaySound(2);
Display(NPC throws fireball");
SetglobalInt(2,GetGlobalInt(2)-2);


randomize with this


PlaySound(3);
Display(NPC throws Lava at you");
SetGlobalInt(2,GetGlobalInt(2)-2);


I hope I'm being clear  ???
Title: Re: Random Attacks
Post by: monkey0506 on Sat 23/12/2006 07:17:39
int ran = Random(1);
if (ran == 0) {
  PlaySound(2);
  Display("NPC throws fireball");
  SetGlobalInt(2, GetGlobalInt(2) - 2);
  }
else { // ran == 1
  PlaySound(3);
  Display("NPC throws Lava at you.");
  SetGlobalInt(2, GetGlobalInt(2) - 2);
  }