Help - Search - Members - Calendar
Full Version: Kread's AI Packages (Cross-engine)
RPG RPG Revolution Forums > Scripting > Script Tutorials > RGSS2
Kread-EX
Kread's AI Packages


Version: 1.2

Author: Kread-EX

Release Date: 9/11/2010


Introduction
This script provides pre-programmed AI Packages, in order to make your life easier when you want to create intelligent enemies. Note that this is only a tool, meant to be used in conjunction with battle events, and doesn't dispense the developper to put a little effort in designing the enemies. Misuse of this script can result in horribly overpowered monsters. Warning given. Although developped for XP, this script is cross-engine and will adapt itself to RMVX.

Instructions
There are 5 provided Packages:
Healy: Enemies using this AI package will try to heal and cure as much as possible, and only if needed. Only if healing is useless, the default AI will resume.
Protect: Enemies using this package will firstly try to buff themselves, then heal, then debuff the party. If nothing of this can work, the default AI will resume.
Support: This package doesn't give any priority. The character will just spam support skills with 0 power. If none of the skills can work, the default AI will resume. I recommand to give a rating of 1 to support skills with this package, and a high rating to attack skills, so the default AI won't try to use ineffective skills.
Wild: Then again, this package doesn't give priority. The characters will just calculate the average damage caused by all their attacks and always select the most damaging.
Balanced: No priorities again, and no orientation either. Basically, this package choose a random skill but only if it works and against a acceptable target. Best used in conjunction with Battle Events.

In the beginning of the script, you have a few constants named AIHealy, AIProtect, AISupport, AIWild and AIBalanced. Very simple, just put in here the IDs of enemies using the selected package, separated by commas.
For VX users: The ever-so-convenient note boxes are here. Just add one of these in the box.
<package: healy>
<package: protect>
<package: support>
<package: wild>
<package: balanced>

If you need to change a package during a battle, use a Call Script command:
$game_troop.enemies[member_index].package = :healy, :protect, :support, :wild or :balanced.

Script
DDL

Compatibility
Should work with all Battle systems, except TBS. Might clash with Tankentai, but I'm not sure.

Terms and Conditions
You are free to adapt this work to suit your needs.
You can use it for both non-commercial and commercial purposes. Credit is appreciated.
Shanghai
This is quite the awesome cross engine script you've given us. Let's hope to see this more in RPG's.
AresWarrior
wow Kread-X you are an awesome scripter! i might use this script for my game. thanks!
crazydragon
Is this script incompatible with Melody? Always get the same error from melody V when I assign a package through noteboxes. Also get a no method from the script call to switch packages.

Click to view attachment
Kread-EX
I don't experience any error with Melody...
Plus, the error you are showing comes from a method I haven't touched.
Could you give me more info? Like what other battle scripts you are using, their order in the editor...
joey101


QUOTE (crazydragon @ Sep 24 2010, 06:39 PM) *
Is this script incompatible with Melody? Always get the same error from melody V when I assign a package through noteboxes. Also get a no method from the script call to switch packages.

Click to view attachment

ummm mabye take a look at both scripts but i dont really know what Melody is
crazydragon
QUOTE (Kread-EX @ Sep 24 2010, 11:32 PM) *
I don't experience any error with Melody...
Plus, the error you are showing comes from a method I haven't touched.
Could you give me more info? Like what other battle scripts you are using, their order in the editor...


Only battle scripts I'm using are the Engine Melody's I through V. They're in their original order, and I've tried this with the AI Package script before and after them. My project file isn't using YEM AI or YEM Enemy levels either. Just to make sure, I tried using this with the original Melody 1.00_m demo and I get the same error. I forgot to mention that I'm using ATB in Sideview, if that makes a difference. In my enemy's notebox,
"<package: protect>" is pasted exactly like that. Before the fight even starts, I get the error I posted above.

Since I couldn't get the battle to start while the enemy had a package assigned, I tried to assign one through the script call during battle. When switch 10 is turned on, my battle event tab calls "$game_troop.enemies[46].package = :wild" and the switch gets turned off. I receive this error both on my project and the Melody 1.00m demo-
Click to view attachment
I'm not familiar with script calls, so I'm pretty sure this is an error on my part and I applied it in an incorrect manner?

When I switched the battle system type to PressTurn battle, I was able to assign a package, but my above method of switching packages gave me the same error.

