Aller au contenu

Photo

Getting allies into combat


  • Veuillez vous connecter pour répondre
Aucune réponse à ce sujet

#1
Magic

Magic
  • Members
  • 187 messages
From EVENT_TYPE_PERCEPTION_APPEAR in rules_core.nss, line 1041:
else if(!IsFollower(oAlly)) // non party members
{
    if(GetLocalInt(oAlly, AI_FLAG_STATIONARY) == 0 && GetLocalInt(oAlly, CLIMAX_ARMY_ID) == 0)
    {
        #ifdef DEBUG
        Log_Trace(LOG_CHANNEL_AI, GetCurrentScriptName(), "Bringing over ally: " + GetTag(oAlly));
        #endif

        //int nRand = Random(10) + 1;
        //float fDistanceToMove = IntToFloat(nRand);
        if(GetLocalInt(OBJECT_SELF, AI_HELP_TEAM_STATUS) <= 1) // allow for 0 (not active) or 1 (active for special system)
        {
            SetLocalInt(OBJECT_SELF, AI_HELP_TEAM_STATUS, AI_HELP_TEAM_STATUS_NORMAL_ALLY_HELP_ACTIVE);
            cMove = CommandMoveToObject(oAppear, TRUE);
            SetCreatureIsStatue(oAlly, FALSE);
            WR_ClearAllCommands(oAlly, TRUE);
            Ambient_Stop(oAlly);
            WR_AddCommand(oAlly, cMove, TRUE, FALSE);
        }
    }
}

You surely noticed that it is possible to draw a few enemies out of a group for combat. The code excerpt above is used to let an NPC, who perceived an enemy, call nearby allies for help. However, flag AI_HELP_TEAM_STATUS is checked and set on OBJECT_SELF. Unless you clear this flag again, this results in every creature being able to call for one additional ally only, because excerpt above is used in a loop through all allies.

Quick fix: Comment out the SetLocalInt() call to set AI_HELP_TEAM_STATUS in a local copy of rules_core.nss and recompile. You should be aware of overriding core scripts. A custom fix could handle the call for help in a separate creature script. Be cautious, as crowded areas can become surprisingly funny with this fix.

Note: Replacing OBJECT_SELF with oAlly works as well but interferes with the call team for help system in ai_main_h_2.nss, line 594. This is: Setting the local variable AI_HELP_TEAM_STATUS to AI_HELP_TEAM_STATUS_ACTIVE (= 1), will get any team member having this flag set the same from anywhere on the map.

Edit: If you're using the roaming system or any system resetting NPCs, you might check to reset call for help flags as well.

Modifié par Magic, 18 avril 2010 - 07:08 .