164 lines
4.9 KiB
Plaintext
164 lines
4.9 KiB
Plaintext
//scriptname: respawnmed
|
|
///////////////////////////////////////////
|
|
//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)
|
|
////////////////////////////////////////////
|
|
|
|
//This script MUST go in the OnOpen Event!
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//IMPORTANT SETTINGS:
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//The # below represents a % chance of a High level item spawning
|
|
//if the opener does not get this % they get a Medium level item instead.
|
|
//Change the # below (default 20) to the % chance you want unique items spawned.
|
|
const int nPercentChance = 20; //20% 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
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "NW_O2_CONINCLUDE"
|
|
#include "x0_i0_treasure"
|
|
|
|
//PROTOTYPE//////////
|
|
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);
|
|
}
|
|
|
|
//PROTOTYPE
|
|
void DestroyTreasure(object oMe)
|
|
{
|
|
object o = GetFirstItemInInventory(oMe);
|
|
while(GetIsObjectValid(o))
|
|
{
|
|
SetPlotFlag(o, FALSE);
|
|
DestroyObject(o, 0.0f);
|
|
o =GetNextItemInInventory(oMe);
|
|
}
|
|
}
|
|
|
|
//Main Script
|
|
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 = 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)));
|
|
|
|
//Prevent Cheating!!
|
|
effect eEffect = EffectDamage(2666, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_NORMAL);
|
|
effect eVis = EffectVisualEffect(VFX_FNF_GREATER_RUIN);
|
|
object oPC = GetLastOpener();
|
|
string sMsg;
|
|
|
|
if(GetHasSpellEffect(SPELL_ETHEREALNESS, oPC) ||
|
|
GetHasSpellEffect(SPELL_IMPROVED_INVISIBILITY, oPC) ||
|
|
GetHasSpellEffect(SPELL_INVISIBILITY, oPC) ||
|
|
GetHasSpellEffect(SPELL_INVISIBILITY_SPHERE, oPC) ||
|
|
GetHasSpellEffect(SPELL_SANCTUARY, oPC))
|
|
{
|
|
if(GetLocalInt(oPC, "GS_LOOTER")==2)
|
|
{
|
|
sMsg = "You cannot be invisible while looting for treasure, YOU WILL RECIEVE NO MORE WARNINGS!";
|
|
FloatingTextStringOnCreature(sMsg, oPC, TRUE);
|
|
DestroyTreasure(OBJECT_SELF);
|
|
CreateItemOnObject("gslootlib", oPC, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC, 0.0f);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC, 2.5f);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
DestroyTreasure(OBJECT_SELF);
|
|
CreateItemOnObject("gslootlib", oPC, 1);
|
|
SetLocalInt(oPC, "GS_LOOTER", 2);
|
|
sMsg = "You cannot be invisible while looting for treasure, YOU HAVE BEEN WARNED!";
|
|
FloatingTextStringOnCreature(sMsg, oPC, TRUE);
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
//Special Treasure System...
|
|
|
|
ExecuteScript("gen_geg_treas", OBJECT_SELF);
|
|
|
|
///////////////Generic Treasure Generated On Open/////////////
|
|
|
|
//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)))
|
|
{
|
|
|
|
//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_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_MED, 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(5);// 5-100 (The Multiplyer of nXGp)
|
|
int nXtra = d100(1); // 1 - 100
|
|
int nXGp = nInt * 50; // 250 - 5,000 Gold
|
|
int nGP = nXGp + nXtra; // 251 - 5,100 (Random #)
|
|
CreateItemOnObject("nw_it_gold001", OBJECT_SELF, nGP);
|
|
|
|
//end if statement
|
|
}
|
|
|
|
//The end :)
|
|
}
|