*edit- I only get the error I posted before in ATB when an enemy starts off with the protect, balanced, or wild package.
Kread-EX
For your error during the script call, it's because you are calling a non-existent enemy. The index you need to put in $game_troop.enemies[index] is not the ID in the database, but the order in the troop. In your example, you are trying to pinpoint the 46th enemy in the current troop.

I'm searching for the incompatibility problem with ATB. I'll get back to you once I found it.
crazydragon
Ah I see. That makes sense : P. Unfortunately when I tried this, I still received the same error. It now reads like this=

$game_troop.enemies[1].package = :wild

My troop only has 1 enemy so this should be the correct number, right? I've tried it with the packages that work with ATB (healy and support)
and still received the same error. Just to make sure, I'm supposed to be calling this from "Script..." under "Advanced" from the third tab in
Event Commands, right?

Thanks for the support, by the way.
Kread-EX
No, with only 1 enemy, the correct number is 0. ^^

As for your ATB problem, I don't seem to be able to replicate it at all. All packages work for me... Are you sure you are using the version 1.1? Because the first version of the script had a bug making the wild package only working with RMXP.
XaineC
I get an error with Wild enemies: "Script 'Enemy AIs' line 489: AugmentError occured. comparison of String with 436 failed."
Kread-EX
Oh, I completely forgot to take strings into consideration. I believe the error appears when the skill is supposed to miss (physical ones for instance).
Anyway, I fixed the problem so you need to download the script again. Now the enemies will not use the skill if it misses when they test it.
Bigace
Im getting a
QUOTE
Script 'Kread's AI Package' Line 575: SyntaxError occured.
Error after I uploaded your new version.
Kread-EX
Typo. tongue.gif
Forgot to close the parenthesis.
Bigace
QUOTE (Kread-EX @ Nov 9 2010, 02:42 AM) *
Typo. tongue.gif
Forgot to close the parenthesis.


That's a facepalm to myself, because I should of notice something so simple. cool.gif
XaineC
Oh no! The site with the script is down! T.T
Kread-EX
Well, if Pockethouse is down, go to Gate of Babylon - I put the script there too. It's no big deal anyway, every site in the world has its downtime.
finalholylight
Link died,please fix the link,I need this script,thanks.
Kread-EX
I've put the code directly in the first post. Until Pockethouse is up again (I hope it will).
wsensor
QUOTE (Kread-EX @ Apr 18 2011, 05:58 AM) *
I've put the code directly in the first post. Until Pockethouse is up again (I hope it will).


Question could this be made to work with AI controlled party members?

Also would their be a way to make it so that an AI could learn as the game goes on enemies weaknesses?

IE: Learning AI:
CODE
Enemy: Slime
Weaknesses: Blank
Strengths: Blank

Controlled Character uses attack (melee damage) Normal Melee attack is ineffective so Learning AI now knows not to use this.
Learning AI party member uses (melee piercing) ineffective it will now no longer try this one on this enemy/enemy type.
Controlled Character uses Fire spell (fire element) enemy takes more than 100% damage. Learning AI now will attempt to use this spell type. (but it should try other types or base them off of players trials and errors.)
Controlled Character uses Water Element spell. Slime heals. Learning AI says ok I will never ever use water on this slime.


I think that would be a great idea have several learning ai's for use with a AI party member. (Perhaps even allow information to be entered for stuff the AI should already know. IE: Learning AI Party Member is a Vampire Slayer: It should know most if not all weaknesses/strengths of vampires and not make mistakes when battling them even if it messes up on other enemies.)

