henesua wrote...
Lightfoot, thanks. I had no idea that you could have a special script that would run first when "DetermineCombatRound" is called. That sounds much better than using a HB.
I assume that this event only occurs once, that being at the start of combat. Is that true?
No, It will happen every combat round. It is in fact written into the "DetermineCombatRound" function. If you look into nw_io.generic you can see where it is at in the combat round. Here is the code fragment that hooks the special AI.
// ----------------------------------------------------------------------------------------
// July 27/2003 - Georg Zoeller,
// Added to allow a replacement for determine combat round
// If a creature has a local string variable named X2_SPECIAL_COMBAT_AI_SCRIPT
// set, the script name specified in the variable gets run instead
// see x2_ai_behold for details:
// ----------------------------------------------------------------------------------------
string sSpecialAI = GetLocalString(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT");
if (sSpecialAI != "")
{
SetLocalObject(OBJECT_SELF,"X2_NW_I0_GENERIC_INTRUDER", oIntruder);
ExecuteScript(sSpecialAI, OBJECT_SELF);
if (GetLocalInt(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT_OK"))
{
DeleteLocalInt(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT_OK");
return;
}
}
So basicly if the special AI string exsists it runs the script by the same name. But before running the script is sets the local object for who the current target is, so that you can retrive it from the special IA script.
After the special AI script is ran it chects to see if the X2_SPECIAL_COMBAT_AI_SCRIPT_OK" local string has been set. If it has it deletes it so that it has to be set againg next round and returns so that the rest of the AI does not run. If it was not set after the special AI script was ran it just continues to run the standard AI.
It seems to me that a pair of scripts would be better than just one - one at the start of combat, and one following up at the end of every combat round....
The OnCombatRoundEnd Event calls DeterminCombatRound if they are still in combat, so it is already taken care of.
....I think all of this could be set up with one special combat ai script and the USERDEF which would handle initialization and the other events.
For example I am assuming that the post spawn event can be used to determine what area the creature has been spawned in rather than use an onarea enter script.
Yes there a may way to set it up. It just come down to how you want to handle it. Just keep in mind that the OnSpawn event will only set things up one time And you will need to have the onspawn event modified to check all creatures vs the area they are spawning into. With the OnAreaEnter event they would fire it when they spawned into the area, That would handle it pretty much the same as the onspawn. However if that creature ever moved to a new area you could change the Special AI event on them entering. Of cource that is not to say that you could not just write your Special AI to check the area they are in first and act accordingly. It is really just a matter of how you decide to do it and what fits the best with what you already have in place.