# Final fantasy style game help

**URL:** <https://forum.kirupa.com/t/final-fantasy-style-game-help/66098>\
**Category:** Uncategorized\
**Created:** [October 2, 2004, 2:58pm UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098 "2004-10-02T14:58:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolmarco2004x](https://avatars.discourse-cdn.com/v4/letter/c/e9c0ed/32.png) [@coolmarco2004x](https://forum.kirupa.com/u/coolmarco2004x)\
**Post date:** [October 2, 2004, 2:58pm UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/1 "2004-10-02T14:58:17Z")

</div>

[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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 2, 2004, 7:23pm UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/2 "2004-10-02T19:23:03Z")

</div>

marco, i previosly asked on of these questions at another forum here is what they replied. [Go Here](http://www.flashkit.com/board/showthread.php?threadid=586227&goto=newpost) after reading everything that should kinda inform you how to fight different monsters.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 3, 2004, 12:48am UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/3 "2004-10-03T00:48:07Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 3, 2004, 1:09am UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/4 "2004-10-03T01:09:41Z")

</div>

Put these two functions on a “functions” layer, which is the same throughout the game:  
**The Functions:**

```auto

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:**

```auto

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:**

```auto

monsterarray = ["slime", "blob", "wolf", "elemental", "snake"];

```

The above code should be put on a “variables” layer. This creates the array for the monster names.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 3, 2004, 1:28am UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/5 "2004-10-03T01:28:05Z")

</div>

To make the monster make random attacks, all you need is a function like the following:

```auto

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:

```auto

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 4, 2004, 4:49pm UTC](https://forum.kirupa.com/t/final-fantasy-style-game-help/66098/6 "2004-10-04T16:49:15Z")

</div>

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
