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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help How to achieve this scenario?
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#6
RE: How to achieve this scenario?

OK, I'll expand a bit on what others have said.

First, for some basic understanding of how the game and the script interact with each other, read this short article.

Now, here we go:
(01-30-2013, 01:54 AM)serbusfish Wrote: You enter a room,
To detect if a player has entered a room or not, you normally set up the script to detect a collision with a script area. So, first make sure that the map itself contains a script area that can be used for this. Depending on what exactly you want to happen, you can just put a thin script area right in front of the door, or you can place a big box in the center of the room to define an inner region where this should happen. In the script file, you would use an AddEntityCollideCallback() to "subscribe to" collision detection with that area, as described above by The chaser and BeeKayK (a more detailed explanation on how to use basic functions and parameters here, and of callbacks here)

(01-30-2013, 01:54 AM)serbusfish Wrote: the sound of a plate or vase smashing is heard from another room,
Similarly, you need something in your level to define the source of the sound. Either edit the script file to break an actual vase entity using SetPropHealth() as The chaser did, or use the level editor to add a script area in the other room (or just near or behind the wall, in empty space - if there's no really another room) to define where the sound should come from. Once this is done, just find the appropriate sound, and edit the script file to make a call to PlaySoundAtEntity() in place of SetPropHealth(), like this (replace the names to match the names in your level - "internal.sound.id" can be whatever you like, the number 0.0f is sound fade in time in seconds (the f is just some data type suffix, don't worry about that)):
PHP Code: (Select All)
PlaySoundAtEntity("internal.sound.id""SoundFileName.snt""ScriptAreaName"0.0f false); 

(01-30-2013, 01:54 AM)serbusfish Wrote: the centre dot 'looks' to where the sound came from,
Use StartPlayerLookAt() as described by The chaser above, and then AddTimer() so that you can exit the forced look-at state after some time, by calling StopPlayerLookAt() inside the timer callback (which The chaser forgot to do).

(01-30-2013, 01:54 AM)serbusfish Wrote: then the sound of a monster walking is heard
Either immediately use PlaySoundAtEntity() as before (but perhaps on a different script area) to play a monster walking sound (just find some footstep sounds that came with the game), or first add a timer if you want to offset the sound playback by some time amount.

(01-30-2013, 01:54 AM)serbusfish Wrote: followed by the sound of a door shutting.
Same as before.

P.S. Consult the engine script functions reference page to find out more about the available functions, and how to use them (what their parameters mean).
(This post was last modified: 01-30-2013, 11:55 AM by TheGreatCthulhu.)
01-30-2013, 11:48 AM
Find


Messages In This Thread
How to achieve this scenario? - by serbusfish - 01-30-2013, 01:54 AM
RE: How to achieve this scenario? - by NaxEla - 01-30-2013, 02:28 AM
RE: How to achieve this scenario? - by serbusfish - 01-30-2013, 04:07 AM
RE: How to achieve this scenario? - by The chaser - 01-30-2013, 09:35 AM
RE: How to achieve this scenario? - by TheGreatCthulhu - 01-30-2013, 11:48 AM
RE: How to achieve this scenario? - by serbusfish - 01-31-2013, 01:58 AM
RE: How to achieve this scenario? - by serbusfish - 01-31-2013, 05:30 PM
RE: How to achieve this scenario? - by serbusfish - 02-01-2013, 04:09 AM
RE: How to achieve this scenario? - by The chaser - 02-01-2013, 10:28 AM
RE: How to achieve this scenario? - by serbusfish - 02-01-2013, 05:04 PM
RE: How to achieve this scenario? - by Kreekakon - 02-01-2013, 05:17 PM
RE: How to achieve this scenario? - by serbusfish - 02-03-2013, 03:58 AM
RE: How to achieve this scenario? - by The chaser - 02-03-2013, 11:54 AM
RE: How to achieve this scenario? - by serbusfish - 02-05-2013, 03:29 AM
RE: How to achieve this scenario? - by serbusfish - 02-08-2013, 02:33 AM
RE: How to achieve this scenario? - by serbusfish - 02-08-2013, 01:48 PM



Users browsing this thread: 1 Guest(s)