Changed folder name.
Changed folder name.
This commit is contained in:
208
_module/nss/onplayerrest.nss
Normal file
208
_module/nss/onplayerrest.nss
Normal file
@@ -0,0 +1,208 @@
|
||||
//Script Name: onplayerrest
|
||||
///////////////////////////////////////
|
||||
//Created by Genisys / Guile
|
||||
//Created on: 3/11/08 (Updated 9/7/08
|
||||
//////////////////////////////////////
|
||||
/*
|
||||
This is my premier OnPlayerRest
|
||||
Module Properties Event script
|
||||
to handle rest within all of my
|
||||
module..
|
||||
*/
|
||||
//////////////////////////////////////
|
||||
|
||||
//Redundant Variable
|
||||
effect eEffect;
|
||||
|
||||
//Required Includes
|
||||
#include "x2_inc_restsys"
|
||||
#include "x2_inc_switches"
|
||||
|
||||
//Main Script
|
||||
void main()
|
||||
{
|
||||
ExecuteScript("prc_rest", OBJECT_SELF);
|
||||
//Declare Major Variables
|
||||
object oPC=GetLastPCRested();
|
||||
object oPlayer = oPC;
|
||||
object oPP = oPC;
|
||||
object oArea = GetArea(oPC);
|
||||
location lSaved = GetLocation(oPP);
|
||||
int MULTI_PLAYER = GetLocalInt(GetModule(), "multi");
|
||||
int nRestType=GetLastRestEventType();
|
||||
int nHD = GetHitDice(oPC);
|
||||
|
||||
|
||||
//This will start the Genisys PC Wand Conversation..
|
||||
if(GetLocalInt(oPC, "REST_STARTED")!=1)
|
||||
{
|
||||
object oTarget = oPC;
|
||||
AssignCommand(oPC, ClearAllActions());
|
||||
AssignCommand(oPC, ActionStartConversation(
|
||||
oTarget, "genisysconv", TRUE));
|
||||
|
||||
//Stop here...
|
||||
return;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
|
||||
{
|
||||
|
||||
//If they are resting do this instead..
|
||||
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)
|
||||
{
|
||||
//Tell the system we are done resting!
|
||||
SetLocalInt(oPC, "REST_STARTED", 0);
|
||||
// No longer used but left in for the community
|
||||
// WMFinishPlayerRest(oPC); // removes sleep effect, etc
|
||||
|
||||
//*******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(GetArea(GetAreaFromLocation(lSaved))!=OBJECT_INVALID)
|
||||
{
|
||||
object oGuild = GetItemPossessedBy(oPC, "guildstone");
|
||||
|
||||
//Store the PC's location, so they can come back here after relogging
|
||||
SetCampaignLocation("LOCATIONS", GetName(oGuild), 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 */
|
||||
|
||||
//IF it's a multiplayer game..
|
||||
if(MULTI_PLAYER)
|
||||
{
|
||||
DelayCommand(1.0, ExportSingleCharacter(oPC)); //Allow them to deshift!
|
||||
FloatingTextStringOnCreature("Your character was saved.", oPC);
|
||||
}
|
||||
else
|
||||
{
|
||||
DelayCommand(2.0, DoSinglePlayerAutoSave());
|
||||
}
|
||||
//Remove any death tokens in their inventory..
|
||||
object oDeath = GetItemPossessedBy(oPC, "death");
|
||||
DestroyObject(oDeath, 0.0f);
|
||||
|
||||
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..)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user