Ge15t's Help Thread! - 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: Ge15t's Help Thread! (/thread-6639.html) Pages:
1
2
|
Ge15t's Help Thread! - Ge15t - 02-19-2011 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 RE: Ge15t's Help Thread! - Oscar House - 02-19-2011 Everything under SetEntityActive is not in any function. You need to place the lantern+tinderbox stuff in OnStart(), like this: Code: //////////////////////////// RE: Ge15t's Help Thread! - Ge15t - 02-20-2011 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 RE: Ge15t's Help Thread! - Oscar House - 02-20-2011 These two SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction); Myfunc(string &in entity) could work. Code: void OnStart() Try it. RE: Ge15t's Help Thread! - Ge15t - 02-21-2011 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 RE: Ge15t's Help Thread! - Oscar House - 02-21-2011 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. RE: Ge15t's Help Thread! - Ge15t - 02-21-2011 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? RE: Ge15t's Help Thread! - Oscar House - 02-21-2011 Okay, I just recreated the script in a map of my own. Code: //////////////////////////// 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 EDIT: And SetEntityPlayerInteractCallback("Door", "Doorfunction", false); It works for me, sound plays, enemy appears. RE: Ge15t's Help Thread! - Ge15t - 02-21-2011 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 RE: Ge15t's Help Thread! - Ge15t - 02-23-2011 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); } |