You are on page 1of 6

//File name: used_cnvrt_lever

//Created by: Shawn Lucas


//Created on: February 16, 2008

/*This script goes in floor lever's OnUsed tab. It controls the combination &
separation of the Color Vessels. Activate color lights.Position certain primary
color NPCs on outside converters. Pull lever. NPCs combine & transform into new
NPC, which appears on middle converter. Put secondary color NPC on middle
converter. Pull lever. NPC turns back into primary color NPCs from which it was
created. Ex. Red & Green NPCs combine to make Yellow NPC, which can be separated
back into Red & Green NPCs. PC will need to do this several times to progress
through module puzzles. Note: Objects created within a trigger can't be
recognized as being within the trigger until they've exited it and re-entered
it. File "trig_conditions" is used in this script.*/

void main()
{
//Defines PC.
object oPC = GetLastUsedBy();

//Defines triggers, which will be used as sub areas.


object oTriggerA = GetObjectByTag("TT_A");
object oTriggerB = GetObjectByTag("TT_B");
object oTriggerC = GetObjectByTag("TT_C");

//Defines waypoints & locations.


object oWaypointA = GetObjectByTag("WP_A");
object oWaypointB = GetObjectByTag("WP_B");
object oWaypointC = GetObjectByTag("WP_C");
location lLocationA = GetLocation(oWaypointA);
location lLocationB = GetLocation(oWaypointB);
location lLocationC = GetLocation(oWaypointC);

//Defines NPCs.
object oNPC1;
object oNPC2;
object oRed = GetObjectByTag("RED_NPC");
object oBlue = GetObjectByTag("BLUE_NPC");
object oGreen = GetObjectByTag("GREEN_NPC");
object oCyan = GetObjectByTag("CYAN_NPC");
object oYellow = GetObjectByTag("YELLOW_NPC");
object oMagenta = GetObjectByTag("MAGENTA_NPC");

//Defines lights.
object oLight1;
object oLight2;
object oRedLight = GetObjectByTag("ShaftofLightRed");
object oBlueLight = GetObjectByTag("ShaftofLightBlue");
object oGreenLight = GetObjectByTag("ShaftofLightGreen");
object oCyanLight = GetObjectByTag("ShaftofLightCyan");
object oYellowLight = GetObjectByTag("ShaftofLightYellow");
object oMagentaLight = GetObjectByTag("ShaftofLightPurple");

//Defines sparks.
object oSparks1;
object oSparks2;
object oRedSparks = GetObjectByTag("MagicSparksRed");
object oBlueSparks = GetObjectByTag("MagicSparksBlue");
object oGreenSparks = GetObjectByTag("MagicSparksGreen");
object oCyanSparks = GetObjectByTag("MagicSparksCyan");
object oYellowSparks = GetObjectByTag("MagicSparksYellow");
object oMagentaSparks = GetObjectByTag("MagicSparksPurple");

//Defines the NPCs' names.


string sNPCName01;
string sNPCName02;
string sNPCName03;
string sRed = GetName(oRed);
string sBlue = GetName(oBlue);
string sGreen = GetName(oGreen);
string sCyan = GetName(oCyan);
string sYellow = GetName(oYellow);
string sMagenta = GetName(oMagenta);

//Defines strings.
string sNewNPC01;
string sNewNPC02;

//Defines VFX & float.


effect eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
float fD = 0.0;

//Makes it look as if lever has been pulled &


//automatically reset.
ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);

//Execute script that returns which NPCs are


//within which triggers.
ExecuteScript("trig_conditions", OBJECT_SELF);

//Defines int, which determines NPC/NPCs to be


//destroyed & created.
int iLever = GetLocalInt(OBJECT_SELF, "iState");

//Defines object and variable.


object oElrendur = GetObjectByTag("ELRENDUR");
int iColor = GetLocalInt(oElrendur, "iColor");

