Aller au contenu

Photo

Creature AI script?


1 réponse à ce sujet

#1
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
I have a AI script that should remove non party followers as soon as they are dead. I've attached this script to creatures's utc.  So far it seems its not working properly, and I don't know where the problem is because it compiles and saves successfuly all the time. Here is my script that is not doing the job
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "var_constants_h"

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
string sDebug;
object oPC = GetHero();
object oParty = GetParty(oPC);
int nEventHandled = FALSE;

switch(nEventType)
{
case EVENT_TYPE_DEATH:
{
object oKiller = GetEventCreator(ev);
int nFollower = GetLocalInt(OBJECT_SELF,CREATURE_DO_ONCE_A);
if(nFollower == TRUE)
{
object oArea = GetArea(OBJECT_SELF);
RemoveNonPartyFollower(OBJECT_SELF);
}

break;
}
}
if (!nEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
}

My script is modification from "bhn200cr_cousland_follower". In case you wanted to look, here is "bhn200cr_cousland_follower.nss"
//::///////////////////////////////////////////////
//:: Creature Events
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Creature events for Cousland nonparty followers
*/
//:://////////////////////////////////////////////
//:: Created By: Cori
//:: Created On: 30/01/09
//:://////////////////////////////////////////////
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nEventHandled = FALSE;
    switch(nEventType)
    {
        ////////////////////////////////////////////////////////////////////////
        // Sent by: AI scripts
        // When: The current creature dies
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_DEATH:
        {
            object oKiller = GetEventCreator(ev);
            int nFollower = GetLocalInt(OBJECT_SELF,CREATURE_DO_ONCE_A);
            //If the creature has been flagged as a non-party follower
            if(nFollower == TRUE)
            {
                object oArea = GetArea(OBJECT_SELF);
                //subtract from the nonpartyfollower counter, so more can be added later
                int nNonPartyFollowers = GetLocalInt(oArea,AREA_COUNTER_1)-1;
                SetLocalInt(oArea,AREA_COUNTER_1,nNonPartyFollowers);
            }
            break;
        }
    }
    if (!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
    }
}

#2
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
I think the issue is with:



int nFollower = GetLocalInt(OBJECT_SELF,CREATURE_DO_ONCE_A);



This is not a global way to tell if a creature is a party follower. I suspect that variable was specificaly set in that one case when the creature was added as a non party follower. Try either setting the variable when you add them as a non party follower, or finding another way to tell if they are. Or even remove the check. I suspect calling RemoveNonPartyFollower() on a creature that isn't one doesn't hurt anything. It's an engine function, and they tend to have safety checks.