Would it also be possible to right an AI that checks for enemies health/status and uses the correct strength spells?
IE: Will not cast Fire 3 when the enemy could/would die from a Fire 1 spell. (Hmm maybe a slightly bad idea since I am not sure if an AI should always know that unless you always show an enemies hp to the player. Just I don't think over killing and wasting precious mp is a good idea lol.)
Kread-EX
No, this system only applies to enemies. It's possible to mimic it to make it work with AI controlled actors (for the VX version at least) and to implement a package to "save" MP. But the AI will prioritize one or another, not the two. Which means, you'll have to give to the player the option to change the package depending of the situation.

If this is okay with you, give me a few days and I'll work on it.
wsensor
QUOTE (Kread-EX @ Apr 28 2011, 05:10 AM) *
No, this system only applies to enemies. It's possible to mimic it to make it work with AI controlled actors (for the VX version at least) and to implement a package to "save" MP. But the AI will prioritize one or another, not the two. Which means, you'll have to give to the player the option to change the package depending of the situation.

If this is okay with you, give me a few days and I'll work on it.


Its fine. I wish there was a way to make a learning AI.
I just would love my ai teammates to learn from using / watching what is used then magically knowing automatically what spell should be used.
I mean if an enemy has never been seen before how should a party member know what to attack with anyways lol.

The only reason why I hate the idea of a party team member using "Fire 3" on an enemy just because its weak to fire spells when it would die from a "Fire 1" spell sort of stupid and overkill. Perhaps I will just use a skill leveling system and remove the ability for multiple of the same spells. I just think that an AI party member should show restraint rather than always using an overpowered skill when an enemy obviously does not need hit by such a powerful ability.
Kread-EX
A learning AI would require a tremendous amount of work and would be hellish to configure. I'm sorry but I have no intention of implementing such a system.
As for "overkilling", like I said, you can't have both at the same time. Either the skill is choosen according to its power, either according to its cost. This script is designed for enemies and if I adapt it for actors, it will be up to you to change the AI stategy accordingly.
wsensor
QUOTE (Kread-EX @ May 9 2011, 02:36 PM) *
A learning AI would require a tremendous amount of work and would be hellish to configure. I'm sorry but I have no intention of implementing such a system.
As for "overkilling", like I said, you can't have both at the same time. Either the skill is choosen according to its power, either according to its cost. This script is designed for enemies and if I adapt it for actors, it will be up to you to change the AI stategy accordingly.


I like the idea to be able to change it accordingly.
Would you make it by seperate AI actor or entire AI party at once? Well either way works as long as I still can control the main party member lol.
Could always add special skill commands using common events with script calls to call for Full power or Reserve mp or Focus on Healing lol.
Ehibika
Hello Kread-EX, I am having some problems with this script, every time I try to open the game with it in VX, it gives me this error:

"Script 'Enemy AI' line 346:SynthaxError occured
I took a look at the script but couldn't pinpoint the problem, before I was getting another synthax error inside the make_xp_package_action method, since it was for XP and I was using VX, I tried to comment the whole thing out, only it lead to the synthax error in line 346.

when the script is not tampered with at all, the synthax error is instead at line 287
Kread-EX
For some reason, all "&" symbols became "&amp;" to be able to be displayed on a web page. I'll fix it later since I can't access my web server right now, but you need to replace every occurrence of &amp;&amp; with && or and.
Moonpearl
This is not a script I'm going to be using personally, because I don't use a classic RPG battle system (when I do use one) biggrin.gif, but I still want to congratulate you Kread-EX for developing the enemies' intelligence, which I think does lack too much in video games. happy.gif I also have some insight regarding AI from my studies in cognitive psychology, if you're interested - though a standard RPG battle system is somewhat too simple a situation for an ANN to do any better than your own script.
Ehibika
Hello again Kread-EX I should have mentioned this much earlier but I got caught up in some things.

There seems to be a glitch with the wild pack aimed at line 502, claiming that there is no implicit conversion from nill to integer, I have no clue what the problem is or how to fix it, but what I do know is that this only happens when all party members are dead and there is still an enemy with the wild pack alive in battle, regardless if all of the enemies with this pack got to act on their turn before the end of that sequence or not.
nohmaan
Is the link not working again?
Kread-EX
I have received a few angry PMs about the links. Yeah, I was busy and on a monthly billing cycle, and forgot to pay the bills. Because I'm a moron, I never make backups of anything and well...
Well, anyways, now this is on dropbox so you shouldn't have this kind of problem anymore.
goldenryu9292
I'm getting an error on line 359 with the healy package when I have two enemies: one enemy dies and the one with the healy package has no revival skills.

EDIT: Nevermind, it was that && thing.
vvalkingman
I know this is necroposting and that I will surely be struck down by the gods......sorry gods sad.gif

It's just that I've started using this package and I applied the healy ai to a blue kobold which I gave the following:

Attack, rating 10
Kobold special, rating 8
Heal, rating 1

Now, if I stand there and just defend having dealt no damage to it....the blue kobold will heal itself until it runs out of mana from healing, then it does nothing. Not once will it attack or perform the kobold special. Is there some way I am supposed to set the ratings so that it'll attack when it goes back to default? Or is there something that I need to change in the healy package code to make it so when there is no damage dealt they just go back to swinging at me?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.