2025/07/28 Update

Added PEPS AI
Full compile.
This commit is contained in:
Jaysyn904
2025-07-28 16:16:23 -04:00
parent 222171781b
commit 4f42bd0a2a
1530 changed files with 45560 additions and 1208 deletions

View File

@@ -1,93 +1,70 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT4
/*
Default OnConversation event handler for NPCs.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
#include "prc_inc_spells"
/*//////////////////////////////////////////////////////////////////////////////
Script: 0e_c2_4_convers
Programmer: Philos
////////////////////////////////////////////////////////////////////////////////
Monster OnConversation;
Fires when oCreature has been clicked on for conversation.
Fires when oCreature hears a shout from another creature.
If SetListening is FALSE then oCreature will not "hear" anything.
*///////////////////////////////////////////////////////////////////////////////
#include "0i_associates"
void ai_MonsterCommands(object oCreature, object oSpeaker, int nMatch);
void main()
{
// * if petrified, jump out
if (PRCGetHasEffect(EFFECT_TYPE_PETRIFY, OBJECT_SELF) == TRUE)
object oCreature = OBJECT_SELF;
ExecuteScript("prc_npc_conv", oCreature);
if(AI_DEBUG) ai_Debug("nw_c2_default4", "15", GetName(oCreature) + " listens " +
IntToString(GetListenPatternNumber()) + " to " + GetName(GetLastSpeaker()) + "." +
" AI_AM_I_SEARCHING: " + IntToString(GetLocalInt(oCreature, AI_AM_I_SEARCHING)));
if(ai_GetIsBusy(oCreature) || ai_Disabled(oCreature) || GetLocalInt(oCreature, AI_AM_I_SEARCHING)) return;
if(ai_GetIsInCombat(oCreature))
{
ai_DoMonsterCombatRound(oCreature);
return;
}
// * If dead, exit directly.
if (GetIsDead(OBJECT_SELF) == TRUE)
{
return;
}
ExecuteScript("prc_npc_conv", OBJECT_SELF);
// See if what we just 'heard' matches any of our
// predefined patterns
object oLastSpeaker = GetLastSpeaker();
int nMatch = GetListenPatternNumber();
object oShouter = GetLastSpeaker();
if (nMatch == -1)
if(nMatch != -1)
{
// Not a match -- start an ordinary conversation
if (GetCommandable(OBJECT_SELF))
{
ClearActions(CLEAR_NW_C2_DEFAULT4_29);
BeginConversation();
}
else
// * July 31 2004
// * If only charmed then allow conversation
// * so you can have a better chance of convincing
// * people of lowering prices
if (PRCGetHasEffect(EFFECT_TYPE_CHARMED) == TRUE)
{
ClearActions(CLEAR_NW_C2_DEFAULT4_29);
BeginConversation();
}
if(GetFactionEqual(oLastSpeaker, oCreature)) ai_MonsterCommands(oCreature, oLastSpeaker, nMatch);
}
// Respond to shouts from friendly non-PCs only
else if (GetIsObjectValid(oShouter)
&& !GetIsPC(oShouter)
&& GetIsFriend(oShouter))
else
{
object oIntruder = OBJECT_INVALID;
// Determine the intruder if any
if(nMatch == 4)
{
oIntruder = GetLocalObject(oShouter, "NW_BLOCKER_INTRUDER");
}
else if (nMatch == 5)
{
oIntruder = GetLastHostileActor(oShouter);
if(!GetIsObjectValid(oIntruder))
{
oIntruder = GetAttemptedAttackTarget();
if(!GetIsObjectValid(oIntruder))
{
oIntruder = GetAttemptedSpellTarget();
if(!GetIsObjectValid(oIntruder))
{
oIntruder = OBJECT_INVALID;
}
}
}
}
// Actually respond to the shout
RespondToShout(oShouter, nMatch, oIntruder);
ai_ClearCreatureActions();
BeginConversation();
}
// Send the user-defined event if appropriate
if(GetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DIALOGUE));
}
}
void ai_MonsterCommands(object oCreature, object oSpeaker, int nMatch)
{
object oTarget = GetLocalObject(oSpeaker, AI_MY_TARGET);
if(nMatch == AI_ALLY_SEES_AN_ENEMY || nMatch == AI_ALLY_HEARD_AN_ENEMY)
{
if(AI_DEBUG) ai_Debug("nw_c2_default4", "46", GetName(oCreature) + " heard " +
GetName(oSpeaker) + " has seen an enemy!");
if(ai_CanIAttack(oCreature)) ai_FindTheEnemy(oCreature, oSpeaker, oTarget, TRUE);
}
else if(nMatch == AI_ALLY_ATKED_BY_WEAPON ||
nMatch == AI_ALLY_ATKED_BY_SPELL)
{
if(AI_DEBUG) ai_Debug("nw_c2_default4", "53", GetName(oCreature) + " heard " +
GetName(oSpeaker) + " has been attacked by " +
GetName(GetLocalObject(oSpeaker, AI_MY_TARGET)) + "!");
if(ai_CanIAttack(oCreature)) ai_FindTheEnemy(oCreature, oSpeaker, oTarget, TRUE);
}
else if(nMatch == AI_ALLY_IS_WOUNDED)
{
if(AI_DEBUG) ai_Debug("nw_c2_default4", "60", GetName(oCreature) + " heard " +
GetName(oSpeaker) + " is wounded!");
if(ai_GetIsInCombat(oCreature)) ai_TryHealingTalent(oCreature, ai_GetNumOfEnemiesInRange(oCreature), oSpeaker);
else ai_TryHealing(oCreature, oSpeaker);
}
/*else if(nMatch == AI_ALLY_IS_DEAD)
{
} */
}