I’ve been at this for hours now and I no longer know what to do so I’ll see if you can maybe help me.
I have a lever puzzle that works splendidly in an area apart from one detail. There is a fence consisting of 4 fence placeables that are supposed to be destroyed when the puzzle is finished, but the fence refuses to be destroyed. My guess is that there’s some mistake in my script. My script is quite convoluted (sorry about that), but I’ve written it like this so that I myself can follow what’s going on. Maybe some of you more experienced people out there can help me figure out what’s wrong.
#include "ginc_object"
void PrepForDestruction(object oTarget)
{
SetPlotFlag(oTarget,FALSE);
SetImmortal(oTarget,FALSE);
AssignCommand(oTarget,SetIsDestroyable(TRUE,FALSE,FALSE));
}
void main()
{
object oPC = GetFirstPC();
object oArea = (GetArea(oPC));
object oBarrier = GetObjectByTag ("force_field_l1");
object oBarrier2 = GetObjectByTag ("force_field_l2");
object oLever1 = GetObjectByTag ("l_lever1");
object oLever2 = GetObjectByTag ("l_lever2");
object oLever3 = GetObjectByTag ("l_lever3");
object oLever4 = GetObjectByTag ("l_lever4");
object oLever5 = GetObjectByTag ("l_lever5");
object oLight1 = GetObjectByTag ("1ge");
object oLight2 = GetObjectByTag ("2ge");
object oLight3 = GetObjectByTag ("3ge");
object oLight4 = GetObjectByTag ("4ge");
object oLight5 = GetObjectByTag ("5ge");
object oGreenlight5 = GetObjectByTag ("1ge5");
object oGreenlight4 = GetObjectByTag ("1ge4");
object oGreenlight3 = GetObjectByTag ("1ge3");
object oGreenlight2 = GetObjectByTag ("1ge2");
object oGreenlight1 = GetObjectByTag ("1ge1");
int Lever1;
int Lever2;
int Lever3;
int Lever4;
int Lever5;
if ( GetLocalInt( OBJECT_SELF, "m_bActivated" ) != TRUE )
{
//Activate the Lever and Mark the Lever as Activated.
SetLocalInt( OBJECT_SELF, "m_bActivated", TRUE );
PlayAnimation( ANIMATION_PLACEABLE_ACTIVATE );
}
else
{
//Deactivate the Lever and Mark the Lever as Deactivated.
SetLocalInt( OBJECT_SELF, "m_bActivated", FALSE );
PlayAnimation( ANIMATION_PLACEABLE_DEACTIVATE );
}
// Get the status of the other levers.
Lever1 = GetLocalInt (oLever1,"m_bActivated");
Lever2 = GetLocalInt (oLever2,"m_bActivated");
Lever3 = GetLocalInt (oLever3,"m_bActivated");
Lever4 = GetLocalInt (oLever4,"m_bActivated");
Lever5 = GetLocalInt (oLever5,"m_bActivated");
int OpenBarrier = GetLocalInt(oBarrier,"opendoor");
if (Lever1 == TRUE && Lever2 == FALSE && Lever3 == FALSE && Lever4 == FALSE && Lever5 == FALSE )
{
SetLocalInt(oBarrier, "opendoor", 1);
PrepForDestruction(oLight1);
DestroyObject(oLight1);
object oGreenlight1 = SpawnObjectAtWP(1024,"1ge1", "1g");
return;
}
else if (OpenBarrier == 1)
{
if (Lever1 == TRUE && Lever2 == FALSE && Lever3 == FALSE && Lever4 == FALSE && Lever5 == TRUE )
{
SetLocalInt(oBarrier, "opendoor", 2);
PrepForDestruction(oLight5);
DestroyObject(oLight5);
object oGreenlight5 = SpawnObjectAtWP(1024,"1ge5", "5g");
}
else
{
SetLocalInt(oBarrier, "opendoor", 0);
PrepForDestruction(oGreenlight1);
DestroyObject(oGreenlight1);
object oLight1 = SpawnObjectAtWP(1024,"1ge", "1g");
}
}
else if (OpenBarrier == 2)
{
if (Lever1 == TRUE && Lever2 == FALSE && Lever3 == FALSE && Lever4 == TRUE && Lever5 == TRUE)
{
SetLocalInt(oBarrier, "opendoor", 3);
PrepForDestruction(oLight4);
DestroyObject(oLight4);
object oGreenlight4 = SpawnObjectAtWP(1024,"1ge4", "4g");
}
else
{
SetLocalInt(oBarrier, "opendoor", 0);
PrepForDestruction(oGreenlight1);
DestroyObject(oGreenlight1);
object oLight1 = SpawnObjectAtWP(1024,"1ge", "1g");
PrepForDestruction(oGreenlight5);
DestroyObject(oGreenlight5);
object oLight5 = SpawnObjectAtWP(1024,"5ge", "5g");
}
}
else if (OpenBarrier == 3)
{
if (Lever1 == TRUE && Lever2 == TRUE && Lever3 == FALSE && Lever4 == TRUE && Lever5 == TRUE)
{
SetLocalInt(oBarrier, "opendoor", 4);
PrepForDestruction(oLight2);
DestroyObject(oLight2);
object oGreenlight2 = SpawnObjectAtWP(1024,"1ge2", "2g");
}
else
{
SetLocalInt(oBarrier, "opendoor", 0);
PrepForDestruction(oGreenlight1);
DestroyObject(oGreenlight1);
object oLight1 = SpawnObjectAtWP(1024,"1ge", "1g");
PrepForDestruction(oGreenlight5);
PrepForDestruction(oGreenlight4);
DestroyObject(oGreenlight5);
DestroyObject(oGreenlight4);
object oLight5 = SpawnObjectAtWP(1024,"5ge", "5g");
object oLight4 = SpawnObjectAtWP(1024,"4ge", "4g");
}
}
else if (OpenBarrier == 4)
{
if (Lever1 == TRUE && Lever2 == TRUE && Lever3 == TRUE && Lever4 == TRUE && Lever5 == TRUE)
{
SetLocalInt(oBarrier, "opendoor", 5);
PrepForDestruction(oLight3);
DestroyObject(oLight3);
object oGreenlight3 = SpawnObjectAtWP(1024,"1ge3", "3g");
PrepForDestruction(oBarrier);
DestroyObject(oBarrier);
PrepForDestruction(oBarrier2);
DestroyObject(oBarrier2);
object oFence1 = GetObjectByTag ("l_fence1");
AssignCommand(oFence1,SetIsDestroyable(TRUE,FALSE,FALSE));
object oFence2 = GetObjectByTag ("l_fence2");
AssignCommand(oFence2,SetIsDestroyable(TRUE,FALSE,FALSE));
object oFence3 = GetObjectByTag ("l3fence");
AssignCommand(oFence3,SetIsDestroyable(TRUE,FALSE,FALSE));
object oFence4 = GetObjectByTag ("l4fence");
AssignCommand(oFence4,SetIsDestroyable(TRUE,FALSE,FALSE));
DestroyObject(oFence1);
DestroyObject(oFence2);
DestroyObject(oFence3);
DestroyObject(oFence4);
MusicBackgroundChangeDay(oArea,169);
MusicBackgroundChangeNight(oArea,169);
}
else
{
SetLocalInt(oBarrier, "opendoor", 0);
PrepForDestruction(oGreenlight1);
DestroyObject(oGreenlight1);
object oLight1 = SpawnObjectAtWP(1024,"1ge", "1g");
PrepForDestruction(oGreenlight5);
PrepForDestruction(oGreenlight4);
PrepForDestruction(oGreenlight2);
DestroyObject(oGreenlight5);
DestroyObject(oGreenlight4);
DestroyObject(oGreenlight2);
object oLight5 = SpawnObjectAtWP(1024,"5ge", "5g");
object oLight4 = SpawnObjectAtWP(1024,"4ge", "4g");
object oLight2 = SpawnObjectAtWP(1024,"2ge", "2g");
}
}
}
(And what is f*%#%g annoying is that these forums refuse to display the script exactly like it is in the toolset when I copy it here, with lines not going parallell to each other, ok, I’m sorry, but I’m so pissed off right now. It’s late and I need to go to sleep…)