Initial Upload
Initial Upload
This commit is contained in:
148
_module/nss/lod_include.nss
Normal file
148
_module/nss/lod_include.nss
Normal file
@@ -0,0 +1,148 @@
|
||||
#include "elv_guildchecker"
|
||||
|
||||
// lod_include.nss
|
||||
// I plan to use this script to utilize some of the many functions
|
||||
// have written to simplify my life.
|
||||
|
||||
|
||||
// Used to simplify the distribution of items to a PC.
|
||||
// Just use the function witht he desired target in the oPC,
|
||||
// And the Item tag in the second position. It will check
|
||||
// the inventory for the item, if it doesn't exist, it gets created.
|
||||
void GivePCItem(object oPC, string sItemTag);
|
||||
|
||||
// Function takes item by tag from oPC if it does currently exist on their person, and sends sMsg
|
||||
void TakePCItem(object oPC, string sItemTag, string sMsg);
|
||||
|
||||
// Jumps oPC to oTarget
|
||||
void JumpPC(object oPC, object oTarget);
|
||||
|
||||
|
||||
|
||||
void GivePCItem(object oPC, string sItemTag)
|
||||
{
|
||||
object oItem = GetItemPossessedBy(oPC, sItemTag);
|
||||
if (oItem == OBJECT_INVALID)
|
||||
CreateItemOnObject(sItemTag, oPC);
|
||||
}
|
||||
|
||||
|
||||
void TakePCItem(object oPC, string sItemTag, string sMsg)
|
||||
{
|
||||
object oItem = GetItemPossessedBy(oPC, sItemTag);
|
||||
if (oItem != OBJECT_INVALID)
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
SendMessageToPC(oPC, sMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JumpPC(object oPC, object oTarget)
|
||||
{
|
||||
AssignCommand(oPC, ClearAllActions());
|
||||
location lTarget = GetLocation(oTarget);
|
||||
|
||||
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
|
||||
AssignCommand(oPC, ActionJumpToLocation(lTarget));
|
||||
}
|
||||
|
||||
|
||||
int IsPCInArea(object oArea)
|
||||
{
|
||||
object oPC = GetFirstPC();
|
||||
|
||||
while(GetIsObjectValid(oPC))
|
||||
{
|
||||
if(GetArea(oPC) == oArea)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
oPC = GetNextPC();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// This is the actual function for the respawn/death penalties. Any editing need only to be done here.
|
||||
|
||||
const int LEVEL_LOSS_RESPAWN = FALSE; // T/F to lose lvls for respawn
|
||||
const int SAFE_LVL = 3; // Now xp/gp loss this lvl & below
|
||||
const int XP_LOSS_PER_LEVEL = 150;
|
||||
const float GOLD_LOSS_PER_LEVEL = 0.10;
|
||||
const int GOLD_LOSS_CAP = 100000;
|
||||
|
||||
void ApplyPenalty(object oDead)
|
||||
{
|
||||
int nXP = GetXP(oDead);
|
||||
int nPenalty = XP_LOSS_PER_LEVEL * GetHitDice(oDead);
|
||||
int nHD = GetHitDice(oDead);
|
||||
|
||||
if (nHD <= SAFE_LVL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (LEVEL_LOSS_RESPAWN)
|
||||
{
|
||||
SetXP(oDead, nXP - nPenalty);
|
||||
}
|
||||
else
|
||||
{
|
||||
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
|
||||
int nNewXP = nXP - nPenalty;
|
||||
if (nNewXP < nMin) nNewXP = nMin;
|
||||
SetXP(oDead, nNewXP);
|
||||
}
|
||||
|
||||
// This is to relate to the new check for the 5k gold for new char
|
||||
if (GetXP(oDead) < 1) SetXP(oDead, 1);
|
||||
|
||||
int nGoldToTake = FloatToInt(GOLD_LOSS_PER_LEVEL * GetGold(oDead));
|
||||
if (nGoldToTake > GOLD_LOSS_CAP)
|
||||
nGoldToTake = GOLD_LOSS_CAP;
|
||||
|
||||
//Prevent people using so called -1 gp pickpocket bug...
|
||||
//Ba'al
|
||||
if(GetGold(oDead) < 10)
|
||||
nGoldToTake = 0;
|
||||
|
||||
AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
|
||||
DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
|
||||
DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));
|
||||
}
|
||||
|
||||
// Gives xp/gp to oKillers party within fDist
|
||||
void LoDBossReward(object oKiller, float fDist, int iXP, int iGP);
|
||||
|
||||
void LoDBossReward(object oKiller, float fDist, int iXP, int iGP)
|
||||
{
|
||||
object oPartyMember = GetFirstFactionMember(oKiller, TRUE);
|
||||
|
||||
if (oPartyMember == OBJECT_INVALID)
|
||||
return;
|
||||
|
||||
while (GetIsObjectValid(oPartyMember))
|
||||
{
|
||||
if ((GetDistanceBetween(oKiller, oPartyMember) < fDist) && (GetArea(oKiller) == GetArea(oPartyMember)))
|
||||
{
|
||||
if (GetIsDead(oPartyMember) == FALSE)
|
||||
{
|
||||
GiveXPToCreature(oPartyMember, iXP);
|
||||
GiveGoldToCreature(oPartyMember, iGP);
|
||||
}
|
||||
}
|
||||
oPartyMember = GetNextFactionMember(oKiller, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Flash - Checks if creature is a boss or not.
|
||||
int IsLoDBoss(object oCreature)
|
||||
{
|
||||
if(GetLocalInt(oCreature, "gpreward") > 1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user