186 lines
5.7 KiB
Plaintext
186 lines
5.7 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name: Sends the PC back to a WayPoint
|
|
//:: FileName: res_sc_wp
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Jumps the PC back to a Temple based on Alignment
|
|
or Sends them to a Waypoint.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Dezran
|
|
//:: Created On: 11/26/02
|
|
//:: Edited On: 08/10/03
|
|
//:://////////////////////////////////////////////
|
|
|
|
#include "nw_i0_plot"
|
|
|
|
void ApplyPenalty(object oPC);
|
|
|
|
void main()
|
|
{
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
// Set up the Variables
|
|
object oRes, oPC;
|
|
location lRes;
|
|
int nAlign, nRespawn, nPen;
|
|
effect eRespawn, eRespawn2;
|
|
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
// Set this variable to determine whether you want Alignment-Based
|
|
// Respawning, or Respawning to a single point.
|
|
// Default is Alignment-Based.
|
|
|
|
// Uncomment the line for the Respawn type you require. Be sure to
|
|
// Re-Comment the other line so that there will not be a conflict.
|
|
//
|
|
nRespawn = 0; // Alignment-Based Respawn
|
|
// nRespawn = 1; // Single Point Respawn
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
// Take a penalty or not
|
|
|
|
// Uncomment the appropriate line for whether you wish to apply a
|
|
// penalty or not
|
|
|
|
// nPen = 0; // No Penalty
|
|
nPen = 1; // Take a Penalty
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// Get the PC
|
|
oPC = GetPCSpeaker();
|
|
|
|
// Get the Alignment to base Effect from
|
|
nAlign = GetLocalInt(oPC, "Res_Align");
|
|
|
|
// Decide which type of Respawn to use
|
|
switch (nRespawn)
|
|
{
|
|
// Set the Respawn point & Effects based on the PC's Alignment
|
|
case 0:
|
|
switch (nAlign)
|
|
{
|
|
case 1:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_LOS_EVIL_30);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_PWKILL);
|
|
oRes = GetWaypointByTag("WP_RESPAWN_EVIL");
|
|
break;
|
|
|
|
case 2:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_NATURES_BALANCE);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_SOUND_BURST);
|
|
oRes = GetWaypointByTag("WP_RESPAWN_NEUT");
|
|
break;
|
|
|
|
case 3:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_DISPEL_DISJUNCTION);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_WORD);
|
|
oRes = GetWaypointByTag("WP_RESPAWN_GOOD");
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
// In this case, the PC will respawn back at one Respawn point.
|
|
oRes = GetWaypointByTag("WP_RESPAWN");
|
|
|
|
// Set some effects based on alignment.
|
|
switch (nAlign)
|
|
{
|
|
case 1:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_LOS_EVIL_30);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_PWKILL);
|
|
break;
|
|
|
|
case 2:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_NATURES_BALANCE);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_SOUND_BURST);
|
|
break;
|
|
|
|
case 3:
|
|
eRespawn = EffectVisualEffect(VFX_FNF_DISPEL_DISJUNCTION);
|
|
eRespawn2 = EffectVisualEffect(VFX_FNF_WORD);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
// Apply a Penalty if appropriate
|
|
if (nPen)
|
|
ApplyPenalty(oPC);
|
|
|
|
// Jump the PC back to the WP
|
|
lRes = GetLocation(oRes);
|
|
AssignCommand(oPC, JumpToLocation(lRes));
|
|
|
|
// Send appropriate effects to the Respawn Location
|
|
DelayCommand(2.0f, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eRespawn, lRes));
|
|
DelayCommand(2.0f, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eRespawn2, lRes));
|
|
|
|
// Clear Local Variables
|
|
DeleteLocalLocation(oPC, "Res_Loc");
|
|
DeleteLocalInt(oPC, "Res_Align");
|
|
}
|
|
|
|
// Apply Penalty Script
|
|
void ApplyPenalty(object oDeadPC)
|
|
{
|
|
int nXP, nPenalty, nHD, nMin, nNewXP, nGoldToTake, nLevelLoss;
|
|
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
/* Set this variable to determine whether a PC can lose a level when
|
|
the respawn penalty is taken.
|
|
|
|
Uncomment the line for Level Loss or not. Be sure to Re-comment
|
|
the other line so that there will not be a conflict.
|
|
*/
|
|
|
|
// nLevelLoss = 0; // No Level Loss
|
|
nLevelLoss = 1; // Level Loss Possible
|
|
|
|
//::////////////////////////////////////////////////////////////////////////
|
|
|
|
nXP = GetXP(oDeadPC);
|
|
nPenalty = 10 * GetHitDice(oDeadPC);
|
|
nHD = GetHitDice(oDeadPC);
|
|
nNewXP = nXP - nPenalty;
|
|
|
|
// Level Loss?
|
|
switch (nLevelLoss)
|
|
{
|
|
// No Level Loss
|
|
case 0:
|
|
// The following check prevents level loss when Respawning
|
|
nMin = ((nHD * (nHD - 1)) / 2) * 1000;
|
|
|
|
if (nNewXP <= nMin)
|
|
{
|
|
nNewXP = nMin;
|
|
nPenalty = nXP - nNewXP;
|
|
}
|
|
break;
|
|
|
|
// Level Loss
|
|
case 1:
|
|
break;
|
|
}
|
|
|
|
//:://////////////////////////////////////////////////////////
|
|
|
|
// Set the PC's new XP after loss
|
|
SetXP(oDeadPC, nNewXP);
|
|
|
|
// Take a Gold Penalty
|
|
nGoldToTake = FloatToInt(0.10 * GetGold(oDeadPC));
|
|
|
|
// Cap GP Penalty at 10000GP
|
|
if (nGoldToTake > 10000)
|
|
nGoldToTake = 10000;
|
|
|
|
// Apply the Gold penalty
|
|
AssignCommand(oDeadPC, TakeGoldFromCreature(nGoldToTake, oDeadPC, TRUE));
|
|
}
|