Added character deleter

Added character deleter.  Updated aps_include.  Updated NWNxEE.
 Boosted XP rewards.  Added XP reward for skinnable creatures.  Full compile.  Updated release archive.
This commit is contained in:
Jaysyn904
2024-08-31 20:23:36 -04:00
parent 94b4c689da
commit 65af23f08d
404 changed files with 7949 additions and 6005 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,904 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// // //
// _kb_loot_corpse (include file) // VERSION 3.3 //
// // //
// by Scrotok on 9 Feb 03 ////////////////////////////
// Thanks to Keron Blackfeld for 99% of the work! //
// email Questions and Comments to: jnbplatte@intellisys.net //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// CAUTION: You MUST re-save/compile (F7 key) "nw_c2_default7" whenever //
// "_kb_loot_corpse" is modified! //
// //
// CAUTION: You MUST re-save (not the F7 key!) "_kb_loot_corpse" if you make //
// any changes to "_kb_inc_invmgmt" (for programmers only: because it is an //
// #include file). To re-save it, make a change to the script, then UNDO //
// the change, then re-save. //
// //
// NEWBIES: You don't need to place this script anywhere -- it's included as //
// part of "nw_c2_default7" using the #include command. All you need to do //
// is configure the script (see below) as desired. //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// //
// CONFIGURING THE SCRIPT //
// //
// This script supports some configuration by the user. Following the //
// void LeaveCorpse() of the _kb_loot_corpse, you'll find a section where //
// you can set a few things. These include: (with default values displayed) //
// //
// //
// int nUseLootable = TRUE This enables the script. Setting is to FALSE //
// disables it. //
// //
// int nMoveEquipped = TRUE Setting this to FALSE will stop the script //
// from moving equipped items (other than //
// Armour/Helmet and Weapons/Shield/Torch) to //
// the lootable corpse placeable. (To prevent //
// the move/copy of Armour/Helmet and Weapons/ //
// Shield/Torch, use the next four toggles.) //
// Remember that CREATURE SLOTTED items are //
// NEVER moved. //
// //
// int nCopyArmour = TRUE This will use the ResRef to create a copy of //
// the Armour/Helmet the creature is wearing. //
// If you do not want to use this function, you //
// may want to consider the next one (called //
// nMoveArmour). nCopyArmour takes precedence //
// over nMoveArmour if both are TRUE. //
// //
// int nMoveArmour = FALSE Setting this TRUE will just move the armour //
// from the Chest slot to the lootable corpse //
// placeable on death; it will also move the //
// helmet from the Head slot to the lootable //
// corpse placeable. This can be a visual issue //
// when used with NPCs - since when the armour //
// is moved, the NPC will become 'naked'. //
// //
// *** If you do not wish to use either of the armour functions, just set //
// both values to FALSE. Then just add an additional suit of armour //
// and/or helmet to the inventory of creatures you want to have drop //
// their armour/helmet. //
// //
// int nDropWeapons = TRUE This will use the ResRef for dropping the //
// weapons on the ground - which is accomplished //
// by creating new ones on the ground and //
// destroying the ones in the creature's //
// inventory. NOTE: Even though the parameter //
// is called nDropWeapons, anything held in the //
// left or right hand (shield, torch, etc.) is //
// affected by this parameter. nDropWeapons //
// takes precedence over nMoveWeapons if both //
// are TRUE. //
// //
// int nMoveWeapons = FALSE Setting this TRUE will just move the weapons //
// to the Lootable Object just as the rest of //
// inventory is handled. NOTE: Even though the //
// parameter is called nMoveWeapons, anything //
// held in the left or right hand (shield, //
// torch, etc.) is affected by this parameter. //
// //
// *** If you do not wish to use either of the weapon functions, just set //
// both values to FALSE. Then just add additional weapons/shields/ //
// torches to the inventory of creatures you want to have drop those //
// items. //
// //
// int nUseBlood = TRUE Set this to TRUE if you want a Bloodspot to //
// appear under the corpse for a little extra //
// gory appeal. In addition, it will allow for //
// a grisly display if the corpse is destroyed. //
// Undead/constructs/elementals will not leave a //
// Bloodspot or "gib" when bashed. //
// //
// int nTinyBlood = FALSE Set this to FALSE if you don't want Tiny- //
// sized creatures (rats, bats, etc.) to leave a //
// Bloodspot, scorch mark, or small flame. They //
// will still "gib" normally. Only applies if //
// nUseBlood = TRUE. //
// //
// int nUseFlame = TRUE Set this to TRUE if you want a scorch mark or //
// a small flame (which burns out after 10-120 //
// seconds, and is replaced by a scorch mark) to //
// appear if 1/3 or more of the damage which //
// killed the creature was fire or electrical. //
// Scorch mark or flame will appear instead of //
// Bloodspot. If the total fire or electrical //
// damage exceeds the creature's max HP, a small //
// flame appears instead of a scorch mark. The //
// corpse will still gib normally. Undead, //
// constructs, and elementals will leave a //
// scorch mark, small flame, or nothing. Only //
// applies if nUseBlood = TRUE. //
// //
// int nCorpseFade = 0 This is the delay in actual seconds that the //
// corpse will remain before it fades. If you //
// set this to 0 (zero) it will turn off the //
// corpse fade - allowing all bodies and loot //
// to remain indefinitely. //
// //
// int nUseBonesBash = TRUE Set this to TRUE if you want bones to appear //
// when the corpse is bashed. The bones cannot //
// be bashed; they will only disappear if //
// nBonesFade > 0. //
// //
// int nUseBonesFade = TRUE Set this to TRUE if you want bones to appear //
// when the corpse fades. The bones cannot //
// be bashed; they will only disappear if //
// nBonesFade > 0. //
// //
// int nBonesFade = 60 This is the delay in actual seconds that the //
// bones will remain before they fade. If you //
// set this to 0 (zero) it will turn off the //
// bones fade - allowing all bones (and loot, //
// if the bones contain any) to remain forever. //
// //
// int nTinyBones = FALSE Set this to FALSE if you don't want Tiny- //
// sized creatures (rats, bats, etc.) to turn //
// into bones when their corpse is bashed or //
// fades. Only applies if nUseBonesBash and/or //
// nUseBonesFade = TRUE. //
// //
// int nKeepInventoryBash = FALSE Set this to TRUE if you want all items //
// in a creature's inventory to remain when //
// its corpse is bashed. If installed, //
// DOA's "Bashed Loot Breakage" plugin //
// ("doa_bashbreak") takes precedence over //
// nKeepInventoryBash. //
// //
// int nKeepInventoryFade = FALSE Set this to TRUE if you want all items //
// in a creature's inventory to remain when //
// its corpse fades. //
// //
// int nKeepEmpties = TRUE Set this to FALSE if you want EMPTY corpses //
// to fade immediately after their inventory is //
// emptied (and dropped weapons are claimed, //
// unless nKeepWeaponsEmpty is TRUE). //
// //
// int nKeepWeaponsBonesFade = FALSE Set this to FALSE if you want //
// dropped, unclaimed, non-plot weapons //
// to be destroyed when bones fade. //
// Only valid if nBonesFade > 0. //
// //
// int nKeepWeaponsCorpseFade = TRUE Set this to FALSE if you want //
// dropped, unclaimed, non-plot weapons //
// to be destroyed when corpses fade. //
// Only valid if nCorpseFade > 0. //
// //
// int nKeepWeaponsBash = TRUE Set this to FALSE if you want //
// dropped, unclaimed, non-plot weapons //
// to be destroyed when corpses are //
// bashed. //
// //
// int nKeepWeaponsEmpty = TRUE Set this to TRUE if you want empty //
// corpses to be destroyed even if //
// dropped weapons are unclaimed. //
// //
// *** Even though the 4 parameters listed above start with "nKeepWeapons", //
// anything held in the left or right hand (shield, torch, etc.) is //
// affected by these parameters, not just weapons. //
// //
// int nOverrideForPlacedCorpses = TRUE Set this to TRUE if you want the //
// 'Spawned Corpses' you place to be //
// permament. Setting it to FALSE //
// will cause your Placed Dead //
// creatures to act as the settings //
// above dictate. (i.e. Fading Out //
// after the delay or being emptied) //
// To use this functionality, you //
// should place the _kb_plc_corpse //
// script in the OnSpawn of the //
// critter you want to spawn dead. //
// //
////////////////////////////////////////////////////////////////////////////////
/* Version 3.3 Change Log:
- added SetPlotFlag to ensure oLootCorpse can't be destroyed before oHostBody is emptied (and weapons are dropped)
- fixed comments to clarify that "doa_bashbreak" script refers to DOA's "Bashed Loot Breakage" plugin
/* Version 3.2 Change Log:
- consolidated inventory management functions to _kb_inc_invmgmt
- DestroyInventory function calls changed to DestroyInventory + DestroyDroppedWeapons in _kb_inc_invmgmt (identical)
- added nTinyBlood and nUseFlame (added Flameout function and rewrote Bloodspot routine)
- added GetIsObjectValid check before destroying Bloodspot
- removed ActionWait (wasn't needed)
- combined several DelayCommand's into a single function (FadeCorpse) to improve performance
- improved FadeCorpse to take advantage of new functionality (nKeepInventoryFade, nUseBonesFade, etc.)
- fixed bug in DropLeftWeapon/DropRightWeapon that caused dropped weapons to have incorrect GetIdentified value
- fixed bug where 2 copies of droppable, equipped, Plot armor were created instead of 1 when corpse was bashed
- fixed bug that caused copied armor to have incorrect GetPlotFlag and GetIdentified values
- added nUseBonesBash to create bones when corpse is bashed
- added nUseBonesFade to create bones when corpse fades
- added nBonesFade to determine when bones fade (if ever)
- added nTinyBones to prevent bones from appearing for tiny-sized creatures
- added nKeepInventoryBash to keep all items in a creature's inventory when its corpse is bashed
- added nKeepInventoryFade to keep all items in a creature's inventory when its corpse fades
- replaced nKeepWeapons with: nKeepWeaponsBonesFade, nKeepWeaponsCorpseFade, nKeepWeaponsBash, and nKeepWeaponsEmpty
- changed comments to clarify weapons/shields/torches are affected by "weapons" parameters/functions
- changed comments to reflect that undead/constructs/elementals will not leave Bloodspot or "gib" when bashed
- fixed bug so that nCopyArmour takes precedence over nMoveArmour if both are TRUE
- added comments to clarify that nCopyArmour takes precedence over nMoveArmour if both are TRUE
- added comments to clarify that nDropWeapons takes precedence over nMoveWeapons if both are TRUE
- renamed oDeadNPC to oHostBody, and vDeadNPCLoc to vHostBodyLoc for consistency
- fixed bug so that nCopyArmour/nMoveArmour affect helmets equipped in the creature's Head slot, as well
- added support for "Destroy Target" command of DM's Helper wand (used to destroy the corpse or bones)
- added code to pass oLeftWpn/oRightWpn from oHostBody to oLootCorpse for use with Scrotok's Raise Dead/Ressurection Plugin
*/
#include "_kb_inc_invmgmt"
#include "sd_lootsystem"
/*******************************************************************************
** This script was borrowed from the Hard Core Ruleset, where they use it to **
** move a Dead PC's inventory to a lootable corpse object. Credit where **
** credit is due, I always say. :) **
*******************************************************************************/
object strip_equipped(object oHostBody, object oLootCorpse, object oEquip)
{
if(GetIsObjectValid(oEquip) && GetDroppableFlag(oEquip))
{
AssignCommand(oLootCorpse, ActionTakeItem(oEquip, oHostBody));
}
return oEquip;
}
/*******************************************************************************
** These scripts drop weapons/shields/torches held in the corpse's hands. **
** **
** SPECIAL THANKS TO DREZDAR and MOJO for their help in getting these two **
** drop weapon scripts written. I never would have gotten the vectors right, **
** but THEY sure did! **
** **
** (East = 0, North = 90, West = 180, South = 270) **
** **
*******************************************************************************/
void DropLeftWeapon(object oLeftWpn, object oLootCorpse)
{
if(GetIsObjectValid(oLeftWpn) && GetDroppableFlag(oLeftWpn))
{
vector vCorpseLoc = GetPositionFromLocation(GetLocation(oLootCorpse));
float fDifferential = 45.0f + IntToFloat(d20());//Randomize the Drop Angle
float fDistance = 0.5f + (IntToFloat(d10())/10);//Randomize the Drop Distance
float fVarWpnFace = -20.0f - IntToFloat(d20(2));//Randomize the Drop Facing
float fFacing = GetFacing(oLootCorpse);
fFacing = fFacing + fDifferential;
if (fFacing > 360.0f)
{ fFacing = 720.0f - fFacing; }
if (fFacing < 0.0f)
{ fFacing = 360.0f + fFacing; }
float fWpnFacing = GetFacing(oLootCorpse) + fVarWpnFace;
if (fWpnFacing > 360.0f)
{ fWpnFacing = 720.0f - fWpnFacing; }
if (fWpnFacing < 0.0f)
{ fWpnFacing = 360.0f + fWpnFacing; }
object oArea = GetArea(oLootCorpse);
//Generate New Location
float fNewX;
float fNewY;
float fNewZ;
if ((fFacing > 0.0f) && (fFacing < 90.0f))
{ fNewX = vCorpseLoc.x + ((cos(fFacing))*fDistance); fNewY = vCorpseLoc.y + ((sin(fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 90.0f) && (fFacing < 180.0f))
{ fNewX = vCorpseLoc.x - ((cos(180.0f - fFacing))*fDistance); fNewY = vCorpseLoc.y + ((sin(180.0f - fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 180.0f) && (fFacing < 270.0f))
{ fNewX = vCorpseLoc.x - ((cos(fFacing - 180.0f))*fDistance); fNewY = vCorpseLoc.y - ((sin(fFacing - 180.0f))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 270.0f) && (fFacing < 360.0f))
{ fNewX = vCorpseLoc.x + ((cos(360.0f - fFacing))*fDistance); fNewY = vCorpseLoc.y - ((sin(360.0f - fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if (fFacing == 0.0f)
{ fNewX = vCorpseLoc.x + fDistance; fNewY = vCorpseLoc.y; fNewZ = vCorpseLoc.z; }
else if (fFacing == 90.0f)
{ fNewX = vCorpseLoc.x; fNewY = vCorpseLoc.y + fDistance; fNewZ = vCorpseLoc.z; }
else if (fFacing == 180.0f)
{ fNewX = vCorpseLoc.x - fDistance; fNewY = vCorpseLoc.y; fNewZ = vCorpseLoc.z; }
else if (fFacing == 270.0f)
{ fNewX = vCorpseLoc.x; fNewY = vCorpseLoc.y - fDistance; fNewZ = vCorpseLoc.z; }
vector vNewFinal = Vector(fNewX, fNewY, fNewZ);
location lDropLeft = Location(oArea, vNewFinal, fWpnFacing);
//Drop Weapon
string sLeftWpnRef = GetResRef(oLeftWpn);
int nID = GetIdentified(oLeftWpn);
if (GetPlotFlag(oLeftWpn))
{
SetPlotFlag(oLeftWpn, FALSE);
DestroyObject(oLeftWpn);
oLeftWpn = CreateObject(OBJECT_TYPE_ITEM, sLeftWpnRef, lDropLeft, FALSE);
SetPlotFlag(oLeftWpn, TRUE);
}
else
{
DestroyObject(oLeftWpn);
oLeftWpn = CreateObject(OBJECT_TYPE_ITEM, sLeftWpnRef, lDropLeft, FALSE);
}
SetIdentified(oLeftWpn, nID);
SetLocalObject(oLootCorpse, "oLeftWpn", oLeftWpn);
}
// We're done with oHostBody, so allow oLootCorpse to be destroyable
AssignCommand(oLootCorpse, ActionDoCommand(SetPlotFlag(oLootCorpse, FALSE)));
}
void DropRightWeapon(object oRightWpn, object oLootCorpse)
{
if(GetIsObjectValid(oRightWpn) && GetDroppableFlag(oRightWpn))
{
vector vCorpseLoc = GetPositionFromLocation(GetLocation(oLootCorpse));
float fDifferential = -45.0f + IntToFloat(d20());//Randomize the Drop Angle
float fDistance = 0.5f + (IntToFloat(d10())/10);//Randomize the Drop Distance
float fVarWpnFace = 20.0f - IntToFloat(d20(2));//Randomize the Drop Facing
float fFacing = GetFacing(oLootCorpse);
fFacing = fFacing + fDifferential;
if (fFacing > 360.0f)
{ fFacing = 720.0f - fFacing; }
if (fFacing < 0.0f)
{ fFacing = 360.0f + fFacing; }
float fWpnFacing = GetFacing(oLootCorpse) + fVarWpnFace;
if (fWpnFacing > 360.0f)
{ fWpnFacing = 720.0f - fWpnFacing; }
if (fWpnFacing < 0.0f)
{ fWpnFacing = 360.0f + fWpnFacing; }
object oArea = GetArea(oLootCorpse);
//Generate New Location
float fNewX;
float fNewY;
float fNewZ;
if ((fFacing > 0.0f) && (fFacing < 90.0f))
{ fNewX = vCorpseLoc.x + ((cos(fFacing))*fDistance); fNewY = vCorpseLoc.y + ((sin(fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 90.0f) && (fFacing < 180.0f))
{ fNewX = vCorpseLoc.x - ((cos(180.0f - fFacing))*fDistance); fNewY = vCorpseLoc.y + ((sin(180.0f - fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 180.0f) && (fFacing < 270.0f))
{ fNewX = vCorpseLoc.x - ((cos(fFacing - 180.0f))*fDistance); fNewY = vCorpseLoc.y - ((sin(fFacing - 180.0f))*fDistance); fNewZ = vCorpseLoc.z; }
else if ((fFacing > 270.0f) && (fFacing < 360.0f))
{ fNewX = vCorpseLoc.x + ((cos(360.0f - fFacing))*fDistance); fNewY = vCorpseLoc.y - ((sin(360.0f - fFacing))*fDistance); fNewZ = vCorpseLoc.z; }
else if (fFacing == 0.0f)
{ fNewX = vCorpseLoc.x + fDistance; fNewY = vCorpseLoc.y; fNewZ = vCorpseLoc.z; }
else if (fFacing == 90.0f)
{ fNewX = vCorpseLoc.x; fNewY = vCorpseLoc.y + fDistance; fNewZ = vCorpseLoc.z; }
else if (fFacing == 180.0f)
{ fNewX = vCorpseLoc.x - fDistance; fNewY = vCorpseLoc.y; fNewZ = vCorpseLoc.z; }
else if (fFacing == 270.0f)
{ fNewX = vCorpseLoc.x; fNewY = vCorpseLoc.y - fDistance; fNewZ = vCorpseLoc.z; }
vector vNewFinal = Vector(fNewX, fNewY, fNewZ);
location lDropRight = Location(oArea, vNewFinal, fWpnFacing);
//Drop Weapon
string sRightWpnRef = GetResRef(oRightWpn);
int nID = GetIdentified(oRightWpn);
if (GetPlotFlag(oRightWpn))
{
SetPlotFlag(oRightWpn, FALSE);
DestroyObject(oRightWpn);
oRightWpn = CreateObject(OBJECT_TYPE_ITEM, sRightWpnRef, lDropRight, FALSE);
SetPlotFlag(oRightWpn, TRUE);
}
else
{
DestroyObject(oRightWpn);
oRightWpn = CreateObject(OBJECT_TYPE_ITEM, sRightWpnRef, lDropRight, FALSE);
}
SetIdentified(oRightWpn, nID);
SetLocalObject(oLootCorpse, "oRightWpn", oRightWpn);
}
}
/*******************************************************************************
** This script gets rid of the bloodspot, lootable corpse, and creature body **
*******************************************************************************/
void FadeCorpse(object oCorpseBlood, object oLootCorpse, object oHostBody)
{
//Delete the BloodSpot (if created)
if (GetIsObjectValid(oCorpseBlood))
{
DestroyObject(oCorpseBlood);
}
// Empty (or don't empty) the lootable corpse placeable
if (GetLocalInt(oLootCorpse, "nKeepInventoryFade") == FALSE)
// Delete all items (except Plot) from lootable corpse placeable
DestroyInventory(oLootCorpse);
else
{
// Do nothing (delete nothing from lootable corpse placeable)
}
// If user wants bones to be created when corpse fades...
if (GetLocalInt(oLootCorpse, "nUseBonesFade"))
{
if ((GetLocalInt(oLootCorpse, "nTinyBones") == FALSE) && (GetCreatureSize(oHostBody) == CREATURE_SIZE_TINY))
{
// Do nothing -- no bones for tiny creatures if nTinyBones is FALSE
}
else
{
// Create the bones
object oBones = CreateObject(OBJECT_TYPE_PLACEABLE, "loot_bones_obj", GetLocation(oLootCorpse), FALSE);
// Move inventory to bones
TransferToBones(oLootCorpse, oBones);
// Fade bones after nBoneFade seconds
if (GetLocalInt(oLootCorpse, "nBonesFade") > 0)
{
// Remember racial type and Blueprint ResRef for use with Scrotok's Raise Dead/Resurrection plugin
SetLocalInt(oBones, "nRacialType", GetLocalInt(oLootCorpse, "nRacialType"));
SetLocalString(oBones, "sHostBodyResRef", GetLocalString(oLootCorpse, "sHostBodyResRef"));
// Pass dropped weapon/shield/torch info to bones
SetLocalObject(oBones, "oLeftWpn", GetLocalObject(oLootCorpse, "oLeftWpn"));
SetLocalObject(oBones, "oRightWpn", GetLocalObject(oLootCorpse, "oRightWpn"));
int nKeepWeaponsBonesFade = GetLocalInt(oLootCorpse, "nKeepWeaponsBonesFade");
// Remember nKeepWeaponsBonesFade for use with DM's Helper wand
SetLocalInt(oBones, "nKeepWeaponsBonesFade", nKeepWeaponsBonesFade);
float fBonesFade = IntToFloat(GetLocalInt(oLootCorpse, "nBonesFade"));
AssignCommand(oBones, DelayCommand(fBonesFade, BonesCleanup(oBones, nKeepWeaponsBonesFade)));
}
}
}
// Delete unclaimed, dropped, non-Plot weapons unless nKeepWeaponsCorpseFade = 1
if (!GetLocalInt(oLootCorpse, "nKeepWeaponsCorpseFade"))
DestroyDroppedWeapons(oLootCorpse);
// Delete the lootable corpse placeable
DestroyObject(oLootCorpse);
// Empty and delete actual creature corpse (body)
DestroyInventory(oHostBody);
/* There is no call to DestroyDroppedWeapons since if the weapons are
dropped, they are already deleted from oHostBody. If the weapons are
not dropped, then the function would still not delete the weapons
since GetItemPossessor would be a valid object */
SetIsDestroyable(TRUE,FALSE,FALSE);
// NOTE: The following line MUST be last in this script, since oHostBody
// is the same as OBJECT_SELF
DestroyObject(oHostBody);
}
/*******************************************************************************
** This script replaces the small flame with a scorch mark **
*******************************************************************************/
void Flameout(object oCorpseBlood, object oLootCorpse)
{
location lBloodLoc = GetLocation(oCorpseBlood);
/*
// Used for debugging
SendMessageToPC(GetFirstPC(), "Flame script started...");
if (!GetIsObjectValid(oCorpseBlood))
{
// This should never happen (if you bash/fade corpse, oHostBody is
// destroyed, so Flameout won't run (can't add to action queue of invalid
// object)
SendMessageToPC(GetFirstPC(), "Flame already destroyed... location for new scorch unknown?");
}
*/
// Get rid of small flame
DestroyObject(oCorpseBlood);
// ... and turn it into a scorch mark
oCorpseBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_weathmark", lBloodLoc, FALSE);
ExecuteScript("sl_destroyself2", oCorpseBlood);
//Set Local for deletion later if needed
SetLocalObject(oLootCorpse, "oBloodSpot", oCorpseBlood);
}
void BodyFade(object oHostBody, object oBlood)
{
object oBones;
location lLoc = GetLocation(oHostBody);
SetPlotFlag(oHostBody, FALSE);
AssignCommand(oHostBody, SetIsDestroyable(TRUE,FALSE,FALSE));
if ((GetRacialType(oHostBody) != RACIAL_TYPE_CONSTRUCT) &&
(GetRacialType(oHostBody) != RACIAL_TYPE_ELEMENTAL)&&
(GetRacialType(oHostBody) != RACIAL_TYPE_DRAGON)&&
(GetRacialType(oHostBody) != RACIAL_TYPE_ANIMAL)&&
GetTag(oHostBody)!="sd_coff_mummy")
{
oBones = CreateObject(OBJECT_TYPE_PLACEABLE, "sd_remains", lLoc, FALSE);
ExecuteScript("sl_destroyself", oBones);
}
DestroyObject(oBlood);
if (GetIsDead(oHostBody))DestroyObject(oHostBody, 0.2f);
}
void LeaveCorpse()
{
//SET YOUR LOOTABLE CORPSES PREFERENCES HERE ///////////////
//
int nUseLootable = TRUE; // Set this to FALSE if you want disable the lootable corpse functionality //
int nMoveEquipped = FALSE; // Set this to FALSE if you don't want to move Equipped items to the corpse //
int nCopyArmour = FALSE; // This will use the ResRef to create a copy of the armour/helmet //
int nMoveArmour = FALSE; // Setting this TRUE will just move the armour/helmet (Naked NPCs) //
int nDropWeapons = TRUE; // This will use the ResRef for dropping the weapons on the ground //
int nMoveWeapons = FALSE; // Setting this TRUE will just move the weapons to the Lootable Object //
int nUseBlood = FALSE; // Set this to TRUE if you want a Bloodspot to appear under the corpse and have //
// "gibs" when a corpse is destroyed. Undead/constructs/elementals won't leave a //
// Bloodspot or gib. //
int nTinyBlood = FALSE; // Set this to FALSE if you don't want Tiny-sized creatures (rats, bats, etc.) to //
// leave a Bloodspot, scorch mark, or small flame. They will still "gib" //
// normally. Only applies if nUseBlood = TRUE. //
int nUseFlame = FALSE; // Set this to TRUE if you want a scorch mark or a small flame (which burns out //
// after 10-120 seconds, and is replaced by a scorch mark) to appear if 1/3 or //
// more of the damage which killed the creature was fire or electrical. Scorch //
// mark or flame will appear instead of Bloodspot. If the total fire or //
// electrical damage exceeds the creature's max HP, a small flame appears instead //
// of a scorch mark. The corpse will still gib normally. Undead, constructs, //
// and elementals will leave a scorch mark, small flame, or nothing. Only //
// applies if nUseBlood = TRUE. //
int nCorpseFade = 0; // Set this to 0 (ZERO) if you DO NOT want the corpses to fade //
int nUseBonesBash = FALSE; // Set this to TRUE if you want bones to appear when the corpse is bashed. The //
// bones cannot be bashed; they will only disappear if nBonesFade > 0. //
int nUseBonesFade = TRUE; // Set this to TRUE if you want bones to appear when the corpse fades. The bones //
// cannot be bashed; they will only disappear if nBonesFade > 0. //
int nBonesFade = 120; // This is the delay in actual seconds that the bones will remain before they fade. //
// If you set this to 0 (zero) it will turn off the bones fade - allowing all //
// bones (and loot, if the bones contain any) to remain forever. //
int nTinyBones = FALSE; // Set this to FALSE if you don't want Tiny-sized creatures (rats, bats, etc.) to //
// turn into bones when their corpse is bashed or fades. Only applies if //
// nUseBonesBash and/or nUseBonesFade = TRUE. //
int nKeepInventoryBash = FALSE; // Set this to TRUE if you want all items in a creature's inventory to remain when //
// its corpse is bashed. If installed, DOA's "Bashed Loot Breakage" plugin //
// ("doa_bashbreak") takes precedence over nKeepInventoryBash. //
int nKeepInventoryFade = FALSE; // Set this to TRUE if you want all items in a creature's inventory to remain when //
// its corpse fades. //
int nKeepEmpties = TRUE; // Set this to FALSE if you want EMPTY corpses to fade immediately. //
int nKeepWeaponsBonesFade = FALSE; // Set this to FALSE if you want dropped, unclaimed, non-plot weapons to be //
// destroyed when bones fade. Only valid if nBonesFade > 0. //
int nKeepWeaponsCorpseFade = FALSE; // Set this to FALSE if you want dropped, unclaimed, non-plot weapons to be //
// destroyed when corpses fade. Only valid if nCorpseFade > 0. //
int nKeepWeaponsBash = TRUE; // Set this to FALSE if you want dropped, unclaimed, non-plot weapons to be //
// destroyed when corpses are bashed. //
int nKeepWeaponsEmpty = TRUE; // Set this to TRUE if you want empty corpses to be destroyed even if dropped //
// weapons are unclaimed. //
int nOverrideForPlacedCorpses = FALSE;// Set this to TRUE if you want the 'Spawned Corpses' you //
// place to be permament. Setting it to FALSE will cause //
// your Placed Dead creatures to act as the settings above dictate. //
float lsDelay = 240.0; // Corpse & loot fade delay
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ALTER THE FOLLOWING AT YOUR OWN RISK :)
object oHostBody = OBJECT_SELF; //Get the Dead Creature Object
object oBlood;
object oSaveBlood;
string sBaseTag = GetTag(oHostBody); //Get that TAG of the dead creature
string sPrefix = GetStringLeft(sBaseTag, 4); //Look for Dead Prefix
location lLoc = GetLocation(oHostBody);
if ((GetRacialType(oHostBody) != RACIAL_TYPE_UNDEAD) &&
(GetRacialType(oHostBody) != RACIAL_TYPE_CONSTRUCT) &&
(GetRacialType(oHostBody) != RACIAL_TYPE_ELEMENTAL)&&
(GetRacialType(oHostBody) != RACIAL_TYPE_DRAGON))
{
oBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bloodstain", lLoc, FALSE);
}
DelayCommand(lsDelay, BodyFade(oHostBody, oBlood));
if(nUseLootable) //If False, do nothing
{
//Do 'spawned corpse' settings if desired
if (sPrefix == "Dead")
{
if (nOverrideForPlacedCorpses)
{
nKeepEmpties = TRUE; //Set 'Spawned Dead' corpses to Keep Empties
nCorpseFade = 0; //Disable Corpse Fade for 'Spawned Dead' corpses
}
}
SetIsDestroyable(FALSE,TRUE,FALSE); //Protect our corpse from decaying
/*
UNDER CONSTRUCTION :)
// Create lootable corpse object only if oHostBody has something to loot
if (GetIsObjectValid(GetFirstItemInInventory(oHostBody)))
{
}
else
{
// Don't create lootable corpse object(nothing to loot)
if (nKeepEmpties == FALSE)
{
// Get rid of corpse immediately, since it's already empty
nCorpseFade = 1;
}
else
{
// Ensure oHostBody is destroyed/fades properly
// Ensure blood spot is created and destroyed/fades properly
}
}
*/
//Set the spawnpoint for our lootable object and sink it
float fSinkCorpseObj = 0.1f; //set depth to sink lootable object
vector vHostBodyLoc = GetPosition(oHostBody); //get original vector so we can change it
float fCorpseFacing = GetFacing(oHostBody); //get original facing
vector vCorpseLoc = Vector(vHostBodyLoc.x, vHostBodyLoc.y, vHostBodyLoc.z - fSinkCorpseObj); //adjust z-axis to sink lootable object
location lCorpseLoc = Location(GetArea(oHostBody), vCorpseLoc, fCorpseFacing); //create new location
object oLootCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "rr_sack", lCorpseLoc, FALSE); //Spawn our lootable object
SetLocalObject(oLootCorpse, "oHostBody", oHostBody); //Set Local for deletion later if needed
SetLocalObject(oLootCorpse, "oBlood", oBlood);
NameSack(oLootCorpse);
DelayCommand(0.1,sd_droploot(oHostBody, oLootCorpse));
DelayCommand(lsDelay, LootClear(oLootCorpse));
// Ensure oLootCorpse can't be destroyed until oHostBody is emptied (and weapons are dropped)
//SetPlotFlag(oLootCorpse, TRUE);
SetLocalInt(oLootCorpse, "nKeepEmpty", nKeepEmpties); //Set Local for deletion later if needed
SetLocalInt(oLootCorpse, "nUseBonesBash", nUseBonesBash); //Set Local for later use
SetLocalInt(oLootCorpse, "nUseBonesFade", nUseBonesFade); //Set Local for later use
SetLocalInt(oLootCorpse, "nBonesFade", nBonesFade); //Set Local for later use
SetLocalInt(oLootCorpse, "nTinyBones", nTinyBones); //Set Local for later use
SetLocalInt(oLootCorpse, "nKeepInventoryBash", nKeepInventoryBash); //Set Local for later use
SetLocalInt(oLootCorpse, "nKeepInventoryFade", nKeepInventoryFade); //Set Local for later use
// Remember racial type and Blueprint ResRef for use with Scrotok's Raise Dead/Resurrection plugin
SetLocalInt(oLootCorpse, "nRacialType", GetRacialType(oHostBody));
SetLocalString(oLootCorpse, "sHostBodyResRef", GetResRef(oHostBody));
object oCorpseBlood;
// If nUseBlood is TRUE and oHostBody isn't Undead/Construct/Elemental, set Local for later "gibbing" if bashed
if ((nUseBlood) && (GetRacialType(oHostBody) != RACIAL_TYPE_UNDEAD) && (GetRacialType(oHostBody) != RACIAL_TYPE_CONSTRUCT) && (GetRacialType(oHostBody) != RACIAL_TYPE_ELEMENTAL))
{
SetLocalInt(oLootCorpse, "nUseBlood", TRUE);
}
// If nUseBlood = TRUE, continue Bloodspot routine
if (nUseBlood)
{
location lBloodLoc = GetLocation(oHostBody); //get original location for placing blood spot
if ((nTinyBlood == FALSE) && (GetCreatureSize(oHostBody) == CREATURE_SIZE_TINY))
{
// Do nothing -- no bloodspot for tiny creatures if nTinyBlood is FALSE
}
else
{
if (nUseFlame)
{
// If nUseFlame = TRUE, determine if scorch, flame, or bloodspot should appear
int nFireDam = GetDamageDealtByType(DAMAGE_TYPE_FIRE);
int nElecDam = GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL);
int nTotDam = GetTotalDamageDealt();
int nMaxHP = GetMaxHitPoints();
int nFlameout;
/*
// Used for debugging
SendMessageToPC(GetFirstPC(), "nFireDam: "+IntToString(nFireDam)+" nElecDam: "+IntToString(nElecDam)+" nTotDam: "+IntToString(nTotDam)+" nMaxHP: "+IntToString(nMaxHP)+" nTotDam/3: "+IntToString(nTotDam/3));
*/
// If 1/3 or more of the damage is due to fire or electricity...
// (only the final damage that actually killed the creature is
// considered; tracking the cumulative damage taken would require
// altering the default OnDamaged script for every creature,
// which is not desirable)
if ((nFireDam >= (nTotDam/3)) || (nElecDam >= (nTotDam/3)))
{
// If massive fire or electricity damage, spawn a small flame
// which turns into a scorch mark after 10-120 seconds
// ("massive" means >= max HP)
if ((nFireDam >= nMaxHP) || (nElecDam >= nMaxHP))
{
oCorpseBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_flamesmall", lBloodLoc, FALSE);
ExecuteScript("sl_destroyself", oCorpseBlood);
/*
// Used for debugging
nFlameout = 30;
*/
nFlameout = d12(10);
DelayCommand(IntToFloat(nFlameout), Flameout(oCorpseBlood, oLootCorpse));
}
else
{
// Otherwise, spawn a scorch mark
oCorpseBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_weathmark", lBloodLoc, FALSE);
ExecuteScript("sl_destroyself", oCorpseBlood);
}
}
else
{
// Not enough (or zero) fire/electrical damage, so just spawn bloodspot (or do nothing for Undead/Constructs/Elementals)
if ((GetRacialType(oHostBody) != RACIAL_TYPE_UNDEAD) && (GetRacialType(oHostBody) != RACIAL_TYPE_CONSTRUCT) && (GetRacialType(oHostBody) != RACIAL_TYPE_ELEMENTAL))
{
oCorpseBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bloodstain", lBloodLoc, FALSE);
ExecuteScript("sl_destroyself", oCorpseBlood);
}
}
}
else
{
// If nUseFlame = FALSE, just spawn the bloodspot (or do nothing for Undead/Constructs/Elementals)
if ((GetRacialType(oHostBody) != RACIAL_TYPE_UNDEAD) && (GetRacialType(oHostBody) != RACIAL_TYPE_CONSTRUCT) && (GetRacialType(oHostBody) != RACIAL_TYPE_ELEMENTAL))
{
oCorpseBlood = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bloodstain", lBloodLoc, FALSE);
ExecuteScript("sl_destroyself", oCorpseBlood);
}
}
// oBloodSpot will either be a bloodstain, scorch mark, small flame, or OBJECT_INVALID (for Undead/Constructs/Elementals)
SetLocalObject(oLootCorpse, "oBloodSpot", oCorpseBlood); //Set Local for deletion later if needed
}
}
// Get DEAD CREATURE'S INVENTORY - Move to oLootCorpse
int nAmtGold = GetGold(oHostBody); //Get any gold from the dead creature
if(nAmtGold)
{
AssignCommand(oLootCorpse, TakeGoldFromCreature(nAmtGold, oHostBody, FALSE));
}
if (nMoveEquipped)
{
//Get any DROPPABLE loot the dead creature has equipped
object oEquip1 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_ARMS, oHostBody));
object oEquip2 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_ARROWS, oHostBody));
object oEquip3 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_BELT, oHostBody));
object oEquip4 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_BOLTS, oHostBody));
object oEquip5 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_BOOTS, oHostBody));
object oEquip6 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_BULLETS, oHostBody));
object oEquip7 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_CLOAK, oHostBody));
// Version 3.2: Moved oEquip8 (helmets) to the armour section (see below)
object oEquip9 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_LEFTRING, oHostBody));
object oEquip10 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_NECK, oHostBody));
object oEquip11 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oHostBody));
SetLocalObject(oLootCorpse, "oEquip1", oEquip1);
SetLocalObject(oLootCorpse, "oEquip2", oEquip2);
SetLocalObject(oLootCorpse, "oEquip3", oEquip3);
SetLocalObject(oLootCorpse, "oEquip4", oEquip4);
SetLocalObject(oLootCorpse, "oEquip5", oEquip5);
SetLocalObject(oLootCorpse, "oEquip6", oEquip6);
SetLocalObject(oLootCorpse, "oEquip7", oEquip7);
// Version 3.2: Moved oEquip8 (helmets) to the armour section (see below)
SetLocalObject(oLootCorpse, "oEquip9", oEquip9);
SetLocalObject(oLootCorpse, "oEquip10", oEquip10);
SetLocalObject(oLootCorpse, "oEquip11", oEquip11);
}
// Handle Weapons/Shields/Torches equipped (held) in left/right hands
// NOTE: nDropWeapons takes precedence over nMoveWeapons if both are TRUE
/*
If oHostBody has nothing in left/right hand, and has oLeftWpn/
oRightWpn set (due to Scrotok's Raise Dead/Resurrection plugin),
set oLeftWpn/oRightWpn (dropped weapon info) on oLootCorpse for
later use
*/
if (nDropWeapons)
{
if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oHostBody) == OBJECT_INVALID)
{
if (GetIsObjectValid(GetLocalObject(oHostBody, "oRightWpn")))
{
SetLocalObject(oLootCorpse, "oRightWpn", GetLocalObject(oHostBody, "oRightWpn"));
}
}
if (GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oHostBody) == OBJECT_INVALID)
{
if (GetIsObjectValid(GetLocalObject(oHostBody, "oLeftWpn")))
{
SetLocalObject(oLootCorpse, "oLeftWpn", GetLocalObject(oHostBody, "oLeftWpn"));
}
}
}
if (nMoveWeapons || nDropWeapons)
{
//Move equipped Weapons/Shields/Torches from oHostBody to oLootCorpse
object oEquip12 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oHostBody));
object oEquip13 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oHostBody));
// oEquip12/13 == OBJECT_INVALID if oHostBody has nothing in right/left hand slots
SetLocalObject(oLootCorpse, "oEquip12", oEquip12);
SetLocalObject(oLootCorpse, "oEquip13", oEquip13);
}
if (nDropWeapons)
{
// oEquip12/13 == OBJECT_INVALID if oHostBody has nothing in right/left hand slots
object oEquip12 = GetLocalObject(oLootCorpse, "oEquip12");
object oEquip13 = GetLocalObject(oLootCorpse, "oEquip13");
// Drop the weapons/shields/torches
/*
The following commands destroy oEquip12 and oEquip13, and store
the dropped weapons on oLootCorpse as "oLeftWpn" and "oRightWpn".
Nothing gets stored in oLeftWpn/oRightWpn if oEquip12/13 ==
OBJECT_INVALID.
*/
// Make sure DropLeftWeapon comes after DropRightWeapon in the lines
// below, in order for the SetPlotFlag fix (version 3.3) to work
AssignCommand(oLootCorpse, ActionDoCommand(DropRightWeapon(oEquip12, oLootCorpse)));
AssignCommand(oLootCorpse, ActionDoCommand(DropLeftWeapon(oEquip13, oLootCorpse)));
SetLocalInt(oLootCorpse, "nKeepWeaponsBonesFade", nKeepWeaponsBonesFade); //Set Local to prevent deletion later if needed
SetLocalInt(oLootCorpse, "nKeepWeaponsCorpseFade", nKeepWeaponsCorpseFade); //Set Local to prevent deletion later if needed
SetLocalInt(oLootCorpse, "nKeepWeaponsBash", nKeepWeaponsBash); //Set Local to prevent deletion later if needed
SetLocalInt(oLootCorpse, "nKeepWeaponsEmpty", nKeepWeaponsEmpty); //Set Local for later use
}
// Handle Armour/Helmets
// NOTE: nCopyArmour takes precedence over nMoveArmour if both are TRUE
if(nCopyArmour)
{
nMoveArmour = FALSE;
// Handle armour
object oArmour = GetItemInSlot(INVENTORY_SLOT_CHEST, oHostBody);
SetLocalObject(oLootCorpse, "oOrigArmour", oArmour);
if (GetDroppableFlag(oArmour))
{
string sArmourRef = GetResRef(oArmour);
object oLootArmour = CreateItemOnObject(sArmourRef, oLootCorpse);
SetPlotFlag(oLootArmour, GetPlotFlag(oArmour));
SetIdentified(oLootArmour, GetIdentified(oArmour));
// Set Plot flag to FALSE for original armor so it can be
// destroyed later if corpse is bashed
SetPlotFlag(oArmour, FALSE);
SetLocalObject(oLootCorpse, "oLootArmour", oLootArmour);
SetLocalObject(oLootCorpse, "oEquip14", oLootArmour);
}
// Handle helmet
object oHelmet = GetItemInSlot(INVENTORY_SLOT_HEAD, oHostBody);
SetLocalObject(oLootCorpse, "oOrigHelmet", oHelmet);
if (GetDroppableFlag(oHelmet))
{
string sHelmetRef = GetResRef(oHelmet);
object oLootHelmet = CreateItemOnObject(sHelmetRef, oLootCorpse);
SetPlotFlag(oLootHelmet, GetPlotFlag(oHelmet));
SetIdentified(oLootHelmet, GetIdentified(oHelmet));
// Set Plot flag to FALSE for original helmet so it can be
// destroyed later if corpse is bashed
SetPlotFlag(oHelmet, FALSE);
SetLocalObject(oLootCorpse, "oLootHelmet", oLootHelmet);
SetLocalObject(oLootCorpse, "oEquip8", oLootHelmet);
}
}
if(nMoveArmour)
{
nCopyArmour = FALSE;
// Handle armour
object oEquip14 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_CHEST, oHostBody));
SetLocalObject(oLootCorpse, "oEquip14", oEquip14);
// Handle helmet
object oEquip8 = strip_equipped(oHostBody, oLootCorpse, GetItemInSlot(INVENTORY_SLOT_HEAD, oHostBody));
SetLocalObject(oLootCorpse, "oEquip8", oEquip8);
}
//Get the remaining loot from the dead creature and move it to oLootCorpse
int nEquipCount = 14;
object oLootEQ = GetFirstItemInInventory(oHostBody);
while(GetIsObjectValid(oLootEQ))
{
nEquipCount++;
// AssignCommand(oLootCorpse, ActionDoCommand(SendMessageToPC(GetFirstPC(), "oEquip"+IntToString(nEquipCount)+": "+GetTag(oLootEQ))));
object oEquipTemp = strip_equipped(oHostBody, oLootCorpse, oLootEQ);
string sEquipCount = "oEquip" + IntToString(nEquipCount);
SetLocalObject(oLootCorpse, sEquipCount, oEquipTemp);
oLootEQ = GetNextItemInInventory(oHostBody);
}
// We're done with oHostBody, so allow oLootCorpse to be destroyable
if (!nDropWeapons)
{
AssignCommand(oLootCorpse, ActionDoCommand(SetPlotFlag(oLootCorpse, FALSE)));
}
// Fade corpse out of existence after specified delay (unless set to 0)
if (nCorpseFade > 0)
{
float fCorpseFade = IntToFloat(nCorpseFade);
// ActionWait(fCorpseFade); // Removed for version 3.2
DelayCommand(fCorpseFade, FadeCorpse(oCorpseBlood, oLootCorpse, oHostBody));
}
}
}
//void main(){}

