LoD_PRC8/_module/nss/onent_beamzone.nss
Jaysyn904 94990edc60 Initial Upload
Initial Upload
2023-09-21 21:20:34 -04:00

62 lines
2.4 KiB
Plaintext

void main()
{
string sVariable = GetStringRight(GetTag(OBJECT_SELF), 6) + "IsOn";
string sType = GetStringLowerCase(GetStringRight(GetTag(OBJECT_SELF), 4));
int nDamageType;
effect eImpact;
if (sType == "elec") {
nDamageType = DAMAGE_TYPE_ELECTRICAL;
eImpact = EffectVisualEffect(VFX_COM_HIT_ELECTRICAL);
} else if (sType == "fire") {
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
} else if (sType == "cold") {
eImpact = EffectVisualEffect(VFX_COM_HIT_FROST);
nDamageType = DAMAGE_TYPE_COLD;
} else if (sType == "evil") {
nDamageType = DAMAGE_TYPE_NEGATIVE;
eImpact = EffectVisualEffect(VFX_COM_HIT_NEGATIVE);
} else if (sType == "mind") {
nDamageType = DAMAGE_TYPE_MAGICAL;
eImpact = EffectVisualEffect(VFX_IMP_HEAD_MIND);
} else if (sType == "holy") {
nDamageType = DAMAGE_TYPE_DIVINE;
eImpact = EffectVisualEffect(VFX_COM_HIT_DIVINE);
} else if (sType == "lash") {
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
}
int nBeamOn = GetLocalInt(GetArea(OBJECT_SELF), sVariable);
object oPC = GetEnteringObject();
object oSource = GetNearestObjectByTag("BeamSource_" + GetStringRight(GetTag(OBJECT_SELF), 6));
if (GetIsPC(oPC) && !GetIsDM(oPC)) {
if (nBeamOn) {
int nDiceSides = GetReflexSavingThrow(oSource);
int nDiceNum = GetFortitudeSavingThrow(oSource);
int nDamage;
if (nDiceNum == 0) {
nDiceNum = GetHitDice(oPC);
if (nDiceNum < 1) {
nDiceNum = 1;
}
}
if (nDiceSides == 0) {
nDamage = nDiceNum;
} else {
int nCount;
for(nCount = 1; nCount <= nDiceNum; nCount++) {
nDamage = nDamage + Random(nDiceSides) + 1;
}
}
effect eDamage = EffectDamage(nDamage, nDamageType, DAMAGE_POWER_NORMAL);
effect eLink = EffectLinkEffects(eImpact, eDamage);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eLink, oPC);
} else {
// Although the beam is not on now, if the PC is standing in the
// trigger when it turns on, they should be damaged.
SetLocalInt(oPC, GetStringRight(GetTag(OBJECT_SELF), 6) + "_InBeam", TRUE);
}
}
}