Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Remilia Scarlet

Fragglescript question

Recommended Posts

Ok, I've been playing around with this for a while, but I just can't figure it out. Anyone know of a way to script a level (with FraggleScript) to where something will happen when all the monsters (or all monsters of a certain kind, whichever) are dead? But only if the monsters are dead, not if only half or so are dead.

I tried a loop once, but it seemed to slow Legacy down so far that it was going at 0 fps. Am I going the wrong direction with a loop?

Share this post


Link to post

Try to ask this question in the Eternity forum (on the very bottom of the forum index). There should be some people who can answer your questions.

Share this post


Link to post

The only way to do this in FraggleScript would be write down the mapthing numbers of every thing of the type whose death you want to monitor, and do something like this:

int num = <first mapthing number here>;
int num2 = <second mapthing number here>;
...
int numN = <Nth mapthing number here>;

script 1
{
while(1)
{
if(objhealth(num) == 0 && objhealth(num2) == 0 &&
... && objhealth(numN) == 0)
{
/* do something in here */
}
wait(1);
}
}

// this starts script 1 at the beginning of the level
startscript(1);

The wait(1) call is critical -- without it, the game will hang permanently as it'll never exit out of running your script.

Be aware, however, the possible problems with this approach. I wrote a somewhat similar loop for Nimrod to implement falling damage, and it caused save game corruption. This is a known problem with the FraggleScript system, and there are no workarounds available.

Share this post


Link to post

That turned out to be a corruption with how the loading of the savegame dealt with the wait(); command being in action however.

according to hurdler anyways. In some cases it worked fine and in some cases it didn't. and it was a problem with loading the savegame, not the saving.

Share this post


Link to post

legacy has a new function called objdead


for Legacy you can have something like


script 1
{
while(1)
{
if((objdead(mobj#) && (objdead(mobj#))) //checks of two of those monsters are dead
{
"enter action"
break();
}
wait(1);
}
}


I believe this will work even if you save and load while this script is in action and if you want to count more monsters, just add another "&& (objdead(#))"


for eternity, you have to use objhealth()

that so far is pretty much the quickest way to do this....

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×