Frictional Games Forum (read-only)
[SCRIPT] Is this possible? (NEW question) - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Is this possible? (NEW question) (/thread-25463.html)



Is this possible? (NEW question) - Neelke - 06-11-2014

So I was thinking of making a script that checks what music is being played. Now unfortently there is no script that checks it. Is it possible to do it in another way?


RE: Is this possible? - Mudbill - 06-11-2014

You can use a variable to determine which plays. Whenever you use PlayMusic, also tick a SetLocalVarInt to a value. When changing the music, you can change that value. Then you can check for which variable matches in order to check the music. Do you know how to set up such a script?


RE: Is this possible? - Neelke - 06-11-2014

Perhaps, but I wanna be certain. Could you perhaps give me an example? Kind of pathetic asking like this, but as I said. I wanna be certain.


RE: Is this possible? - Mudbill - 06-11-2014

I'm unsure how you plan on changing the music this freaquently, but let's see.

PHP Code:
void OnStart()
{
    
PlayMusic(music 1 etc);
    
SetLocalVarInt("Music"1);
}

void SomeCallback()
{
    
PlayMusic(change to music 2);
    
SetLocalVarInt("Music"2); 
}

void CheckMusic()
{
    if(
GetLocalVarInt("Music") == 1) {
        
//Music track number 1.
    
}
    if(
GetLocalVarInt("Music") == 2) {
        
//Music track number 2.
    
}
    if(
GetLocalVarInt("Music") == 0) {
        
//No music.
    
}
}

void NoMusic()
{
    
StopMusic(whatever music);
    
SetLocalVarInt("Music"0);


This is a very basic example. I'm sure you'll figure out where to place these things. As I said, I'm unsure what you need this for so I can't really tell you exactly what to put, but it should be fairly similar.


RE: Is this possible? (NEW question) - Neelke - 06-11-2014

Actually, another question. Is it possible to also check if an enemy is searching or hunting the player?


RE: Is this possible? (NEW question) - MsHannerBananer - 06-11-2014

(06-11-2014, 05:35 PM)Neelke Wrote: Actually, another question. Is it possible to also check if an enemy is searching or hunting the player?

Just set up local (or global, if you're doing it across maps) variables. If you set up a local variable when the monster is spawned (and is therefore looking for the player), and set that variable to a number of your choosing, you can do a similar thing to what you did with the music.

In the script you have for the monster spawning, just add:

PHP Code:
SetLocalVarInt(stringasNameint alVal); 

Then you just have to set up a point where it checks for the variable (I'd do it by script box), and do the same check that Mudbill has kindly provided for the music. Big Grin