![]() |
Scripting noob, help needed! - 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 (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: Scripting noob, help needed! (/thread-8179.html) |
Scripting noob, help needed! - willochill - 05-22-2011 I just starting scripting a level i made and in this level there is a bone saw (named bone_saw_2) in one room, and another room is blocked off with wooden boards. basically this is what i want to happen: when you use the saw with the boards the boards fall apart, and a grunt in the blocked off room awakens. so i have a set of inactive broken wooden boards (right near the intact boards) which i want to activate, and the intact boards will be deactivated, to create the illusion of the boards breaking. the grunt in the room is inactive and i want to activate it as well once the saw hits the intact boards. i scripted this but when i test it in the map it's still not working. i copied/pasted the script i wrote for the level below. please tell me what i'm doing wrong here, very confused! (P.S. to have a script .hps file correspond to a certain map, do you just need to name them the same thing, or is it more complicated than that? also, i have all the maps im testing and their scripts (or at least this one i wrote) in a folder in the "maps" folder in common/amnesia tdd. should they be somewhere else for the script to correspond to it?) void OnStart () { AddEntityCollideCallback("bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true, 1); } void SawGruntAlert(string &in asParent, string &in asChild, int alState) { SetEntityActive("wooden_boards_block_1", false); SetEntityActive("wooden_boards_block_broken_1", true); SetEntityActive("servant_grunt_1", true); } RE: Scripting noob, help needed! - Kyle - 05-22-2011 Well, you could say I can literally almost script anything with the HPL 2 engine. I see what you are trying to do, since the bone_saw_2 is a item, you need to go into your inventory and use it on the boards. I could make it so complex to where it shows the animation of the saw cutting the boards, but I'm short on time. :/ Try this: Code: void OnStart() RE: Scripting noob, help needed! - Karai16 - 05-22-2011 (05-22-2011, 12:15 PM)Kyle Wrote: Well, you could say I can literally almost script anything with the HPL 2 engine.wow Kyle, you're everywhere today O.o ... I just wanted to put in the same thing ![]() RE: Scripting noob, help needed! - Kyle - 05-22-2011 Thanks. I know, I can be at 3 places at once. It's my speciality. :p RE: Scripting noob, help needed! - willochill - 05-26-2011 Okay, so first of all, this was great, problem was the sound of the saw didn't stop, so this is how I changed the script: void OnStart() { AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true); } void SawGruntAlert(string &in asItem, string &in asEntity) { SetEntityActive("wooden_boards_block_1", false); SetEntityActive("wooden_boards_block_broken_1", true); PlaySoundAtEntity("", "23_saw2.snt", "Player", 0, false); AddTimer("", 1, "TimerFunc"); AddTimer("StopSoundTimer", 1, "TimerFunc2"); } void TimerFunc(string &in asTimer) { SetEntityActive("servant_grunt_1", true); } void TimerFunc2(string &in asTimer) { StopSound("23_saw2.snt", 0); } But it didn't do anything. Second, I wanted to start an ambience sound file playing from the beginning of the map so this is what I added: void OnStart() { FadeInSound("amb_guardian.snt", 0, abPlayStart); } { AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true); } void SawGruntAlert(string &in asItem, string &in asEntity) { SetEntityActive("wooden_boards_block_1", false); SetEntityActive("wooden_boards_block_broken_1", true); PlaySoundAtEntity("", "23_saw2.snt", "Player", 0, false); AddTimer("", 1, "TimerFunc"); AddTimer("StopSoundTimer", 1, "TimerFunc2"); } void TimerFunc(string &in asTimer) { SetEntityActive("servant_grunt_1", true); } void TimerFunc2(string &in asTimer) { StopSound("23_saw2.snt", 0); } Once i add the fade in sound the map crashes. Third of all although I don't want to learn how to do it all could you post whatever script you would need to make the sawing animation with the sound? that would be a lot cooler than just what it is now. thx. |