Aller au contenu

Photo

How do I use "AddNonPartyFollower"?


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
I'm trying to make my NPCs to follow my character in some areas to fight with me. Wiki says "Adds a creature that follows the player around but it is not part of the player's party. The creature will not cross an area transition." and wiki doesn't give any examples to integrate into the script. Is there anyone who is good at scripting knows how to work this out?
EDIT: I looked up the script called "bhn200cr_cousland_follower" and "bhn200ar_castle_after_siege"  that was created by the developers. I tried to modify it but my NPCs are not still following me. These the scripts that I looked at

"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);
    }
}

Other ScriptPosted Image "bhn200ar_castle_after_siege.nss"

void BHN_CheckNonPartyFollower(object oCousland,string sWaypoint)
{
    object oArea = GetArea(oCousland);
    int nNonPartyFollowers = GetLocalInt(oArea,AREA_COUNTER_1);
    if(nNonPartyFollowers < 2)
    {
        nNonPartyFollowers = nNonPartyFollowers + 1;
        SetLocalInt(oArea,AREA_COUNTER_1,nNonPartyFollowers);
        //SET check for on death script
        SetLocalInt(oCousland,CREATURE_DO_ONCE_A,TRUE);
        AddNonPartyFollower(oCousland);


If I was to change it so that my people would follow me as nonpartymember, what parts should I modify to make it effective to my NPCs?

Modifié par AnnoyingDisplayName, 31 décembre 2009 - 07:25 .


#2
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
No one? I think I need Developer's help on how to use this.

#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
The mechanics of this function are quite simple - call it on a creature who is not in the party (but is in the area) and they will follow the player when not in combat. (This won't particulalry affect hostile creatures since they will automatically enter combat). Call RemoveNonPartyFollower when you don't want the creature to follow any more.
The important thing to remember is that the creature won't stop trying to follow the player until RemoveNonPartyFollower is applied, so this should probably be called on the area exit event if it isn't called before then.

Modifié par Craig Graff, 01 janvier 2010 - 07:22 .


#4
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
So if I spawn NPCs via "runscript _________" the script won't even have effect? Is there a script that I can use to make them follow after I manually spawn them? If so, can you give me a sample script?

Modifié par AnnoyingDisplayName, 01 janvier 2010 - 07:47 .


#5
Craig Graff

Craig Graff
  • Members
  • 608 messages
In the script that creates your creature:

[dascript]

object oNonPartyFollower = CreateObject(OBJECT_TYPE_CREATURE, R"your_creature.utc", GetSafeLocation(GetLocation(GetHero())));

AddNonPartyFollower(oNonPartyFollower);

[/dascript]

#6
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Thank You Craig! but do I just put
object oNonPartyFollower = CreateObject(OBJECT_TYPE_CREATURE, R"your_creature.utc", GetSafeLocation(GetLocation(GetHero())));
AddNonPartyFollower(oNonPartyFollower);
into my spawn creature script?

EDIT: Putting in my spawn script does nothing while putting it as a separate AI script gives me "Dragon Age has stopped working". 
This is AI script
void main()
{
    object oNonPartyFollower = CreateObject(OBJECT_TYPE_CREATURE, R"grey_warden_soldier2.utc", GetSafeLocation(GetLocation(GetHero())));
        AddNonPartyFollower(oNonPartyFollower); 
}

Modifié par AnnoyingDisplayName, 01 janvier 2010 - 08:37 .


#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
Could you post your "spawn script" please?

#8
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
This is my script, I withdrew my NPC's name for his privacy!Posted Image
void main()
{
    object oPC = GetHero();
    location lLoc = GetLocation(oPC);
    CreateObject(OBJECT_TYPE_CREATURE, R"my_creature.utc", lLoc);
}

#9
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
[dascript]
void main()
{ object oPC = GetHero();
   location lLoc = GetSafeLocation( GetLocation( oPC ));
   AddNonPartyFollower( CreateObject( OBJECT_TYPE_CREATURE, R"my_creature.utc", lLoc ));
}[/dascript]

Modifié par Axe_Murderer, 01 janvier 2010 - 05:05 .


#10
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Thank You I will certainly try that!

#11
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
SOLVED FINALLY! BLESS YOU ALL THOSE PEOPLE WHO HELPED ME!

#12
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Well, I solved my problem but it created new problem... sometimes, scripts don't load, making followers not follow me... I have to reload the save to make script properly function. Any solutions?

Modifié par AnnoyingDisplayName, 03 janvier 2010 - 02:40 .


#13
Craig Graff

Craig Graff
  • Members
  • 608 messages
You'll likely need to give a lot more information for anyone to be able to actually help. What is your script attached to (area, trigger, conversation, etc.) What isn't firing? Have you used PrintToLog or some other debug function to try to track down where things are failing?

#14
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
void main()
{
object oNonPartyFollower = CreateObject(OBJECT_TYPE_CREATURE, R"my_nonpartfollower.utc", GetSafeLocation(GetLocation(GetHero())));
AddNonPartyFollower(oNonPartyFollower);
}
Does fire immediately when used like above but when I use this script like below,
object oNonPartyFollower = CreateObject(OBJECT_TYPE_CREATURE, R"my_nonpartfollower.utc", GetSafeLocation(GetLocation(GetHero())));
{
AddNonPartyFollower(oNonPartyFollower);
}

object oNonPartyFollower1 = CreateObject(OBJECT_TYPE_CREATURE, R"my_nonpartfollower1.utc", GetSafeLocation(GetLocation(GetHero())));
{
AddNonPartyFollower(oNonPartyFollower1);
}

object oNonPartyFollower2 = CreateObject(OBJECT_TYPE_CREATURE, R"my_nonpartfollower2.utc", GetSafeLocation(GetLocation(GetHero())));
{
AddNonPartyFollower(oNonPartyFollower2);
}
Non Party Followers will follow some times or they just stand on the location where I've spawned them unless I reload savegame and spawn them again.
I personally think that this problem is caused by numerous CreateObject command in this script. Is there other command to spawn NPCs not a NPC?
And I will post my scripts if I got problems in the future.

Modifié par AnnoyingDisplayName, 04 janvier 2010 - 08:30 .


#15
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
I searched through wiki and got nothing, I tried "CreateObjectIn3DSpace" thing but don't know how to use it properly. Any help?

#16
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Any possible cause of script not firing properly other than my guess? I will try to describe the situation.
When I spawn NPCs, sometimes only one NPC follows me or no one follows me. I also think it may be due to dead NPCs not "removed" from the list of  Non Party Followers. Any suggestion on script that will remove dead NPCs from NonPartyFollowers?

Modifié par AnnoyingDisplayName, 05 janvier 2010 - 08:18 .