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

98 lines
3.0 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Glowing Items Heartbeat script
//:: glowitem_hb
//:: Copyright (c) 2004 Jason Stephenson
//:://////////////////////////////////////////////
/*
Install this script in your module's onHeartbeat
event in order to enable melee weapons that glow
when within a certain range of a certain race of
creature.
If you already have an onHeartbeat script in your
module, you could call this script from your current
onHeartbeat with the following line:
ExecuteScript("glowitem_hb");
*/
//:://////////////////////////////////////////////
//:: Created By: Jason Stephenson (Dyrcona)
//:: Created On: July 18, 2004
//:://////////////////////////////////////////////
/*
* Modified on: August 8, 2004
* Added handling of alignment checking items.
*/
int PCIsInArea(object oArea)
{
object oPC = GetFirstObjectInArea(oArea);
if(!GetIsPC(oPC))
{
oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oPC);
}
return(GetIsObjectValid(oPC));
}
#include "glowitem_inc"
void main()
{
int iGlowItemCount = GetLocalInt(GetModule(), "GlowItemCount");
// Placeholder for current item.
object oCurrent;
// Placeholder for previous item.
object oPrevious = OBJECT_INVALID;
// Placeholder for result of race check.
int iTargetFound = 0;
int iTargetFoundPrev = 0;
// Variables required for various effects.
object oPC;
int iTarget;
int iIsAlign;
int iEffect;
float fRange;
int i;
for (i = 1; i <= iGlowItemCount; i++ ) {
oCurrent = GetLocalObject(GetModule(), "GlowItem" + IntToString(i));
oPC = GetLocalObject(GetModule(), "GlowItemHolder" + IntToString(i));
iTarget = GetLocalInt(GetModule(), "GlowItemTarget" + IntToString(i));
iIsAlign = GetLocalInt(GetModule(), "GlowItemIsAlign" + IntToString(i));
iEffect = GetLocalInt(GetModule(), "GlowItemEffect" + IntToString(i));
fRange = GetLocalFloat(GetModule(), "GlowItemRange" + IntToString(i));
if (oCurrent == oPrevious) {
if (!iTargetFoundPrev) {
if (iIsAlign == 1)
iTargetFound = CheckGlowItemAlignmentInRange(oPC, iTarget, fRange);
else
iTargetFound = CheckGlowItemRaceInRange(oPC, iTarget, fRange);
if (iTargetFound)
ApplyGlowItemEffect(oCurrent, iEffect);
else
RemoveGlowItemEffect(oCurrent);
}
else {
iTargetFound = iTargetFoundPrev;
}
}
else {
if (iIsAlign == 1)
iTargetFound = CheckGlowItemAlignmentInRange(oPC, iTarget, fRange);
else
iTargetFound = CheckGlowItemRaceInRange(oPC, iTarget, fRange);
if (iTargetFound)
ApplyGlowItemEffect(oCurrent, iEffect);
else
RemoveGlowItemEffect(oCurrent);
}
iTargetFoundPrev = iTargetFound;
oPrevious = oCurrent;
}
}