Aller au contenu

Photo

[SOLVED] Script about Followers without AddNonPartyFollower Possible or not?


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

#1
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Hey guys, when I played climax part of the game yesterday, I saw that I could call on reinforcements with reinforcement pannel and gave me an idea of how to do non-party follower thing without NonPartyFollower script functions. When I looked at the script of those soldiers, script had this part

// Climax army member creature script
// On death: send event to area
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "ai_main_h_2"
#include "cli_constants_h"
void MoveToLeader()
{
    #ifdef DEBUG
    Log_Trace_AI("EVENT_TYPE_CUSTOM_COMMAND_COMPLETE", "MOVING TO LEADER");
    #endif
    object oPC = GetMainControlled();
    command cMove = CommandMoveToObject(oPC, TRUE, 8.0);
    WR_ClearAllCommands(OBJECT_SELF, TRUE);
    WR_AddCommand(OBJECT_SELF, cMove, FALSE, FALSE, -1, 5.0);
}

I tried to make my AI script with this alone and it seems its not working because it doesn't have starting conditional or main. So I tried to put
    command cMove = CommandMoveToObject(oPC, TRUE, 8.0);
    WR_ClearAllCommands(OBJECT_SELF, TRUE);
    WR_AddCommand(OBJECT_SELF, cMove, FALSE, FALSE, -1, 5.0);
to my spawning script and this is my resulting script
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "plot_h"
#include "sys_ambient_h"
void main()
{                                          
   
    object oMainControlled = GetMainControlled();
    object oArea = GetArea(oMainControlled);       
    vector vControlled = GetPosition(oMainControlled);
    vector vSpawn1 = vControlled + AngleToVector(90.0) * 1.5;
    vector vSpawn2 = vControlled + AngleToVector(180.0) * 1.5;
    vector vSpawn3 = vControlled + AngleToVector(270.0) * 1.5;
    vector vSpawn4 = vControlled + AngleToVector(45.0) * 3.0;
    vector vSpawn5 = vControlled + AngleToVector(135.0) * 3.0;
    location lSpawn1 = GetSafeLocation( Location(oArea, vSpawn1, 0.0) );
    location lSpawn2 = GetSafeLocation( Location(oArea, vSpawn2, 0.0) );
    location lSpawn3 = GetSafeLocation( Location(oArea, vSpawn3, 0.0) );
    location lSpawn4 = GetSafeLocation( Location(oArea, vSpawn4, 0.0) );
    location lSpawn5 = GetSafeLocation( Location(oArea, vSpawn5, 0.0) );   
    command cMove = CommandMoveToObject(oMainControlled, TRUE, 8.0);
    object oNonPartyFollower1 = CreateObject(OBJECT_TYPE_CREATURE, R"npf1.utc", lSpawn1);
    {
        AddCommand(oNonPartyFollower1, cMove, FALSE, FALSE, -1);
    }
    object oNonPartyFollower2 = CreateObject(OBJECT_TYPE_CREATURE, R"npf2.utc", lSpawn2); 
    {
        AddCommand(oNonPartyFollower2, cMove, FALSE, FALSE, -1);
    }
    object oNonPartyFollower3 = CreateObject(OBJECT_TYPE_CREATURE, R"npf3.utc", lSpawn3);
    {
        AddCommand(oNonPartyFollower3, cMove, FALSE, FALSE, -1);
    }
    object oNonPartyFollower4 = CreateObject(OBJECT_TYPE_CREATURE, R"npf4.utc", lSpawn2);  
    {
        AddCommand(oNonPartyFollower4, cMove, FALSE, FALSE, -1);
    }
    object oNonPartyFollower5 = CreateObject(OBJECT_TYPE_CREATURE, R"npf5.utc", lSpawn3);   
    {
        AddCommand(oNonPartyFollower5, cMove, FALSE, FALSE, -1);
    }
}

When I spawn with this script, followers would spread out like 8 meter or whatever measurement system that this game use and not follow. From my understanding this script command should make whatever object that has this script should move to wherever I go. Am I making wrong assumption? If so, Can someone help me to complete this script?

Modifié par AnnoyingDisplayName, 30 janvier 2010 - 12:09 .


#2
Craig Graff

Craig Graff
  • Members
  • 608 messages
For this to work you'd need to be calling MoveToLeader from within the creature script, probably under EVENT_TYPE_HANDLE_CUSTOM_AI like cli000cr_army_member.nss does.

#3
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
I hate logging in everytime! I just want to stay logged in and reply. Anyway, You mean I have to put

