Triggering script based on enemy's HP?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Triggering script based on enemy's HP?

Postby gloomiest666 » Sat Nov 16, 2019 9:05 am

I'm trying to make an ACS execute after a certain mob that has a TID of 3 loses 50% of its health points or more (in this case the monster has 100 base HP).

I've tried with:


script 1 OPEN
{
When (GetActorProperty (3, APROP_HEALTH,"monstername") <= 50)
{
Acs_Execute(2,0);
}
}


and also:


script 1 OPEN
{
if (GetActorProperty (3, APROP_HEALTH) <= 50)
Acs_Execute(2,0);
}


Yet none worked. What am I doing wrong?
gloomiest666
 
Joined: 16 Nov 2019

Re: Triggering script based on enemy's HP?

Postby KeksDose » Sat Nov 16, 2019 9:19 am

It's pretty close. There's no "when", but there's "while" and delays, so you can do this:

Code: Select allExpand view
script 1 OPEN
{
   while(50 < GetActorProperty(3, APROP_HEALTH))
   {
      Delay(1);
   }
   Acs_Execute(2, 0);
}

Usually, you'll be writing scripts that wait a lot like that to time your triggers.
User avatar
KeksDose
kek
 
Joined: 06 Jul 2007
Location: MOOOOON

Re: Triggering script based on enemy's HP?

Postby gloomiest666 » Sat Nov 16, 2019 11:53 am

KeksDose wrote:It's pretty close. There's no "when", but there's "while" and delays, so you can do this:

Code: Select allExpand view
script 1 OPEN
{
   while(50 < GetActorProperty(3, APROP_HEALTH))
   {
      Delay(1);
   }
   Acs_Execute(2, 0);
}

Usually, you'll be writing scripts that wait a lot like that to time your triggers.


Thank you very much :)
gloomiest666
 
Joined: 16 Nov 2019


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests