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);
}
}
Creature AI script?
Débuté par
AnnoyingDisplayName
, janv. 08 2010 10:44
#1
Posté 08 janvier 2010 - 10:44
#2
Posté 09 janvier 2010 - 12:41
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.
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.
#3
Posté 09 janvier 2010 - 04:52
Thank you, David. But, how do I state it in a global way?
EDIT: I've looked into "bhn200ar_castle_after_siege.nss", and "bhn200pt_panicked.nss" These are all plot related scripts according to my noob knowledge. However, I don't know how I am going to write this AI script and don't know where to begin. My intention is clear that AI script that I've tried should remove dead creatures from non party followers. Also by modifying my spawn script, I think I managed to get a really brief, and initial effect that didn't even last 2 testings that I've done. Anyway here's the spawning 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; // 1.5 is the number of meters away from the player the spawn point will be
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) );
object oNonPartyFollower1 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower1.utc", lSpawn1);
object oNonPartyFollower2 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower2.utc", lSpawn2);
object oNonPartyFollower3 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower3.utc", lSpawn3);
object oNonPartyFollower4 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower4.utc", lSpawn2);
object oNonPartyFollower5 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower5.utc", lSpawn3);
// this is the part where I added some extra stuff to try to get that AI script work. I got
// these from "bhn200ar_castle_after_siege.nss", and "bhn200pt_panicked.nss" after studying them.
int nNonPartyFollowers = GetLocalInt(oArea,AREA_COUNTER_1);
nNonPartyFollowers = nNonPartyFollowers + 1;
SetLocalInt(oArea,AREA_COUNTER_1,nNonPartyFollowers);
//SET check for on death script
SetLocalInt(oNonPartyFollower1,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower2,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower3,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower4,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower5,CREATURE_DO_ONCE_A,TRUE);
AddNonPartyFollower(oNonPartyFollower1);
AddNonPartyFollower(oNonPartyFollower2);
AddNonPartyFollower(oNonPartyFollower3);
AddNonPartyFollower(oNonPartyFollower4);
AddNonPartyFollower(oNonPartyFollower5);
}
EDIT: I've looked into "bhn200ar_castle_after_siege.nss", and "bhn200pt_panicked.nss" These are all plot related scripts according to my noob knowledge. However, I don't know how I am going to write this AI script and don't know where to begin. My intention is clear that AI script that I've tried should remove dead creatures from non party followers. Also by modifying my spawn script, I think I managed to get a really brief, and initial effect that didn't even last 2 testings that I've done. Anyway here's the spawning 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; // 1.5 is the number of meters away from the player the spawn point will be
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) );
object oNonPartyFollower1 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower1.utc", lSpawn1);
object oNonPartyFollower2 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower2.utc", lSpawn2);
object oNonPartyFollower3 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower3.utc", lSpawn3);
object oNonPartyFollower4 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower4.utc", lSpawn2);
object oNonPartyFollower5 = CreateObject(OBJECT_TYPE_CREATURE, R"my_creature_follower5.utc", lSpawn3);
// this is the part where I added some extra stuff to try to get that AI script work. I got
// these from "bhn200ar_castle_after_siege.nss", and "bhn200pt_panicked.nss" after studying them.
int nNonPartyFollowers = GetLocalInt(oArea,AREA_COUNTER_1);
nNonPartyFollowers = nNonPartyFollowers + 1;
SetLocalInt(oArea,AREA_COUNTER_1,nNonPartyFollowers);
//SET check for on death script
SetLocalInt(oNonPartyFollower1,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower2,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower3,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower4,CREATURE_DO_ONCE_A,TRUE);
SetLocalInt(oNonPartyFollower5,CREATURE_DO_ONCE_A,TRUE);
AddNonPartyFollower(oNonPartyFollower1);
AddNonPartyFollower(oNonPartyFollower2);
AddNonPartyFollower(oNonPartyFollower3);
AddNonPartyFollower(oNonPartyFollower4);
AddNonPartyFollower(oNonPartyFollower5);
}
Modifié par AnnoyingDisplayName, 09 janvier 2010 - 05:03 .
#4
Posté 09 janvier 2010 - 07:20
I'm doing everything I can but seems no progress has been made. I think no one is willing to help me. I need a script master!
#5
Posté 09 janvier 2010 - 10:59
How convinient it would be if there's a tutorial on this... non party follower thing. I hope one of developers or anyone who knows and understands scripting very well will put this tutorial on.
#6
Posté 10 janvier 2010 - 04:14
See how this flyz:
[dascript]
#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);
int nEventHandled = FALSE;
switch( nEventType )
{ case EVENT_TYPE_DEATH:
RemoveNonPartyFollower( OBJECT_SELF );
break;
}
if( !nEventHandled ) HandleEvent( ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
[/dascript]
[dascript]
#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);
int nEventHandled = FALSE;
switch( nEventType )
{ case EVENT_TYPE_DEATH:
RemoveNonPartyFollower( OBJECT_SELF );
break;
}
if( !nEventHandled ) HandleEvent( ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
[/dascript]
Modifié par Axe_Murderer, 10 janvier 2010 - 04:16 .
#7
Posté 10 janvier 2010 - 05:37
Thank you, good sir! I'll try that and notify.
#8
Posté 12 janvier 2010 - 07:51
I think I will not mess with this until tutorial is up... This is too hard for a noob like me. So instead I decided to make a summoning spell but looking for tutorial on how to associate my custom summon creature to new magic that I made.
#9
Posté 22 janvier 2010 - 03:15
I don't know this removal script is working now or not but may be I need other way around.





Retour en haut






