PoA_PRC8/_module/nss/onconv_rowan.nss

108 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2022-10-07 14:20:31 -04:00
//:://////////////////////////////////////////////////
//:: 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 "nwnx_system"
void main()
{
if(GetListenPatternNumber() == 5432) // pattern set in listen_activate as **::**
if(GetLocalObject(OBJECT_SELF, "Master") == GetLastSpeaker())
{
string sCommand = GetMatchedSubstring(0);
string sParameter = GetMatchedSubstring(2);
object oPlayer = GetLastSpeaker();
if(sCommand == "nwnx")
{
NWNXSystemCommandHandler(oPlayer, sParameter);
return;
}
else
SendMessageToPC(oPlayer, "That command cannot be understood by the listener");
}
// * if petrified, jump out
if (GetHasEffect(EFFECT_TYPE_PETRIFY, OBJECT_SELF) == TRUE)
{
return;
}
// * If dead, exit directly.
if (GetIsDead(OBJECT_SELF) == TRUE)
{
return;
}
// See if what we just 'heard' matches any of our
// predefined patterns
int nMatch = GetListenPatternNumber();
object oShouter = GetLastSpeaker();
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 (GetHasEffect(EFFECT_TYPE_CHARMED) == TRUE)
{
ClearActions(CLEAR_NW_C2_DEFAULT4_29);
BeginConversation();
}
}
// Respond to shouts from friendly non-PCs only
else if (GetIsObjectValid(oShouter)
&& !GetIsPC(oShouter)
&& GetIsFriend(oShouter))
{
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);
}
// Send the user-defined event if appropriate
if(GetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DIALOGUE));
}
}