Help! - LoneWolf - 12-14-2010
Code: ////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "playsound", "playsound", true, 1);
AddEntityCollideCallback("Player", "abc", "abc", true, 1);
AddEntityCollideCallback("Player", "def", "def", true, 1);
AddEntityCollideCallback("Player", "ghi", "ghi", true, 1);
AddEntityCollideCallback("Player", "jkl", "jkl", true, 1);
AddEntityCollideCallback("Player", "mno", "mno", true, 1);
AddEntityCollideCallback("Player", "pqr", "pqr", true, 1);
AddEntityCollideCallback("Player", "stu", "stu", true, 1);
AddUseItemCallback("", "PickFinalAcid", "web_2", "acid", true);
//----ENTITY INIT----//
for(int i=1;i<=4;i++) {
ConnectEntities("Part_"+i, "Valve_"+i,
"Valve_"+i+"_AreaValve", false, 0, "InteractTurnValve");
SetWheelStuckState("Valve_"+i, -1, false);
ConnectEntities("Ignite", "ValveIgnite", "Valve_1_AreaBottle",
false, 0, "InteractTurnOnAcidMachine");
SetEntityActive("chemical_container_static_1", false);
SetEntityActive("chemical_container_2", false);
SetWheelStuckState("ValveIgnite", -1, false);
AddUseItemCallback("placebottle", "chemical_container_1",
"AreaUseMachine", "ItemJarOnMachine", true);
AddUseItemCallback("placebottle2", "chemical_container_1",
"AreaPlaceJar", "ItemJarOnMachine", true);
AddUseItemCallback("placebottle3", "chemical_container_1",
"ValveIgnite", "ItemJarOnMachine", true);
for(int i=1;i<=4;i++) {
AddUseItemCallback("placebottlev"+i, "chemical_container_1",
"Valve_"+i, "ItemJarOnMachine", true);
AddUseItemCallback("Chemicalvi_"+i, "Chemical_"+i,
"ValveIgnite", "AddChemical", true);
AddUseItemCallback("Chemicala_"+i, "Chemical_"+i,
"AreaUseMachine", "AddChemical", true);
AddUseItemCallback("Chemicalm_"+i, "Chemical_"+i,
"acid_machine_1", "AddChemical", true);
for(int j=1;j<=4;j++)
AddUseItemCallback("Chemicalv_"+i, "Chemical_"+i,
"Valve_"+j, "AddChemical", true);
}
SetEntityPlayerInteractCallback("ValveIgnite",
"InteractAcidMachine", false);
for(int i=1;i<=4;i++) SetEntityPlayerInteractCallback("Valve_"+i,
"InteractAcidMachine", false);
AddUseItemCallback( "placeepoxy", "chemical_container_2",
"cave_in_1", "UseEpoxyOnCavein", false );
AddEntityCollideCallback("Player", "AreaBoomDamage",
"CollideBoomArea", false, 1);
AddEntityCollideCallback("Player", "AreaBoomDeath",
"CollideBoomArea", false, 1);
AddEntityCollideCallback("Player", "AreaBoomEscape",
"CollideBoomArea", false, 1);
BlockHint("EntityWheel");
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++)
{
GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
GiveItemFromFile("chemical_container_2",
"chemical_container_epoxy.ent");
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
//----PRELOADING----//
PreloadSound("12_epoxy_flow");
PreloadSound("12_epoxy_fill"); PreloadSound("puzzle_place_jar");
PreloadSound("12_epoxy_drip"); PreloadSound("player_climb");
PreloadSound("player_crouch"); PreloadSound("12_epoxy_blow");
PreloadSound("12_noise_1"); PreloadSound("12_noise_2");
PreloadSound("12_noise_2"); PreloadSound("12_noise_3");
PreloadSound("12_noise_4"); PreloadSound("03_rock_move");
PreloadSound("puzzle_place_jar"); PreloadSound
("puzzle_add_chemical"); PreloadSound("general_fire_burning_low");
PreloadSound("puzzle_boil"); PreloadSound("puzzle_gas");
PreloadSound("puzzle_boil_low");
PreloadSound("puzzle_acid"); PreloadSound("puzzle_acid_success");
PreloadSound("puzzle_acid_fail");
PreloadSound("04_water_puff"); PreloadSound("general_thunder");
PreloadParticleSystem("ps_liquid_epoxy");
PreloadParticleSystem("ps_dust_drilling");
PreloadParticleSystem("ps_liquid_epoxy_splatt");
PreloadParticleSystem("ps_liquid_epoxy_drip");
PreloadParticleSystem("ps_acid_machine_bubble_large02");
PreloadParticleSystem("ps_acid_machine_bubble_end");
PreloadParticleSystem("ps_acid_machine_bubble_large");
PreloadParticleSystem("ps_acid_machine_bubble_small");
SetWheelStuckState("ValveIgnite", -1, false);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
void playsound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("guardian_distant2.snt", "guardian_distant2.snt",
"guardian_distant2.snt", 0, false);
}
void abc(string &in asParent, string &in asChild, int alState)
{
GivePlayerDamage(500, "BloodSplat", true, false);
}
void def(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "1a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "2a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "3a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "4a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "5a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "6a", false);
CreateParticleSystemAtEntity("", "ps_break_cavein.ps", "7a", false);
CreateParticleSystemAtEntity("", "ps_water_dump.ps", "8a", false);
CreateParticleSystemAtEntity("", "ps_water_dump.ps", "9a", false);
PlaySoundAtEntity("05_rock_fall_2.snt", "05_rock_fall_2.snt",
"05_rock_fall_2.snt", 0, false);
PlaySoundAtEntity("guardian_ontop.snt", "guardian_ontop.snt",
"guardian_ontop.snt", 0, false);
StartScreenShake(0.1, 4.0, 0.1, 0.5);
}
void ghi(string &in asParent, string &in asChild, int alState)
{
GivePlayerDamage(500, "BloodSplat2", true, false);
}
void jkl(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("amb_alert.snt", "amb_alert.snt", "amb_alert.snt", 0,
false);
GiveSanityDamage(25, true);
}
void mno(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_1", true);
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_20", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_21", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_22", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_23", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_24", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_25", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_26", 3.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_27", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_28", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_29", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_30", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_31", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_32", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_33", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_34", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_35", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_36", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_37", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_38", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_39", 5.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_40", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_41", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_42", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_43", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_44", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_45", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_46", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_47", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_48", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_49", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_50", 3.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_51", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_52", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_53", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_54", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_55", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_56", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_57", 1.0f, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_58", 1.0f, "");
}
void pqr(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_59", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_60", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_61", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_62", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_63", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_64", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_65", 3.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_66", 1.0f, "");
AddEnemyPatrolNode("servant_brute_2", "PathNodeArea_67", 1.0f, "");
}
void stu(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_3", true);
StartPlayerLookAt("servant_brute_3", 5, 5, "");
}
void acid(string &in asItem, string &in asEntity)
{
AddTimer("music", 1, "TimerMusicDelay");
PlaySoundAtEntity("gameplay_acid_web.snt", "gameplay_acid_web.snt",
"gameplay_acid_web.snt", 0, false);
SetEntityActive("web_2", false);
RemoveItem("PickFinalAcid");
CreateParticleSystemAtEntity("", "ps_acid_web_dissolve.ps",
"ps_acid_web_dissolve.ps", false);
}
void TimerMusicDelay(string &in asTimer)
{
PlayMusic("02_puzzle", false, 1, 0.1f, 10, false);
}
//////////////////////
//BEGIN ACID MACHINE//
/*Use jar on machine to place it under pipe
*/
void ItemJarOnMachine(string &in asItem, string &in asEntity)
{
SetEntityActive("chemical_container_static_1", true);
RemoveItem(asItem);
PlaySoundAtEntity("PlaceJar","puzzle_place_jar",
"AreaCompleteSuccess", 0, false);
SetLocalVarInt("chemical_container_static_1", 1);
}
/*Use chemicals on machine or valves to add it to bottles
*/
void AddChemical(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
AddLocalVarInt("ChemicalsInMachine", 1);
SetEntityActive("JarEmpty"+asItem, false);
SetEntityActive("Jar"+asItem, true);
PlaySoundAtEntity(asItem+"Sound","puzzle_add_chemical.snt",
asEntity, 1, false);
FadeLightTo("Light"+asItem, -1, -1, -1, -1, 0.5f, 0.1f);
//Moved sanity boost to first instead of last, migth be better to
boost early if player didn't get all 4.
//if(GetLocalVarInt("ChemicalsInMachine") == 1)
// GiveSanityBoostSmall();
//if(GetLocalVarInt("ChemicalsInMachine") == 3 )
// BreakMyStairs();
if(GetLocalVarInt("ChemicalsInMachine") == 4)
{
CompleteQuest("04FindChemicals","04FindChemicals");
UnBlockHint("EntityWheel");
for(int i=1;i<=4;i++)
SetEntityPlayerInteractCallback("Valve_"+i,
"InteractAcidMachine02", true);
}
}
/*When touching the vales
*/
void InteractAcidMachine(string &in asEntity)
{
if(GetLocalVarInt("ChemicalsInMachine") != 4)
{
AddQuest("04FindChemicals","04FindChemicals");
SetMessage("Ch01Level04", "InteractAcidMachineNoChem",-1);
}
else if(GetLocalVarInt("ChemicalsInMachine") == 4)
{
SetWheelStuckState("ValveIgnite", 0, false);
}
}
void InteractAcidMachine02(string &in asEntity)
{
if(GetLocalVarInt("ValveIgniteFirst") == 0)
{
SetMessage("Ch01Level03", "MachineNeedsToStart", 0);
SetLocalVarInt("ValveIgniteFirst", 1);
for(int i=1;i<=4;i++)
SetEntityPlayerInteractCallback("Valve_"+i,
"InteractAcidMachine", false);
}
}
/*Moving the big valve will turn on the burners and ready the machine
*/
void InteractTurnOnAcidMachine(string &in asName, string &in asMainEntity,
string &in asConnectEntity, int alState)
{
AddDebugMessage("Connect "+asMainEntity+" and "+asConnectEntity+"
state:"+alState, false);
if(alState == 1)
{
for(int i=1;i<=4;i++)
{
CreateParticleSystemAtEntity(asName+"Fire"+i,
"ps_fire_candle.ps", "Valve_"+i+"_AreaBottle", false);
FadeLightTo("Valve_"+i+"_Light", -1, -1, -1, -1,
0.4f, 1);
SetWheelStuckState("Valve_"+i, 0, true);
}
SetLocalVarInt("ValveIgniteFirst", 1);
FadeLightTo("LightBurn", -1, -1, -1, -1, 3.0f, 2);
PlaySoundAtEntity("IgniteSound", "general_fire_burning_low",
"Valve_1_AreaBottle", 1, false);
SetWheelStuckState("ValveIgnite", 1, true);
}
else if(alState == -1)
{
for(int i=1;i<=4;i++){
DestroyParticleSystem(asName+"Fire"+i);
FadeLightTo("Valve_"+i+"_Light", -1, -1, -1, -1, 0,
1);
SetWheelStuckState("Valve_"+i, -1, true);
}
FadeLightTo("LightBurn", -1, -1, -1, -1, 0, 2);
StopSound("IgniteSound", 1);
}
}
/*Turning the four valves on/off to try and get the sequence right
*/
void InteractTurnValve(string &in asName, string &in asMainEntity, string
&in asConnectEntity, int alState)
{
/*START WHAT HAPPENS WHEN VAVLES ARE TURNED ON
*/
if(alState == 1)
{
/*Mark Valve as on
*/
//SetLocalVarInt(asMainEntity, 1);
AddLocalVarInt("ValvesNrOn", 1);
AddDebugMessage("ValvesNrOn: "+GetLocalVarInt("ValvesNrOn")
+" And Feet "+GetLocalVarInt("DoBigFeet"), false);
if(GetLocalVarInt("ValvesNrOn") == 0)
{
SetWheelStuckState("ValveIgnite", -1, true);
PlaySoundAtEntity("FinalBoil","puzzle_boil.snt",
"Valve_4_AreaValve", 1, false);
CreateParticleSystemAtEntity("FinalSteam",
"ps_acid_machine_bubble_large02.ps", "Valve_4_AreaValve", false);
CreateParticleSystemAtEntity("FinalFlow",
"ps_acid_machine_bubble_end.ps", "AreaCompleteSuccess", false);
FadeLightTo("LightBurn", -1, 1, -1, -1, 3.0f, 5);
FadeLightTo("LightAcid", -1, -1, -1, -1, 0.3f, 2);
AddTimer("done", 2, "TimerAcidDone");
}
else DoEffectLarge(asName, asConnectEntity);
/*Only an event, nothing puzzle related
*/
if(GetLocalVarInt("ValvesNrOn") == -2 && GetLocalVarInt
("DoBigFeet") == 0)
{
AddTimer("Feet_1", 2.5f, "TimerBigFeet");
PlaySoundAtEntity("bang","general_thunder.snt",
"Player", 0, false);
PlaySoundAtEntity("biggus","04_big_feet.snt",
"Player", 0, false);
SetLocalVarInt("DoBigFeet", 1);
}
}
/*START WHAT HAPPENS WHEN VAVLES ARE TURNED OFF
*/
else if(alState == -1)
{
AddLocalVarInt("ValvesNrOn", -1);
DestroyParticleSystem(asName+"PSteam");
StopSound(asName+"SBoil",1); StopSound(asName+"SSteam",1);
}
AddDebugMessage("Rate of success "+GetLocalVarInt("RoadToSuccess"),
false);
AddDebugMessage(asMainEntity+" is turned to "+alState, true);
}
/*Large effects as correct valve rotated
*/
void DoEffectLarge(string &in asName, string &in asWhere)
{
CreateParticleSystemAtEntity(asName+"PSteam",
"ps_acid_machine_bubble_large.ps", asWhere, false);
PlaySoundAtEntity(asName+"SBoil","puzzle_boil_low.snt", asWhere, 1,
false);
PlaySoundAtEntity(asName+"SSteam","puzzle_gas.snt", asWhere, 1,
false);
AddLocalVarInt("RoadToSuccess", 1);
}
/*Small effects as incorrect valve rotated
*/
void DoEffectSmall(string &in asName, string &in asWhere)
{
CreateParticleSystemAtEntity(asName+"PSteam",
"ps_acid_machine_bubble_small.ps", asWhere, false);
PlaySoundAtEntity(asName+"SBoil","puzzle_boil_low.snt", asWhere, 1,
false);
}
/*When reseting machine on more than 2 valves turned, this timer turns it on
again
*/
void TimerReleaseValves(string &in asTimer)
{
for(int i=1;i<=4;i++) SetWheelStuckState("Valve_"+i, 0, false);
SetLocalVarInt("RoadToSuccess", 0);
}
/*The acid spit on success, if no jar present the acid will just spill and
it is possible to try again
*/
void TimerAcidDone(string &in asTimer)
{
DestroyParticleSystem("Part4PSteam");
DestroyParticleSystem("FinalSteam");
PlaySoundAtEntity("AcidDone","puzzle_acid", "AreaCompleteSuccess",
0, false);
StopSound("FinalBoil",1);
FadeLightTo("LightAcid", -1, -1, -1, -1, 0, 4);
FadeLightTo("LightBurn", -1, 0.3f, -1, -1, 0, 3);
SetWheelStuckState("ValveIgnite", 0, true);
if(GetLocalVarInt("chemical_container_static_1") == 1)
{
SetEntityActive("chemical_container_static_1", false);
SetEntityActive("chemical_container_2", true);
PlaySoundAtEntity("AcidSuccess","puzzle_acid_success",
"AreaCompleteSuccess", 0, false);
//GiveSanityBoostSmall();
SetWheelStuckState("ValveIgnite", -1, true);
}
else
{
PlaySoundAtEntity("AcidFail","puzzle_acid_fail",
"AreaCompleteSuccess", 0, false);
SetMessage("Ch03Level26", "NoContainerBelowSqueezer", 0);
}
}
void PickFinalAcid(string &in asEntity, string &in asType)
{
SetGlobalVarString(asEntity, asEntity);
}
//END ACID MACHINE//
////////////////////////////////////
I get an unexpected end of file error for the end of my script (//END ACID MACHINE//
////////////////////////////////////
)
RE: Help! - DIGI Byte - 12-14-2010
(12-14-2010, 01:11 PM)LoneWolf Wrote: ------------------
that's a lot of code
------------------
I get an unexpected ending error for the end of my script (//END ACID MACHINE//
////////////////////////////////////
)
that error means it unexpectedly ended, meaning your most likely forgot to close something whether its a close bracket } or a semi-colon ;
did the code work at one stage, go and look at any changes you made since it last worked, you probably deleted or forgot to close something, i'll read over the code and see if I can find anything
RE: Help! - LoneWolf - 12-14-2010
I added most of it in today. I had alot of it already writin out in previous maps.
Anyway it says the error is at the ending, says unexpected end. But i dont know what i've done wrong... too much code to try fix it up. Also when i add a } to the end of the machine acid, it comes up with tons of unexpected tokens throughout my whole script.
unexpected end of file error on line ( 435 , 1 ) thats a space though.... wtf.
RE: Help! - Akumasama - 12-14-2010
Pro-tip, get Programmer's Notepad and set langauge to C/C++.
Then you will see brackets on the left of your code to see where a function ends.
That should make it alot easier to find your problem.
RE: Help! - LoneWolf - 12-14-2010
EDIT. Downloaded the programmers notepad. It helped alot, i found out that it was a } token that i was missing therefore a hwoel chunk of my script was missing.
Thanks.
|