void MoveToLeader()

{

#ifdef DEBUG

Log_Trace_AI("EVENT_TYPE_CUSTOM_COMMAND_COMPLETE", "MOVING TO LEADER");

#endif

object oPC = GetMainControlled();

command cMove = CommandMoveToObject(oPC, TRUE, 8.0);

WR_ClearAllCommands(OBJECT_SELF, TRUE);

WR_AddCommand(OBJECT_SELF, cMove, FALSE, FALSE, -1, 5.0);

}

Under EVENT_TYPE_HANDLE_CUSTOM_AI? Will I need any extra?

#4
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Still the same... Here's my new script.
// Climax army member creature script
// On death: send event to area

#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "ai_main_h_2"
#include "cli_constants_h"

void MoveToLeader()
{
#ifdef DEBUG
Log_Trace_AI("EVENT_TYPE_CUSTOM_COMMAND_COMPLETE", "MOVING TO LEADER");
#endif
object oPC = GetMainControlled();
command cMove = CommandMoveToObject(oPC, TRUE, 8.0);
WR_ClearAllCommands(OBJECT_SELF, TRUE);
WR_AddCommand(OBJECT_SELF, cMove, FALSE, FALSE, -1, 5.0);
}
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: The engine
// When: The creature spawns into the game. This can happen only once,
// regardless of save games.
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_SPAWN:
{
break;
}
case EVENT_TYPE_HANDLE_CUSTOM_AI:
{
MoveToLeader();
}
}
}
What did I do wrong this time?

Modifié par AnnoyingDisplayName, 29 janvier 2010 - 08:35 .


#5
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Okay, I think I'll need this script to repeat itself.

Modifié par AnnoyingDisplayName, 29 janvier 2010 - 09:47 .


#6
Craig Graff

Craig Graff
  • Members
  • 608 messages
A repeating or heartbeat script is possible, but unnecessary. Just make sure that there is a positive value in the local variable AI_CUSTOM_AI_ACTIVE and try the script you have above again. Just keep in mind that the command you have set up will place the creature 8 meters away from the PC. You would be better off with a line like

CommandMoveToObject(oPC, TRUE, 1.0, FALSE, 8.0);

This will keep your follower within 1-8 meters away from the PC.

#7
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Thanks, I will try this! :)

#8
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Wait, I just realized that AI_CUSTOM_AI_ACTIVE made my NPCs stupid enough to not fight... What causes this?

#9
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Well, that didn't work so well, they only follow me one time and whenever I stop, they just stop follow me.

#10
Craig Graff

Craig Graff
  • Members
  • 608 messages
You are basically trying to copy the functionality of cli000cr_army_member.nss but you aren't copying enough.
EVENT_TYPE_HANDLE_CUSTOM_AI only fires during combat, so you will want to copy everything under EVENT_TYPE_HANDLE_CUSTOM_AI and also everything under EVENT_TYPE_CUSTOM_COMMAND_COMPLETE. The only part to exclude would be the sections beginning with if(GetTag(GetArea(OBJECT_SELF)) == "cli220ar_fort_roof_1").

(AI_DetermineCombatRound is the thing that needs to be called under EVENT_TYPE_HANDLE_CUSTOM_AI if you want your creatures to fight.)

Modifié par Craig Graff, 29 janvier 2010 - 10:52 .


#11
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Thank You, I will try that

#12
AnnoyingDisplayName

AnnoyingDisplayName
  • Members
  • 53 messages
Worked Like Charm! Thank You!

#13
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
so glad i found this thead.... ;-)

#14
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
I am unable to locate "cli000cr_army_member.nss" - can someone point me in the right direction?

#15
Craig Graff

Craig Graff
  • Members
  • 608 messages
In the Single Player module.

#16
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
thanks...I was actually searching my HDD after searchig scripts in the toolset - I did not realize you actually had to open the module......leaning a bit more each day.




#17
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Thanks to all the thoughtful guidance here, I've things working quite well. There are however two behaviours i'd like to ajust:



(1) Creatures running the script (modified army_member) do not follow the controlled character until after the first battle (essentially, if you want their help, you have to bring the fight to them - not so hard, but not the intended effect).



(2) When travelling accross a large room or area, the creatures running the modified army_member script follow the controlled character in fits and starts. Also - it seems the closer they are to the controlled character the frequency of the fits & starts deline.



I have ideas on both these in terms of diagnosing, but I really am a rookie and some advice would be great.



Thanks....RR....