UW2_PRC8/_module/nss/x2_mod_def_rest.nss
Jaysyn904 d44d9fef07 Consolidated menus
Consolidated menus.  Fixed AMS not restoring spell on rest.  Full compile. Updated release archive.
2023-11-18 21:42:23 -05:00

256 lines
8.6 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name: x2_onrest
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
The generic wandering monster system
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: June 9/03
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified Date: January 28th, 2008
//:://////////////////////////////////////////////
#include "x2_inc_restsys"
#include "x2_inc_switches"
#include "x3_inc_horse"
effect eEffect;
void main()
{
//Declare Major Variables
object oPC =GetLastPCRested();
object oPlayer = oPC;
string sName = GetStringLeft(GetName(oPC), 20);
object oPP = oPC;
location lSaved = GetLocation(oPP);
int nRestType =GetLastRestEventType();
int nHD = GetHitDice(oPC);
object oMount;
if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DISMOUNT"))
{ // make sure not mounted
/* Deva, Jan 17, 2008
Do not allow a mounted PC to rest
*/
if (HorseGetIsMounted(oPC))
{ // cannot mount
if (GetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT"))
{ // cancel message already played
DeleteLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT");
} // cancel message already played
else
{ // play cancel message
FloatingTextStrRefOnCreature(112006,oPC,FALSE);
SetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT",TRUE); // sentinel
// value to prevent message played a 2nd time on canceled rest
} // play cancel message
AssignCommand(oPC,ClearAllActions(TRUE));
return;
} // cannot mount
} // make sure not mounted
if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DESPAWN"))
{ // if there is a paladin mount despawn it
oMount=HorseGetPaladinMount(oPC);
if (!GetIsObjectValid(oMount)) oMount=GetLocalObject(oPC,"oX3PaladinMount");
if (GetIsObjectValid(oMount))
{ // paladin mount exists
if (oMount==oPC||!GetIsObjectValid(GetMaster(oMount))) AssignCommand(oPC,HorseUnsummonPaladinMount());
else { AssignCommand(GetMaster(oMount),HorseUnsummonPaladinMount()); }
} // paladin mount exists
} // if there is a paladin mount despawn it
if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
{
/* Georg, August 11, 2003
Added this code to allow the designer to specify a variable on the module
Instead of using a OnAreaEnter script. Nice new toolset feature!
Basically, the first time a player rests, the area is scanned for the
encounter table string and will set it up.
*/
object oArea = GetArea (oPC);
string sTable = GetLocalString(oArea,"X2_WM_ENCOUNTERTABLE") ;
if (sTable != "" )
{
int nDoors = GetLocalInt(oArea,"X2_WM_AREA_USEDOORS");
int nDC = GetLocalInt(oArea,"X2_WM_AREA_LISTENCHECK");
WMSetAreaTable(oArea,sTable,nDoors,nDC);
//remove string to indicate we are set up
DeleteLocalString(oArea,"X2_WM_ENCOUNTERTABLE");
}
/* Brent, July 2 2003
- If you rest and are a low level character at the beginning of the module.
You will trigger the first dream cutscene
*/
if (GetLocalInt(GetModule(), "X2_G_LOWLEVELSTART") == 10)
{
AssignCommand(oPC, ClearAllActions());
if (GetHitDice(oPC) >= 12)
{
ExecuteScript("bk_sleep", oPC);
return;
}
else
{
FloatingTextStrRefOnCreature(84141 , oPC);
return;
}
}
if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
{
if (!WMStartPlayerRest(oPC))
{
// The resting system has objections against resting here and now
// Probably because there is an ambush already in progress
FloatingTextStrRefOnCreature(84142 ,oPC);
AssignCommand(oPC,ClearAllActions());
}
if (WMCheckForWanderingMonster(oPC))
{
//This script MUST be run or the player won't be able to rest again ...
ExecuteScript("x2_restsys_ambus",oPC);
}
}
else if (GetLastRestEventType()==REST_EVENTTYPE_REST_CANCELLED)
{
// No longer used but left in for the community
// WMFinishPlayerRest(oPC,TRUE); // removes sleep effect, etc
}
else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED)
{
// No longer used but left in for the community
// WMFinishPlayerRest(oPC); // removes sleep effect, etc
SetLocalInt(oPC, "REST_STARTED", 0);
//*******LOCATION SAVING OPTION************
//Type // at the start of the Set and Send lines to deactivate this feature.
//For the guild only!
//If they are in the guild...
if(GetItemPossessedBy(oPC, "guildpass")!=OBJECT_INVALID)
{
if(GetAreaFromLocation(lSaved)!=OBJECT_INVALID)
{
//Store the PC's location, so they can come back here after relogging
//SetCampaignLocation("LOCATIONS", GetName(oPC), lSaved, oPC);
//Tell the PC their location was saved..
//SendMessageToPC(oPP, "Location Saved!");
}
}
//************CLEAR THE PC'S REPUTATION WITH ALL NPCS*****************
if(GetIsPC(oPlayer))
{
AssignCommand(oPlayer, ClearAllActions());
//Clear Reputation of PC
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
}
//*****EXPORT SINGLE CHARACTER******
/*
Delete the // at the start of the two lines below to -
activate the player character auto saving features
*/
//Save the PC's character instantly..
if(GetLocalInt(GetModule(), "MULTI")==TRUE)
{
DelayCommand(1.0, ExportSingleCharacter(oPC)); //Allow them to deshift!
FloatingTextStringOnCreature("Your character was saved.", oPC);
}
//Remove any and ALL death tokens...
object oToken;
string sTag;
if(GetItemPossessedBy(oPC, "death")!=OBJECT_INVALID)
{
oToken = GetFirstItemInInventory(oPC);
while(GetIsObjectValid(oToken))
{
sTag = GetTag(oToken);
if(sTag=="death")
{ DestroyObject(oToken, 0.0f); }
oToken = GetNextItemInInventory(oPC);
}
}
if(nHD == 40 || GetItemPossessedBy(oPC, "guildpass")!=OBJECT_INVALID)
{
//If the player is Legendary Level 60 give them a cool power!
if(GetXP(oPC) >5000000 || GetItemPossessedBy(oPC, "guildpass")!=OBJECT_INVALID)
{
//The legendary character is immune to death!
eEffect = EffectImmunity(IMMUNITY_TYPE_SKILL_DECREASE);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
//The legendary character is immune to poison!
eEffect = EffectImmunity(IMMUNITY_TYPE_ABILITY_DECREASE);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
//The legendary character is immune to disease!
eEffect = EffectImmunity(IMMUNITY_TYPE_NEGATIVE_LEVEL);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
}
//Make ALL level 40s have 40% concealment
//Make them harder to hit 40% miss chance...
eEffect = EffectConcealment(40);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
//Apply the Ghost Like Visual to all Level 40 PCs
//Type // at the start of the two lines below to de-activate this.
if(nHD == 40)
{
DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT,
SupernaturalEffect(EffectVisualEffect(VFX_DUR_GLOW_WHITE)), oPC));
}
}
//if the PC is immortal (has the immotoken)
if (GetItemPossessedBy(oPC, "immotoken")!= OBJECT_INVALID)
{
//See this script to adjust the immortal options..
ExecuteScript("powerimmortal", oPC);
}
//Your code goes here. (This happens when the PC is done resting..)
}
}
}