Jaysyn904 a203d11310 Fixed rest menu & alignment changer
Fixed rest menu & alignment changer.  Updated release archive.
2023-11-17 21:54:26 -05:00

222 lines
7.2 KiB
Plaintext

//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()
{
//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);
//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.
*/
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");
}
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(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);
}
ExecuteScript("prc_rest", oPC);
//Your code goes here. (This happens when the PC is done resting..)
}
}
}