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

105 lines
4.8 KiB
Plaintext

void main()
{
if (GetLocalInt(OBJECT_SELF, "BeamSetToOn") == TRUE) {
string sType = GetStringLowerCase(GetStringRight(GetTag(OBJECT_SELF), 4));
object oSource = OBJECT_SELF; // GetNearestObjectByTag("BeamSource_" + GetStringRight(GetTag(OBJECT_SELF), 6));
object oTarget = GetNearestObjectByTag("BeamTarget_" + GetStringRight(GetTag(OBJECT_SELF), 6));
float fDelay = IntToFloat(GetMaxHitPoints(oSource)) / 100;
effect eBeam;
int nDamageType;
effect eImpact;
int nEffectType;
string sVariable = GetStringRight(GetTag(OBJECT_SELF), 6) + "IsOn";
if (sType == "elec") {
// eBeam = EffectBeam(VFX_BEAM_LIGHTNING, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_ELECTRICAL;
eImpact = EffectVisualEffect(VFX_COM_HIT_ELECTRICAL);
nEffectType = VFX_BEAM_LIGHTNING;
} else if (sType == "fire") {
// eBeam = EffectBeam(VFX_BEAM_FIRE, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
nEffectType = VFX_BEAM_FIRE;
} else if (sType == "cold") {
// eBeam = EffectBeam(VFX_BEAM_COLD, oTarget, BODY_NODE_CHEST, FALSE);
eImpact = EffectVisualEffect(VFX_COM_HIT_FROST);
nDamageType = DAMAGE_TYPE_COLD;
nEffectType = VFX_BEAM_COLD;
} else if (sType == "evil") {
// eBeam = EffectBeam(VFX_BEAM_EVIL, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_NEGATIVE;
eImpact = EffectVisualEffect(VFX_COM_HIT_NEGATIVE);
nEffectType = VFX_BEAM_EVIL;
} else if (sType == "mind") {
// eBeam = EffectBeam(VFX_BEAM_MIND, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_MAGICAL;
eImpact = EffectVisualEffect(VFX_IMP_HEAD_MIND);
nEffectType = VFX_BEAM_MIND;
} else if (sType == "holy") {
// eBeam = EffectBeam(VFX_BEAM_HOLY, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_DIVINE;
eImpact = EffectVisualEffect(VFX_COM_HIT_DIVINE);
nEffectType = VFX_BEAM_HOLY;
} else if (sType == "lash") {
// eBeam = EffectBeam(VFX_BEAM_FIRE_LASH, oTarget, BODY_NODE_CHEST, FALSE);
nDamageType = DAMAGE_TYPE_FIRE;
eImpact = EffectVisualEffect(VFX_COM_HIT_FIRE);
nEffectType = VFX_BEAM_FIRE_LASH;
}
int nCountDis = 1;
SetLocalInt(GetArea(OBJECT_SELF), sVariable, TRUE);
if (GetMaxHitPoints(oSource) >= 10) {
while (GetIsObjectValid(oTarget)) {
// SendMessageToPC(GetFirstPC(), "[DEBUG] CountDis = " + IntToString(nCountDis));
eBeam = EffectBeam(nEffectType, oTarget, BODY_NODE_CHEST, FALSE);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, OBJECT_SELF, fDelay);
nCountDis++;
oTarget = GetNearestObjectByTag("BeamTarget_" + GetStringRight(GetTag(OBJECT_SELF), 6), oSource, nCountDis);
}
DelayCommand(fDelay, SetLocalInt(GetArea(OBJECT_SELF), sVariable, FALSE));
DelayCommand(fDelay * 2, ExecuteScript("ud_beamtarget", OBJECT_SELF));
} else {
while (GetIsObjectValid(oTarget)) {
// SendMessageToPC(GetFirstPC(), "[DEBUG] CountDis = " + IntToString(nCountDis));
eBeam = EffectBeam(nEffectType, oTarget, BODY_NODE_CHEST, FALSE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBeam, OBJECT_SELF, fDelay);
nCountDis++;
oTarget = GetNearestObjectByTag("BeamTarget_" + GetStringRight(GetTag(OBJECT_SELF), 6), oSource, nCountDis);
}
}
// 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(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);
}
oPC = GetNextObjectInShape(SHAPE_SPHERE, 10.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_CREATURE);
}
}
}