This currently brings two problems with it:
1) Only enemies of the attacked enemy's teamID join in, no other enemies that stand around
2) It might mess with special encounters or special situations where enmies aren't supposed to join their allies
I've come up with the below script to work around point 1 and minimize the risks involved of point 2. I have two questions about this:
1) Is there a better way to be certain that a creature isn't part of a special encounter or has any other special commands ordered? I currently only allow creatures with INVALID commands to join the attack. Would it be enough to just exclude any creatures that have the "AI_COMMAND_RUN_SCRIPT" attached to them? Or perhaps only allow "INVALID" and "WAIT"?
2) For debugging purposes, I had all the surrounding creatures display their current commands. In one of the first areas after the origins (don't want to spoiler) there are archers standing on top of a cliff. They had current command "14" set, which - according to AI_Constants_h - equals:
AI_COMMAND_FLY = 14; // used currently only for *** (special creature)
Seems like that shouldn't be happening?
case EVENT_TYPE_ATTACKED:
{
if(IsPartyMember(OBJECT_SELF) == FALSE
&& IsPartyMember(GetEventObject(ev, 0)) == TRUE)
{
object oAttacker = GetEventObject(ev, 0);
object [] oAllies =
GetNearestObjectByHostility(OBJECT_SELF, FALSE, OBJECT_TYPE_CREATURE, 5, 1, 1);
int nMax = GetArraySize(oAllies);
int i;
for(i = 0; i < nMax; i++)
{
object oCreature = oAllies[i];
if (GetCombatState(oCreature) == FALSE
&& IsPartyMember(oCreature) == FALSE
&& IsObjectHostile(oAttacker, oCreature) == TRUE)
{
command aCurr = GetCurrentCommand(oCreature);
if(GetCommandType(aCurr) != AI_COMMAND_RUN_SCRIPT)
{
object oPartyMember = GetRandomPartyMember();
object oAtt = oAttacker;
object [] oPerceived = GetPerceivedCreatureList(oCreature, 1);
int nSize = GetArraySize(oPerceived);
if(IsPerceiving(oCreature, oPartyMember) == TRUE)
{
oAtt = oPartyMember;
}
else if(nSize != 0)
{
oAtt = oPerceived[Random(nSize)];
}
SetCombatState(oCreature, TRUE);
command cAtt = CommandAttack(oAtt);
WR_AddCommand(oCreature, cAtt);
}
}
}
}
HandleEvent(ev); // this passes the event to the default handler of the event's target object
break;
}
Modifié par Joshua Raven, 28 novembre 2009 - 10:33 .





Retour en haut






