Rune_PRC8/_module/nss/ud_beamtarget.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

76 lines
3.5 KiB
Plaintext

void main()
{
string sType = GetStringLowerCase(GetStringRight(GetTag(OBJECT_SELF), 4));
object oSource = GetNearestObjectByTag("BeamSource_" + GetStringRight(GetTag(OBJECT_SELF), 6));
float fDelay = IntToFloat(GetMaxHitPoints(oSource)) / 100;
effect eBeam;
int nDamageType;
effect eImpact;
string sVariable = GetStringRight(GetTag(OBJECT_SELF), 6) + "IsOn";
if (sType == "elec") {
eBeam = EffectBeam(VFX_BEAM_LIGHTNING, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_ELECTRICAL;
eImpact = EffectVisualEffect(VFX_COM_HIT_ELECTRICAL);
} else if (sType == "fire") {
eBeam = EffectBeam(VFX_BEAM_FIRE, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
} else if (sType == "cold") {
eBeam = EffectBeam(VFX_BEAM_COLD, oSource, BODY_NODE_CHEST, FALSE);
eImpact = EffectVisualEffect(VFX_COM_HIT_FROST);
nDamageType = DAMAGE_TYPE_COLD;
} else if (sType == "evil") {
eBeam = EffectBeam(VFX_BEAM_EVIL, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_NEGATIVE;
eImpact = EffectVisualEffect(VFX_COM_HIT_NEGATIVE);
} else if (sType == "mind") {
eBeam = EffectBeam(VFX_BEAM_MIND, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_MAGICAL;
eImpact = EffectVisualEffect(VFX_IMP_HEAD_MIND);
} else if (sType == "holy") {
eBeam = EffectBeam(VFX_BEAM_HOLY, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_DIVINE;
eImpact = EffectVisualEffect(VFX_COM_HIT_DIVINE);
} else if (sType == "lash") {
eBeam = EffectBeam(VFX_BEAM_FIRE_LASH, oSource, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
}
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, OBJECT_SELF, fDelay);
SetLocalInt(GetArea(OBJECT_SELF), sVariable, TRUE);
DelayCommand(fDelay, SetLocalInt(GetArea(OBJECT_SELF), sVariable, FALSE));
DelayCommand(fDelay * 2, ExecuteScript("ud_beamtarget", OBJECT_SELF));
// Let's check to see if any players are in the beam when it's turned on.
string sInBeam = GetStringRight(GetTag(OBJECT_SELF), 6) + "_InBeam";
int nBeam;
object oPC = GetFirstObjectInShape(SHAPE_SPHERE, 10.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_CREATURE);
while (GetIsObjectValid(oPC)) {
nBeam = GetLocalInt(oPC, sInBeam);
if (nBeam == TRUE && GetIsPC(oPC) && !GetIsDM(oPC)) {
int nDiceSides = GetReflexSavingThrow(OBJECT_SELF);
int nDiceNum = GetFortitudeSavingThrow(OBJECT_SELF);
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);
}
oPC = GetNextObjectInShape(SHAPE_SPHERE, 10.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_CREATURE);
}
}