Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: shdwlink1993 on January 23, 2009, 07:35:03 pm

Title: Question concerning Enemy AI
Post by: shdwlink1993 on January 23, 2009, 07:35:03 pm
For my next little scripting project, I decided to delve into that mystical, mysterious, and blindingly horrific area of the standard scripts known as Battle AI. For those of you who genuinely have no idea what the heck I mean, let me enlighten you:

Whenever you enter battle in RPG Maker XP (assuming that you are, of course, using the Default Battle System and not something much better, like Blizz-ABS), your virtual opponent selects the attack they make carefully. It's based on a number of conditions, and they carefully consider the target they choose so as to screw you over the most. Also, Blizzard cannot script anything, the SDK is the best compatibility aid on the planet, and Chaos Project is the worst RMXP game on the planet. :^_^':

In reality, the AI essentially picks the attack to use by looking at a few conditionals, and then randomly selects it based off of action ratings. Then, it picks the target... with less care than what it uses: randomly picking anyone there. All it checks is if it's meant for someone on their side, or yours, and if it's meant for dead people or not. Nothing fancy.

Anyways, something rather interesting has come up while I was looking through these AI functions (Which would be much less infuriating to look through if they didn't have it spread in several different scripts scattered all over the place :<_<: ), and I'm wondering if anyone actually can tell me why this glaringly blatant flaw was made. So, in lieu of any other brilliant ideas, like staring at code, I decided to make a post about it, and see if someone else will be willing to do the staring for me :^_^':.

Basically, in the enemy AI, it checks for each action to see if it's possible based on a number of criteria, said criteria being battle turns, enemy HP condition, party levels, and switches before shoving it into it's list of choices (This can all be found in Game_Enemy.make_action, for all you curious people :P).

Something odd I noticed here, and perhaps you did as well, is that the ability to actually, you know, use the skill (is there enough SP, is the user silenced) isn't actually a condition to being placed in it's list of available options. It is factored in at a later time, of course (Game_Battler.skill_can_use?, and this is after the skill candidate has been finalized, just before the skill is used), but it's rather odd that they didn't want to make certain that a skill wasn't selected, almost used, and then canceled, leaving the player with a free turn that may or may not have been intended to be present.

So, getting to the actual question, does anyone know why that wouldn't have been factored in? The player cannot use any skills that they cannot use, as it's grayed out and non-selectable. You can't waste a turn unless the action couldn't be performed because of something that happened that turn, like dying or silencing or whatever. Why wouldn't the AI get the same benefits?
Title: Re: Question concerning Enemy AI
Post by: winkio on January 23, 2009, 07:38:07 pm
It is modeled after some games (final fantasy's included) in which if you drain an enemy's SP, they will still try to use their skills but fail, wasting a turn.  It is a very popular feature, and adds some advantage to draining a monster's SP.

Games I can think of off the top of my head are Final fantasy and Golden sun, but I know that many others do as well.
Title: Re: Question concerning Enemy AI
Post by: Zeriab on January 24, 2009, 05:45:07 am
Enemies can be stupid as long they are not blatantly stupid (excluding deliberately stupid enemies like zombies).
They have never heard that sentence.

The idea of an enemy losing their turn if SP was drained so they cannot afford the spell is nice, but the idea of an enemy continuously trying to use a spell it does not have the SP for is not nice. It should either not be present or be optional. I guess it's just about them implementing a popular feature in a wrong way.

*hugs*
- Zeriab
Title: Re: Question concerning Enemy AI
Post by: Blizzard on January 24, 2009, 07:32:49 am
All that needs to be said was already said. I can only add that there is a semantical problem in the selection of skills. If no skill is available to use due to SP shortage and no other action is there, the system would need some additional and messy code selection an action. That's the only think I can think of besides what was mentioned already.