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
GetEntityExists
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#1
GetEntityExists

Hey Guys!

So I tried some things out, lately, but somehow it doesn't work.

I want to check, if a grunt disappears, with this line of code:

void CheckMonster(string &in asTimer){
    if(GetEntityExists("grunt2") == false){
        StopMusic(0.5, 0);
        PlayMusic("01_amb_darkness", true, 100, 1.5, 0, true);
    }
    else{
        AddTimer("CheckMonsterAgain", 0.1, "CheckMonster");
    }
}

so, is there any other error, or can't I use this GetEntityExists() for a disappeared grunt?

The Well: Descent - Take a look at it!
08-02-2011, 11:57 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: GetEntityExists

You can't loop it like this into the same function, but you can loop it to a different function that has the timer that goes to this function again.

There also may be a problem with the music because you're stopping music and then playing some music nearly at the same time, but this is only a thought.

Try this for now:

void CheckMonster(string &in asTimer){
    if(GetEntityExists("grunt2") == false){
        StopMusic(0.5, 0);
        PlayMusic("01_amb_darkness", true, 100, 1.5, 0, true);
    }
    else{
        CheckMonsterAgain();
     }
}
void CheckMonsterAgain()
{
     AddTimer("", 0.1, "CheckMonster");
}

08-02-2011, 01:00 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#3
RE: GetEntityExists

Hmm, no doesn't work, the monster disappears, but the music is still playing :/

Does GetEntityExists() only checks for entities, which aren't on the map anymore, and not 'disabled'?

The Well: Descent - Take a look at it!
08-02-2011, 01:14 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: GetEntityExists

You may be better off with clicking on the monster in the editor and under the Entity tab type in a callback function name. When the monster disappears the game merely disables it, not destroys (deletes) it. Checking for OnAutoDisabled should do the trick.

Tutorials: From Noob to Pro
08-02-2011, 01:28 PM
Website Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#5
RE: GetEntityExists

I think I know why it doesn't work. It's because the StopMusic and PlayMusic function commands are in the same function happening nearly at the same time and they both have the same priority.

Change the "PlayMusic" function command to this:

PlayMusic("01_amb_darkness", true, 100, 1.5, 1, true);


Also to note that when you stop the music for this music that you just started, make sure that it looks like this:

StopMusic(0.5, 1);

Make sure that this edited "StopMusic" function command should NOT be in the part of the script that you shown everyone. Smile

(This post was last modified: 08-02-2011, 08:37 PM by Kyle.)
08-02-2011, 01:30 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#6
RE: GetEntityExists

That didn't worked too :/

Well, I found another solution. I just copied the original grunt file, and changed
the active sound to mine, and this works.
Anyways thanks for help Smile

The Well: Descent - Take a look at it!
08-02-2011, 02:21 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#7
RE: GetEntityExists

it wont have worked because the priority for the monster music is 256, so you'd have to use StopMusic(0.5f , 256); which is why it's easier to just edit the monster, like you have done, then to change it's enabled music with scripts

(This post was last modified: 08-02-2011, 02:35 PM by DRedshot.)
08-02-2011, 02:34 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#8
RE: GetEntityExists

but a priority of 256 would be one of the lowest used <.<
Monstermusic always plays in the foreground, doesn't it?
Or am I again confused of the 0 = highest priority?

The Well: Descent - Take a look at it!
08-02-2011, 02:39 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#9
RE: GetEntityExists

i dont know, i didnt mean to confuse you, but i think that the description in the wiki has a typo, because from experience if i used stopmusic(0.5f , 256); // 256 or higher
it would stop the monster music, and in game if you tick show sounds playing it tells you the music priority for a monster sound is 256. so i assumed it was an error on the wiki, someone can correct me if im wrong though...

Edit: i just tested it, and couldn't get the music to stop with a priority of 255, 256 or 257. Its probably coded into the game in a way that the script can't stop the music no matter what. For my above comment saying i got it to work, i think i actually did something different, i was using PlayMusic with a priority higher than 256 to 'overwrite' the monster music, this works - i tested it.

Another edit: I am now also confused. it seems that if i use StopMusic(1.0f , x); (where x is any number) the Monster music doesn't stop,
but if i use PlayMusic("04_amb.ogg" , false , 1.0f , 1.0f , x , true); (where x is again anything)
The music has higher priority than the monster music, and plays over it, with no relavance to the int prio. Maybe this is just happening because we are trying to stop music which isn't activated by our script, it is activated by the entity itself.

(This post was last modified: 08-02-2011, 03:04 PM by DRedshot.)
08-02-2011, 02:44 PM
Find




Users browsing this thread: 3 Guest(s)