generated from Jaysyn/ModuleTemplate
225 lines
8.3 KiB
Plaintext
225 lines
8.3 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: HIPS restrictions
|
|
//:: tk_hips_inc.nss
|
|
//::
|
|
//:: Created By: The_Krit
|
|
//:: Created On: 10/03/06
|
|
//::
|
|
//:: Based on: sf_hips_inc.nss by scarface.
|
|
//:://////////////////////////////////////////////
|
|
// Forces a character out of stealth if they were in stealth and combat in the
|
|
// past HIPS_DELAY seconds.
|
|
//
|
|
// For greater efficiency, you can skip the combat check. Comment out the
|
|
// entire TK_HiPS_PseudoHeartbeat() function at the top of this file, and
|
|
// uncomment the one at the bottom.
|
|
//:://////////////////////////////////////////////
|
|
|
|
|
|
// Number of seconds a HiPSter must be visible before re-entering stealth.
|
|
const int HIPS_DELAY = 6; // 1 round.
|
|
|
|
// Flags to indicate the status of the PC one second ago.
|
|
const int HIPS_OK = 0; // The PC may act freely.
|
|
const int HIPS_INSTEALTH = 1; // The PC is in stealth mode.
|
|
const int HIPS_NEWLYSEEN = 2; // The PC becomes restricted by combat.
|
|
const int HIPS_RESTRICTED = 3; // The PC may not enter stealth mode.
|
|
|
|
|
|
// Pseudo heartbeat function to enforce delay before re-entering stealth.
|
|
// nMode is one of the above constants.
|
|
// nTimer is the number of seconds the PC must wait before re-entering stealth.
|
|
// As with nMode, nTimer is current as of one second ago.
|
|
// (So nTimer == 1 indicates that stealth will be permitted as soon as the
|
|
// current function call ends, but not before.)
|
|
// nTimer is only used when the mode is HIPS_NEWLYSEEN or HIPS_RESTRICTED.
|
|
void TK_HiPS_PseudoHeartbeat(object oPC, int nMode, int nTimer)
|
|
{
|
|
// If the PC no longer exists, cancel the recursion.
|
|
if (!GetIsObjectValid(oPC))
|
|
return;
|
|
|
|
// See if the PC is currently in stealth.
|
|
int bInStealth = GetActionMode(oPC, ACTION_MODE_STEALTH);
|
|
|
|
// Set the new state of the PC based on the previous state.
|
|
switch ( nMode )
|
|
{
|
|
case HIPS_OK: // May enter stealth.
|
|
// Check current stealth mode.
|
|
if ( bInStealth )
|
|
// For the recursion, the PC will have been in stealth mode.
|
|
nMode = HIPS_INSTEALTH;
|
|
break;
|
|
|
|
case HIPS_INSTEALTH: // Might leave stealth.
|
|
// Check current stealth mode.
|
|
if ( !bInStealth )
|
|
{
|
|
// Left stealth. New mode depends on combat.
|
|
if ( GetIsInCombat(oPC) )
|
|
// For the recursion, the PC will be restricted.
|
|
nMode = HIPS_RESTRICTED;
|
|
else
|
|
// For the recursion, the PC will have been newly seen.
|
|
nMode = HIPS_NEWLYSEEN;
|
|
|
|
// Reset the timer.
|
|
nTimer = HIPS_DELAY;
|
|
}
|
|
break;
|
|
|
|
case HIPS_NEWLYSEEN: // Becomes restricted if in combat.
|
|
// Check current stealth mode.
|
|
if ( bInStealth )
|
|
// For the recursion, the PC will have been in stealth mode.
|
|
nMode = HIPS_INSTEALTH;
|
|
else
|
|
{
|
|
// Decrement the timer.
|
|
--nTimer;
|
|
|
|
// Did the timer run out?
|
|
if ( nTimer == 0 )
|
|
// End the restriction.
|
|
nMode = HIPS_OK;
|
|
|
|
// Check combat status.
|
|
else if ( GetIsInCombat(oPC) )
|
|
// For the recursion, the PC will be restricted.
|
|
nMode = HIPS_RESTRICTED;
|
|
}
|
|
break;
|
|
|
|
case HIPS_RESTRICTED: // May not enter stealth.
|
|
// Check current stealth mode.
|
|
if ( bInStealth )
|
|
{
|
|
// Pull the PC out of stealth.
|
|
SetActionMode(oPC, ACTION_MODE_STEALTH, FALSE);
|
|
// Provide some feedback.
|
|
SendMessageToPC(oPC,
|
|
"You may not enter stealth mode for another " +
|
|
IntToString(nTimer) + " seconds.");
|
|
// The following line will anger your players if you uncomment it. :)
|
|
//DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oPC, 3.0));
|
|
// The following line will add unnecessary pizazz if you uncomment it. :)
|
|
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_BIGBYS_CLENCHED_FIST), oPC, 1.5);
|
|
}
|
|
|
|
// Decrement the timer.
|
|
--nTimer;
|
|
|
|
// Did the timer run out?
|
|
if ( nTimer == 0 )
|
|
// End the restriction.
|
|
nMode = HIPS_OK;
|
|
break;
|
|
}//switch(nMode)
|
|
|
|
// Recursion call in one second.
|
|
DelayCommand(1.0, TK_HiPS_PseudoHeartbeat(oPC, nMode, nTimer));
|
|
}
|
|
|
|
|
|
// Call this OnClientEnter.
|
|
// oPC should be the entering object, as given by GetEnteringObject().
|
|
void TK_HiPS_OnClientEnter(object oPC)
|
|
{
|
|
// See if the PC is a HiPSter.
|
|
if ( GetHasFeat(FEAT_HIDE_IN_PLAIN_SIGHT, oPC) )
|
|
{
|
|
// Flag this PC and start the pseudo heartbeat.
|
|
SetLocalInt(oPC, "HIPS_PSEUDOBEAT_RUNNING", TRUE);
|
|
TK_HiPS_PseudoHeartbeat(oPC, HIPS_OK, 0);
|
|
}
|
|
}
|
|
|
|
// Call this when a PC might have gained a feat.
|
|
// (e.g., OnPlayerLevelUp and OnEquipItem.)
|
|
// If the feat is from an item, the pseudo heartbeat will
|
|
// continue after the item is unequipped.
|
|
void TK_HiPS_OnFeatChange(object oPC)
|
|
{
|
|
// See if the PC just became a HiPSter.
|
|
if ( GetHasFeat(FEAT_HIDE_IN_PLAIN_SIGHT, oPC) &&
|
|
!GetLocalInt(oPC, "HIPS_PSEUDOBEAT_RUNNING") )
|
|
{
|
|
// Flag this PC and start the pseudo heartbeat.
|
|
SetLocalInt(oPC, "HIPS_PSEUDOBEAT_RUNNING", TRUE);
|
|
TK_HiPS_PseudoHeartbeat(oPC, HIPS_OK, 0);
|
|
}
|
|
}
|
|
|
|
|
|
// Pseudo heartbeat function to enforce delay before re-entering stealth.
|
|
// Smaller version -- use if efficiency is of utmost importance.
|
|
// nMode is one of the above constants (but not HIPS_NEWLYSEEN).
|
|
// nTimer is the number of seconds the PC must wait before re-entering stealth.
|
|
// As with nMode, nTimer is current as of one second ago.
|
|
// (So nTimer == 1 indicates that stealth will be permitted as soon as the
|
|
// current function call ends, but not before.)
|
|
// nTimer is only used when the mode is HIPS_RESTRICTED.
|
|
/* -- begin comment
|
|
void TK_HiPS_PseudoHeartbeat(object oPC, int nMode, int nTimer)
|
|
{
|
|
// If the PC no longer exists, cancel the recursion.
|
|
if (!GetIsObjectValid(oPC))
|
|
return;
|
|
|
|
// See if the PC is currently in stealth.
|
|
int bInStealth = GetActionMode(oPC, ACTION_MODE_STEALTH);
|
|
|
|
// Set the new state of the PC based on the previous state.
|
|
switch ( nMode )
|
|
{
|
|
case HIPS_OK: // May enter stealth.
|
|
// Check current stealth mode.
|
|
if ( bInStealth )
|
|
// For the recursion, the PC will have been in stealth mode.
|
|
nMode = HIPS_INSTEALTH;
|
|
break;
|
|
|
|
case HIPS_INSTEALTH: // Might leave stealth.
|
|
// Check current stealth mode.
|
|
if ( !bInStealth )
|
|
{
|
|
// For the recursion, the PC will be restricted.
|
|
nMode = HIPS_RESTRICTED;
|
|
// Reset the timer.
|
|
nTimer = HIPS_DELAY;
|
|
}
|
|
break;
|
|
|
|
case HIPS_RESTRICTED: // May not enter stealth.
|
|
// Check current stealth mode.
|
|
if ( bInStealth )
|
|
{
|
|
// Pull the PC out of stealth.
|
|
SetActionMode(oPC, ACTION_MODE_STEALTH, FALSE);
|
|
// Provide some feedback.
|
|
SendMessageToPC(oPC,
|
|
"You may not enter stealth mode for another " +
|
|
IntToString(nTimer) + " seconds.");
|
|
// The following line will anger your players if you uncomment it. :)
|
|
//DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oPC, 3.0));
|
|
// The following line will add unnecessary pizazz if you uncomment it. :)
|
|
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_BIGBYS_CLENCHED_FIST), oPC, 1.5);
|
|
}
|
|
|
|
// Decrement the timer.
|
|
--nTimer;
|
|
|
|
// Did the timer run out?
|
|
if ( nTimer == 0 )
|
|
// End the restriction.
|
|
nMode = HIPS_OK;
|
|
break;
|
|
}//switch(nMode)
|
|
|
|
// Recursion call in one second.
|
|
DelayCommand(1.0, TK_HiPS_PseudoHeartbeat(oPC, nMode, nTimer));
|
|
}
|
|
-- end comment */
|
|
|