The idea behind this project has been to create a set of artificial intelligence scripts for combat that can be easily configured and extended to suit the needs of the community. Configuration is simple enough that even those with little or no scripting experience should be able to get creatures behaving as they want, while the extensibility allows those with scripting experience to add new behaviours and integrate them with the existing core set of behaviours with a small amount of work. The core behaviours provided with the package were written with the approach of making the creatures fight more like humans fight when playing NWN. It tries to simulate the creatures being more aware of what is happening around them, using their abilities more intelligently, and especially improving the teamwork of groups of creatures. If you have questions about these scripts or need help with any aspect of their use please direct them to the Scripting board in the forums at the CODI site.
Posted by Xovian at 2010-02-01 21:25:07 Voted 10.00 on 02/01/10
It's a bit late, but well done.
Posted by Almighty God at 2009-07-19 16:38:23 Voted 10.00 on 07/19/09
Hm. Everithing's still very stupid but that is quite an improvement. Quite a big one :> _________________________ [...] And the world was created. [...]
Posted by Katdoral at 2008-10-09 16:09:52 Voted 10.00 on 10/09/08
Absolutely great ai system, adding my vote now
Posted by Luusah at 2008-07-18 01:59:08 Voted 10.00 on 07/18/08
The best AI out there!
Posted by Kergael at 2008-06-26 07:22:52 Voted 10.00 on 06/26/08
Thank you very much for this interesting and very useful script :) _________________________ Tell me how you play, I'll tell you who you are...
Posted by Shargast at 2007-10-14 01:42:37 Voted 10.00 on 10/09/07
Rewrite of CODI AI no_ai_dh with respawning creatures integrated into the code.
I've partially written and partially patched this code together and I'm in the initial testing period. It seems to be adjusting faction (prr system), droping weapons (se_drop_weapons) and respawning the creatures in question as well as interfacing with the CODI AI system.
Rather pleased atm - could someone please have a look at my code and clean it up (as I have the feeling that some things in there are not quite right).
Appreciate any help
NWScript:
//::///////////////////////////////////////////////
//:: On Death -- no_ai_dh_dorg// Kast // Raien
//:: replaces no_ai_dh in CODI AI
//:: Patched and jimmied by Shargast
//:://////////////////////////////////////////////
/*
On Death script incorporating prr, weapon drop,
simple creature respawn and CODI AI system
(used in conjunction with the entire CODI AI system)
*/
//:://////////////////////////////////////////////
void RespawnObject(string sTag, int iType, location lLoc) {
// ResRef must be derivable from Tag
string sResRef = GetStringLowerCase(GetStringLeft(sTag, 16));
CreateObject(iType, sResRef, lLoc);
}
void main()
{
// Scarfaces xp system
ExecuteScript("sf_xp", OBJECT_SELF);
// End Sf_xp system
// Sir Elrics drop weapon system
SE_DropHandSlot(OBJECT_SELF, INVENTORY_SLOT_LEFTHAND, 180.0, TRUE);
SE_DropHandSlot(OBJECT_SELF, INVENTORY_SLOT_RIGHTHAND, 180.0, TRUE);
// End se_drop_weapons
string sTag = GetTag(OBJECT_SELF);
int iType = GetObjectType(OBJECT_SELF);
// For creatures, save the location at spawn-time as a local location and
// use it instead. Otherwise, the creature will respawn where it died.
location lLoc = GetLocation(OBJECT_SELF);
float fDelay = 360.0; // 6 minute delay
AssignCommand(GetArea(OBJECT_SELF),
DelayCommand(fDelay, RespawnObject(sTag, iType, lLoc)));
//CODI AI Creature Death scripting
//float fDieDelay = GetLocalFloat( OBJECT_SELF, "#DECAYDELAY" );
//corpse decay deactivated for Murray module
float fDieDelay = 10.0;
ClearAllActions();
//broadcast death
SpeakString( "BC_DEAD", TALKVOLUME_SILENT_TALK );
//PrintString( GetName( OBJECT_SELF ) + " killed by " + GetName( GetLastKiller() ) );
if ( GetName( GetItemInSlot( INVENTORY_SLOT_CARMOUR, OBJECT_SELF ) ) == "Balor Properties" )
{
ExecuteScript( "nw_s3_balordeth", OBJECT_SELF );
}
DelayCommand( fDieDelay, ExecuteScript( "no_scr_cleanvars", OBJECT_SELF ) );
DelayCommand( fDieDelay + 0.5, ExecuteScript( "no_scr_excorpse", OBJECT_SELF ) );
//signal death to userdef
//End CODI AI creature death scripting
SignalEvent( OBJECT_SELF, EventUserDefined( 1007 ) );
}
Best
Sai _________________________ Realms of Shargast V1-V5ab, LOTR V15, The Undeath Clave & Faithful of Aerth
Posted by Shargast at 2007-10-09 23:43:49 Voted 10.00 on 10/09/07
3 votes and 5000 dl's - the world is not fair!!
Well put together user-friendly system that requires only logical thinking to implement! Along the way I learned also quite a bit about scripting! The inlcluded module was a nice touch to get me started!
Thanks a bundle!
Best
Sai aka Shargast _________________________ Realms of Shargast V1-V5ab, LOTR V15, The Undeath Clave & Faithful of Aerth
Posted by Dreggas ( 70.34.xxx.xxx ) at 2005-12-14 06:57:34
Has anyone had an issue with knockdown NOT working on the creatures using this script set??? If so what was the solution, we have had creatures be knocked down yet they continue to slide across the screen, get up and continue to run as if nothing happened.
Posted by Arlain ( 58.164.xxx.xxx ) at 2005-10-11 17:34:17
Ok is there an updated version of the AI or is it just that the documentation is now out of date?
If the creatures are spawned dual-wielding they'll attempt to use those weapons whenever they're in melee. If they've been disarmed and lost one of their weapons they may try to pick the weapon up to wield it again if it's still on the ground.
Posted by commche at 2005-05-17 00:56:27 Voted 9.75 on 03/14/05
Posted by Plundar ( 4.19.xxx.xxx ) at 2004-10-26 13:52:00
Here is an interesting post by AlanC9.
*****
Well, isn't that special? Look at this comment from x0_i0_talent:
"ISSUE 1: The check in this function to use a random ability
after failing to use best will fail in the following
case. The creature is unable to affect the target with the
spell and has only 1 spell of that type. This can
be eliminated with a check in the else to the effect of :
A number of the scripts don't compile. Unfortunately I found this out after I spent several hours applying these scripts to every creature in my module.
This is a compilation of the old system into a single score. There were 24 that made this score of 9.28 then rounded to 9.
Posted by merentha at 2004-02-20 04:34:00 Voted 10.00 on 04/01/04
Open the script editor inside the toolset for your module that uses the CODI AI then do a search for "SendMessageToDM" on all files in the module...if the script that has that function is called no_* then open it and see if it's the offending line(s). BTW, if I miswrote the call just look for it under functions on the right hand panel of the script editor, it'll turn up.-Merentha
Purveyor of Fine Music, Fine Wines and Fine Women!
(hey we all dream!) _________________________ Currently awfg and deep into cyberpunk of AO, but I'll eventually come back to NWN :)
No wait, playin' DDO! But I've got a copy of NWN2 to load up and play ><
Posted by Weld ( ..xxx.xxx ) at 2004-02-19 16:17:00
OK, so I get the point that nobody has a clue.
Firstly, why does CODI when used make the NPCs send messages to the DM channel on attack? And why can't I find where it does that? *grumble*
Secondly: where do I find the function InitCombat()? I've searched through all the linked include files.
Posted by Weld ( ..xxx.xxx ) at 2004-02-19 13:59:00
And what is up with the triggering user defined events when there is no user defined script file in the package?
Posted by Weld ( ..xxx.xxx ) at 2004-02-19 13:49:00
That post doesn't seem to help. I just installed these scripts into my PW and set them up on a few choice NPCs. Was nice to see some NPCs with brains! But after awhile (and after they killed my test subject a few times) they just stopped attacking.
They were still activating the attack shout, which means they did perceive - but they'd just stand there. I think after a little while of one-hit and run from the player, they started attacking again.
Anyone using this AI unmodified from this post and it works perfectly?
Posted by merentha at 2004-01-24 09:22:00 Voted 10.00 on 04/01/04
I just had a dragon chase me across areas last night and when we finished transitioning I stood in place and unloaded all spells and a number of scrolls taking it down. The entire time the dragon just stood facing me. The scripts this particular beast was on are the AI scripts I got from here. In case the info helps...I had just assumed it was because after we transitioned it shifted me behind the area transition point on that map and so I may have been in an invalid place?-Merentha
Purveyor of Fine Music, Fine Wines and Fine Women!
(hey we all dream!) _________________________ Currently awfg and deep into cyberpunk of AO, but I'll eventually come back to NWN :)
No wait, playin' DDO! But I've got a copy of NWN2 to load up and play ><
Posted by Plundar ( ..xxx.xxx ) at 2004-01-19 12:38:00
I see Namelessone mentioned this:
"In the release of v1.0 we overwrote the default scripts and that cause problems for a fair amount of people. This time around we went with non-overwriting scripts to avoid that. You still have the option to save the creature event scripts (any scripts with names of the form no_ai_*, eg/ no_ai_atk, no_ai_blk, etc) with the names of the corresponding default scripts."
I have not worked with any of the scripts before but I am familiar with making backups and changing filenames. Could I get a list of which CODI files replace which default files so I can make the CODI AI the default AI? Could this be added to the readme file perhaps?
Well, I just checked that area in the toolset ... all creatures are already set to "Long" so that can't be the problem.
Posted by Dromin ( ..xxx.xxx ) at 2004-01-17 23:27:00
Well, it may have been that the creatures have a "short" perception or "average". I always set my critters to "long", that way the PCs don't get a free round of ranged fire at them.
LoCash:
Thanks for the feedback. I haven't noticed the behaviour you've described in my own testing, but that doesn't mean there isn't some set of circumstances leading to what you're describing. There's only so many things I can test myself while working on these scripts. I'll take another look at it and see if I can spot any perception holes or anything else that might cause creatures not to kick into and remain in combat mode.
hermyt:
Good job. I have a rewrite of the healing behaviour planned (couldn't fit it in before release for the 12 days of madness) to allow it to include undead allies and inflict spells for consideration if the possiblity is there.
CSM:
I've just downloaded and tested the file myself and couldn't find anything wrong with it.
Posted by CSM ( ..xxx.xxx ) at 2004-01-13 17:46:00
The file is corrupted. Each time when I download the file or open it, I get a message that states that it is corrupted.
Posted by hermyt ( ..xxx.xxx ) at 2004-01-05 15:09:00
hmm, well to make this ai a tad more useful for undead casters of no small power, I added in the harmself ability into the dohealself function in no_lib_actions
if(GetRacialType( OBJECT_SELF ) == RACIAL_TYPE_UNDEAD )
{
if(GetHasSpell(759) && (iDam * 100) / GetMaxHitPoints() > 60) //undeads new harm self, no constant for it, dug it from 2da's
{
ActionCastSpellAtObject(759, OBJECT_SELF);
SetLocalObject( OBJECT_SELF, "#HEALER", OBJECT_SELF );
DelayCommand( 4.0, DeleteLocalObject( OBJECT_SELF, "#HEALER" ) );
return TRUE;
}
}
dunno if that will format properly when posted, but you should get the gist, I added that call right after the check for healing potions which tests if the caller was undead, that if statement comes just after that block
this block here actually:
//iCR = 20;
iCR = 10;
iHealTalent = 0;
if ( GetRacialType( OBJECT_SELF ) != RACIAL_TYPE_UNDEAD ) //undead do not use healing potions
{
//while ( iCR && GetIsTalentValid( tP = GetCreatureTalentBest( TALENT_CATEGORY_BENEFICIAL_HEALING_POTION, iCR-- ) ) )
while ( iCR-- && GetIsTalentValid( tP = GetCreatureTalentRandom( TALENT_CATEGORY_BENEFICIAL_HEALING_POTION ) ) )
{
if ( iP = GetTalentPotionHealAmount( tP ) )
{
if ( iP > iHealTalent && iP 60)
{
tHeal = tP;
iHealTalent = iP;
}
}
}
}
}
anyways, hope that's helpful I'll throw it on the codi site too.
Well, speaking with some other builders, it seems that some engine changes were made in 1.59-1.61 which would probably impact many AI scripts (how NPCs handle the combat round, and of course DelayCommand functionality) so maybe that has something to do with it. The fact that I didn't find the demo particularly tough isn't a big deal since I'm used to playing with custom AI scripts (usually Tony_K's).
Oh yeah, Happy New Year CODI! Let's hope we can see a real .mod from you guys sometime in 2004.
Posted by LoCash_ ( ..xxx.xxx ) at 2003-12-27 14:16:00
Either this script package isn't all that its cracked out to be, or the Demo mod included with it is faulty.
Taking my 10Barb/2Wiz (horribly non-optimal build, only good for RPing) through most of the Demo rooms resulted in easy combats (exception being the Dragon). In the "Band of the Hand" room, it almost seemed like it was the BioWare AI all over again; while I'm in melee with one hostile in one part of the room, a hostile in another part of the room *just stands there* staring at me (I'm right in its line of sight) without engaging or firing ranged at me. Then after I take care of the rest and go after it, it seems to wake up and try to flee.
Also, I noticed that AI casters seem to have no compunctions about firing AoE spells when they have friendlies in the area of effect. Thats how one of the drow mages killed herself; throwing a fireball at me when I was just a few steps away from her, and getting herself fried in the process.