Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting noob, help needed!
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#1
Scripting noob, help needed!

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);
}
05-22-2011, 04:45 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: Scripting noob, help needed!

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:

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");
}
void TimerFunc(string &in asTimer)
{
     SetEntityActive("servant_grunt_1", true);
}

05-22-2011, 12:15 PM
Find
Karai16 Offline
Member

Posts: 164
Threads: 24
Joined: Apr 2011
Reputation: 0
#3
RE: Scripting noob, help needed!

(05-22-2011, 12:15 PM)Kyle Wrote: 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:

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");
}
void TimerFunc(string &in asTimer)
{
     SetEntityActive("servant_grunt_1", true);
}
wow Kyle, you're everywhere today O.o ... I just wanted to put in the same thing Tongue saves me work though.

Custom stories:
Her Games (100% Complete)
Her Games, All Bugs Fixed (100% Complete)
05-22-2011, 02:16 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: Scripting noob, help needed!

Thanks. I know, I can be at 3 places at once. It's my speciality. :p

05-22-2011, 02:26 PM
Find
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#5
RE: Scripting noob, help needed!

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.

05-26-2011, 04:19 AM
Find




Users browsing this thread: 1 Guest(s)