Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with enemy AI :(

I'm sorry if this has already been posted before, but I tried searching to forums for it but couldn't find anything...

Is there a way to make it so the enemy doesn't keep casting a skill on himself or actor that gives him the same state he already has on?
For example the enemy will cast barrier on himself 2 turns in a row instead of using normal attack or a skill he has.

Just wondering if anyone knows fix to make the enemy not cast a state inflicting skill on himself or the actor if that state is already inflicted.

Thank you in advance!

And I'm using RPGXP.
 
I don't think you need a script for this; as far as I know, you can check the condition in the "Enemy Group" database tab and force the enemy to use a different skill if they've already used something like Shell. Still, it would get quite complex if the enemy had several buffing skills and would also be tiresome for enemies with a vast number of skills. Equally, having to paste it through all "Enemy Groups" would be a pain...

Anyway, the easiest way would be to have something like this:

Code:
>Fork Condition: If Enemy Has "Shell" Then...
    >Variable[xxxx]: Random Number[0-1]
    >If Variable[xxxx] = 0 Then...
        >Attack
    >End If
    >If Variable[xxxx] = 1 Then...
        >Cast "Fire"
    >End If
  >End If
  >Else
    >Variable[xxxx]: Random Number[0-2]
    >If Variable[xxxx] = 0 Then...
        >Attack
    >End If
    >If Variable[xxxx] = 1 Then...
        >Cast "Fire"
    >End If
    >If Variable[xxxx] =2 Then...
        >Cast "Shell"
    >End If
  >End Else
>End Fork Condition

So, in this case, the enemy only has the possibility of casting "Shell" when it hasn't already got it. But it only has a 1/3 chance. However, if you wanted the enemy to automatically re-buff as soon as the "Shell" (or whatever" has ran out then all you would have to do is replace the "Else" section with:

Code:
>Else
    >Cast "Shell"
  >End Else
>End Fork Condition

You would have to do this for every enemy in the battle that uses buffs and for every enemy group, thus meaning it could take up a lot more of your time than coding. Also, this doesn't solve the problem of the enemy deciding whether or not to cast "Shell" on it's teammates who already have it (that would be much more complex in terms of eventing it). So, a code would be the easier solution if someone has one for you...
 
Wow I never thought of that! That works perfectly for one enemy troops, I'm gonna mess around with it and see what I can do with more enemies ^^

But thank you so much for the reply I really appreciate it :D
 
No problem.

It should work fine with more enemies, you'll just have to specify the code to each one. And if you wanted the enemy to cast the spell on other enemies the code would just have to check to see if the other enemies have the buff and, if they don't, offer the chance to cast it specifically on that enemy. It should only take a little tinkering to get working for full groups of enemies.

Still, it would take a lot of work to implement it for every, single enemy group in your game. If someone can come up with an RGSS solution then it would probably be a lot easier for you to use, I just put that up as a last solution (it's how I would have to do it in RM2K anyway).
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top