Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Saliva

Scripting question

Recommended Posts

Hi everyone!

I've been looking into some scripting tutorials but I seem to be stuck with this one. I'd like to spawn some additional monsters when the monster with TID 16 has reached 50% health. When I start fighting the creature and eventually kill it, nothing happens. The creature has a total of 3000 health points. Every TID has been assigned correctly in the map. I'm not sure what I'm doing wrong here. Any help would be greatly appreciated!

script 6 OPEN
{

while(1)

{
        if(GetActorProperty (16, APROP_Health) <= 1500)
        {
            Thing_Spawn (12, 6, 0);
                Delay (35);
            Thing_Spawn (13, 6, 128);
                Delay (35);
            Thing_Spawn (14, 6, 192);
                Delay (35);
            Thing_Spawn (15, 6, 64);
            Terminate;
         }
      
}

}

Share this post


Link to post

There is not enough "Delay (1);" after "While". Due to its absence, the While loop becomes infinite and GZDoom automatically stops its execution.

Try this at first:

 

Script 6 Open { 

	While(True) { Delay (1);

		If (GetActorProperty (16, APROP_Health) <= 1500) { Print (s:"-------------"); Terminate; }
                                                   
	}	}

 

Share this post


Link to post

How about this while loop:

script 1 OPEN
{
 while (GetActorProperty (6, APROP_HEALTH) >= 1501)
 {
  Delay (1); //Do nothing
 }
 {
  //Do stuff after his health drops to 1,500 or below
 }
}

This checks about 35 times per second if the monster's health is above 1,500, and if it returns true, it will hit that delay and check again until it returns false, in which case it will execute everything in between the second set of braces.

You don't have to write terminate at the end, because the script will terminate itself upon hitting a closing brace outside the while/until/if-else loop.

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
×