[left]hi[/left]
[left]i have 3 questions to ask[/left]
[left]1.how do you do that when your walking around suddenly a battle begins[/left]
[left]of course with always different monsters[/left]
[left]2.how do you do that when youve attacked that the enemy attacks after[/left]
[left]with different attacks always and maybe items of course[/left]
[left]3.how can i do that you can always attack a different monster?[/left]
[left] [/left]
marco, i previosly asked on of these questions at another forum here is what they replied. Go Here after reading everything that should kinda inform you how to fight different monsters.
Okay, what you want is to have a random statement, so that everytime you take a step, it generates a random number say in the range of 1-20. If that number equals 1 or any other number that you want, you call up a function to initiate a battle. This function should randomly pick the monsters with numbers. The monster names can be stored in an array so that instead of having to have a lot of if statments, you can make a statment saying:
monster1 = array[randomnumber];
That will put the name of the monster of “array[1]” if the random number is 1 or “array[2]” if the random number is 2 and so on into the “monster1” variable.
I’ll add more in a second.
Put these two functions on a “functions” layer, which is the same throughout the game:
The Functions:
initbattle = function()
{
monster1=monsterarray[random(4)];
monster2=monsterarray[random(4)];
monster3=monsterarray[random(4)];
gotoAndStop("battle");
}
randbattle = function()
{
if(random(20)==5)
{
initbattle();
}
}
The above code will pick three random monsters from an array of five monsters called “monsterarray” and go to the frame named “battle” in the function “initbattle”. “initbattle” is called by the function “randbattle” when the random number that is chosen is equal to five.
Calling Random Battle:
onClipEvent(keyDown)
{
//put movement stuff here
_root.randbattle();
}
The above code should go on the guy that is moving. When a key is pressed the movement code moves him(this code hasn’t been written in yet and will replace the comment("//put movement stuff here"). Then “randbattle()” will be called and decide if a random battle will occur.
The Variables:
monsterarray = ["slime", "blob", "wolf", "elemental", "snake"];
The above code should be put on a “variables” layer. This creates the array for the monster names.
To make the monster make random attacks, all you need is a function like the following:
randattack = function(monster)
{
if(monster = "blob")
{
randnum = random(4);
if(randnum = 0)
{
attack = "absorb";
}
//put "else if" statments here for other attack names
}
return(attack);
}
That will pick an attack for every monster. All you have to do is add more “else if” statements for the attacks and monsters. In the battle frame, when it’s the monster’s turn, call up the “randattack” function like this:
attack = _root.randattack(monster1);
That will return the name of the attack for the monster named in the variable “monster1”. All you need to program is a random damage function to return a certain amount of damage depending on the level of the monster(which also has to be randomized in the init battle function which will have to be modified to generate a monster level and put it into a monster level variable depending on which section of the map you’re in).
If you have trouble with the functions or programming the rest you need, don’t hesitate to ask. Sorry, but I may not be able to reply immediately because I have a lot of studing to do.
The only thing i need to know now to start a game is:
how do i do so that the maximum amount of life mp or whatever is 200 or 300?
(i want it like this: HP/maximum)
please help
thanks