Files
HeroesStone_PRC8/_module/nss/corpse_lib.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

2221 lines
68 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name corpse_lib
//:: FileName
//::
//:://////////////////////////////////////////////
/*
Contains constants and usefull functions.
*/
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 21/04/2003
//:://////////////////////////////////////////////
#include "prc_inc_skin"
//Objects Tags
string CorpseInvisibleObjectTag = "CorpseInvisibleObject";
string CorpseMPickableCorpseTag = "CorpseMaleCorpseObject";
string CorpseFPickableCorpseTag = "CorpseFemaleCorpseObject";
string CorpsePickableWayPoint = "CorpsePickableWayPoint";
string CorpseSkinToolsTag = "CorpseSkinTools";
//Dialogs
string CorpseOneLinerDialogName = "corpse";
//Objects blueprints
string CorpseObjectBlueprint = "deadinv";
string CorpseMPickableBlueprint = "corpse_m";
string CorpseFPickableBlueprint = "corpse_f";
//Scripts Names
string ResurectionScriptName = "corp_ressurect";
string RaiseDeadScriptName = "corps_raisdead";
string SavesScriptName = "corpse_save";
string DyingScriotName = "corpse_dying";
//Local variable names. If the variable are to be changed, no need to modify scripts.
string CorpseFindDifficultyVarName = "CorpseFindDifficultyValue"; //Varaible storing the difficulty for a search
string CorpseFindMaxValueVarName = "CorpseFindDifficultyMaxValue"; //Varaible storing the upper limit for search test. Above this limit all objects are found.
string CorpseCreatureCorpse = "CorpseCreatureCorpse"; //Variable storing the creature linked to the corpse
string CorpseOriginalObject = "CorpseOriginalObject"; //Variable storing the orignal object from which the object has been duplicated
string CorpseSpellCaster = "CorpseSpellCaster"; //Varaible storing the caster of the last spell targetting the invisible placeable
string CorpseFindAttemptRoot = "CharacterTryedToFind"; //Variable storing the fact that a player has already tried to find something in that corpse
string CorpseFindAttemptNumber = "CorpseFindAttemptNumber"; //Variable storing the number of player that tried to find something in the corpse.
string CorpseCriticalResult = "CorpseCriticalResult"; //Variable storing if get 1 or 20 on a 20 dice durring the search test
string CorpseItemFoundBy = "CorpseItemFoundBy"; //Variable storing by whom the object has been found
string CorpseItemFound = "CorpseItemFound"; //Variable storing if the item has been found
string CorpseItemFoundNumber = "CorpseItemFoundNumber"; //Variable storing the identifiers of the ones who found the object.
string CorpseIsHidden = "CorpseIsHidden"; //Variable storing if the item is hidden. No used yet.
string CorpseUseDecay = "CorpseUseDecay"; //Variable storing if the corpse should disappear.
string CorpseDecayDealy = "CorpseDecayDealy"; //Variable storing the delay befor corpse disappearing.
string CorpseUseSaves = "CorpseUseSaves"; //Variable storing if items must performs save throws when corpses are damaged.
string CorpseRaceLeaveACorpse = "CorpseRaceLeaveAcorp"; //Variables storing if a race do not leave a corp.
string CorpseItemFireDammage = "CorpseItemFireDammage"; //Variable storing the amount of fire dammage taken by the object.
string CorpseItemAcidDammage = "CorpseItemAcidDammage"; //Variable storing the amount of acid dammage taken by the object.
string CorpseItemTotalDammage = "CorpseItemTotalDammage"; //Variable storing the amount of dammage taken by the object.
string CorpseItemLastHP = "CorpseItemLastHP"; //Variable storing the number of hit point the corpse had before it was dammaged.
string CorpsePickableCorpse = "CorpsePickableCorpse"; //Variable storing the corpse item associated with the corpse.
string CorpseIsNotCorpsePickable = "CorpseIsNotCorpsePickable"; //Variable storing if the creature corpse can be picked.
string CorpseUsePickablePCCorpses = "CorpseUsePickablePCCorpses"; //Variable storing if PC corpse items are to be used.
string CorpseIsCorpseCopying = "CorpseIsCorpseCopying"; //Variable storing if the corpse is being copied.
string CorpseDialogFound = "CorpseDialogFound"; //Variable storing if the player found something.
string CorpseDialogFoundNumber = "CorpseDialogFoundNumber"; //Variable storing the number of items found by the player.
string CorpseDialogMoved = "CorpseDialogMoved"; //Variable storing if the corpse is being moved (not used).
string CorpsePCCorpse = "CorpsePCCorpse"; //Variable storing the corpse associated withe PC and the PC associated with the corpse.
string CorpseIsNotResurectable = "CorpseIsNotResurectable"; //Variable storing if the dead creature shouldn't being resurectable.
string CorpseSkinDialogIndex = "CorpseSkinDialogIndex"; //This variable stores the index of string to speak when a PC attempt to cut off a skin.
string CorpseUserLocalVariablesRoot = "CorpseUserLocalVariablesRoot"; //Variable storing the name of a local variable.
string CorpseUserLocalVariablesNb = "CorpseUserLocalVariablesNb"; //Variable storing the number of local variable to copy with the corpse.
string CorpseUserLocalVarTypeRoot = "CorpseUserLocalVariablesRoot"; //Variable storing the Type of the associated variable.
string CorpseDeadPCLeftArray = "CorpseDeadPCLeftArray"; //An array storring dead pc who left the game.
string CorpseDeadPCLeftID = "CorpseDeadPCLeftID"; //A variable storring the ID of th dead PC on the corpse.
string CorpsePCID = "CorpsePCID"; //Stores the PC ID
//string CorpseDeadPCLeftRoot = "CorpseDeadPCLeftRoot"; //Variable storing the ID of a gone dead PC.
//string CorpseDeadPCLeftNb = "CorpseDeadPCLeftNb"; //Variable storing the number a gone dead PC.
//Functions
//::///////////////////////////////////////////////
//:: Name MoveCorpseTo
//::
//:://////////////////////////////////////////////
//
// Moves corpse to newPlace.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
object MoveCorpseTo(location newPlace,object corpse = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetStringInArray
//::
//:://////////////////////////////////////////////
//
// Returns the string stored at index in arrayName
// on target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
string GetStringInArray(string arrayName,int index = 0,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetStringInArray
//::
//:://////////////////////////////////////////////
//
// Sets the value of string stored at index in arrayName
// on target to value.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
void SetStringInArray(string arrayName,string value,int index = 0,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetStringArraySize
//::
//:://////////////////////////////////////////////
//
// Returns the size of arrayName
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
int GetStringArraySize(string arrayName,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name DeleteStringInArray
//::
//:://////////////////////////////////////////////
//
// Deletes the entry at index.
// Warning: Deleting an entry modifies the index of all
// following entries.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
void DeleteStringInArray(string arrayName,int index,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetLocal*_Corpse
//::
//:://////////////////////////////////////////////
//
// Allow to retrieve local variables after a corpse
// has been moved use them if you are to store variables
// on a creature that leaves a moveable corpse after death
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
//::///////////////////////////////////////////////
//:: Name DeleteLocal*_Corpse
//::
//:://////////////////////////////////////////////
//
// Allow to retrieve local variables after a corpse
// has been moved use them if you are to store variables
// on a creature that leaves a moveable corpse after death
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
void SetLocalFloat_Corpse(object oObject,string sVarName,float fValue);
void SetLocalInt_Corpse(object oObject,string sVarName, int nValue);
void SetLocalLocation_Corpse(object oObject,string sVarName, location lValue);
void SetLocalObject_Corpse(object oObject,string sVarName, object oValue);
void SetLocalString_Corpse(object oObject,string sVarName, string sValue);
void DeleteLocalFloat_Corpse(object oObject,string sVarName);
void DeleteLocalInt_Corpse(object oObject,string sVarName);
void DeleteLocalLocation_Corpse(object oObject,string sVarName);
void DeleteLocalObject_Corpse(object oObject,string sVarName);
void DeleteLocalString_Corpse(object oObject,string sVarName);
//::///////////////////////////////////////////////
//:: Name GetPCID
//::
//:://////////////////////////////////////////////
//
// Return a string that identify the PC character.
// This string is supposed to be unique, I said supposed :D
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 29/05/2003
//:://////////////////////////////////////////////
string GetPCID(object player);
//::///////////////////////////////////////////////
//:: Name CorpseCutOffCreatureSkin
//::
//:://////////////////////////////////////////////
//
// Allows PC to try to get target's skin.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 19/05/2003
//:://////////////////////////////////////////////
void CorpseCutOffCreatureSkin(object PC,object target);
//::///////////////////////////////////////////////
//:: Name SetCorpseIsNotResurectable
//::
//:://////////////////////////////////////////////
//
// Sets if target should be resurectable.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 18/05/2003
//:://////////////////////////////////////////////
void SetCorpseIsNotResurectable(int boolean=TRUE,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetCorpseIsNotResurectable
//::
//:://////////////////////////////////////////////
//
// Gets if target should be resurectable.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 18/05/2003
//:://////////////////////////////////////////////
int GetCorpseIsNotResurectable(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetCorpseDialogMoved
//::
//:://////////////////////////////////////////////
//
// Sets the variable CorpseDialogMoved value.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void SetCorpseDialogMoved(int boolean,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetCorpseDialogMoved
//::
//:://////////////////////////////////////////////
//
// Gets the variable CorpseDialogMoved value.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
int GetCorpseDialogMoved(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetCorpseDialogFound
//::
//:://////////////////////////////////////////////
//
// Sets the variable CorpseDialogFound value.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void SetCorpseDialogFound(int boolean,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetCorpseDialogFound
//::
//:://////////////////////////////////////////////
//
// Gets the variable CorpseDialogFound value.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
int GetCorpseDialogFound(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetCorpseDialogFoundNumber
//::
//:://////////////////////////////////////////////
//
// Sets the number of items found.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void SetCorpseDialogFoundNumber(int number,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetCorpseDialogFoundNumber
//::
//:://////////////////////////////////////////////
//
// Gets the number of items found.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
int GetCorpseDialogFoundNumber(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetIsCorpseCopying
//::
//:://////////////////////////////////////////////
//
// Sets if target is beeing copied.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void SetIsCorpseCopying(int boolean = TRUE,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetIsCorpseCopying
//::
//:://////////////////////////////////////////////
//
// Gets if target is beeing copied.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
int GetIsCorpseCopying(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name DestroyEquipment
//::
//:://////////////////////////////////////////////
//
// Destroy equipment of target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void DestroyEquipment(object target);
//::///////////////////////////////////////////////
//:: Name CopyCorpseLocals
//::
//:://////////////////////////////////////////////
//
// Copyes originalCorpse local variable to newCorpse.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void CopyCorpseLocals(object originalCorpse,object newCorpse);
//::///////////////////////////////////////////////
//:: Name CopyCreatureLocals
//::
//:://////////////////////////////////////////////
//
// Copyes originalCreature local variable to newCreature.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void CopyCreatureLocals(object originalCreature,object newCreature);
//::///////////////////////////////////////////////
//:: Name getEquipment
//::
//:://////////////////////////////////////////////
//
// Makes the caller get the equipment of target.
// Equipment is duplicated, not transfered.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void getEquipment(object target);
//::///////////////////////////////////////////////
//:: Name CreateCorpsePlaceable
//::
//:://////////////////////////////////////////////
//
// Creates a corpse placeable associated with dead.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
object CreateCorpsePlaceable(object dead = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name CreatePickableCorpse
//::
//:://////////////////////////////////////////////
//
// Create a pickableCorpse on corpse. corpse is
// the corpse associated with dead.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 23/04/2003
//:://////////////////////////////////////////////
void CreatePickableCorpse(object corpse,object dead = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetPickableCorpse
//::
//:://////////////////////////////////////////////
//
// Sets corpse as the PickableCorpse associated to target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 23/04/2003
//:://////////////////////////////////////////////
void SetPickableCorpse(object corpse,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetPickableCorpse
//::
//:://////////////////////////////////////////////
//
// Gets the PickableCorpse associated to target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 23/04/2003
//:://////////////////////////////////////////////
object GetPickableCorpse(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetCantPickCorpse
//::
//:://////////////////////////////////////////////
//
// Sets if target corpse cannot be picked
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 21/05/2003
//:://////////////////////////////////////////////
void SetCantPickCorpse(int use = TRUE,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetCantPickCorpse
//::
//:://////////////////////////////////////////////
//
// Gets if target corpse cannot be picked
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 21/05/2003
//:://////////////////////////////////////////////
int GetCantPickCorpse(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetUsePCPickableCorpse
//::
//:://////////////////////////////////////////////
//
// Sets the use of pickeable corpses for PC.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 23/04/2003
//:://////////////////////////////////////////////
void SetUsePCPickableCorpse(int use = TRUE);
//::///////////////////////////////////////////////
//:: Name GetUsePCPickableCorpse
//::
//:://////////////////////////////////////////////
//
// Gets the use of pickeable corpses for PC.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 23/04/2003
//:://////////////////////////////////////////////
int GetUsePCPickableCorpse();
//::///////////////////////////////////////////////
//:: Name SetDamageTaken
//::
//:://////////////////////////////////////////////
//
// Sets the amount of dammage of dammageType
// type taken by target.
//
// dammageType: 0 -> total
// 1 -> fire
// 2 -> acid
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetDamageTaken(int ammount, int dammageType = 0,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetDamageTaken
//::
//:://////////////////////////////////////////////
//
// Retrieves the amount of dammage of dammageType
// type taken by target.
//
// dammageType: 0 -> total
// 1 -> fire
// 2 -> acid
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetDamageTaken(int dammageType = 0,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name giveBackItems
//::
//:://////////////////////////////////////////////
//
// Give back items to target.
// If unSetFound is TRUE then items are no longer
// marked as found.
// If destroySelf is true, the caller is destroyed.
// If destroyCopy is TRUE then items that was
// duplicated at the creature death are destroyed.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void giveBackItems(object target,int destroyCopy = TRUE,int unSetFound = FALSE,int destroySelf = FALSE);
//::///////////////////////////////////////////////
//:: Name SetRaceCannotLeaveACorpse
//::
//:://////////////////////////////////////////////
//
// Sets if a race can leave a corpse.
// Default: All races leave a corpse.
//
// ratialType is a RACIAL_TYPE_* constant.
//
// If boolean is TRUE then the race will not leave a corpse.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetRaceCannotLeaveACorpse(int ratialType,int boolean = TRUE);
//::///////////////////////////////////////////////
//:: Name GetRaceCannotLeaveACorpse
//::
//:://////////////////////////////////////////////
//
// Gets if a race can leave a corpse.
// Default: All races leave a corpse.
//
// ratialType is a RACIAL_TYPE_* constant.
//
// A TRUE return value means the race do not leave a corpse.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetRaceCannotLeaveACorpse(int ratialType);
//::///////////////////////////////////////////////
//:: Name SetUseSaves
//::
//:://////////////////////////////////////////////
//
// Sets if a test is to be performed on items when
// a corpse is dameged.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetUseSaves(int use = TRUE);
//::///////////////////////////////////////////////
//:: Name SetUseSaves
//::
//:://////////////////////////////////////////////
//
// Returns true if a test is to be performed on
// items when a corpse is dameged.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetUseSaves();
//::///////////////////////////////////////////////
//:: Name SetDecay
//::
//:://////////////////////////////////////////////
//
// Sets if the corpse of the creature must disappear
// after decayDelay seconds.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetDecay(int useDecay,float decayDelay = 60.0,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetUseDecay
//::
//:://////////////////////////////////////////////
//
// Returns true if the corpse of the creature must disappear
// after decayDelay seconds.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetUseDecay(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetDecayDealy
//::
//:://////////////////////////////////////////////
//
// Returns the number of seconds before the corpse disappears.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
float GetDecayDealy(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetOriginalCorpse
//::
//:://////////////////////////////////////////////
//
// Returns the creature that died and generated the
// target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
object GetOriginalCorpse(object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetFoundBy
//::
//:://////////////////////////////////////////////
//
// Sets if item has been found by finder.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetFoundBy(int found,object finder,object item=OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name SetHidden
//::
//:://////////////////////////////////////////////
//
// Sets if item is hidden.
//
// Reserved for further use.
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetHidden(int hidden = TRUE,object item=OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetHidden
//::
//:://////////////////////////////////////////////
//
// Returns TRUE if item is hidden.
//
// Reserved for further use.
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetHidden(object item);
//::///////////////////////////////////////////////
//:: Name SetMaxDD
//::
//:://////////////////////////////////////////////
//
// Sets the limit for search tests. If the searcher
// score is higher than this value it finds all items
// on target corpse.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetMaxDD(int DD,object target = OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetMaxDD
//::
//:://////////////////////////////////////////////
//
// Retrieves the limit for search tests. If the searcher
// score is higher than this value it finds all items
// on target corpse.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetMaxDD(object target);
//::///////////////////////////////////////////////
//:: Name GetFound
//::
//:://////////////////////////////////////////////
//
// Returns TRUE if item has been found by someone.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetFound(object item);
//::///////////////////////////////////////////////
//:: Name GetFound
//::
//:://////////////////////////////////////////////
//
// Sets if item has been found by someone.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void SetFound(object item,int found = TRUE);
//::///////////////////////////////////////////////
//:: Name SetFoundBy
//::
//:://////////////////////////////////////////////
//
// Returns true if item has been found by finder.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int GetFoundBy(object finder,object item=OBJECT_SELF);
//::///////////////////////////////////////////////
//:: Name GetFoundItemsInInventory
//::
//:://////////////////////////////////////////////
//
// Makes the caller take items found by finder on target.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void GetFoundItemsInInventory(object target,object finder);
//::///////////////////////////////////////////////
//:: Name GetItemsInInventory
//::
//:://////////////////////////////////////////////
//
// Make the caller take number items on target.
// If number equals 0 then all items are taken.
// If markAsFound is TRUE and finder is a valid object,
// then items will be marked as found by finder.
// If destroyTarget is TRUE, then target is destroyed.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void GetItemsInInventory(object target,int number = 0,int markAsFound = FALSE,object finder = OBJECT_INVALID,int destroyTarget = FALSE);
void GetItemsInInventory(object target,int number = 0,int markAsFound = FALSE,object finder = OBJECT_INVALID,int destroyTarget = FALSE)
{
object item = GetFirstItemInInventory(target);
int given = 0;
int numberOfItem;
if(number == 0)
{
numberOfItem = -1;
}
else
{
numberOfItem = number;
}
ClearAllActions(TRUE);
while(GetIsObjectValid(item) && given != numberOfItem)
{
if(GetDroppableFlag(item))
{
ActionTakeItem(item,target);
if(markAsFound && GetIsObjectValid(finder))
{
//WriteTimestampedLogEntry("Marking Item" + GetTag(item));
SetFoundBy(TRUE,finder,item);
}
given++;
}
item = GetNextItemInInventory(target);
}
if(destroyTarget)
{
ActionDoCommand(AssignCommand(target,SetIsDestroyable(TRUE)));
ActionDoCommand(DestroyObject(target));
}
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
SetCorpseDialogFoundNumber(given);
}
//::///////////////////////////////////////////////
//:: Name setFindDificulty
//::
//:://////////////////////////////////////////////
//
// Set the dificulty of finding an item on target.
// A DD of 0 means that no test is needed to find something.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
void setFindDifficulty(int DD=0,object target = OBJECT_SELF);
void setFindDifficulty(int DD=0,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseFindDifficultyVarName,DD);
}
//::///////////////////////////////////////////////
//:: Name setFindDificulty
//::
//:://////////////////////////////////////////////
//
// Retrieves the dificulty of finding an object on the caller.
//
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 22/04/2003
//:://////////////////////////////////////////////
int getFindDifficulty(object target = OBJECT_SELF);
int getFindDifficulty(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseFindDifficultyVarName);
}
void SetFoundBy(int found,object finder,object item=OBJECT_SELF)
{
string suffix = GetTag(finder)+GetName(finder);
SetLocalInt(item,CorpseItemFoundBy+suffix,found);
int number = GetLocalInt(item,CorpseItemFoundNumber);
//WriteTimestampedLogEntry("SetFoundBy old CorpseItemFoundNumber: "+IntToString(GetLocalInt(item,CorpseItemFoundNumber)));
SetLocalInt(item,CorpseItemFoundNumber,number+1);
//WriteTimestampedLogEntry("SetFoundBy new CorpseItemFoundNumber: "+IntToString(GetLocalInt(item,CorpseItemFoundNumber)));
SetLocalString(item,CorpseItemFoundBy+IntToString(number),suffix);
if(found)
{
SetLocalInt(item,CorpseItemFound,TRUE);
}
}
int GetFound(object item)
{
return GetLocalInt(item,CorpseItemFound);
}
int GetFoundBy(object finder,object item=OBJECT_SELF)
{
return GetLocalInt(item,CorpseItemFoundBy+GetTag(finder)+GetName(finder));
}
void GetFoundItemsInInventory(object target,object finder)
{
object item = GetFirstItemInInventory(target);
ClearAllActions(TRUE);
while(GetIsObjectValid(item))
{
//WriteTimestampedLogEntry("Testing Item" + GetTag(item));
if(GetDroppableFlag(item) && GetFoundBy(finder,item))
{
if(GetFound(item))
{
ActionTakeItem(item,target);
//WriteTimestampedLogEntry("Getting Item" + GetTag(item));
}
else
{
SetFoundBy(FALSE,finder,item);
}
}
item = GetNextItemInInventory(target);
}
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
}
void giveBackItems(object target,int destroyCopy = TRUE,int unSetFound = FALSE,int destroySelf = FALSE)
{
object item = GetFirstItemInInventory();
ClearAllActions(TRUE);
while(GetIsObjectValid(item))
{
object linked = GetLocalObject(item,CorpseOriginalObject);
if(GetIsObjectValid(linked) || GetIsObjectValid(GetLocalObject(item,CorpsePCCorpse)) || item == GetPickableCorpse())
{
if(destroyCopy)
{
DeleteLocalObject(item,CorpseOriginalObject);
//ActionDoCommand(DestroyObject(item));
DestroyObject(item);
//WriteTimestampedLogEntry("Deleting item "+ GetTag(item));
}
}
else
{
ActionGiveItem(item,target);
}
if(unSetFound)
{
SetFound(item,FALSE);
}
item = GetNextItemInInventory();
}
if(destroySelf)
{
ActionDoCommand(DestroyObject(OBJECT_SELF));
}
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
}
void SetFound(object item,int found = TRUE)
{
SetLocalInt(item,CorpseItemFound,found);
if(!found)
{
int number = GetLocalInt(item,CorpseItemFoundNumber);
int i;
//WriteTimestampedLogEntry("Unsetting "+IntToString(number)+" variables.");//Debug
for(i = 0; i < number;i++)
{
string suffix = GetLocalString(item,CorpseItemFoundBy+IntToString(i));
//WriteTimestampedLogEntry("Unsetting variable "+CorpseItemFoundBy+suffix);//Debug
DeleteLocalInt(item,CorpseItemFoundBy+suffix);
}
DeleteLocalInt(item,CorpseItemFoundNumber);
}
}
object GetOriginalCorpse(object target = OBJECT_SELF)
{
return GetLocalObject(target,CorpseCreatureCorpse);
}
void SetMaxDD(int DD,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseFindMaxValueVarName,DD);
}
int GetMaxDD(object target)
{
return GetLocalInt(target,CorpseFindMaxValueVarName);
}
void SetDecay(int useDecay,float decayDelay = 60.0,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseUseDecay,useDecay);
SetLocalFloat(target,CorpseDecayDealy,decayDelay);
}
int GetUseDecay(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseUseDecay);
}
float GetDecayDealy(object target = OBJECT_SELF)
{
return GetLocalFloat(target,CorpseDecayDealy);
}
void SetUseSaves(int use = TRUE)
{
SetLocalInt(GetModule(),CorpseUseSaves,use);
}
int GetUseSaves()
{
return GetLocalInt(GetModule(),CorpseUseSaves);
}
void SetRaceCannotLeaveACorpse(int racialType,int boolean = TRUE)
{
SetLocalInt(GetModule(),CorpseRaceLeaveACorpse+IntToString(racialType),boolean);
}
int GetRaceCannotLeaveACorpse(int ratialType)
{
return GetLocalInt(GetModule(),CorpseRaceLeaveACorpse+IntToString(ratialType));
}
void SetDamageTaken(int ammount, int dammageType = 0,object target = OBJECT_SELF)
{
switch(dammageType)
{
case 1: SetLocalInt(target,CorpseItemFireDammage,ammount);
break;
case 2: SetLocalInt(target,CorpseItemAcidDammage,ammount);
break;
case 0:
default: SetLocalInt(target,CorpseItemTotalDammage,ammount);
break;
}
}
int GetDamageTaken(int dammageType = 0,object target = OBJECT_SELF)
{
int retval = 0;
switch(dammageType)
{
case 1: retval = GetLocalInt(target,CorpseItemFireDammage);
break;
case 2: retval = GetLocalInt(target,CorpseItemAcidDammage);
break;
case 0:
default: retval = GetLocalInt(target,CorpseItemTotalDammage);
break;
}
return retval;
}
void SetUsePCPickableCorpse(int use = TRUE)
{
SetLocalInt(GetModule(),CorpseUsePickablePCCorpses,use);
}
int GetUsePCPickableCorpse()
{
return GetLocalInt(GetModule(),CorpseUsePickablePCCorpses);
}
void SetPickableCorpse(object corpse,object target = OBJECT_SELF)
{
SetLocalObject(target,CorpsePickableCorpse,corpse);
}
object GetPickableCorpse(object target = OBJECT_SELF)
{
return GetLocalObject(target,CorpsePickableCorpse);
}
void CreatePickableCorpse(object corpse,object dead = OBJECT_SELF)
{
object newCorpse;
switch(GetGender(dead))
{
case GENDER_FEMALE: newCorpse = CreateItemOnObject(CorpseFPickableBlueprint,corpse);
break;
case GENDER_MALE:
default: newCorpse = CreateItemOnObject(CorpseMPickableBlueprint,corpse);
break;
}
SetPickableCorpse(newCorpse,corpse);
SetPickableCorpse(corpse,newCorpse);
}
void getEquipment(object target)
{
int i = INVENTORY_SLOT_ARMS;
object item = GetItemInSlot(i,target);
object PC = GetLocalObject(target,CorpsePCCorpse);
int isPcLinked = GetIsObjectValid(GetLocalObject(target,CorpsePCCorpse));
object newItem;
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_ARROWS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_BELT;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_BOLTS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_BOOTS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_BULLETS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CARMOUR;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CHEST;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CLOAK;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CWEAPON_B;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CWEAPON_L;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_CWEAPON_R;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_HEAD;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_LEFTHAND;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_LEFTRING;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_NECK;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_RIGHTHAND;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
i = INVENTORY_SLOT_RIGHTRING;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
newItem = CopyObject(item,GetLocation(target),OBJECT_SELF);
SetLocalObject(newItem,CorpseOriginalObject,item);
if(isPcLinked)
{
SetLocalObject(newItem,CorpsePCCorpse,GetItemInSlot(i,PC));
}
}
TakeGoldFromCreature(GetGold(target),target);
}
object CreateCorpsePlaceable(object dead = OBJECT_SELF)
{
object inventory = CreateObject(OBJECT_TYPE_PLACEABLE,CorpseObjectBlueprint,GetLocation(dead));
SetLocalObject(inventory,CorpseCreatureCorpse,dead);
SetLocalObject(dead,CorpseCreatureCorpse,inventory);
ChangeFaction(inventory,dead);
int DD = getFindDifficulty(dead);
int maxDD = GetMaxDD(dead);
//Setting corpse values equal to original creature values
AssignCommand(inventory,setFindDifficulty(DD));
SetMaxDD(maxDD,inventory);
//Corpse resistence and imuities. Corpses are difficult to destroy ;-)
effect immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID,25);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_FIRE,25);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_ELECTRICAL,100);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_COLD,100);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_DIVINE,100);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_NEGATIVE,100);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
immune = EffectDamageImmunityIncrease(DAMAGE_TYPE_SONIC,100);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,immune,inventory);
SetLocalInt(inventory,CorpseItemLastHP,GetMaxHitPoints(inventory));
if(GetUseDecay())
{
effect death = EffectDeath(FALSE,FALSE);
DelayCommand(GetDecayDealy(),ApplyEffectToObject(DURATION_TYPE_INSTANT,death,inventory));
}
AssignCommand(inventory,getEquipment(dead));
if(!GetCantPickCorpse())
{
CreatePickableCorpse(inventory,dead);
}
int resurectable = !GetCorpseIsNotResurectable(dead);
AssignCommand(inventory,SetIsDestroyable(FALSE,resurectable,TRUE));
return inventory;
}
void CopyCreatureLocals(object originalCreature,object newCreature)
{
int DD = getFindDifficulty(originalCreature);
int maxDD = GetMaxDD(originalCreature);
int useDecay = GetUseDecay(originalCreature);
float decayDelay = GetDecayDealy(originalCreature);
//WriteTimestampedLogEntry("originalCreature DD: "+IntToString(DD)+" maxDD: "+IntToString(maxDD)+" useDecay: "+IntToString(useDecay));
//WriteTimestampedLogEntry("newCreature DD: "+IntToString(getFindDifficulty(newCreature))+" maxDD: "+IntToString(GetMaxDD(newCreature))+" useDecay: "+IntToString(GetUseDecay(newCreature)));
setFindDifficulty(DD,newCreature);
SetMaxDD(maxDD,newCreature);
SetDecay(useDecay,decayDelay,newCreature);
SetLocalObject(newCreature,CorpsePCCorpse,GetLocalObject(originalCreature,CorpsePCCorpse));
//WriteTimestampedLogEntry("newCreature DD: "+IntToString(getFindDifficulty(newCreature))+" maxDD: "+IntToString(GetMaxDD(newCreature))+" useDecay: "+IntToString(GetUseDecay(newCreature)));
SetCorpseIsNotResurectable(GetCorpseIsNotResurectable(originalCreature),newCreature);
SetCantPickCorpse(GetCantPickCorpse(originalCreature),newCreature);
int i;
int max = GetLocalInt(originalCreature,CorpseUserLocalVariablesNb);
for(i = 0; i < max;++i)
{
string varName = GetLocalString(originalCreature,CorpseUserLocalVariablesRoot+IntToString(i));
// SetLocalString(newCorpse,CorpseUserLocalVariablesRoot+IntToString(i),varName);
string varType = GetLocalString(originalCreature,CorpseUserLocalVarTypeRoot+IntToString(i));
// SetLocalString(newCorpse,CorpseUserLocalVarTypeRoot+IntToString(i),varType);
if("f" == varType)
{
SetLocalFloat_Corpse(newCreature,varName,GetLocalFloat(originalCreature,varName));
}
else if("i" == varType)
{
SetLocalInt_Corpse(newCreature,varName,GetLocalInt(originalCreature,varName));
}
else if("o" == varType)
{
SetLocalObject_Corpse(newCreature,varName,GetLocalObject(originalCreature,varName));
}
else if("l" == varType)
{
SetLocalLocation_Corpse(newCreature,varName,GetLocalLocation(originalCreature,varName));
}
else if("s" == varType)
{
SetLocalString_Corpse(newCreature,varName,GetLocalString(originalCreature,varName));
}
}
}
void CopyCorpseLocals(object originalCorpse,object newCorpse)
{
int i;
int max = GetLocalInt(originalCorpse,CorpseFindAttemptNumber);
SetLocalInt(newCorpse,CorpseFindAttemptNumber,max);
for(i = 0; i < max;++i)
{
string suffix = GetLocalString(originalCorpse,CorpseFindAttemptRoot+IntToString(i));
SetLocalString(newCorpse,CorpseFindAttemptRoot+IntToString(i),suffix);
string varName = CorpseFindAttemptRoot+suffix;
SetLocalInt(newCorpse,varName,GetLocalInt(originalCorpse,varName));
}
}
void DestroyEquipment(object target)
{
object item = GetItemInSlot(INVENTORY_SLOT_ARMS,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_ARROWS,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_BELT,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_BOLTS,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_BOOTS,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_BULLETS,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CARMOUR,target);
//DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CHEST,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CLOAK,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CWEAPON_L,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_CWEAPON_R,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_HEAD,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_LEFTRING,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_NECK,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,target);
DestroyObject(item);
item = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,target);
DestroyObject(item);
TakeGoldFromCreature(GetGold(target),target);
}
object MoveCorpseTo(location newPlace,object corpse = OBJECT_SELF)
{
object originalCorpse = GetOriginalCorpse(corpse);
object newCreature = CopyObject(originalCorpse,newPlace);
object retval = newCreature;
if(GetIsObjectValid(newCreature))
{
SetIsCorpseCopying(TRUE,newCreature);
CopyCreatureLocals(originalCorpse,newCreature);
object copy = CreateCorpsePlaceable(newCreature);
CopyCorpseLocals(corpse,copy);
//WriteTimestampedLogEntry("Test oldDD: "+IntToString(getFindDifficulty(originalCorpse)) + " new DD " +IntToString(getFindDifficulty(newCreature)));
object oldItem = GetFirstItemInInventory(newCreature);
while(GetIsObjectValid(oldItem))
{
//WriteTimestampedLogEntry("Destyroying item " + GetTag(oldItem));
if(!GetIsObjectValid(GetLocalObject(oldItem,CorpseOriginalObject)))
{
DestroyObject(oldItem);
}
oldItem = GetNextItemInInventory(newCreature);
}
AssignCommand(corpse,giveBackItems(newCreature,TRUE,FALSE,TRUE));
DestroyEquipment(originalCorpse);
AssignCommand(copy,GetItemsInInventory(originalCorpse,0,FALSE,OBJECT_INVALID,TRUE));
AssignCommand(copy,SetCommandable(TRUE));
AssignCommand(copy,ActionDoCommand(giveBackItems(newCreature,FALSE)));
AssignCommand(copy,ActionDoCommand(SetCommandable(TRUE)));
AssignCommand(copy,SetCommandable(FALSE));
retval = copy;
}
return retval;
}
int GetIsCorpseCopying(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseIsCorpseCopying);
}
void SetIsCorpseCopying(int boolean = TRUE,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseIsCorpseCopying,boolean);
}
void SetCorpseDialogFound(int boolean,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseDialogFound,boolean);
}
int GetCorpseDialogFound(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseDialogFound);
}
void SetCorpseDialogFoundNumber(int number,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseDialogFoundNumber,number);
}
int GetCorpseDialogFoundNumber(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseDialogFoundNumber);
}
void SetCorpseDialogMoved(int boolean,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseDialogMoved,boolean);
}
int GetCorpseDialogMoved(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseDialogMoved);
}
/*object PCMoveCorpseTo(location newPlace,object corpse = OBJECT_SELF)
{
object originalCorpse = GetOriginalCorpse(corpse);
object newCreature = CopyObject(originalCorpse,newPlace);
object retval = newCreature;
if(GetIsObjectValid(newCreature))
{
SetIsCorpseCopying(TRUE,newCreature);
CopyCreatureLocals(originalCorpse,newCreature);
object copy = CreateCorpsePlaceable(newCreature);
CopyCorpseLocals(corpse,copy);
//WriteTimestampedLogEntry("Test oldDD: "+IntToString(getFindDifficulty(originalCorpse)) + " new DD " +IntToString(getFindDifficulty(newCreature)));
object oldItem = GetFirstItemInInventory(newCreature);
while(GetIsObjectValid(oldItem))
{
//WriteTimestampedLogEntry("Destyroying item " + GetTag(oldItem));
if(!GetIsObjectValid(GetLocalObject(oldItem,CorpseOriginalObject)))
{
DestroyObject(oldItem);
}
oldItem = GetNextItemInInventory(newCreature);
}
AssignCommand(corpse,giveBackItems(newCreature,TRUE,FALSE,TRUE));
DestroyEquipment(originalCorpse);
AssignCommand(copy,GetItemsInInventory(originalCorpse,0,FALSE,OBJECT_INVALID,TRUE));
retval = copy;
}
return retval;
}*/
void SetCorpseIsNotResurectable(int boolean=TRUE,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseIsNotResurectable,boolean);
}
int GetCorpseIsNotResurectable(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseIsNotResurectable);
}
void CorpseCutOffCreatureSkin(object PC,object target)
{
object realTarget = GetOriginalCorpse(target);
if(target == PC)
{
SetLocalInt(PC,CorpseSkinDialogIndex,0);
}
else if(GetDistanceBetween(PC,target) > 1.0)
{
SetLocalInt(PC,CorpseSkinDialogIndex,4);
}
//else if(GetIsObjectValid(realTarget) && GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_CARMOUR,realTarget)))
else if(GetIsObjectValid(realTarget) && GetIsObjectValid(GetPCSkin(realTarget)))
{
SetLocalInt(PC,CorpseSkinDialogIndex,3);
int pickPocketRank = GetSkillRank(SKILL_PICK_POCKET);
int loreRank = GetSkillRank(SKILL_LORE);
int skillRank;
if(pickPocketRank < 0)
{
skillRank = loreRank + GetAbilityModifier(ABILITY_DEXTERITY);
}
else
{
skillRank = loreRank + pickPocketRank;
}
int DC = GetAC(realTarget) - GetHitDice(PC);
if(DC < 0)
{
DC = 0;
}
int dice = d20();
if(dice > 1)
{
if(skillRank + dice >= DC || dice == 20)
{
//NW_IT_MMIDMISC06
//object skin = GetItemInSlot(INVENTORY_SLOT_CARMOUR,realTarget);
object skin = GetPCSkin(realTarget);
string skinTag = GetTag(skin);
string skinResRef = GetStringLowerCase(skinTag);
if(GetSubString(skinTag,0,7) == "Corpse_")
{
object result = CreateItemOnObject(skinResRef,PC);
if(!GetIsObjectValid(result) || GetResRef(result) != skinResRef)
{
if(GetIsObjectValid(result))
{
DestroyObject(result);
}
result = CreateItemOnObject("NW_IT_MMIDMISC06",PC);
if(GetIsObjectValid(result))
{
SetLocalInt(PC,CorpseSkinDialogIndex,1);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(FALSE,FALSE),target);
}
}
else
{
SetLocalInt(PC,CorpseSkinDialogIndex,1);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(FALSE,FALSE),target);
}
}
else
{
object result = CreateItemOnObject("NW_IT_MMIDMISC06",PC);
if(GetIsObjectValid(result))
{
SetLocalInt(PC,CorpseSkinDialogIndex,1);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(FALSE,FALSE),target);
}
}
}
}
else
{
SetLocalInt(PC,CorpseSkinDialogIndex,2);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(FALSE,FALSE),target);
}
}
AssignCommand(PC,SpeakOneLinerConversation("corpse_skin",PC));
}
void SetCantPickCorpse(int use = TRUE,object target = OBJECT_SELF)
{
SetLocalInt(target,CorpseIsNotCorpsePickable,use);
}
int GetCantPickCorpse(object target = OBJECT_SELF)
{
return GetLocalInt(target,CorpseIsNotCorpsePickable);
}
string GetPCID(object player)
{
string result = "";
if(GetIsPC(player))
{
result = GetTag(player)+GetName(player)+GetPCPublicCDKey(player);
}
return result;
}
void SetLocalFloat_Corpse(object oObject,string sVarName,float fValue)
{
SetLocalFloat(oObject,sVarName,fValue);
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb),sVarName);
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb),"f");
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb+1);
}
void SetLocalInt_Corpse(object oObject,string sVarName, int nValue)
{
SetLocalInt(oObject,sVarName,nValue);
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb),sVarName);
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb),"i");
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb+1);
}
void SetLocalLocation_Corpse(object oObject,string sVarName, location lValue)
{
SetLocalLocation(oObject,sVarName,lValue);
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb),sVarName);
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb),"l");
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb+1);
}
void SetLocalObject_Corpse(object oObject,string sVarName, object oValue)
{
SetLocalObject(oObject,sVarName,oValue);
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb),sVarName);
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb),"o");
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb+1);
}
void SetLocalString_Corpse(object oObject,string sVarName, string sValue)
{
SetLocalString(oObject,sVarName,sValue);
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb),sVarName);
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb),"s");
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb+1);
}
void DeleteLocalVar(object oObject,string sVarName)
{
int i = 0;
int nb = GetLocalInt(oObject,CorpseUserLocalVariablesNb);
int found = FALSE;
while(i < nb && !found)
{
if(GetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(i)) == sVarName)
{
found = TRUE;
}
else
{
i++;
}
}
if(i < nb)
{
DeleteLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(i));
DeleteLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(i));
if(i < --nb)
{
SetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(i),GetLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb)));
SetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(i),GetLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb)));
DeleteLocalString(oObject,CorpseUserLocalVariablesRoot+IntToString(nb));
DeleteLocalString(oObject,CorpseUserLocalVarTypeRoot+IntToString(nb));
}
SetLocalInt(oObject,CorpseUserLocalVariablesNb,nb);
}
}
void DeleteLocalFloat_Corpse(object oObject,string sVarName)
{
DeleteLocalFloat(oObject, sVarName);
DeleteLocalVar(oObject, sVarName);
}
void DeleteLocalInt_Corpse(object oObject,string sVarName)
{
DeleteLocalInt(oObject, sVarName);
DeleteLocalVar(oObject, sVarName);
}
void DeleteLocalLocation_Corpse(object oObject,string sVarName)
{
DeleteLocalLocation(oObject, sVarName);
DeleteLocalVar(oObject, sVarName);
}
void DeleteLocalObject_Corpse(object oObject,string sVarName)
{
DeleteLocalObject(oObject, sVarName);
DeleteLocalVar(oObject, sVarName);
}
void DeleteLocalString_Corpse(object oObject,string sVarName)
{
DeleteLocalString(oObject, sVarName);
DeleteLocalVar(oObject, sVarName);
}
string GetStringInArray(string arrayName,int index = 0,object target = OBJECT_SELF)
{
return GetLocalString(target,arrayName+IntToString(index));
}
void SetStringInArray(string arrayName,string value,int index = 0,object target = OBJECT_SELF)
{
SetLocalString(target,arrayName+IntToString(index),value);
if(index >= GetLocalInt(target,arrayName))
{
SetLocalInt(target,arrayName,index);
}
}
int GetStringArraySize(string arrayName,object target = OBJECT_SELF)
{
return GetLocalInt(target,arrayName);
}
void DeleteStringInArray(string arrayName,int index,object target = OBJECT_SELF)
{
if(index < GetLocalInt(target,arrayName))
{
DeleteLocalString(target, arrayName+IntToString(index));
int i;
int max = GetLocalInt(target,arrayName);
int size = max-1;
int cur = index;
for(i = index+1;i < max;++i)
{
if(GetLocalString(target,arrayName+IntToString(i)) == "")
{
--size;
}
else
{
SetLocalString(target,arrayName+IntToString(cur),GetLocalString(target,arrayName+IntToString(i)));
cur++;
}
DeleteLocalString(target,arrayName+IntToString(i));
}
}
}
void LinkEquipment(object target)
{
int i = INVENTORY_SLOT_ARMS;
object item = GetItemInSlot(i,target);
object PC = GetLocalObject(target,CorpsePCCorpse);
if(GetIsObjectValid(PC))
{
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_ARROWS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_BELT;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_BOLTS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_BOOTS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_BULLETS;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CARMOUR;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CHEST;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CLOAK;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CWEAPON_B;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CWEAPON_L;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_CWEAPON_R;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_HEAD;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_LEFTHAND;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_LEFTRING;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_NECK;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_RIGHTHAND;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
i = INVENTORY_SLOT_RIGHTRING;
item = GetItemInSlot(i,target);
if(GetDroppableFlag(item))
{
SetLocalObject(item,CorpsePCCorpse,GetItemInSlot(i,PC));
}
//TakeGoldFromCreature(GetGold(target),target);
}
}