View File

@@ -37,6 +37,9 @@ void main()
{
SignalEvent(GetAreaFromLocation(GetLocation(OBJECT_SELF)), EventUserDefined(1007));
}
ExecuteScript("prc_npc_death", OBJECT_SELF);
ExecuteScript("prc_pwondeath", OBJECT_SELF);
}
object CreatePlaceable(string sObject, location lPlace, float fDuration)

View File

@@ -1,7 +1,7 @@
// Name : Avlis Persistence System include
// Purpose : Various APS/NWNX2 related functions
// Authors : Ingmar Stieger, Adam Colon, Josh Simon
// Modified : January 1st, 2005
// Modified : December 21, 2003
// This file is licensed under the terms of the
// GNU GENERAL PUBLIC LICENSE (GPL) Version 2
@@ -10,12 +10,13 @@
/* Return codes */
/************************************/
const int SQL_ERROR = 0;
const int SQL_SUCCESS = 1;
int SQL_ERROR = 0;
int SQL_SUCCESS = 1;
/************************************/
/* Function prototypes */
/************************************/
sqlquery last_sql_query;
// Setup placeholders for ODBC requests and responses
void SQLInit();
@@ -61,45 +62,33 @@ vector APSStringToVector(string sVector);
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration =
0, string sTable = "pwdata");
void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration = 0, string sTable = "pwdata");
// Set oObject's persistent integer variable sVarName to iValue
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
void SetPersistentInt(object oObject, string sVarName, int iValue, int iExpiration =
0, string sTable = "pwdata");
void SetPersistentInt(object oObject, string sVarName, int iValue, int iExpiration = 0, string sTable = "pwdata");
// Set oObject's persistent float variable sVarName to fValue
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration =
0, string sTable = "pwdata");
void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration = 0, string sTable = "pwdata");
// Set oObject's persistent location variable sVarName to lLocation
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
// This function converts location to a string for storage in the database.
void SetPersistentLocation(object oObject, string sVarName, location lLocation, int iExpiration =
0, string sTable = "pwdata");
void SetPersistentLocation(object oObject, string sVarName, location lLocation, int iExpiration = 0, string sTable = "pwdata");
// Set oObject's persistent vector variable sVarName to vVector
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
// This function converts vector to a string for storage in the database.
void SetPersistentVector(object oObject, string sVarName, vector vVector, int iExpiration =
0, string sTable = "pwdata");
// Set oObject's persistent object with sVarName to sValue
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwobjdata)
void SetPersistentObject(object oObject, string sVarName, object oObject2, int iExpiration =
0, string sTable = "pwobjdata");
void SetPersistentVector(object oObject, string sVarName, vector vVector, int iExpiration = 0, string sTable = "pwdata");
// Get oObject's persistent string variable sVarName
// Optional parameters:
@@ -131,12 +120,6 @@ location GetPersistentLocation(object oObject, string sVarname, string sTable =
// * Return value on error: 0
vector GetPersistentVector(object oObject, string sVarName, string sTable = "pwdata");
// Get oObject's persistent object sVarName
// Optional parameters:
// sTable: Name of the table where object is stored (default: pwobjdata)
// * Return value on error: 0
object GetPersistentObject(object oObject, string sVarName, object oOwner = OBJECT_INVALID, string sTable = "pwobjdata");
// Delete persistent variable sVarName stored on oObject
// Optional parameters:
// sTable: Name of the table where variable is stored (default: pwdata)
@@ -156,40 +139,22 @@ string SQLDecodeSpecialChars(string sString);
void SQLInit()
{
int i;
// Placeholder for ODBC persistence
string sMemory;
for (i = 0; i < 8; i++) // reserve 8*128 bytes
sMemory +=
"................................................................................................................................";
SetLocalString(GetModule(), "NWNX!ODBC!SPACER", sMemory);
SQLExecDirect("CREATE TABLE IF NOT EXISTS pwdata(player varchar(64), tag varchar(64), name varchar(64), val text, expire int(11), last timestamp NOT NULL DEFAULT DEFAULT_TIMESTAMP, PRIMARY KEY (player,tag,name))");
}
void SQLExecDirect(string sSQL)
{
SetLocalString(GetModule(), "NWNX!ODBC!EXEC", sSQL);
sqlquery sql = SqlPrepareQueryCampaign("db",sSQL);
last_sql_query = sql;
if(GetStringLowerCase(GetStringLeft(sSQL,6)) != "select")
{
SqlStep(sql);
}
}
int SQLFetch()
{
string sRow;
object oModule = GetModule();
SetLocalString(oModule, "NWNX!ODBC!FETCH", GetLocalString(oModule, "NWNX!ODBC!SPACER"));
sRow = GetLocalString(oModule, "NWNX!ODBC!FETCH");
if (GetStringLength(sRow) > 0)
{
SetLocalString(oModule, "NWNX_ODBC_CurrentRow", sRow);
return SQL_SUCCESS;
}
else
{
SetLocalString(oModule, "NWNX_ODBC_CurrentRow", "");
return SQL_ERROR;
}
return SqlStep(last_sql_query);
}
// deprecated. use SQLFetch().
@@ -206,45 +171,7 @@ int SQLNextRow()
string SQLGetData(int iCol)
{
int iPos;
string sResultSet = GetLocalString(GetModule(), "NWNX_ODBC_CurrentRow");
// find column in current row
int iCount = 0;
string sColValue = "";
iPos = FindSubString(sResultSet, "<22>");
if ((iPos == -1) && (iCol == 1))
{
// only one column, return value immediately
sColValue = sResultSet;
}
else if (iPos == -1)
{
// only one column but requested column > 1
sColValue = "";
}
else
{
// loop through columns until found
while (iCount != iCol)
{
iCount++;
if (iCount == iCol)
sColValue = GetStringLeft(sResultSet, iPos);
else
{
sResultSet = GetStringRight(sResultSet, GetStringLength(sResultSet) - iPos - 1);
iPos = FindSubString(sResultSet, "<22>");
}
// special case: last column in row
if (iPos == -1)
iPos = GetStringLength(sResultSet);
}
}
return sColValue;
return SqlGetString(last_sql_query,iCol-1);
}
// These functions deal with various data types. Ultimately, all information
@@ -364,7 +291,7 @@ void SetPersistentString(object oObject, string sVarName, string sValue, int iEx
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
if (SQLFirstRow() == SQL_SUCCESS)
{
// row exists
sSQL = "UPDATE " + sTable + " SET val='" + sValue +
@@ -404,7 +331,7 @@ string GetPersistentString(object oObject, string sVarName, string sTable = "pwd
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
if (SQLFirstRow() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
@@ -426,30 +353,7 @@ void SetPersistentInt(object oObject, string sVarName, int iValue, int iExpirati
int GetPersistentInt(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
string sTag;
object oModule;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
oModule = GetModule();
SetLocalString(oModule, "NWNX!ODBC!FETCH", "-2147483647");
return StringToInt(GetLocalString(oModule, "NWNX!ODBC!FETCH"));
return StringToInt(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration =
@@ -460,30 +364,7 @@ void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpi
float GetPersistentFloat(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
string sTag;
object oModule;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
oModule = GetModule();
SetLocalString(oModule, "NWNX!ODBC!FETCH", "-340282306073709650000000000000000000000.000000000");
return StringToFloat(GetLocalString(oModule, "NWNX!ODBC!FETCH"));
return StringToFloat(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentLocation(object oObject, string sVarName, location lLocation, int iExpiration =
@@ -508,73 +389,6 @@ vector GetPersistentVector(object oObject, string sVarName, string sTable = "pwd
return APSStringToVector(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentObject(object oOwner, string sVarName, object oObject, int iExpiration =
0, string sTable = "pwobjdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oOwner))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oOwner));
sTag = SQLEncodeSpecialChars(GetName(oOwner));
}
else
{
sPlayer = "~";
sTag = GetTag(oOwner);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT player FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
// row exists
sSQL = "UPDATE " + sTable + " SET val=%s,expire=" + IntToString(iExpiration) +
" WHERE player='" + sPlayer + "' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
StoreCampaignObject ("NWNX", "-", oObject);
}
else
{
// row doesn't exist
sSQL = "INSERT INTO " + sTable + " (player,tag,name,val,expire) VALUES" +
"('" + sPlayer + "','" + sTag + "','" + sVarName + "',%s," + IntToString(iExpiration) + ")";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
StoreCampaignObject ("NWNX", "-", oObject);
}
}
object GetPersistentObject(object oObject, string sVarName, object oOwner = OBJECT_INVALID, string sTable = "pwobjdata")
{
string sPlayer;
string sTag;
object oModule;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
if (!GetIsObjectValid(oOwner))
oOwner = oObject;
return RetrieveCampaignObject ("NWNX", "-", GetLocation(oOwner), oOwner);
}
void DeletePersistentVariable(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
@@ -642,52 +456,3 @@ string SQLDecodeSpecialChars(string sString)
return sReturn;
}
// Gets the current REAL WORLD time, uses NWNX2
// Year-Month-Day Time
// 1997-12-15 23:50:26
string GetSQLTime();
string GetSQLTime()
{
string sSQL = "SELECT CURRENT_TIME";
SQLExecDirect(sSQL);
if(SQLFetch() == SQL_SUCCESS)
{
return SQLGetData(1);
}
else
{
return "Database error";
}
}
// Gets the current REAL WORLD date, uses NWNX2
string GetSQLDate();
string GetSQLDate()
{
string sSQL = "SELECT CURRENT_DATE";
SQLExecDirect(sSQL);
if(SQLFetch() == SQL_SUCCESS)
{
return SQLGetData(1);
}
else
{
return "Database error";
}
}
// Gets the current REAL WORLD time stamp, uses NWNX2
string GetSQLTimeStamp();
string GetSQLTimeStamp()
{
string sSQL = "SELECT CURRENT_TIMESTAMP";
SQLExecDirect(sSQL);
if(SQLFetch() == SQL_SUCCESS)
{
return SQLGetData(1);
}
else
{
return "Database error";
}
}

View File

@@ -0,0 +1,19 @@
#include "nw_i0_tool"
/* Script generated by
Lilac Soul's NWN Script Generator, v. 1.6
For download info, please visit:
http://www.lilacsoul.revility.com */
//Put this on action taken in the conversation editor
void main()
{
object oPC = GetPCSpeaker();
if (GetHitDice(oPC) <= 2)
{
RewardPartyXP(3000, oPC, FALSE);
}
}

View File

@@ -2,8 +2,10 @@
void main()
{
ExecuteScript("prc_npc_death", OBJECT_SELF);
object oKiller = GetLastKiller();
object oVictim = OBJECT_SELF;
int noleech = 0;
int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
@@ -18,9 +20,9 @@ void main()
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
float BaseEXP = ((GetChallengeRating(OBJECT_SELF)*3.0)+5);
float BonusEXP = GetChallengeRating(OBJECT_SELF)+5;
float BaseMonEXP = BaseEXP;
float BaseEXP = ((GetChallengeRating(oVictim)*5.0)+2);
float BonusEXP = ((GetChallengeRating(oVictim)*2.0)+5);
float BaseMonEXP = BaseEXP;
int NumOfParty = 0;
float PartyLevelSum = 0.0;
object oPartyMember = GetFirstFactionMember(oKiller, TRUE);

View File

@@ -0,0 +1,20 @@
#include "nwnx_admin"
void main()
{
object oPlayer = GetPCSpeaker();
string sName = GetName(oPlayer);
string sPlayer = GetPCPlayerName(oPlayer);
SendMessageToPC(oPlayer,"sPlayer = "+sPlayer);
SendMessageToPC(oPlayer,"sName = "+sName);
NWNX_Administration_DeletePlayerCharacter(oPlayer, 1, "Character Deleted");
SendMessageToPC(oPlayer,sPlayer+" has deleted "+sName);
SendMessageToAllDMs(sPlayer+" has deleted "+sName);
}

2470
_module/nss/ms_name_inc.nss Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
//:://////////////////////////////////////////////////////
//:: NW_C2_DEFAULT7
/*
Default OnDeath event handler for NPCs.
Adjusts killer's alignment if appropriate and
alerts allies to our death.
*/
//::///////////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//::///////////////////////////////////////////////////////
//::///////////////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: April 1st, 2008
//:: Added Support for Dying Wile Mounted
//:: Modified By: Sir Elric
//:: Modified On: July 20th, 2008
//:: Added Support for Sir Elric's Simple Creature Respawns
//::///////////////////////////////////////////////////////
#include "x2_inc_compon"
#include "x0_i0_spawncond"
#include "x3_inc_horse"
#include "se_respawn_inc"
#include "_kb_loot_corpse"
void main()
{
ExecuteScript("sf_xp", OBJECT_SELF);
int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
object oKiller = GetLastKiller();
if (GetLocalInt(GetModule(),"X3_ENABLE_MOUNT_DB")&&GetIsObjectValid(GetMaster(OBJECT_SELF))) SetLocalInt(GetMaster(OBJECT_SELF),"bX3_STORE_MOUNT_INFO",TRUE);
// If we're a good/neutral commoner,
// adjust the killer's alignment evil
if(nClass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
{
AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
}
// Call to allies to let them know we're dead
SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
// NOTE: the OnDeath user-defined event does not
// trigger reliably and should probably be removed
if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
craft_drop_items(oKiller);
LeaveCorpse();
// -----------------------------------------------------------------------------
// Sir Elric's Simple Creature Respawns additions - SE v2.0
// -----------------------------------------------------------------------------
// Do not respawn creature if tagged with _NSP eg. NW_GOBLINA_NSP
if (FindSubString(GetTag(OBJECT_SELF), "NSP") > -1)
return;
if(GetLocalInt(OBJECT_SELF, "PLACED"))// Only respawn original placed mobs
SE_DoCreatureRespawn(5, 10);
}

View File

@@ -1,337 +0,0 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT9
/*
* Default OnSpawn handler with XP1 revisions.
* This corresponds to and produces the same results
* as the default OnSpawn handler in the OC.
*
* This can be used to customize creature behavior in three main ways:
*
* - Uncomment the existing lines of code to activate certain
* common desired behaviors from the moment when the creature
* spawns in.
*
* - Uncomment the user-defined event signals to cause the
* creature to fire events that you can then handle with
* a custom OnUserDefined event handler script.
*
* - Add new code _at the end_ to alter the initial
* behavior in a more customized way.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/11/2002
//:: Modified By: Sir Elric
//:: Modified On: July 20th, 2008
//:: Added Support for Sir Elric's Simple Creature Respawns
//:://////////////////////////////////////////////////
//:: Updated 2003-08-20 Georg Zoeller: Added check for variables to active spawn in conditions without changing the spawnscript
#include "x0_i0_anims"
// #include "x0_i0_walkway" - in x0_i0_anims
#include "x0_i0_treasure"
#include "x2_inc_switches"
void main()
{
// ***** Spawn-In Conditions ***** //
ExecuteScript("spawn_rand_stats", OBJECT_SELF);
//ExecuteScript("wotr_npc_onspawn", OBJECT_SELF);
// * REMOVE COMMENTS (// ) before the "Set..." functions to activate
// * them. Do NOT touch lines commented out with // *, those are
// * real comments for information.
// * This causes the creature to say a one-line greeting in their
// * conversation file upon perceiving the player. Put [NW_D2_GenCheck]
// * in the "Text Seen When" field of the greeting in the conversation
// * file. Don't attach any player responses.
// *
// SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION);
// * Same as above, but for hostile creatures to make them say
// * a line before attacking.
// *
// SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION);
// * This NPC will attack when its allies call for help
// *
// SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
// * If the NPC has the Hide skill they will go into stealth mode
// * while doing WalkWayPoints().
// *
// SetSpawnInCondition(NW_FLAG_STEALTH);
//--------------------------------------------------------------------------
// Enable stealth mode by setting a variable on the creature
// Great for ambushes
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_STEALTH) == TRUE)
{
SetSpawnInCondition(NW_FLAG_STEALTH);
}
// * Same, but for Search mode
// *
// SetSpawnInCondition(NW_FLAG_SEARCH);
//--------------------------------------------------------------------------
// Make creature enter search mode after spawning by setting a variable
// Great for guards, etc
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_SEARCH) == TRUE)
{
SetSpawnInCondition(NW_FLAG_SEARCH);
}
// * This will set the NPC to give a warning to non-enemies
// * before attacking.
// * NN -- no clue what this really does yet
// *
// SetSpawnInCondition(NW_FLAG_SET_WARNINGS);
// * Separate the NPC's waypoints into day & night.
// * See comment on WalkWayPoints() for use.
// *
// SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING);
// * If this is set, the NPC will appear using the "EffectAppear"
// * animation instead of fading in, *IF* SetListeningPatterns()
// * is called below.
// *
//SetSpawnInCondition(NW_FLAG_APPEAR_SPAWN_IN_ANIMATION);
// * This will cause an NPC to use common animations it possesses,
// * and use social ones to any other nearby friendly NPCs.
// *
// SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
//--------------------------------------------------------------------------
// Enable immobile ambient animations by setting a variable
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_AMBIENT_IMMOBILE) == TRUE)
{
SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
}
// * Same as above, except NPC will wander randomly around the
// * area.
// *
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
//--------------------------------------------------------------------------
// Enable mobile ambient animations by setting a variable
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_AMBIENT) == TRUE)
{
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
}
// **** Animation Conditions **** //
// * These are extra conditions you can put on creatures with ambient
// * animations.
// * Civilized creatures interact with placeables in
// * their area that have the tag "NW_INTERACTIVE"
// * and "talk" to each other.
// *
// * Humanoid races are civilized by default, so only
// * set this flag for monster races that you want to
// * behave the same way.
// SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);
// * If this flag is set, this creature will constantly
// * be acting. Otherwise, creatures will only start
// * performing their ambient animations when they
// * first perceive a player, and they will stop when
// * the player moves away.
SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);
// * Civilized creatures with this flag set will
// * randomly use a few voicechats. It's a good
// * idea to avoid putting this on multiple
// * creatures using the same voiceset.
// SetAnimationCondition(NW_ANIM_FLAG_CHATTER);
// * Creatures with _immobile_ ambient animations
// * can have this flag set to make them mobile in a
// * close range. They will never leave their immediate
// * area, but will move around in it, frequently
// * returning to their starting point.
// *
// * Note that creatures spawned inside interior areas
// * that contain a waypoint with one of the tags
// * "NW_HOME", "NW_TAVERN", "NW_SHOP" will automatically
// * have this condition set.
// SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE);
// **** Special Combat Tactics *****//
// * These are special flags that can be set on creatures to
// * make them follow certain specialized combat tactics.
// * NOTE: ONLY ONE OF THESE SHOULD BE SET ON A SINGLE CREATURE.
// * Ranged attacker
// * Will attempt to stay at ranged distance from their
// * target.
// SetCombatCondition(X0_COMBAT_FLAG_RANGED);
// * Defensive attacker
// * Will use defensive combat feats and parry
// SetCombatCondition(X0_COMBAT_FLAG_DEFENSIVE);
// * Ambusher
// * Will go stealthy/invisible and attack, then
// * run away and try to go stealthy again before
// * attacking anew.
// SetCombatCondition(X0_COMBAT_FLAG_AMBUSHER);
// * Cowardly
// * Cowardly creatures will attempt to flee
// * attackers.
// SetCombatCondition(X0_COMBAT_FLAG_COWARDLY);
// **** Escape Commands ***** //
// * NOTE: ONLY ONE OF THE FOLLOWING SHOULD EVER BE SET AT ONE TIME.
// * NOTE2: Not clear that these actually work. -- NN
// * Flee to a way point and return a short time later.
// *
// SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN);
// * Flee to a way point and do not return.
// *
// SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE);
// * Teleport to safety and do not return.
// *
// SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE);
// * Teleport to safety and return a short time later.
// *
// SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN);
// ***** CUSTOM USER DEFINED EVENTS ***** /
/*
If you uncomment any of these conditions, the creature will fire
a specific user-defined event number on each event. That will then
allow you to write custom code in the "OnUserDefinedEvent" handler
script to go on top of the default NPC behaviors for that event.
Example: I want to add some custom behavior to my NPC when they
are damaged. I uncomment the "NW_FLAG_DAMAGED_EVENT", then create
a new user-defined script that has something like this in it:
if (GetUserDefinedEventNumber() == 1006) {
// Custom code for my NPC to execute when it's damaged
}
These user-defined events are in the range 1001-1007.
*/
// * Fire User Defined Event 1001 in the OnHeartbeat
// *
// SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);
// * Fire User Defined Event 1002
// *
// SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);
// * Fire User Defined Event 1005
// *
// SetSpawnInCondition(NW_FLAG_ATTACK_EVENT);
// * Fire User Defined Event 1006
// *
// SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);
// * Fire User Defined Event 1008
// *
// SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT);
// * Fire User Defined Event 1003
// *
// SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);
// * Fire User Defined Event 1004
// *
// SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);
// ***** DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ***** //
// * Goes through and sets up which shouts the NPC will listen to.
// *
SetListeningPatterns();
// * Walk among a set of waypoints.
// * 1. Find waypoints with the tag "WP_" + NPC TAG + "_##" and walk
// * among them in order.
// * 2. If the tag of the Way Point is "POST_" + NPC TAG, stay there
// * and return to it after combat.
//
// * Optional Parameters:
// * void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)
//
// * If "NW_FLAG_DAY_NIGHT_POSTING" is set above, you can also
// * create waypoints with the tags "WN_" + NPC Tag + "_##"
// * and those will be walked at night. (The standard waypoints
// * will be walked during the day.)
// * The night "posting" waypoint tag is simply "NIGHT_" + NPC tag.
WalkWayPoints();
//* Create a small amount of treasure on the creature
//if ((GetLocalInt(GetModule(), "X2_L_NOTREASURE") == FALSE) &&
// (GetLocalInt(OBJECT_SELF, "X2_L_NOTREASURE") == FALSE) )
//{
// CTG_GenerateNPCTreasure(TREASURE_TYPE_MONSTER, OBJECT_SELF);
//}
// ***** ADD ANY SPECIAL ON-SPAWN CODE HERE ***** //
// -----------------------------------------------------------------------------
// Sir Elric's Simple Creature Respawns additions - SE v1.9
// -----------------------------------------------------------------------------
SetLocalLocation(OBJECT_SELF, "spawn", GetLocation(OBJECT_SELF));
// Set as original placed mobs...
if(!GetLocalInt(GetModule(), "ORIGINAL_PLACED_MOBS"))
{
SetLocalInt(OBJECT_SELF, "PLACED", 1);
}
// * If Incorporeal, apply changes
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_IS_INCORPOREAL) == TRUE)
{
effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
eConceal = ExtraordinaryEffect(eConceal);
effect eGhost = EffectCutsceneGhost();
eGhost = ExtraordinaryEffect(eGhost);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, OBJECT_SELF);
}
// * Give the create a random name.
// * If you create a script named x3_name_gen in your module, you can
// * set the value of the variable X3_S_RANDOM_NAME on OBJECT_SELF inside
// * the script to override the creature's default name.
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_RANDOMIZE_NAME) == TRUE)
{
ExecuteScript("x3_name_gen",OBJECT_SELF);
string sName = GetLocalString(OBJECT_SELF,"X3_S_RANDOM_NAME");
if ( sName == "" )
{
sName = RandomName();
}
SetName(OBJECT_SELF,sName);
}
}

137
_module/nss/nwnx.nss Normal file
View File

@@ -0,0 +1,137 @@
/// @addtogroup nwnx NWNX
/// @brief Functions for plugin developers.
/// @{
/// @file nwnx.nss
const string NWNX_Core = "NWNX_Core"; ///< @private
/// @brief Scripting interface to NWNX.
/// @param pluginName The plugin name.
/// @param functionName The function name (do not include NWNX_Plugin_).
void NWNX_CallFunction(string pluginName, string functionName);
/// @brief Pushes the specified type to the c++ side
/// @param value The value of specified type to push.
void NWNX_PushArgumentInt(int value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentFloat(float value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentObject(object value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentString(string value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentEffect(effect value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentItemProperty(itemproperty value);
/// @copydoc NWNX_PushArgumentInt()
void NWNX_PushArgumentJson(json value);
/// @brief Returns the specified type from the c++ side
/// @return The value of specified type.
int NWNX_GetReturnValueInt();
/// @copydoc NWNX_GetReturnValueInt()
float NWNX_GetReturnValueFloat();
/// @copydoc NWNX_GetReturnValueInt()
object NWNX_GetReturnValueObject();
/// @copydoc NWNX_GetReturnValueInt()
string NWNX_GetReturnValueString();
/// @copydoc NWNX_GetReturnValueInt()
effect NWNX_GetReturnValueEffect();
/// @copydoc NWNX_GetReturnValueInt()
itemproperty NWNX_GetReturnValueItemProperty();
/// @copydoc NWNX_GetReturnValueInt()
json NWNX_GetReturnValueJson();
/// @brief Determines if the given plugin exists and is enabled.
/// @param sPlugin The name of the plugin to check. This is the case sensitive plugin name as used by NWNX_CallFunction, NWNX_PushArgumentX
/// @note Example usage: NWNX_PluginExists("NWNX_Creature");
/// @return TRUE if the plugin exists and is enabled, otherwise FALSE.
int NWNX_PluginExists(string sPlugin);
/// @private
const string NWNX_PUSH = "NWNXEE!ABIv2!X!Y!PUSH";
const string NWNX_POP = "NWNXEE!ABIv2!X!Y!POP";
/// @}
void NWNX_CallFunction(string pluginName, string functionName)
{
PlaySound("NWNXEE!ABIv2!" + pluginName + "!" + functionName + "!CALL");
}
void NWNX_PushArgumentInt(int value)
{
SetLocalInt(OBJECT_INVALID, NWNX_PUSH, value);
}
void NWNX_PushArgumentFloat(float value)
{
SetLocalFloat(OBJECT_INVALID, NWNX_PUSH, value);
}
void NWNX_PushArgumentObject(object value)
{
SetLocalObject(OBJECT_INVALID, NWNX_PUSH, value);
}
void NWNX_PushArgumentString(string value)
{
SetLocalString(OBJECT_INVALID, NWNX_PUSH, value);
}
void NWNX_PushArgumentEffect(effect value)
{
TagEffect(value, NWNX_PUSH);
}
void NWNX_PushArgumentItemProperty(itemproperty value)
{
TagItemProperty(value, NWNX_PUSH);
}
void NWNX_PushArgumentJson(json value)
{
SetLocalJson(OBJECT_INVALID, NWNX_PUSH, value);
}
int NWNX_GetReturnValueInt()
{
return GetLocalInt(OBJECT_INVALID, NWNX_POP);
}
float NWNX_GetReturnValueFloat()
{
return GetLocalFloat(OBJECT_INVALID, NWNX_POP);
}
object NWNX_GetReturnValueObject()
{
return GetLocalObject(OBJECT_INVALID, NWNX_POP);
}
string NWNX_GetReturnValueString()
{
return GetLocalString(OBJECT_INVALID, NWNX_POP);
}
effect NWNX_GetReturnValueEffect()
{
effect e;
return TagEffect(e, NWNX_POP);
}
itemproperty NWNX_GetReturnValueItemProperty()
{
itemproperty ip;
return TagItemProperty(ip, NWNX_POP);
}
json NWNX_GetReturnValueJson()
{
return GetLocalJson(OBJECT_INVALID, NWNX_POP);
}
int NWNX_PluginExists(string sPlugin)
{
string sFunc = "PluginExists";
NWNX_PushArgumentString(sPlugin);
NWNX_CallFunction(NWNX_Core, sFunc);
return NWNX_GetReturnValueInt();
}

391
_module/nss/nwnx_admin.nss Normal file
View File

@@ -0,0 +1,391 @@
/// @addtogroup admin Administration
/// @brief Various admin related functions
/// @{
/// @file nwnx_admin.nss
#include "nwnx"
const string NWNX_Administration = "NWNX_Administration"; ///< @private
/// @name Administration Options
/// @anchor admin_opts
///
/// @{
const int NWNX_ADMINISTRATION_OPTION_ALL_KILLABLE = 0; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_NON_PARTY_KILLABLE = 1; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_REQUIRE_RESURRECTION = 2; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_STOLEN_ITEMS = 3; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_ITEMS = 4; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_EXP = 5; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_GOLD = 6; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_GOLD_NUM = 7; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_EXP_NUM = 8; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_LOSE_ITEMS_NUM = 9; // DOES NOT DO ANYTHING
const int NWNX_ADMINISTRATION_OPTION_PVP_SETTING = 10; // 0 = No PVP, 1 = Party PVP, 2 = Full PVP
const int NWNX_ADMINISTRATION_OPTION_PAUSE_AND_PLAY = 11; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_ONE_PARTY_ONLY = 12; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_ENFORCE_LEGAL_CHARACTERS = 13; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_ITEM_LEVEL_RESTRICTIONS = 14; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_CDKEY_BANLIST_ALLOWLIST = 15; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_DISALLOW_SHOUTING = 16; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_SHOW_DM_JOIN_MESSAGE = 17; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_BACKUP_SAVED_CHARACTERS = 18; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_AUTO_FAIL_SAVE_ON_1 = 19; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_VALIDATE_SPELLS = 20; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_EXAMINE_EFFECTS = 21; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_EXAMINE_CHALLENGE_RATING = 22; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_USE_MAX_HITPOINTS = 23; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_RESTORE_SPELLS_USES = 24; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_RESET_ENCOUNTER_SPAWN_POOL = 25; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_HIDE_HITPOINTS_GAINED = 26; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_PLAYER_PARTY_CONTROL = 27; // TRUE/FALSE
const int NWNX_ADMINISTRATION_OPTION_SHOW_PLAYER_JOIN_MESSAGES = 28; // TRUE/FALSE
/// @}
/// @name Administration Debug Types
/// @anchor admin_debug
///
/// @{
const int NWNX_ADMINISTRATION_DEBUG_COMBAT = 0; // TRUE/FALSE
const int NWNX_ADMINISTRATION_DEBUG_SAVING_THROW = 1; // TRUE/FALSE
const int NWNX_ADMINISTRATION_DEBUG_MOVEMENT_SPEED = 2; // TRUE/FALSE
const int NWNX_ADMINISTRATION_DEBUG_HIT_DIE = 3; // TRUE/FALSE
/// @}
/// @brief Gets the current player password.
/// @return The current player password.
string NWNX_Administration_GetPlayerPassword();
/// @brief Sets the password for players to login.
/// @param password The password to use.
void NWNX_Administration_SetPlayerPassword(string password);
/// @brief Clears the player password required to login.
void NWNX_Administration_ClearPlayerPassword();
/// @brief Gets the current DM password.
/// @return The current DM password.
string NWNX_Administration_GetDMPassword();
/// @brief Sets the password for DMs to login.
/// @param password The password to use.
void NWNX_Administration_SetDMPassword(string password);
/// @brief Signals the server to immediately shut down.
void NWNX_Administration_ShutdownServer();
/// @brief Deletes the player character from the servervault
///
/// The PC will be immediately booted from the game with a "Delete Character" message
///
/// @param oPC The player to delete.
/// @param bPreserveBackup If true, it will leave the file on server, only appending ".deleted0" to the bic filename.
/// @param sKickMessage An optional kick message, if left blank it will default to "Delete Character" as reason.
void NWNX_Administration_DeletePlayerCharacter(object oPC, int bPreserveBackup = TRUE, string sKickMessage = "");
/// @brief Bans the provided IP.
/// @param ip The IP Address to ban.
void NWNX_Administration_AddBannedIP(string ip);
/// @brief Removes the ban on the provided IP.
/// @param ip The IP Address to unban.
void NWNX_Administration_RemoveBannedIP(string ip);
/// @brief Bans the provided Public CD Key.
/// @param key The Public CD Key to ban.
void NWNX_Administration_AddBannedCDKey(string key);
/// @brief Removes the ban on the provided Public CD Key.
/// @param key The Public CD Key to unban.
void NWNX_Administration_RemoveBannedCDKey(string key);
/// @brief Bans the provided playername.
/// @param playerName The player name (community name) to ban.
/// @warning A user can change their playername at will.
void NWNX_Administration_AddBannedPlayerName(string playerName);
/// @brief Removes the ban on the provided playername.
/// @param playerName The player name (community name) to unban.
void NWNX_Administration_RemoveBannedPlayerName(string playerName);
/// @brief Get a list of all banned IPs/Keys/names as a string.
/// @return A string with a listing of the banned IPs/Keys/names.
string NWNX_Administration_GetBannedList();
/// @brief Set the module's name as shown to the serverlist.
/// @param name The name to give the module.
void NWNX_Administration_SetModuleName(string name);
/// @brief Set the server's name as shown to the serverlist.
/// @param name The name to give the server.
void NWNX_Administration_SetServerName(string name);
/// @brief Returns the server's name as shown to the serverlist.
string NWNX_Administration_GetServerName();
/// @brief Get an @ref admin_opts "Administration Option" value.
/// @param option An @ref admin_opts "Administration Option".
/// @return The current setting for the supplied option from @ref admin_opts "Administration Options".
int NWNX_Administration_GetPlayOption(int option);
/// @brief Set an @ref admin_opts "Administration Options" to a value.
/// @param option The option to adjust from @ref admin_opts "Administration Options".
/// @param value The new value for the option.
void NWNX_Administration_SetPlayOption(int option, int value);
/// @brief Delete the TURD of playerName + characterName.
///
/// At times a PC may get stuck in a permanent crash loop when attempting to log
/// in. This function allows administrators to delete their Temporary User
/// Resource Data where the PC's current location is stored allowing them to log
/// into the starting area.
///
/// @param playerName The community (login name).
/// @param characterName The character name.
/// @return Returns TRUE if successful
int NWNX_Administration_DeleteTURD(string playerName, string characterName);
/// @brief Get an @ref admin_debug "Administration Debug Type" value.
/// @param type An @ref admin_debug "Administration Debug Type".
/// @return The current value for the supplied debug type from @ref admin_debug "Administration Debug Types".
int NWNX_Administration_GetDebugValue(int type);
/// @brief Set an @ref admin_debug "Administration Debug Type" to a value.
/// @param type The debug type to adjust from @ref admin_debug "Administration Debug Types".
/// @param state The new state for the debug type, TRUE or FALSE
void NWNX_Administration_SetDebugValue(int type, int state);
/// @brief Reload all rules (2da stuff etc).
/// @warning DANGER, DRAGONS. Bad things may or may not happen.
void NWNX_Administration_ReloadRules();
/// @brief Get the servers minimum level.
/// @return The minimum level for the server.
int NWNX_Administration_GetMinLevel();
/// @brief Set the servers minimum level.
/// @param nLevel The minimum level for the server.
void NWNX_Administration_SetMinLevel(int nLevel);
/// @brief Get the servers maximum level.
/// @return The maximum level for the server.
int NWNX_Administration_GetMaxLevel();
/// @brief Set the servers maximum level.
/// @note Attention when using this and the MaxLevel plugin. They both change the same value.
/// @param nLevel The maximum level for the server.
void NWNX_Administration_SetMaxLevel(int nLevel);
/// @}
string NWNX_Administration_GetPlayerPassword()
{
string sFunc = "GetPlayerPassword";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueString();
}
void NWNX_Administration_SetPlayerPassword(string password)
{
string sFunc = "SetPlayerPassword";
NWNX_PushArgumentString(password);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_ClearPlayerPassword()
{
string sFunc = "ClearPlayerPassword";
NWNX_CallFunction(NWNX_Administration, sFunc);
}
string NWNX_Administration_GetDMPassword()
{
string sFunc = "GetDMPassword";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueString();
}
void NWNX_Administration_SetDMPassword(string password)
{
string sFunc = "SetDMPassword";
NWNX_PushArgumentString(password);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_ShutdownServer()
{
string sFunc = "ShutdownServer";
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_DeletePlayerCharacter(object oPC, int bPreserveBackup = TRUE, string sKickMessage = "")
{
string sFunc = "DeletePlayerCharacter";
NWNX_PushArgumentString(sKickMessage);
NWNX_PushArgumentInt(bPreserveBackup);
NWNX_PushArgumentObject(oPC);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_AddBannedIP(string ip)
{
string sFunc = "AddBannedIP";
NWNX_PushArgumentString(ip);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_RemoveBannedIP(string ip)
{
string sFunc = "RemoveBannedIP";
NWNX_PushArgumentString(ip);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_AddBannedCDKey(string key)
{
string sFunc = "AddBannedCDKey";
NWNX_PushArgumentString(key);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_RemoveBannedCDKey(string key)
{
string sFunc = "RemoveBannedCDKey";
NWNX_PushArgumentString(key);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_AddBannedPlayerName(string playerName)
{
string sFunc = "AddBannedPlayerName";
NWNX_PushArgumentString(playerName);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_RemoveBannedPlayerName(string playerName)
{
string sFunc = "RemoveBannedPlayerName";
NWNX_PushArgumentString(playerName);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
string NWNX_Administration_GetBannedList()
{
string sFunc = "GetBannedList";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueString();
}
void NWNX_Administration_SetModuleName(string name)
{
string sFunc = "SetModuleName";
NWNX_PushArgumentString(name);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_SetServerName(string name)
{
string sFunc = "SetServerName";
NWNX_PushArgumentString(name);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
string NWNX_Administration_GetServerName()
{
string sFunc = "GetServerName";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueString();
}
int NWNX_Administration_GetPlayOption(int option)
{
string sFunc = "GetPlayOption";
NWNX_PushArgumentInt(option);
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueInt();
}
void NWNX_Administration_SetPlayOption(int option, int value)
{
string sFunc = "SetPlayOption";
NWNX_PushArgumentInt(value);
NWNX_PushArgumentInt(option);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
int NWNX_Administration_DeleteTURD(string playerName, string characterName)
{
string sFunc = "DeleteTURD";
NWNX_PushArgumentString(characterName);
NWNX_PushArgumentString(playerName);
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueInt();
}
int NWNX_Administration_GetDebugValue(int type)
{
string sFunc = "GetDebugValue";
NWNX_PushArgumentInt(type);
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueInt();
}
void NWNX_Administration_SetDebugValue(int type, int state)
{
string sFunc = "SetDebugValue";
NWNX_PushArgumentInt(state);
NWNX_PushArgumentInt(type);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
void NWNX_Administration_ReloadRules()
{
string sFunc = "ReloadRules";
NWNX_CallFunction(NWNX_Administration, sFunc);
}
int NWNX_Administration_GetMinLevel()
{
string sFunc = "GetMinLevel";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueInt();
}
void NWNX_Administration_SetMinLevel(int nLevel)
{
string sFunc = "SetMinLevel";
NWNX_PushArgumentInt(nLevel);
NWNX_CallFunction(NWNX_Administration, sFunc);
}
int NWNX_Administration_GetMaxLevel()
{
string sFunc = "GetMaxLevel";
NWNX_CallFunction(NWNX_Administration, sFunc);
return NWNX_GetReturnValueInt();
}
void NWNX_Administration_SetMaxLevel(int nLevel)
{
string sFunc = "SetMaxLevel";
NWNX_PushArgumentInt(nLevel);
NWNX_CallFunction(NWNX_Administration, sFunc);
}

File diff suppressed because it is too large Load Diff

View File

@@ -11,10 +11,17 @@
//:: Created On: Oct 25, 2001
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
object CreatePlaceable(string sObject, location lPlace, float fDuration);
void RewardCombatXP(object oKiller, object oVictim = OBJECT_SELF);
void main()
{
SetIsDestroyable(FALSE,FALSE,FALSE);
object oKiller = GetLastKiller();
SetIsDestroyable(FALSE,FALSE,FALSE);
DelayCommand(120.0,SetIsDestroyable(TRUE,FALSE,FALSE));
DelayCommand(121.0,DestroyObject(OBJECT_SELF));
object oTemp = CreatePlaceable("corpse",GetLocation(OBJECT_SELF),120.0);
@@ -227,12 +234,120 @@ void main()
{
SignalEvent(GetAreaFromLocation(GetLocation(OBJECT_SELF)), EventUserDefined(1007));
}
RewardCombatXP(oKiller);
ExecuteScript("prc_npc_death", OBJECT_SELF);
}
object CreatePlaceable(string sObject, location lPlace, float fDuration)
{
object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,sObject,lPlace,FALSE);
if (fDuration != 0.0)
DestroyObject(oPlaceable,fDuration);
return oPlaceable;
}
void RewardCombatXP(object oKiller, object oVictim = OBJECT_SELF)
{
int noleech = 0;
float BaseEXP = ((GetChallengeRating(oVictim)*5.0)+2);
float BonusEXP = ((GetChallengeRating(oVictim)*2.0)+5);
float BaseMonEXP = BaseEXP;
int NumOfParty = 0;
float PartyLevelSum = 0.0;
object oPartyMember = GetFirstFactionMember(oKiller, TRUE);
while(GetIsObjectValid(oPartyMember)) {
if (GetArea(oVictim) == GetArea(oPartyMember))
{
int leech = GetHitDice(oPartyMember);
if (leech >= noleech){
noleech = leech;
}
NumOfParty++;
PartyLevelSum += GetCharacterLevel(oPartyMember);
}
oPartyMember = GetNextFactionMember(oKiller, TRUE);
}
if (PartyLevelSum <= 1.0)
{
PartyLevelSum = 1.0;
}
if (NumOfParty <= 1)
{
NumOfParty = 1;
}
float PartyAvgLvl = PartyLevelSum / NumOfParty;
//Calculate Adjustment Value
if (PartyAvgLvl <= 1.0)
{
PartyAvgLvl = 1.0;
}
float x = GetChallengeRating(oVictim);
if (x <= 1.0)
{
x = 1.0;
}
float z = (x / PartyAvgLvl);
float AdjustValue = ((z+2)/3);
float FinalMonValue;
//Determine Final Experience Value
if (AdjustValue == 0.0) {
FinalMonValue = BaseMonEXP;
} else {
if (AdjustValue < 1.0) {
FinalMonValue = BaseMonEXP * AdjustValue;
} else {
FinalMonValue = BaseMonEXP + (BonusEXP * (AdjustValue * (1.10)));
}
}
//Determine the value of the Split EXP
if (NumOfParty >= 8)
{
NumOfParty = 8;
}
if (NumOfParty <= 1)
{
NumOfParty = 1;
}
if (FinalMonValue <= 1.0)
{
FinalMonValue = 1.0;
}
float SplitFinalEXP = FinalMonValue / NumOfParty;
if (SplitFinalEXP <= 1.0)
{
SplitFinalEXP = 1.0;
}
float y = (FinalMonValue - SplitFinalEXP);
if (y <= 1.0)
{
y = 1.0;
}
if (PartyAvgLvl >= 15.0)
{
FinalMonValue = FinalMonValue - ( PartyAvgLvl);
}
float PartyBonus = ((y +1)/ 1.75) + (FinalMonValue + ((21-PartyAvgLvl)/3));
int SFEint = FloatToInt(PartyBonus);
//Distribute EXP to all PCs in the Party
oPartyMember = GetFirstFactionMember(oKiller, TRUE);
while (GetIsObjectValid(oPartyMember))
{
if (GetArea(OBJECT_SELF) == GetArea(oPartyMember)) {
int nHD = GetHitDice(oPartyMember) + 1;
int nMax = (((nHD * (nHD - 1)) / 2) * 1000)+1;
if (nMax <= GetXP(oPartyMember) && nHD <= 40) {
SendMessageToPC(oPartyMember, "You cannot gain experience until you have leveled.");
} else if (GetIsDead(oPartyMember)) {
SendMessageToPC(oPartyMember, "You cannot gain experience while dead. Your XP has been reset.");
} else if ((GetHitDice(oPartyMember)) <= (noleech - 7) || (GetHitDice(oPartyMember)) >= FloatToInt(PartyAvgLvl) + 7) {
SendMessageToPC(oPartyMember, "All party members must be within 6 levels of each other.");
} else {
GiveXPToCreature(oPartyMember, SFEint);
}
}
oPartyMember = GetNextFactionMember(oKiller, TRUE);
}
}