20255/17/19 Update

Added PEPS AI.
Full compile.
This commit is contained in:
Jaysyn904
2025-07-19 18:27:32 -04:00
parent dd3496e400
commit d2a9c50615
2533 changed files with 136137 additions and 13984 deletions

View File

@@ -1,102 +1,136 @@
//::///////////////////////////////////////////////
//:: Default On Percieve
//:: NW_C2_DEFAULT2
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Checks to see if the perceived target is an
enemy and if so fires the Determine Combat
Round function
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 16, 2001
//:://////////////////////////////////////////////
#include "hench_i0_ai"
/*//////////////////////////////////////////////////////////////////////////////
Script: nw_c2_default2
Programmer: Philos
////////////////////////////////////////////////////////////////////////////////
Monster OnPerception script when not in combat;
There are 4 types of perception - Heard, Inaudible, Seen, Vanished.
Only one type will ever be true in an event trigger.
The order of trigger is Heard/Seen and Inaudible/Vanished.
There are two states of percepion Heard and Seen.
These states can be set at the same time thus a heard event can see the creature.
Fires when ever one of these states changes from TRUE to FALSE or FALSE to TRUE.
*///////////////////////////////////////////////////////////////////////////////
#include "0i_associates"
void main()
{
// * if not runnning normal or better Ai then exit for performance reasons
// * if not runnning normal or better Ai then exit for performance reasons
if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
//ExecuteScript("prc_npc_percep", OBJECT_SELF);
// * if not runnning normal or better AI then exit for performance reasons
//if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
object oCreature = OBJECT_SELF;
ExecuteScript("prc_npc_percep", OBJECT_SELF);
if(AI_DEBUG) ai_Debug("nw_c2_default2", "19", "AI_ONSPAWN_EVENT: " + IntToString(GetLocalInt(oCreature, AI_ONSPAWN_EVENT)));
if(!GetLocalInt(oCreature, AI_ONSPAWN_EVENT)) return;
if(GetLastPerceptionSeen())
{
if(AI_DEBUG) ai_Debug("nw_c2_default2", "22", GetName(oCreature) + " sees " +
GetName(GetLastPerceived()) + " Distance: " +
FloatToString(GetDistanceBetween(GetLastPerceived(), oCreature), 0, 2) + ".");
}
if(GetLastPerceptionHeard())
{
if(AI_DEBUG) ai_Debug("nw_c2_default2", "28", GetName(oCreature) + " heard " +
GetName(GetLastPerceived()) + " Distance: " +
FloatToString(GetDistanceBetween(GetLastPerceived(), oCreature), 0, 2) + ".");
}
if(GetLastPerceptionVanished ())
{
if(AI_DEBUG) ai_Debug("nw_c2_default2", "34", GetName(oCreature) + " lost sight of " +
GetName(GetLastPerceived ()) + ".");
}
// We do nothing on Inaudibles so drop out early!
if(GetLastPerceptionInaudible())
{
if(AI_DEBUG) ai_Debug("nw_c2_default2", "41", GetName(oCreature) + " lost sound of " +
GetName(GetLastPerceived()) + ".");
return;
}
object oLastPerceived = GetLastPerceived();
if(AI_DEBUG) ai_Debug("nw_c2_default2", "45", "Dead? " + IntToString(GetIsDead(oLastPerceived)) +
" Enemy? " + IntToString(GetIsEnemy(oLastPerceived, oCreature)));
if(ai_Disabled(oCreature)) return;
if(GetIsDead(oLastPerceived)) return;
int bSeen = GetLastPerceptionSeen();
//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(oLastPerceived) &&
bSeen)
// This will cause all NPC's to speak their one-liner conversation
// on perception even if they are already in combat.
if(GetIsPC(oLastPerceived) && bSeen)
{
SpeakOneLinerConversation();
}
//If the last perception event was hearing based or if someone vanished then go to search mode
if (GetLastPerceptionVanished() || GetLastPerceptionInaudible())
{
// Jug_Debug(GetName(OBJECT_SELF) + " lost perceived " + GetName(oLastPerceived) + " seen " + IntToString(GetObjectSeen(oLastPerceived)) + " heard " + IntToString(GetObjectHeard(oLastPerceived)));
if (!GetObjectSeen(oLastPerceived) && !GetObjectHeard(oLastPerceived) &&
!GetIsDead(oLastPerceived) && GetArea(oLastPerceived) == GetArea(OBJECT_SELF) &&
GetIsEnemy(oLastPerceived) && (!HENCH_MONSTER_DONT_CHECK_HEARD_MONSTER || GetIsPC(GetTopMaster(oLastPerceived))))
if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION))
{
// Jug_Debug(GetName(OBJECT_SELF) + " move to last heard or seen");
SetEnemyLocation(oLastPerceived);
// add check if target - prevents creature from following the target
// due to ActionAttack without actually perceiving them
if (GetLocalObject(OBJECT_SELF, sHenchLastTarget) == oLastPerceived)
SpeakOneLinerConversation();
}
}
if(GetIsEnemy(oLastPerceived, oCreature))
{
// ************************** ENEMY SEEN *******************************
if(bSeen)
{
// If the creature we are perceiving was our invisible creature then
// remove that they are invisible.
if(oLastPerceived == GetLocalObject(oCreature, AI_IS_INVISIBLE))
{
DeleteLocalObject(OBJECT_SELF, sHenchLastTarget);
HenchDetermineCombatRound(oLastPerceived, TRUE);
DeleteLocalObject(oCreature, AI_IS_INVISIBLE);
}
ai_MonsterEvaluateNewThreat(oCreature, oLastPerceived, AI_I_SEE_AN_ENEMY);
}
// ************************** ENEMY HEARD ******************************
else if(GetLastPerceptionHeard())
{
ai_MonsterEvaluateNewThreat(oCreature, oLastPerceived, AI_I_HEARD_AN_ENEMY);
}
// ************************** ENEMY VANISHED ***************************
else if(GetLastPerceptionVanished())
{
// Lets keep a mental note of the invisible creature.
SetLocalObject(oCreature, AI_IS_INVISIBLE, oLastPerceived);
if(AI_DEBUG) ai_Debug("0e_c2_2_percept", "82", " We saw " + GetName(oLastPerceived) + " disappear!");
if(ai_GetIsBusy(oCreature)) return;
// If in combat check to see if our target disappeared.
// If they have and we are not in melee with them then reevaluate combat
// since we lost our target.
if(ai_GetIsInCombat(oCreature))
{
if(AI_DEBUG) ai_Debug("nw_c2_default2", "89", "Is this our target? " +
IntToString(ai_GetAttackedTarget(oCreature, TRUE, TRUE) == oLastPerceived));
if(ai_GetAttackedTarget(oCreature, TRUE, TRUE) == oLastPerceived)
{
ai_DoMonsterCombatRound(oCreature);
}
}
// We are not in combat so lets move to that location and check it out.
else ActionMoveToLocation(GetLocation(oLastPerceived), TRUE);
// we use to move to the object but thats a bit creepy!
//else ActionMoveToObject(oLastPerceived, TRUE, AI_RANGE_CLOSE);
}
// ************************ ENEMY INAUDIBLE*****************************
// Not used.
}
else
{
// ************************ NON_ENEMY SEEN *****************************
if(bSeen)
{
if(ai_GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) ai_DetermineSpecialBehavior(oCreature);
else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(oLastPerceived))
{
ActionStartConversation(oCreature);
}
}
}
//Do not bother checking the last target seen if already fighting
else if(bSeen && !GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
if(!IsInConversation(oCreature))
{
// Jug_Debug(GetName(OBJECT_SELF) + " checking perceived " + GetName(oLastPerceived) + " " + IntToString(GetObjectSeen(oLastPerceived)));
// note : hearing is disabled and is only done in heartbeat. Calling GetIsEnemy with hearing causes
// a noticeable lag to machine
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
if(GetIsPostOrWalking())
{
HenchDetermineSpecialBehavior();
WalkWayPoints();
}
else if(GetIsEnemy(oLastPerceived) && !GetIsDead(oLastPerceived))
else if(GetIsPC(oLastPerceived) &&
(GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS) ||
GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN) ||
GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS) ||
GetIsEncounterCreature()))
{
if(!GetHasEffect(EFFECT_TYPE_SLEEP))
{
// Jug_Debug(GetName(OBJECT_SELF) + " starting combat round in percep");
SetFacingPoint(GetPosition(oLastPerceived));
HenchDetermineCombatRound(oLastPerceived);
}
SetAnimationCondition(NW_ANIM_FLAG_IS_ACTIVE);
}
//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(oLastPerceived) && GetObjectSeen(oLastPerceived))
{
ActionStartConversation(OBJECT_SELF);
}
// TODO is this wanted????
// activate ambient animations or walk waypoints if appropriate
/* if (!IsInConversation(OBJECT_SELF)) {
if (GetIsPostOrWalking()) {
WalkWayPoints();
} else if (GetIsPC(oLastPerceived) &&
(GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
|| GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN)
|| GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS)
|| GetIsEncounterCreature()))
{
SetAnimationCondition(NW_ANIM_FLAG_IS_ACTIVE);
}
} */
}
else if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL) && bSeen)
{
HenchDetermineSpecialBehavior();
}
// Send the user-defined event if appropriate
if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT) && bSeen)
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_PERCEIVE));