Initial upload
Initial upload. PRC8 has been added. Module compiles, PRC's default AI & treasure scripts have been integrated. Started work on top hak for SLA / Ability / Scripting modifications.
This commit is contained in:
687
_module/nss/jw_thief_usd.nss
Normal file
687
_module/nss/jw_thief_usd.nss
Normal file
@@ -0,0 +1,687 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Custom User Defined Event
|
||||
//:: FileName
|
||||
//:: Copyright (c) 2001 Bioware Corp.
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By:
|
||||
//:: Created On:
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "NW_I0_GENERIC"
|
||||
#include "jw_custom_spells"
|
||||
|
||||
string sPlace="PLACE_"+GetTag(OBJECT_SELF);
|
||||
// waypoints should be called WALK_tag1 to WALK_tag6
|
||||
string sWalk="WALK_"+GetTag(OBJECT_SELF);
|
||||
int LOOKING=1;
|
||||
int STEALING=2;
|
||||
int RUNNING=3;
|
||||
object oHome=GetWaypointByTag(sPlace);
|
||||
object oPotion=GetItemPossessedBy(OBJECT_SELF,"NW_IT_MPOTION004");
|
||||
|
||||
// standard on combat round end
|
||||
void standardcbr();
|
||||
// standard on damaged
|
||||
void standarddam();
|
||||
// standard heartbeat
|
||||
void standardhb();
|
||||
// standard on perceive
|
||||
void standardperc();
|
||||
// standard on attacked
|
||||
void standardattack();
|
||||
// set the state the thief is in - LOOKING, STEALING or RUNNING
|
||||
void setstate (int nState);
|
||||
// get the state the thief is in - LOOKING, STEALING OR RUNNING
|
||||
int getstate ();
|
||||
// The PC becomes the theif's mark - he won't try to steal from anyone else while the mark is in his sights
|
||||
void setmark (object oPC);
|
||||
// returns TRUE if the theif is at home, otherwise returns FALSE
|
||||
int ishome();
|
||||
// returns TRUE if the theif is very close to their home, otherwise returns FALSE
|
||||
int rightathome();
|
||||
// Get the theif's mark
|
||||
object getmark ();
|
||||
// Thief runs home, or if he is at home he sets his state to looking
|
||||
void runaway ();
|
||||
// Thief sets the PC he has just seen as his mark and steals from him, before running away
|
||||
void stealing (object oPC);
|
||||
// Thief leaves his home and walks his waypoints looking for a mark
|
||||
void looking();
|
||||
// Thief chooses a waypoint at random to walk to, and if he is already there he chooses another
|
||||
void waypointwalk();
|
||||
// returns TRUE if the thief is at his waypoint, or FALSE if he is not.
|
||||
int isatwaypoint();
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
|
||||
|
||||
int nUser = GetUserDefinedEventNumber();
|
||||
|
||||
if(nUser == 1001) //HEARTBEAT
|
||||
{
|
||||
|
||||
if (ishome()&&GetIsInCombat(OBJECT_SELF))
|
||||
{
|
||||
standardhb();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (getstate()==LOOKING)
|
||||
{
|
||||
looking();
|
||||
}
|
||||
else if (getstate()==RUNNING)
|
||||
{
|
||||
runaway();
|
||||
}
|
||||
else if (getstate()==STEALING)
|
||||
{
|
||||
if (!GetObjectSeen(getmark(),OBJECT_SELF))
|
||||
{
|
||||
// SpeakString("My mark has vanished so I will walk waypoints");
|
||||
waypointwalk();
|
||||
setstate(LOOKING);
|
||||
}
|
||||
else
|
||||
{
|
||||
// SpeakString("I am half way through stealing and will not change my action until I am done");
|
||||
// no action
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setstate(LOOKING);
|
||||
looking();
|
||||
}
|
||||
|
||||
}
|
||||
else if(nUser == 1002) // PERCEIVE
|
||||
{
|
||||
object oPC=GetLastPerceived();
|
||||
if (!ishome()&&getstate()==LOOKING)
|
||||
{
|
||||
if ((GetIsPC(oPC))&&(!GetIsDM(oPC))&&(GetRacialType(oPC)!=RACIAL_TYPE_HALFLING))
|
||||
{
|
||||
setstate(STEALING);
|
||||
stealing (oPC);
|
||||
}
|
||||
}
|
||||
|
||||
else if (ishome())
|
||||
{
|
||||
standardperc();
|
||||
}
|
||||
|
||||
}
|
||||
else if(nUser == 1003) // END OF COMBAT
|
||||
{
|
||||
if (!ishome())
|
||||
{
|
||||
|
||||
|
||||
|
||||
setstate(RUNNING);
|
||||
runaway();
|
||||
}
|
||||
else
|
||||
{
|
||||
standardcbr();
|
||||
}
|
||||
|
||||
}
|
||||
else if(nUser == 1004) // ON DIALOGUE
|
||||
{
|
||||
// if (!ishome())
|
||||
// {
|
||||
|
||||
// if (GetStealthMode(OBJECT_SELF)==STEALTH_MODE_ACTIVATED)
|
||||
// {
|
||||
// ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
|
||||
// }
|
||||
// if (GetIsObjectValid(oPotion))
|
||||
// {
|
||||
// talent tUse = GetCreatureTalentBest(TALENT_CATEGORY_BENEFICIAL_ENHANCEMENT_POTION, 20);
|
||||
// if(GetIsTalentValid(tUse))
|
||||
// {
|
||||
// ActionUseTalentOnObject(tUse, OBJECT_SELF);
|
||||
// }
|
||||
// }
|
||||
// ActionDoCommand(SpeakString("someine trying to talk to me, this can't be good - setting state from stealing to running"));
|
||||
// setstate(RUNNING);
|
||||
// runaway();
|
||||
// }
|
||||
|
||||
}
|
||||
else if(nUser == 1005) // ATTACKED
|
||||
{
|
||||
if (!ishome())
|
||||
{
|
||||
|
||||
if (GetStealthMode(OBJECT_SELF)==STEALTH_MODE_ACTIVATED)
|
||||
{
|
||||
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
|
||||
//SpeakOneLinerConversation("jw_thief_con");
|
||||
}
|
||||
setstate(RUNNING);
|
||||
runaway();
|
||||
}
|
||||
else
|
||||
{
|
||||
standardattack();
|
||||
}
|
||||
}
|
||||
else if(nUser == 1006) // DAMAGED
|
||||
{
|
||||
if (GetLocalInt(OBJECT_SELF,"donegarrote")!=1)
|
||||
{
|
||||
object oDamager=GetLastDamager();
|
||||
SetFacingPoint(GetPosition(oDamager));
|
||||
int nHD=GetHitDice(OBJECT_SELF)/4;
|
||||
if (nHD<1)
|
||||
{
|
||||
nHD=1;
|
||||
}
|
||||
if (nHD>4)
|
||||
{
|
||||
nHD=4;
|
||||
}
|
||||
garrote(oDamager, nHD);
|
||||
SetLocalInt(OBJECT_SELF,"donegarrote",1);
|
||||
}
|
||||
|
||||
|
||||
if (!ishome())
|
||||
{
|
||||
|
||||
if (GetStealthMode(OBJECT_SELF)==STEALTH_MODE_ACTIVATED)
|
||||
{
|
||||
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
|
||||
//SpeakOneLinerConversation("jw_thief_con");
|
||||
}
|
||||
setstate(RUNNING);
|
||||
runaway();
|
||||
}
|
||||
else
|
||||
{
|
||||
standarddam();
|
||||
}
|
||||
}
|
||||
else if(nUser == 1007) // DEATH
|
||||
{
|
||||
|
||||
}
|
||||
else if(nUser == 1008) // DISTURBED
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void standardcbr()
|
||||
{
|
||||
|
||||
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
|
||||
{
|
||||
DetermineSpecialBehavior();
|
||||
}
|
||||
else if(!GetSpawnInCondition(NW_FLAG_SET_WARNINGS))
|
||||
{
|
||||
DetermineCombatRound();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void standarddam()
|
||||
|
||||
{
|
||||
object oMemory=GetAttackTarget();
|
||||
if(!GetFleeToExit())
|
||||
{
|
||||
if(!GetSpawnInCondition(NW_FLAG_SET_WARNINGS))
|
||||
{
|
||||
if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
|
||||
{
|
||||
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
|
||||
{
|
||||
DetermineSpecialBehavior(GetLastDamager());
|
||||
}
|
||||
else if(GetIsObjectValid(GetLastDamager()))
|
||||
{
|
||||
DetermineCombatRound();
|
||||
if(!GetIsFighting(OBJECT_SELF))
|
||||
{
|
||||
object oTarget = GetLastDamager();
|
||||
if ((GetAbilityScore(OBJECT_SELF,ABILITY_INTELLIGENCE)>11)&&(GetIsObjectValid(GetMaster(oTarget))))
|
||||
{
|
||||
if (GetObjectSeen(GetMaster(oTarget)))
|
||||
{oTarget=GetMaster(oTarget);}
|
||||
}
|
||||
if(!GetObjectSeen(oTarget) && GetArea(OBJECT_SELF) == GetArea(oTarget))
|
||||
{
|
||||
ActionMoveToLocation(GetLocation(oTarget), TRUE);
|
||||
ActionDoCommand(DetermineCombatRound());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!GetIsObjectValid(GetAttemptedSpellTarget()))
|
||||
{
|
||||
object oTarget = GetAttackTarget();
|
||||
if ((GetAbilityScore(OBJECT_SELF,ABILITY_INTELLIGENCE)>11)&&(GetIsObjectValid(GetMaster(oTarget))))
|
||||
{
|
||||
if (GetObjectSeen(GetMaster(oTarget)))
|
||||
{oTarget=GetMaster(oTarget);}
|
||||
}
|
||||
if(!GetIsObjectValid(oTarget))
|
||||
{
|
||||
oTarget = GetAttemptedAttackTarget();
|
||||
}
|
||||
object oAttacker = GetLastHostileActor();
|
||||
if ((GetAbilityScore(OBJECT_SELF,ABILITY_INTELLIGENCE)>11)&&(GetIsObjectValid(GetMaster(oAttacker))))
|
||||
{
|
||||
if (GetObjectSeen(GetMaster(oAttacker)))
|
||||
{oAttacker=GetMaster(oAttacker);}
|
||||
}
|
||||
if (GetIsObjectValid(oAttacker) && oTarget != oAttacker && GetIsEnemy(oAttacker) &&
|
||||
(GetTotalDamageDealt() > (GetMaxHitPoints(OBJECT_SELF) / 4) ||
|
||||
(GetHitDice(oAttacker) - 2) > GetHitDice(oTarget) ) )
|
||||
{
|
||||
DetermineCombatRound(oAttacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void standardhb()
|
||||
{
|
||||
if(GetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY))
|
||||
{
|
||||
if(TalentAdvancedBuff(40.0))
|
||||
{
|
||||
SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY, FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(GetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING))
|
||||
{
|
||||
int nDay = FALSE;
|
||||
if(GetIsDay() || GetIsDawn())
|
||||
{
|
||||
nDay = TRUE;
|
||||
}
|
||||
if(GetLocalInt(OBJECT_SELF, "NW_GENERIC_DAY_NIGHT") != nDay)
|
||||
{
|
||||
if(nDay == TRUE)
|
||||
{
|
||||
SetLocalInt(OBJECT_SELF, "NW_GENERIC_DAY_NIGHT", TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLocalInt(OBJECT_SELF, "NW_GENERIC_DAY_NIGHT", FALSE);
|
||||
}
|
||||
WalkWayPoints();
|
||||
}
|
||||
}
|
||||
|
||||
if(!GetHasEffect(EFFECT_TYPE_SLEEP))
|
||||
{
|
||||
if(!GetIsPostOrWalking())
|
||||
{
|
||||
if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
|
||||
{
|
||||
if(!GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN)))
|
||||
{
|
||||
if(!GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL) && !IsInConversation(OBJECT_SELF))
|
||||
{
|
||||
if(GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS) || GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN))
|
||||
{
|
||||
PlayMobileAmbientAnimations();
|
||||
}
|
||||
else if(GetIsEncounterCreature() && (GetLocalInt(OBJECT_SELF,"norw")!=1) &&
|
||||
!GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN)))
|
||||
{
|
||||
PlayMobileAmbientAnimations();
|
||||
}
|
||||
else if(GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS) &&
|
||||
!GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN)))
|
||||
{
|
||||
PlayImmobileAmbientAnimations();
|
||||
}
|
||||
else if (GetLocalInt(OBJECT_SELF,"norw")==2)
|
||||
{
|
||||
PlayMobileAmbientAnimations();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DetermineSpecialBehavior();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//DetermineCombatRound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetSpawnInCondition(NW_FLAG_SLEEPING_AT_NIGHT))
|
||||
{
|
||||
effect eVis = EffectVisualEffect(VFX_IMP_SLEEP);
|
||||
if(d10() > 6)
|
||||
{
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void standardperc()
|
||||
|
||||
{
|
||||
//This is the equivalent of a force conversation bubble, should only be used if you want an NPC
|
||||
//to say something while he is already engaged in combat.
|
||||
if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION) && GetIsPC(GetLastPerceived()) && GetLastPerceptionSeen())
|
||||
{
|
||||
SpeakOneLinerConversation();
|
||||
}
|
||||
//If the last perception event was hearing based or if someone vanished then go to search mode
|
||||
if ((GetLastPerceptionVanished()) && GetIsEnemy(GetLastPerceived()))
|
||||
{
|
||||
object oGone = GetLastPerceived();
|
||||
if((GetAttemptedAttackTarget() == GetLastPerceived() ||
|
||||
GetAttemptedSpellTarget() == GetLastPerceived() ||
|
||||
GetAttackTarget() == GetLastPerceived()) && GetArea(GetLastPerceived()) != GetArea(OBJECT_SELF))
|
||||
{
|
||||
ClearAllActions();
|
||||
DetermineCombatRound();
|
||||
}
|
||||
}
|
||||
//Do not bother checking the last target seen if already fighting
|
||||
else if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
|
||||
{
|
||||
//Check if the last percieved creature was actually seen
|
||||
if(GetLastPerceptionSeen())
|
||||
{
|
||||
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
|
||||
{
|
||||
DetermineSpecialBehavior();
|
||||
}
|
||||
else if(GetIsEnemy(GetLastPerceived()))
|
||||
{
|
||||
if(!GetHasEffect(EFFECT_TYPE_SLEEP))
|
||||
{
|
||||
SetFacingPoint(GetPosition(GetLastPerceived()));
|
||||
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
|
||||
DetermineCombatRound();
|
||||
}
|
||||
}
|
||||
//Linked up to the special conversation check to initiate a special one-off conversation
|
||||
//to get the PCs attention
|
||||
else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(GetLastPerceived()))
|
||||
{
|
||||
ActionStartConversation(OBJECT_SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void standardattack()
|
||||
{
|
||||
object oTarget=GetLastAttacker();
|
||||
object oMemory=GetAttackTarget();
|
||||
|
||||
//Shout Attack my target, only works with the On Spawn In setup
|
||||
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
|
||||
//Shout that I was attacked
|
||||
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
|
||||
|
||||
if ((GetAbilityScore(OBJECT_SELF,ABILITY_INTELLIGENCE)>11)&&(GetIsObjectValid(GetMaster(oTarget))))
|
||||
{
|
||||
if (GetObjectSeen(GetMaster(oTarget)))
|
||||
{oTarget=GetMaster(oTarget);}
|
||||
}
|
||||
|
||||
if(!GetFleeToExit())
|
||||
{
|
||||
if(!GetSpawnInCondition(NW_FLAG_SET_WARNINGS))
|
||||
{
|
||||
if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()) )
|
||||
{
|
||||
if (GetIsObjectValid(oMemory)&&!GetIsDead(oMemory)&&GetObjectSeen(oMemory) &&GetIsInCombat(OBJECT_SELF))
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(GetIsObjectValid(GetLastAttacker()))
|
||||
{
|
||||
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
|
||||
{
|
||||
//AdjustReputation(GetLastAttacker(), OBJECT_SELF, -100);
|
||||
SetSummonHelpIfAttacked();
|
||||
|
||||
DetermineSpecialBehavior(oTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetArea(GetLastAttacker()) == GetArea(OBJECT_SELF))
|
||||
{
|
||||
SetSummonHelpIfAttacked();
|
||||
DetermineCombatRound();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Put a check in to see if this attacker was the last attacker
|
||||
//Possibly change the GetNPCWarning function to make the check
|
||||
SetSpawnInCondition(NW_FLAG_SET_WARNINGS, FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivateFleeToExit();
|
||||
}
|
||||
}
|
||||
|
||||
void setstate (int nState)
|
||||
{
|
||||
SetLocalInt(OBJECT_SELF,"thiefstate",nState);
|
||||
}
|
||||
|
||||
int getstate ()
|
||||
{
|
||||
int nState=GetLocalInt(OBJECT_SELF,"thiefstate");
|
||||
return (nState);
|
||||
}
|
||||
|
||||
void setmark (object oPC)
|
||||
{
|
||||
SetLocalObject(OBJECT_SELF,"oMark",oPC);
|
||||
}
|
||||
|
||||
int ishome()
|
||||
{
|
||||
int nHome;
|
||||
if (GetDistanceToObject(oHome)>14.0)
|
||||
{
|
||||
nHome=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nHome=1;
|
||||
}
|
||||
return (nHome);
|
||||
}
|
||||
|
||||
int rightathome()
|
||||
{
|
||||
int nHome;
|
||||
if (GetDistanceToObject(oHome)>1.5)
|
||||
{
|
||||
nHome=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nHome=1;
|
||||
}
|
||||
return (nHome);
|
||||
}
|
||||
|
||||
object getmark ()
|
||||
{
|
||||
object oMark=GetLocalObject(OBJECT_SELF,"oMark");
|
||||
return (oMark);
|
||||
}
|
||||
|
||||
void runaway ()
|
||||
{
|
||||
//SpeakString("runaway command");
|
||||
|
||||
if (!rightathome())
|
||||
{
|
||||
ClearAllActions();
|
||||
|
||||
ActionMoveToObject(oHome,TRUE);
|
||||
//SpeakString("not at home so going home");
|
||||
}
|
||||
else
|
||||
{
|
||||
setstate(LOOKING);
|
||||
WalkWayPoints();
|
||||
//SpeakString("at home so setting state to looking and doing wwp again");
|
||||
}
|
||||
}
|
||||
|
||||
void stealing (object oPC)
|
||||
{
|
||||
// SpeakString("stealing command");
|
||||
setmark (oPC);
|
||||
ClearAllActions();
|
||||
ActionUseSkill(SKILL_PICK_POCKET,oPC);
|
||||
//ActionDoCommand(SpeakString("debug running away cos I just stole something"));
|
||||
// ActionDoCommand(SpeakString("setting state from stealing to running"));
|
||||
ActionDoCommand(setstate(RUNNING));
|
||||
ActionDoCommand(runaway());
|
||||
}
|
||||
|
||||
|
||||
void looking()
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
//SpeakString("looking command");
|
||||
|
||||
object oPC=GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC);
|
||||
if ((!GetIsObjectValid(oPC))&&(GetStealthMode(OBJECT_SELF)==STEALTH_MODE_DISABLED))
|
||||
{
|
||||
|
||||
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
|
||||
//SpeakString("debug hiding cos no PCs around");
|
||||
setstate(LOOKING);
|
||||
waypointwalk();
|
||||
}
|
||||
else if ((!GetObjectSeen(OBJECT_SELF,oPC))&&(GetStealthMode(OBJECT_SELF)==STEALTH_MODE_DISABLED)&&(!GetIsDM(oPC)))
|
||||
{
|
||||
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
|
||||
//SpeakString("debug hiding cos nearest PC cant see me");
|
||||
setstate(LOOKING);
|
||||
waypointwalk();
|
||||
}
|
||||
else if ((GetIsObjectValid(oPC))&&(GetObjectSeen(OBJECT_SELF,oPC))&&(!GetIsDM(oPC)))
|
||||
{
|
||||
//SpeakString("been seen so setting state from looking to running");
|
||||
setstate(RUNNING);
|
||||
// run away
|
||||
}
|
||||
|
||||
// if the NPC is at home then run the standard heartbeat scrip which includes the
|
||||
// possibility of attacking an hostile PC
|
||||
|
||||
if (ishome())
|
||||
{
|
||||
//SpeakString("I am at home and I am doing the standard HB script");
|
||||
standardhb();
|
||||
waypointwalk();
|
||||
}
|
||||
// else simply walk waypoints
|
||||
else
|
||||
{
|
||||
// SpeakString("I am not at home so I should be walking waypoints unless something has gone wrong");
|
||||
waypointwalk();
|
||||
}
|
||||
}
|
||||
|
||||
void waypointwalk()
|
||||
{
|
||||
if (GetIsInCombat(OBJECT_SELF))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int nDestination=GetLocalInt(OBJECT_SELF,"destination");
|
||||
if (nDestination==0)
|
||||
{
|
||||
nDestination=d6();
|
||||
SetLocalInt(OBJECT_SELF,"destination",nDestination);
|
||||
}
|
||||
|
||||
string sDest=sWalk+IntToString(nDestination);
|
||||
|
||||
if (!isatwaypoint())
|
||||
{
|
||||
ClearAllActions();
|
||||
ActionMoveToObject(GetWaypointByTag(sDest));
|
||||
}
|
||||
else
|
||||
{
|
||||
nDestination=d6();
|
||||
SetLocalInt(OBJECT_SELF,"destination",nDestination);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int isatwaypoint()
|
||||
{
|
||||
int nIsthere;
|
||||
int nDestination=GetLocalInt(OBJECT_SELF,"destination");
|
||||
string sDest=sWalk+IntToString(nDestination);
|
||||
object oDest=GetWaypointByTag(sDest);
|
||||
|
||||
if (GetDistanceToObject(oDest)>3.0)
|
||||
{
|
||||
nIsthere=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nIsthere=1;
|
||||
}
|
||||
|
||||
return (nIsthere);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user