PWE_PRC8/_module/nss/monk_weap_check.nss
Jaysyn904 ee1dc35889 Initial Commit
Initial Commit
2025-04-03 10:29:41 -04:00

187 lines
6.5 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Weapon Check Guard v 1.0
//:: On Heartbeat
//:: onheart_chkwpn
//:://////////////////////////////////////////////
/*
Guard will warn player with weapon in hand to put it away.
After a few warnings the guard will attack the offending player.
*/
//:://////////////////////////////////////////////
//:: Created By: David "The Shadowlord" Corrales
//:: Created On: August 20 2002
//:://////////////////////////////////////////////
#include "inc_utility"
#include "NW_I0_GENERIC"
//VARIABLES START - EDIT AT OWN PLEASURE
string WARNING1 = "Please put away your weapon";
string WARNING2 = "This is a Temple of peace. Put that weapon away!";
string WARNING3 = "If you will not disarm peacefully, I will do it for you with force!";//Move to Player
string ATTACK_MSG = "Very well... you were warned three times. I shall not tolerate any more! ATTACK!";//Attack here
string COMPLY_REPLY = "Thank you.";
float WARN_DISTANCE = 20.0;//Distance in which to spot player
float ANGER_DUR = 120.0; //Length of time (sec) that will remain angry at the pc
//END OF VARIABLES
void main()
{
ExecuteScript("prc_npc_hb", OBJECT_SELF);
object oPC;
object item;
oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;
if (GetItemPossessedBy(oPC, "RykarianArmySignetRing")!= OBJECT_INVALID)
return;
if(oPC != OBJECT_INVALID && (GetDistanceBetween(OBJECT_SELF,oPC) < WARN_DISTANCE) && GetObjectSeen(oPC) && !GetIsEnemy(oPC))
{
if((item = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC))!=OBJECT_INVALID)
{
if(GetLocalObject(OBJECT_SELF,"LastOffender")==oPC)
{
if(GetLocalInt(OBJECT_SELF,"OffenseCount")==2)
{
SpeakString(ATTACK_MSG);
SetIsTemporaryEnemy(oPC,OBJECT_SELF,TRUE,ANGER_DUR);
ActionAttack(oPC);
}
else if(GetLocalInt(OBJECT_SELF,"OffenseCount")==1)
{
ActionMoveToObject(oPC,TRUE);
SetLocalInt(OBJECT_SELF,"OffenseCount",2);
SpeakString(WARNING3);
}
else
{
SetLocalInt(OBJECT_SELF,"OffenseCount",1);
SpeakString(WARNING2);
}
}
else
{
SetLocalInt(OBJECT_SELF,"OffenseCount",0);
SpeakString(WARNING1);
SetLocalObject(OBJECT_SELF,"LastOffender",oPC);
}
}
else
{
if( GetLocalObject(OBJECT_SELF,"LastOffender")!= OBJECT_INVALID)
SpeakString(COMPLY_REPLY);
DeleteLocalObject(OBJECT_SELF,"LastOffender");
SetLocalInt(OBJECT_SELF,"OffenseCount",0);
}
}
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(!PRCGetHasEffect(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() &&
!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
{
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);
}
}
}
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}
}
/* Script generated by
Lilac Soul's NWN Script Generator, v. 1.3
For download info, please visit:
http://www.lilacsoul.revility.com */
//Goes on creature's OnHeartbeat. Fires when not fighting or talking.
//void main()
//{
//object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
//if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;
//if (GetItemPossessedBy(oPC, "RykarianArmySignetRing")== OBJECT_INVALID)
//return;
//}