Sorry I'm asking so many questions if you've noticed me, but I promise when I get everything down I'll give back to the Development Support community.
So I took some ideas from an old thread and came up with this for solving a lever puzzle that is 6 machine levers hanging on a machine (Not regular wall levers)
I put areas above and below them for the entities to collide with and call their corresponding functions.
This is what I have.
(In the OnStart:
AddEntityCollideCallback("lever_1", "leverup", "lever1", true, 1);
AddEntityCollideCallback("lever_2", "leverdown", "lever2", true, 1);
AddEntityCollideCallback("lever_3", "leverdown", "lever3", true, 1);
AddEntityCollideCallback("lever_4", "leverup", "lever4", true, 1);
AddEntityCollideCallback("lever_5", "leverdown", "lever5", true, 1);
AddEntityCollideCallback("lever_6", "leverup", "lever6", true, 1);
}
///Lever Puzzle
void PerformLeverTaskCompleted()
{
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0.5f, false);
StartEffectFlash(1, 0.4, 1);
}
void lever1 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void lever2 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void lever3 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void lever4 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void lever5 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void lever6 (string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Levers", 1);
CheckLevers();
}
void CheckLevers()
{
if (GetLocalVarInt("Levers") == 6)
{
PerformLeverTaskCompleted();
}
}
Everything works as it should, except for the fact that you don't have to actually have to have the puzzle correct in the end, just have each lever in the correct position at some time because it'll add a value each time a lever is put into a position. So how do I get it to subtract that value if it's moved out of position?
I've tried, but I just get errors each time I try to fix this.
~Thank you
RandomGuy