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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ge15t's Help Thread!
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#1
Ge15t's Help Thread!

I have looked through all the tutorials and various web pages to deepen my knowledge of scripting and scripting with HPL2, but I still get a few problems.
So, I decided to just create one of these said problems. My current one is this:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

{
GiveItemFromFile("lantern", "lantern.ent");

for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
PlayMusic("01_amb_darkness.ogg", true, 1, 3, 0, true);
}


This is right isnt it? I want for "player" to collide with "mobspawn_1" which spawns a monster in the next room. The monster is of course not active or anything. But when I start the map, it crashes with fatal error main (12,1) unexpected token.

Sorry again for the newbie questions
02-19-2011, 07:48 AM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#2
RE: Ge15t's Help Thread!

Everything under SetEntityActive is not in any function. You need to place the lantern+tinderbox stuff in OnStart(), like this:

////////////////////////////
// Run first time starting map
void OnStart()
{
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
    GiveItemFromFile("lantern", "lantern.ent");
    for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
    PlayMusic("01_amb_darkness.ogg", true, 1, 3, 0, true);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
    SetEntityActive("servant_grunt_1" , true);
}

[Image: 2exldzm.png]
02-19-2011, 10:24 AM
Find
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#3
RE: Ge15t's Help Thread!

Thanks so much! Works perfectly now! Now im stuck on a new problem, I dont know what the function would be if when a door that is locked is trying to be opened it would play a sound file. So far this is all I got:

PlaySoundAtEntity("ramble", "CH01_DanielRamble_01", "door_1", 0);

what would be the function for this? eg, player attempts to open locked door, sound file is played, once only
(This post was last modified: 02-20-2011, 08:59 AM by Ge15t.)
02-20-2011, 08:58 AM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#4
RE: Ge15t's Help Thread!

These two
SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
Myfunc(string &in entity)
could work.

void OnStart()
{
SetEntityPlayerInteractCallback("Door", "Doorfunction", 0);
}

Doorfunction(string &in entity)
{
PlaySoundAtEntity("ramble", "CH01_DanielRamble_01", "door_1", 0);
}

Try it.

[Image: 2exldzm.png]
(This post was last modified: 02-20-2011, 09:38 AM by Oscar House.)
02-20-2011, 09:37 AM
Find
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#5
RE: Ge15t's Help Thread!

Thanks for the replies, but no that doesnt seem to work. I tried playing around with it a bit, but still crashes with fatal error. So is it possible to essentially make your own functions? Like what you did there?

EDIT: I found this in the script functions page, so slightly edited your layout there:

void SetEntityPlayerInteractCallback("Door", "Doorfunction", 0)
{
Doorfunction(string &in entity, string &in type);
PlaySoundAtEntity("ramble", "CH01_DanielRamble_01", "door_2", 0);
}

I have played around with the {} a bit as well, but still fatal error.
I am also having trouble with another function:
void OnStart()
{
AddEntityCollideCallback("Player" , "SoundArea_1" , "SoundFunc1" , true , 1);
}

and:
void SoundFunc1(string &in asParent , string &in asChild , int alState)
{
PlaySoundAtEntity("babycry", "insanity_baby_cry1.ogg", "Soundarea_1", 0.0f, false);
}

The game actually loads, but no sound is played when the soundarea is entered.. Without a crash I honestly do not see what I am doing wrong lol
(This post was last modified: 02-21-2011, 11:44 AM by Ge15t.)
02-21-2011, 11:03 AM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#6
RE: Ge15t's Help Thread!

I see now what I did wrong with my script, I forgot void.
void Doorfunction

Yes, you can make your own functions, just remember to call them!

For the sound problem, try playing insanity_baby_cry.snt instead.

[Image: 2exldzm.png]
02-21-2011, 04:48 PM
Find
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#7
RE: Ge15t's Help Thread!

I tried for the sound file first, and the sound still doesnt play. Which is weird, my AddEntityCollideCallback for the monster spawn works in script area 1 works fine, but when a sound file is attempted to be played in the same fashion, it doesnt work. Its almost as if the game ignores the function under void start.

As for the door bit, still not happening, fatal error. This is what it looks like atm:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "Soundarea_1" , "SoundFunc1" , true , 1);
SetEntityPlayerInteractCallback("Door", "Doorfunction", 0);
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
PlayMusic("04_amb.ogg", true, 1, 3, 0, true);
}

void Doorfunction(string &in entity, string &in type)

{
PlaySoundAtEntity("ramble", "CH01_DanielRamble_01.", "door_2", 0);
}

void SoundFunc1(string &in asParent , string &in asChild , int alState)
{
PlaySoundAtEntity("babycry", "insanity_baby_cry1.", "Soundarea_1", 0.0f, false);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
}

Is it because there is no actual 'function' for trying to open the door? Or is that automatically assumed by the game?
02-21-2011, 08:00 PM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#8
RE: Ge15t's Help Thread!

Okay, I just recreated the script in a map of my own.

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunc1", true, 1);
AddEntityCollideCallback("Player", "Soundarea_1", "SoundFunc1", true, 1);
SetEntityPlayerInteractCallback("door_2", "Doorfunction", false);
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
PlayMusic("04_amb.ogg", true, 1, 3, 0, true);
}

void Doorfunction(string &in asEntity, string &in asType)
{
PlaySoundAtEntity("ramble", "CH01_DanielRamble_01.snt", "door_2", 0.0f, false);
}

void SoundFunc1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("babycry", "insanity_baby_cry.snt", "Soundarea_1", 0.0f, false);
}

void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
}
Changed "Door" to "door_2", as it appears like that in Doorfunction
Added .snt and 0.0f, also changed 0 to false, all in the first PlaySoundAtEntity
Added .snt to insanity_baby_cry
Also, wiped off some spaces as that's how I like it Tongue
EDIT: And SetEntityPlayerInteractCallback("Door", "Doorfunction", false);

It works for me, sound plays, enemy appears.

[Image: 2exldzm.png]
(This post was last modified: 02-21-2011, 08:53 PM by Oscar House.)
02-21-2011, 08:52 PM
Find
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#9
RE: Ge15t's Help Thread!

Ok, that seems to have the baby cry sound working, but not the door sound to play. I have no idea whats wrong, because the map loads fine, but it ignores the function
(This post was last modified: 02-21-2011, 10:05 PM by Ge15t.)
02-21-2011, 09:47 PM
Find
Ge15t Offline
Junior Member

Posts: 48
Threads: 8
Joined: Feb 2011
Reputation: 0
#10
RE: Ge15t's Help Thread!

Bump for help! Still cant seem to get the door (when opened) to play that sound file. The game loads fine, but it almost seems to ignore the function of the current set up:

SetEntityPlayerInteractCallback("door_2", "Doorfunction", false);

and

void Doorfunction(string &in asEntity, string &in asType)
{
PlaySoundAtEntity("ramble", "CH01_DanielRamble_01.snt", "door_2", 0.0f, false);
}
02-23-2011, 07:10 AM
Find




Users browsing this thread: 1 Guest(s)