REO-EE/_module/nss/lightswitch1use1.nss
Jaysyn904 f82740bbbd Initial commit
Initial commit
2024-02-22 13:22:03 -05:00

103 lines
3.7 KiB
Plaintext

void CreateLight1(object oLinkedLights1, int iId1)
{
object oNPC;
oNPC = CreateObject(OBJECT_TYPE_CREATURE, "electriclight001", GetLocation(oLinkedLights1), FALSE, "" + IntToString(iId1) + "");
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20), oNPC);
AssignCommand(oNPC, ActionJumpToLocation(GetLocation(oLinkedLights1)));
}
void main()
{
object oPC = GetLastUsedBy();
object oNPC = OBJECT_SELF;
object oLinkedLights1;
object oElectricLight1;
object oArea = GetArea(oNPC);
int iLightSwitch1 = GetLocalInt(oNPC, "iLightSwitch1"); //Turn on(0) Turn off(1)
int iId1;
float fAntiSwitchBack1 = 0.0;
effect eLight1;
string sLightSwitchable1 = GetLocalString(oNPC, "sLightSwitchable1"); //Checks if its a light switch
string sLightSwitchLink1 = GetLocalString(oNPC, "sLightSwitchLink1"); //Checks the objects in the area with the same string variable
string sLightSource1 = GetLocalString(oNPC, "sLightSource1"); //Checks if this placeable is a light source
// DEBUGS:
// SendMessageToPC(oPC, "sLightSwitchable1 = " + sLightSwitchable1); // DEBUG
// SendMessageToPC(oPC, "sLightSwitchLink1 = " + sLightSwitchLink1); // DEBUG
// SendMessageToPC(oPC, "sLightSource1 = " + sLightSource1); // DEBUG
if (iLightSwitch1 <= -1)
{
SetLocalInt(oNPC, "iLightSwitch1", 0);
}
if (sLightSwitchable1 == "Yes")
{
oLinkedLights1 = GetFirstObjectInArea(oArea);
while (GetIsObjectValid(oLinkedLights1))
{
if (GetLocalString(oLinkedLights1, "sLightSwitchLink1") == sLightSwitchLink1)
{
if (iLightSwitch1 <= 0)
{
//AssignCommand(oLinkedLights1, SpeakString("Light Off"));
/*eLight1 = GetFirstEffect(oNPC);
while (GetIsEffectValid(eLight1))
{
RemoveEffect(oNPC, eLight1);
eLight1 = GetNextEffect(oNPC);
}*/
oElectricLight1 = GetNearestObjectByTag("" + IntToString(GetLocalInt(oLinkedLights1, "LightSourceLightLink1")) + "");
DestroyObject(oElectricLight1);
SetLocalInt(oNPC, "iLightSwitch1", 1);
}
if (iLightSwitch1 >= 1)
{
if (sLightSource1 == "Yes" && oLinkedLights1 == oNPC)
{
//AssignCommand(oLinkedLights1, SpeakString("Light switch Light On"));
iId1 = Random(9999999) + 1;
DelayCommand(0.2, CreateLight1(oLinkedLights1, iId1));
SetLocalInt(oElectricLight1, "LightSourceLightLink1", iId1);
SetLocalInt(oLinkedLights1, "LightSourceLightLink1", iId1);
//ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20), oLinkedLights1);
}
if(oLinkedLights1 != oNPC)
{
//AssignCommand(oLinkedLights1, SpeakString("Light source Light On"));
iId1 = Random(9999999) + 1;
DelayCommand(0.2, CreateLight1(oLinkedLights1, iId1));
SetLocalInt(oElectricLight1, "LightSourceLightLink1", iId1);
SetLocalInt(oLinkedLights1, "LightSourceLightLink1", iId1);
//ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20), oLinkedLights1);
}
SetLocalInt(oNPC, "iLightSwitch1", 0);
}
}
oLinkedLights1 = GetNextObjectInArea(oArea);
}
}
}