Script help - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: Script help (/thread-18323.html) |
Script help - skatekai - 09-14-2012 Hello friends, I am creating a new story and I need a personalized help with a script. If you have not played the amnesia story, but on the map there are three puzzles 13_machine_room and'm copying because I loved it. The problem is that I work on my map. For example when you have to get the three little pieces in a machine, I do not accept them, tells me that this object does not fit or when you have to turn up and down the 6 levers. Then I leave here the script that or I say it as guidance. //////////////////////////// // Run first time starting map void OnStart() { for(int i=1;i<7;i++){ SetEntityConnectionStateChangeCallback("lever_"+i, "LeverRiddle"); } } //////////////////////////// // Run when entering map void OnEnter() { PreloadSound("impact_generic_hard_low"); PreloadSound("13_rod_in"); PreloadSound("13_press_done"); PreloadSound("13_steam"); PreloadSound("13_press_fail"); PreloadSound("17_attach_crank"); PreloadSound("13_rod_out"); PreloadParticleSystem("ps_steam"); PreloadParticleSystem("ps_steam_puff"); AutoSave(); } //////////////////////////// // Run when leaving map void OnLeave() { } void UseRod(string &in asItem, string &in asEntity) { if(GetLocalVarInt(asEntity) == 1){ //SetMessage("MapsLevel03-2", "SlotToken", 0); PlaySoundAtEntity("clank", "impact_generic_hard_low", asEntity, 0.5f, false); return; } if(asItem == "guiding_rod01_1" && asEntity == "ra01"){ SetLocalVarString(asItem, asEntity+"_correct"); } else if(asItem == "guiding_rod02_1" && asEntity == "ra02"){ SetLocalVarString(asItem, asEntity+"_correct"); } else if(asItem == "guiding_rod03_1" && asEntity == "ra03"){ SetLocalVarString(asItem, asEntity+"_correct"); } else { SetLocalVarString(asItem, asEntity+"_error"); } RemoveItem(asItem); CreateEntityAtArea(asItem, asItem, "magic_"+asEntity, true); SetEntityCallbackFunc(asItem, "PickRod"); SetLocalVarInt(asEntity, 1); AddLocalVarInt("RodsInPosition", 1); if(GetLocalVarString("guiding_rod01") == "ra01_correct" && GetLocalVarString("guiding_rod02") == "ra02_correct" && GetLocalVarString("guiding_rod03") == "ra03_correct"){ //setMessage("", "", 0);////////////////////////7777 //////////////////////77 /////////////////Ted SetLocalVarInt("GuideOK", 1); PlaySoundAtEntity("done"+asItem, "13_press_done.snt", "magic_"+asEntity, 0, false); for(int i=1;i<=6;i++){ CreateParticleSystemAtEntity("PreesP"+i, "ps_steam.ps", "PressParticles"+i, true); PlaySoundAtEntity("PressS"+i, "13_steam", "PressParticles_"+i, 0.5, true); } for(int i=1;i<=3;i++) SetEntityInteractionDisabled("guiding_rod0"+i, true); return; } /*Incorrect rod positions*/ if(GetLocalVarInt("RodsInPosition") == 3){ PlaySoundAtEntity("error1", "13_press_fail.snt", "magic_"+asEntity, 0, false); PlaySoundAtEntity("error2", "17_attach_crank.snt", "magic_"+asEntity, 0.5f, false); } AddDebugMessage(asItem+" Value: "+GetLocalVarInt(asItem), false); } void PickRod(string &in asEntity, string &in asType){ /*If a rod is removed, set the area to empty */ if(StringContains(GetLocalVarString(asEntity), "ra01")){ SetLocalVarInt("ra01", 0); PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra01", 0, false); CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra01", false); } else if(StringContains(GetLocalVarString(asEntity), "ra02")){ SetLocalVarInt("ra02", 0); PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra02", 0, false); CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra02", false); } else if(StringContains(GetLocalVarString(asEntity), "ra03")){ SetLocalVarInt("ra03", 0); PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra03", 0, false); CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra03", false); } AddLocalVarInt("RodsInPosition", -1); SetLocalVarString(asEntity, "_error"); AddDebugMessage(asEntity+" Value: "+GetLocalVarString(asEntity), false); } void LeverRiddle(string &in asEntity, int alState) { if(alState == -1){ if(asEntity == "lever_machine_lever01_1") SetLocalVarInt("up_"+asEntity, 3); else if(asEntity == "lever_machine_lever01_2") SetLocalVarInt("up_"+asEntity, 3); else if(asEntity == "lever_machine_lever01_3") SetLocalVarInt("up_"+asEntity, 5); else if(asEntity == "lever_machine_lever01_4") SetLocalVarInt("up_"+asEntity, 1); else if(asEntity == "lever_machine_lever01_5") SetLocalVarInt("up_"+asEntity, 2); else if(asEntity == "lever_machine_lever01_6") SetLocalVarInt("up_"+asEntity, 4); CheckValue(asEntity); AddDebugMessage("Lever Min & up value: " + GetLocalVarInt("up_value"), false); } else if(alState == 1){ if(asEntity == "lever_machine_lever01_1") SetLocalVarInt("down_"+asEntity, 1); else if(asEntity == "lever_machine_lever01_2") SetLocalVarInt("down_"+asEntity, 5); else if(asEntity == "lever_machine_lever01_3") SetLocalVarInt("down_"+asEntity, 4); else if(asEntity == "lever_machine_lever01_4") SetLocalVarInt("down_"+asEntity, 5); else if(asEntity == "lever_machine_lever01_5") SetLocalVarInt("down_"+asEntity, 2); else if(asEntity == "lever_machine_lever01_6") SetLocalVarInt("down_"+asEntity, 2); CheckValue(asEntity); AddDebugMessage("Lever Max & down value: " + GetLocalVarInt("down_value"), false); } else if(alState == 0){ SetLocalVarInt("up_"+asEntity, 0); SetLocalVarInt("down_"+asEntity, 0); AddDebugMessage("Lever Mid", false); } /*All levers correct */ if(GetLocalVarInt("up_value") == 8 && GetLocalVarInt("down_value") == 8) { for(int i=1;i<7;i++) { SetLeverStuckState("lever_"+i, GetLeverState("lever_"+i), true); } } } void CheckValue(string sEntity) { PlaySoundAtEntity("s"+sEntity, "lever_mech_min_max", sEntity, 0.0f, false); SetLocalVarInt("up_value", 0); SetLocalVarInt("down_value", 0); for(int i=1;i<=6;i++){ AddLocalVarInt("up_value", GetLocalVarInt("up_lever_"+i)); AddLocalVarInt("down_value", GetLocalVarInt("down_lever_"+i)); } } Thank you very much and I hope you understand my English xD because I'm Spanish. RE: Script help - Robby - 09-14-2012 I'd love to help, but this is so complicated to me. I just learned about these "LocalVarInt" parts, so I don't know how to use these. Maybe somebody else will help? |