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

Spawn monsters when bosses health reaches a certain amount?

Question

10 answers to this question

Recommended Posts

  • 2
11 hours ago, shroomzy5000 said:

Im kinda new to mapping myself but im pretty sure ive seen this before using CheckActorProperty paired with APROP_Health

 

CheckActorProperty - ZDoom Wiki

 

So you can set up a bool variable to always be checking the boss health with

Then run a while loop that says while boss health > 50 - delay

and have it spawn the rest of the enemies when < 50

 

Someone smarter and more experienced might have a better way though.

I was able to compile this real quick.

 

#include "zcommon.acs"
bool Bosshealth = 4000;

script 1 (void)
{
    while(CheckActorProperty(0, APROP_Health,Bosshealth) > 2000)
    {
        delay(3);
    }
    Thing_SpawnFacing(0,0,0,0);
}
 

the logic might be flawed and i didnt test it in a map but this is i think at least a step in the right direction.

 

The way I understand it,

the bool bosshealth = cyberdemon hit points

 

when script runs, it checks the actor property, tag cyberdemon and put where i put a 0.

APROP HEALTH will return the health number to be compared against the 4000.

if this number is greater than 2000 (%50 cyberdemon health) delay 3 tics

when it becomes less than 2000, script moves on and spawns various demons of your choosing lol

 

Hopefully helpful, but i think i possibly set up the boolian varbile wrong... let me know if it works, ill test it tomorrow but i bet this is doable

Booleans cannot store values other than 0 or 1, you want a integer variable to store the cyberdemon health, but you don't even need that, you can use GetActorProperty and you're done.

 

So, something like this:

script "CheckBossHealth" (int tid) { //You can use 'ENTER' scripts if you don't want to 'manually' trigger with lines or something else
  while(GetActorProperty(tid, APROP_Health) > GetActorProperty(tid, APROP_SpawnHealth) / 2) { //Variable 'tid' for the actual tid you need to give to the actor you want this script to do stuff. Since You have that in the script arguments, you can (and have to) set any tid you want on the script trigger, this way you can choose whatever actor you want, do it multiple times with different triggers and just have this one script.
    Delay(7);
  }
  do {
     delay(1);
     int x = GetActorX(tid) + 64.0; //Will spawn the monster that you want 64 units in front of the boss.
     int y = GetActorY(tid);
     int z = GetActorZ(tid);
     int angle = GetActorAngle(0) >> 8;
 
   } until (Spawn("MonsterToSpawn", x, y, z, 0, angle)); //Necessary loop to avoid to spawn the monster inside walls of failing the spawn.
}

It should work fine

 

But, if you have a custom boss monster, than you should definitely do the thing in ZSCRIPT/DECORATE

Share this post


Link to post
  • 0

Im kinda new to mapping myself but im pretty sure ive seen this before using CheckActorProperty paired with APROP_Health

 

CheckActorProperty - ZDoom Wiki

 

So you can set up a bool variable to always be checking the boss health with

Then run a while loop that says while boss health > 50 - delay

and have it spawn the rest of the enemies when < 50

 

Someone smarter and more experienced might have a better way though.

I was able to compile this real quick.

 

#include "zcommon.acs"
bool Bosshealth = 4000;

script 1 (void)
{
    while(CheckActorProperty(0, APROP_Health,Bosshealth) > 2000)
    {
        delay(3);
    }
    Thing_SpawnFacing(0,0,0,0);
}
 

the logic might be flawed and i didnt test it in a map but this is i think at least a step in the right direction.

 

The way I understand it,

the bool bosshealth = cyberdemon hit points

 

when script runs, it checks the actor property, tag cyberdemon and put where i put a 0.

APROP HEALTH will return the health number to be compared against the 4000.

if this number is greater than 2000 (%50 cyberdemon health) delay 3 tics

when it becomes less than 2000, script moves on and spawns various demons of your choosing lol

 

Hopefully helpful, but i think i possibly set up the boolian varbile wrong... let me know if it works, ill test it tomorrow but i bet this is doable

Edited by shroomzy5000 : continuation of thought

Share this post


Link to post
  • 0

First, why is the tid 66666 in the beginning and later 66667? That does not match the example - it would spawn the baron in front of a different actor than the one you're checking the health of.

 

And second, you don't show the error, but I tried it and it tells me the issue is this: script "CheckBossHealth" (int 66666) - you could use script "CheckBossHealth" (void) instead and then just manually fill the tid elsewhere as you have. Or leave it exactly as Kan3 suggested, the just assign a TID to the boss and make him call the script somehow.

Edited by Rifleman

Share this post


Link to post
  • 0

@Rifleman honestly I didn't even know about the message I must've had it turned off or something, so what am I doing wrong now. Its probably obvious but yh

 

Nvm I got it workin

 

 

 

 

Edited by Nightcrawler552

Share this post


Link to post
  • 0
24 minutes ago, Nightcrawler552 said:

@Rifleman honestly I didn't even know about the message I must've had it turned off or something, so what am I doing wrong now. Its probably obvious but yh

 

 

 

image.png

You didn't have to do anything with the script I wrote there, it was already completed except for the monster class to spawn x)

No need to specify the tid of the monster here, also, why a so huge number? Note that the max value a tid/tag can have is 32767 (or -32767), of course it's giving you an error.

 

Here's how you should've set up the thing:

Spoiler

sv8tYf5.png

Spoiler

cNoq2iP.png

 

And here's the script in action:

Spoiler

 

I'm replacing the imp, that's why he spawned that monster

Although, the issue here was pretty basic, so my suggestion is to first get more straight forward examples of scripting on the wiki or forums, to initially have a solid ground before entering darker realms. Even if the original question might sound a pretty simple task, you have to keep in mind how far your questions are from vanilla Doom "core" and why.

Share this post


Link to post
  • 0

Yep, just put whatever you want to happen in that script. It could be something like this:
 

Spoiler

 

script "CheckBossHealth" (int tid)

{

    while(GetActorProperty(tid, APROP_Health) > GetActorProperty(tid, APROP_SpawnHealth) / 2)

    {

          Delay(7);

    }

    Your code here

}

 

 

Share this post


Link to post
  • 0
On 11/29/2023 at 10:18 PM, Nightcrawler552 said:

@Kan3Kan3it works but for some reason the door only opens when the boss is dead 

It should work fine like Rifleman said.

Show the script

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
×