Battledale_PRC8/_removed/nw_c2_default1.nss
Jaysyn904 7b9e44ebbb 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.
2024-03-11 23:44:08 -04:00

254 lines
6.2 KiB
Plaintext

////////////::////////////////////////////////////////////////////
//:: Default On Heartbeat
//:: NW_C2_DEFAULT1
//:: Copyright (c) 2001 Bioware Corp.
//::////////////////////////////////////////////////////
/*
This script will have people perform default
animations.
*/
//::///////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 23, 2001
//:://///////////////////////////////////////////////
// makes the mob sneak if it should be
void CheckSneak(object oMob=OBJECT_SELF);
#include "NW_I0_GENERIC"
void main()
{
int nTalent=FALSE;
object oTarget=GetTarget();
if ((GetIsDead(oTarget))||(!GetIsEnemy(oTarget)))
{
SetTarget(OBJECT_INVALID);
oTarget=OBJECT_INVALID;
}
// NB, note D8 check below also applies
if ((GetArea(oTarget)!=GetArea(OBJECT_SELF))&&(d4()==1))
{
SetTarget(OBJECT_INVALID);
oTarget=OBJECT_INVALID;
}
int nCoward=FALSE;
if ((GetLevelByClass(CLASS_TYPE_COMMONER)>=1)||(GetLocalInt(OBJECT_SELF,"coward")==TRUE))
{
nCoward=TRUE;
}
// puts the NPC into spot mode if it is near its target but cannot see it
/// or takes it out if it is already near its target and has failed to see it
if ((!GetObjectSeen(oTarget))&&(GetIsObjectValid(oTarget))&&(GetDistanceToObject(oTarget)<12.0)&&(!GetIsFighting(OBJECT_SELF)))
{
if ((!GetHasEffect(EFFECT_TYPE_TRUESEEING))&&(!GetHasEffect(EFFECT_TYPE_SEEINVISIBLE)))
{
nTalent=TalentSeeInvisible();
}
if ((!GetDetectMode(OBJECT_SELF))&&(!GetIsFighting(OBJECT_SELF))&&(nTalent==FALSE))
{
ActionUseSkill(SKILL_SPOT,OBJECT_SELF);
SetTarget(OBJECT_INVALID);
oTarget=OBJECT_INVALID;
}
}
if (!GetIsObjectValid(oTarget))
{
oTarget=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,OBJECT_SELF,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN_AND_HEARD);
if (!GetIsObjectValid(oTarget))
{
oTarget=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,OBJECT_SELF,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN_AND_NOT_HEARD);
}
if (!GetIsObjectValid(oTarget))
{
oTarget=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,OBJECT_SELF,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_HEARD_AND_NOT_SEEN);
}
if (GetIsObjectValid(oTarget))
{
SetTarget(oTarget);
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
}
if(GetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY))
{
if(TalentAdvancedBuff(40.0))
{
SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY, FALSE);
return;
}
}
if(!GetIsInCombat(OBJECT_SELF)&&(GetIsObjectValid(oTarget))&&(nCoward==FALSE))
{
if (GetObjectSeen(oTarget)||GetObjectHeard(oTarget))
{
if ((GetStealthMode(OBJECT_SELF)!=TRUE)&&(d3()==1))
{
PlayVoiceChat(VOICE_CHAT_ATTACK);
}
if (!GetIsFighting(OBJECT_SELF))
{
DetermineCombatRound();
}
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
else
{
if ((GetHitDice(OBJECT_SELF)<4)||(d8()==1))
{
SetTarget(OBJECT_INVALID);
oTarget=OBJECT_INVALID;
}
else
{
ActionMoveToObject(oTarget,TRUE,4.0);
}
}
}
else
if((!GetIsInCombat())&&(GetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING))&&(!GetIsObjectValid(oTarget)))
{
// turn off spot mode if in spot mode
if (GetDetectMode(OBJECT_SELF))
{
ActionUseSkill(SKILL_SPOT,OBJECT_SELF);
}
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();
}
}
else
if((!GetIsInCombat())&&(!GetHasEffect(EFFECT_TYPE_SLEEP))&&(!GetIsObjectValid(oTarget))&& (!IsInConversation(OBJECT_SELF)))
{
// make the mob sneak at this point if it should be
CheckSneak(OBJECT_SELF);
// check if it has any waypoints to walk
if(GetIsPostOrWalking())
{
///SpeakString("I should be wwp");
WalkWayPoints();
}
else
/// no waypoints so do something else
if (GetisCustomEncounterCreature())
{
// custom encounter creatures check where they are and go home if needed
if ((GetDistanceBetweenLocations(GetLocation(OBJECT_SELF),GetStartLocation())>7.0)||(GetAreaFromLocation(GetStartLocation())!=GetArea(OBJECT_SELF)))
{
ActionMoveToLocation(GetStartLocation());
}
// It is at home already so . .
else
{
// check if we need to rest
if (!MonsterRest())
{ // We dont need to rest, so just do our animations
PlayMobileAmbientAnimations();
}
}
// End custom encounter creature stuff
}
else
// Now we have non custom mobs - they just do immobile animations if needed
if (GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS))
{
//SpeakString("I have failed to wwp");
PlayImmobileAmbientAnimations();
}
}
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}
}
void CheckSneak(object oMob=OBJECT_SELF)
{
if ((GetChallengeRating(OBJECT_SELF)>3.0)&&(GetLevelByClass(CLASS_TYPE_ROGUE,OBJECT_SELF)>=1)&&(GetStandardFactionReputation(STANDARD_FACTION_DEFENDER,OBJECT_SELF)<40))
{
if (!GetStealthMode(OBJECT_SELF)==STEALTH_MODE_ACTIVATED)
{
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
//SpeakString("stealthing from hb");
return;
}
else
{
return;
}
}
else
{
return;
}
}