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

109 lines
3.3 KiB
Plaintext

//Example XP2 Treasure Script (low to high treasure)
//Created by Genisys for the Enchanting Gem system..
//Created On: 4/21/09
//Please see the ///****LOOK HERE*** below...
#include "NW_O2_CONINCLUDE"
#include "x0_i0_treasure"
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);
}
void main()
{
//Prevents spam looting.
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
{
return;
}
object oLastOpener = GetLastOpener();
//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 = 1800.0; // 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)));
///////////////Generic Treasure Generated On Open/////////////
//Ok if you want to use NWN Base Treasure System, here is what you do..
//Delete the // below on the line you wish to activate
//MAKE SURE you save this script under a new name, something you will
//remember later so you can place it on other chest / placeables.
//You can type //at the beginning of the function you don't want to use.
//Do not touch this line below as it's necessary!
if (!(CTG_GetIsTreasureGenerated(OBJECT_SELF))) {
////////////////////////////////////////////////////////////////
///////////***********LOOK HERE*************////////////////////
//Specail function for generating Enchanted Gems..
ExecuteScript("gen_geg_treas", 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 <31)
{
//This script will put any high level item into the chest.
CTG_CreateTreasure(TREASURE_TYPE_MED, GetLastOpener(), OBJECT_SELF);
}
//10% chance of getting a High level item..
else if(bInt >89)
{
//This script will put any high level item into the chest.
CTG_CreateTreasure(TREASURE_TYPE_HIGH, GetLastOpener(), OBJECT_SELF);
}
//Otherwise they just get a Low level item..
else
{
//This script will put any low level item into the chest.
CTG_CreateTreasure(TREASURE_TYPE_LOW, GetLastOpener(), OBJECT_SELF);
}
//This will generate a Medium amount of Gold in the chest
CTG_CreateGoldTreasure(TREASURE_TYPE_HIGH, GetLastOpener(), OBJECT_SELF);
//This makes sure we aren't regenerating treasure!
CTG_SetIsTreasureGenerated(OBJECT_SELF);
//Always spawn gold into the chest..
//ADJUST This to your likings..
int nInt = d20(4);// 4-80 (The Multiplyer of nXGp)
int nXtra = d100(2); // 2-200
int nXGp = nInt * 200; // 800 - 16,000 Gold
int nGP = nXGp + nXtra; // 802 - 16,200
CreateItemOnObject("nw_it_gold001", OBJECT_SELF, nGP);
//end if statement
}
//The end :)
}