UW2_PRC8/_module/nss/respawnlow.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

107 lines
3.3 KiB
Plaintext

//scriptname: respawnlow
///////////////////////////////////////////
//Created by Guile
//Some functions are from: AW_Olorin (POA)
///////////////////////////////////////////
//Created On 8/02/08
///////////////////////////////////////////
//This script generates treasure and
//respawns the chest automatically after
//a set amount of time. (See below)
////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//IMPORTANT SETTING:
//////////////////////////////////////////////////////////////////////////////
//The # below represents a % chance of a Medium item spawning
//if the opener does not get this % they get a Low level item instead.
//Change the # below (default 30) to the % chance you want unique items spawned.
const int nPercentChance = 30; //30% chance
//Determine how many minutes you want to pass before the treasure chest respawn
//Enter 10 for 10 minute 30 for 30 minutes etc..
const int nMinutes = 30; //Default = 30
///////////////////////////////////////////////////////////////////////////////
//Includes
#include "NW_O2_CONINCLUDE"
#include "x0_i0_treasure"
//PROTOTYPE FUNCTION DEFINED
void RespawnObject(string sTag, int iType, location lLoc)
{
// ResRef Name must be derivable from Tag Name
string sResRef = GetStringLowerCase(GetStringLeft(sTag, 16));
CreateObject(iType, sResRef, lLoc);
}
//Main Script
void main()
{
//Prevents spam looting.
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
{
return;
}
object oLastOpener = GetLastOpener();
//Always generate a low level treasure no matter what.
GenerateLowTreasure(oLastOpener, OBJECT_SELF);
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
ShoutDisturbed();
//Note this only works for placeables
//Creatures use a different script, which is in the OnDeath Event
location lLoc = GetLocation(OBJECT_SELF);
string sTag = GetTag(OBJECT_SELF);
int iType = GetObjectType(OBJECT_SELF);
float fDelay = 60.0 * IntToFloat(nMinutes); // 30 Minute delay
//A fancy sunbeam effect OnOpen.
//ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUNBEAM), OBJECT_SELF);
SetPlotFlag(OBJECT_SELF, FALSE);
DestroyObject(OBJECT_SELF, 0.0);
AssignCommand(GetArea(OBJECT_SELF), DelayCommand(fDelay, RespawnObject(sTag, iType, lLoc)));
///////////////Generate Generic Treasure - On Open or On Death/////////////
if (!(CTG_GetIsTreasureGenerated(OBJECT_SELF)))
{
//Let's choose between one of 3 treasures, depending upon a % of the roll..
int bInt = d100(1);
//Roll a d6 dice then determine which treasure table(s) to use..
//30% chance of getting a Medium level Item..
if(bInt<nPercentChance)
{
//This script will put any high level item into the chest.
CTG_CreateTreasure(TREASURE_TYPE_MED, GetLastOpener(), OBJECT_SELF);
}
else
{
//This script will put any low level item into the chest.
CTG_CreateTreasure(TREASURE_TYPE_LOW, GetLastOpener(), OBJECT_SELF);
}
//Adjust this to your taste..
int nInt = d20(1);// 1-20 (The Multiplyer of nXGp)
int nXtra = d100(10); // 10 - 1,000
int nXGp = nInt * 100; // 100 - 2,000 Gold
int nGP = nXGp + nXtra; // 110 - 3,000 (Random #)
CreateItemOnObject("nw_it_gold001", OBJECT_SELF, nGP);
//This makes sure we aren't regenerating treasure!
CTG_SetIsTreasureGenerated(OBJECT_SELF);
//End if statement
}
//End Script
}