/*This section fires if 2 primary color NPCs are


in the correct triggers & color lights have been selected.
See "trig_conditions" & "at_set_color_1-6".*/
if(iLever == 1 && iColor >= 1)
{
//If Red & Blue are in triggers A & C.
if(GetIsInSubArea(oRed, oTriggerA) && GetIsInSubArea(oBlue, oTriggerC))
{
//NPCs in triggers.
oNPC1 = oRed;
oNPC2 = oBlue;

//NPC to be created.
sNewNPC01 = "magentavessel";

//NPC names.
sNPCName01 = sRed;
sNPCName02 = sBlue;
sNPCName03 = "Magenta Vessel";

//Lights & sparks.


oLight1 = oRedLight;
oLight2 = oBlueLight;
oSparks1 = oMagentaSparks;

//Sets variable which causes new NPC to move out of trigger.


SetLocalInt(oTriggerB, "iMoveNPC", 1);
}

//If Red & Green are in triggers A & C.


else if(GetIsInSubArea(oRed, oTriggerA) && GetIsInSubArea(oGreen, oTriggerC) && iColor == 1)
{
//NPCs in triggers.
oNPC1 = oRed;
oNPC2 = oGreen;

//NPC to be created.
sNewNPC01 = "yellowvessel";

//NPC names.
sNPCName01 = sRed;
sNPCName02 = sGreen;
sNPCName03 = "Yellow Vessel";

//Lights & sparks.


oLight1 = oRedLight;
oLight2 = oGreenLight;
oSparks1 = oYellowSparks;

//Sets variable which causes new NPC to move out of trigger.


SetLocalInt(oTriggerB, "iMoveNPC", 2);
}

//If Blue & Green are in triggers A & C.


else if(GetIsInSubArea(oBlue, oTriggerA) && GetIsInSubArea(oGreen, oTriggerC))
{
//NPCs in triggers.
oNPC1 = oBlue;
oNPC2 = oGreen;

//NPC to be created.
sNewNPC01 = "cyanvessel";

//NPC names.
sNPCName01 = sBlue;
sNPCName02 = sGreen;
sNPCName03 = "Cyan Vessel";

//Lights & sparks.


oLight1 = oBlueLight;
oLight2 = oGreenLight;
oSparks1 = oCyanSparks;

//Sets variable which causes new NPC to move out of trigger.


SetLocalInt(oTriggerB, "iMoveNPC", 3);
}

//Destroy lights and sparks.


DestroyObject(oLight1);
DestroyObject(oLight2);
DestroyObject(oSparks1);

//Apply VFX & destroy objects.


ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationA, 8.0);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationC, 8.0);
DestroyObject(oNPC1);
DestroyObject(oNPC2);

//Apply VFX & create object.


ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationB, 8.0);
CreateObject(OBJECT_TYPE_CREATURE, sNewNPC01, lLocationB);

//Display text stating old objects became new object.


DelayCommand(fD+=2.5, FloatingTextStringOnCreature

("The " + sNPCName01 + " and " + sNPCName02 +" became the " + sNPCName03 + ".", oPC, FALSE));

//Reset iColor to 0.
SetLocalInt(oElrendur, "iColor", 0);
}

/*This section fires if 1 secondary color NPC is


in trigger B & color lights have been selected.
See "trig_conditions" & "at_set_color_1-6".*/
else if(iLever == 2)
{
//If Cyan is in trigger B.
if(GetIsInSubArea(oCyan, oTriggerB))
{
//NPC in trigger.
oNPC1 = oCyan;

//NPCs to be created.
sNewNPC01 = "bluevessel";
sNewNPC02 = "greenvessel";

//NPC names.
sNPCName01 = sCyan;
sNPCName02 = "Blue Vessel";
sNPCName03 = "Green Vessel";

//Lights & sparks.


oSparks1 = oBlueSparks;
oSparks2 = oGreenSparks;
oLight1 = oCyanLight;
//Sets variable which causes new NPCs to move out of triggers.
SetLocalInt(oTriggerA, "iMoveNPC", 3);
}

//If Yellow is in trigger B.


else if(GetIsInSubArea(oYellow, oTriggerB))
{
//NPC in trigger.
oNPC1 = oYellow;

//NPCs to be created.
sNewNPC01 = "redvessel";
sNewNPC02 = "greenvessel";

//NPC names.
sNPCName01 = sYellow;
sNPCName02 = "Red Vessel";
sNPCName03 = "Green Vessel";

//Lights & sparks.


oSparks1 = oRedSparks;
oSparks2 = oGreenSparks;
oLight1 = oYellowLight;

//Sets variable which causes new NPCs to move out of triggers.


SetLocalInt(oTriggerA, "iMoveNPC", 2);
}

//If Magenta is in trigger B.


else if(GetIsInSubArea(oMagenta, oTriggerB))
{
//NPC in trigger.
oNPC1 = oMagenta;

//NPCs to be created.
sNewNPC01 = "redvessel";
sNewNPC02 = "bluevessel";

//NPC names.
sNPCName01 = sMagenta;
sNPCName02 = "Red Vessel";
sNPCName03 = "Blue Vessel";

//Lights & sparks.


oSparks1 = oRedSparks;
oSparks2 = oBlueSparks;
oLight1 = oMagentaLight;

//Sets variable which causes new NPCs to move out of triggers.


SetLocalInt(oTriggerA, "iMoveNPC", 1);
}

//Destroy lights and sparks.


DestroyObject(oSparks1);
DestroyObject(oSparks2);
DestroyObject(oLight1);

//Apply VFX & destroy object.


ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationB, 8.0);
DestroyObject(oNPC1);

//Apply VFX & create objects.


ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationA, 8.0);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLocationC, 8.0);
CreateObject(OBJECT_TYPE_CREATURE, sNewNPC01, lLocationA);
CreateObject(OBJECT_TYPE_CREATURE, sNewNPC02, lLocationC);

//Display text stating old object became new objects.


DelayCommand(fD+=2.5, FloatingTextStringOnCreature

("The " + sNPCName01 + " split into the " + sNPCName02 +" and " + sNPCName03 + ".", oPC, FALSE));

//Reset iColor to 0.
SetLocalInt(oElrendur, "iColor", 0);
}

//If trigger does not contain any of


//the right combinations of NPCs.
else if(iLever == 3)
{
//Display text.
FloatingTextStringOnCreature("Nothing happened.", oPC, FALSE);
}
}