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

90 lines
3.8 KiB
Plaintext

void main()
{
object oPC = GetEnteringObject();
if (GetIsPC(oPC) && !GetIsDM(oPC)) {
string sTag = GetTag(OBJECT_SELF);
string sBeam;
if (GetStringLength(sTag) == 14) {
// We turn one matching beam off
sBeam = GetStringRight(sTag, 6);
object oBeamSource = GetNearestObjectByTag("BeamSource_" + sBeam);
SetLocalInt(oBeamSource, "BeamSetToOn", FALSE);
effect eCheck = GetFirstEffect(oBeamSource);
while(GetIsEffectValid(eCheck)) {
if(GetEffectType(eCheck) == EFFECT_TYPE_BEAM) {
RemoveEffect(oBeamSource, eCheck);
SetLocalInt(GetArea(OBJECT_SELF), sBeam + "IsOn", FALSE);
}
eCheck = GetNextEffect(oBeamSource);
}
} else if (GetStringLength(sTag) == 12) {
// We turn off all beams of same type
int nCountNum = 0;
string sType = GetStringRight(sTag, 4);
string sCount = "00";
object oBeamSource= GetNearestObjectByTag("BeamSource_" + sCount + sType);
while (GetIsObjectValid(oBeamSource)) {
SetLocalInt(oBeamSource, "BeamSetToOn", FALSE);
effect eCheck = GetFirstEffect(oBeamSource);
while(GetIsEffectValid(eCheck)) {
if(GetEffectType(eCheck) == EFFECT_TYPE_BEAM) {
RemoveEffect(oBeamSource, eCheck);
SetLocalInt(GetArea(OBJECT_SELF), sCount + sType + "IsOn", FALSE);
}
eCheck = GetNextEffect(oBeamSource);
}
nCountNum++;
sCount = IntToString(nCountNum);
if (nCountNum < 10) {
sCount = "0" + sCount;
}
oBeamSource = GetNearestObjectByTag("BeamSource_" + sCount + sType);
}
} else if (GetStringLength(sTag) == 11) {
// We turn off all beams in the area
int nCountNum;
int nForCount;
string sCount;
object oBeamSource;
string sType;
for (nForCount = 0; nForCount <= 6; nForCount++) {
nCountNum = 0;
sCount = "00";
if (nForCount == 0) {
sType = "Cold";
} else if (nForCount == 1) {
sType = "Elec";
} else if (nForCount == 2) {
sType = "Evil";
} else if (nForCount == 3) {
sType = "Fire";
} else if (nForCount == 4) {
sType = "Holy";
} else if (nForCount == 5) {
sType = "Lash";
} else if (nForCount == 6) {
sType = "Mind";
}
oBeamSource = GetNearestObjectByTag("BeamSource_" + sCount + sType);
while (GetIsObjectValid(oBeamSource)) {
SetLocalInt(oBeamSource, "BeamSetToOn", FALSE);
effect eCheck = GetFirstEffect(oBeamSource);
while(GetIsEffectValid(eCheck)) {
if(GetEffectType(eCheck) == EFFECT_TYPE_BEAM) {
RemoveEffect(oBeamSource, eCheck);
SetLocalInt(GetArea(OBJECT_SELF), sCount + sType + "IsOn", FALSE);
}
eCheck = GetNextEffect(oBeamSource);
}
nCountNum++;
string sCount = IntToString(nCountNum);
if (nCountNum < 10) {
sCount = "0" + sCount;
}
oBeamSource = GetNearestObjectByTag("BeamSource_" + sCount + sType);
}
}
}
}
}