Shields on a monster
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Shields on a monster
Just playing around with an idea, would it be possible to give a monster rechargable shields, like the Protoss from Starcraft, or the Halo Master Chief?
A more technical way of putting it would be temporary hit points. When they're gone, it starts really taking damage, but the temporary health can regenerate.
A more technical way of putting it would be temporary hit points. When they're gone, it starts really taking damage, but the temporary health can regenerate.
Re: Shields on a monster
It should be possible to give the enemy a custom inventory item to track this. In the Pain state, you would then check the inventory to make sure it has "shields" left, and reduce the shields amount by how much damage was taken. (This can be determined by monitoring the enemy's health over time) Then heal the enemy for the amount taken, or the amount of remaining shields, whichever is less. It would be a good idea to change the monster's state to something showing him without shields and/or change the pain state so the player could tell when actual damage is being done.
If you needed the shields to regenerate as well, this could be done by giving the monster "shields" periodically during its normal states, or making an entirely separate "recharge" state that he can go into to restore them.
Of course it's also notable that the player would be able to kill an enemy with these shields if the damage amount is higher than the monster's remaining health.
If you needed the shields to regenerate as well, this could be done by giving the monster "shields" periodically during its normal states, or making an entirely separate "recharge" state that he can go into to restore them.
Of course it's also notable that the player would be able to kill an enemy with these shields if the damage amount is higher than the monster's remaining health.
Re: Shields on a monster
That's what I was thinking, but it'd be just about impossible, without damagetypes on every weapon, to heal the exact amount of damage, and even with that, with hitscan attacks (and other randomized attacks) it still might heal more or less damage than it took.
Re: Shields on a monster
Code: Select all
DECORATE:
Pain:
TNT1 A 0 ACS_Execute (2, 0)
...
ACS:
#define MonsterTID 62
int MonsterCurHealth;
script 1 OPEN
{
// Init monster health
MonsterCurHealth = GetActorProperty(MonsterTID, APROP_HEALTH);
}
script 2 (void)
{
// Check monster's health against previous known value
int Diff = MonsterCurHealth - GetActorProperty (MonsterTID, APROP_Health);
// Check monster's inventory for shield items
int Shields = CheckInventory ("Shield");
if (Shields > Diff)
{
// Heal and reduce shields
SetActorProperty (MonsterTID, APROP_HEALTH, MonsterCurHealth);
TakeInventory ("Shield", Diff);
terminate;
}
MonsterCurHealth = GetActorProperty (MonsterTID, APROP_Health);
if (Shields > 0)
{
// Heal shield value and remove shields
SetActorProperty (MonsterTID, APROP_Health, (MonsterCurHealth + Shields));
TakeInventory ("Shield", Shields);
}
}
Re: Shields on a monster
That'd probably work for boss battles, but isn't nearly practical for common monsters. Also, keep a chaingun on that thing, and it won't move because of the pain state :/.
Oh well, onto my next idea
.
Oh well, onto my next idea

Re: Shields on a monster
Boss battles would probably be the best place for a shielded monster anyway; that said, I could probably come up with a generic solution to be used with normal enemies. Either way would most likely need ACS work, though.Ghastly_dragon wrote:That'd probably work for boss battles, but isn't nearly practical for common monsters. Also, keep a chaingun on that thing, and it won't move because of the pain state :/.
Also, there's no reason why the pain state has to hold the enemy still. The only reason existing pain states do that is because the author adds in frames which don't call A_Chase or one of its variants. However, you could just as easily do something like this to ensure that the script gets triggered every time, but the enemy only gets held a quarter of the time:
Code: Select all
Pain:
TNT1 A 0 ACS_Execute (2, 0)
TNT1 A 0 A_Jump (192, "See")
MONS G 4 A_Pain
MONS G 4
goto See
- David Ferstat
- Posts: 1113
- Joined: Wed Jul 16, 2003 8:53 am
- Location: Perth, Western Australia
- Contact:
Re: Shields on a monster
Hmm ... how would this go?
Let's assume that your actor is to have 100 maximum health, and 100 maximum shield.
So, let's create a couple of int variables: DisplayHealth and Shield, and set each to 100. We'll use these to update the HUD. Now, define the actor's actual maximum health to the sum of DisplayHealth and Shield.
Incoming damage will still be deducted by the game from the actor's actual health, but it also get's deducted from Shield and, if Shield hits zero, from DisplayHealth as well. We then recalculate the actor's actual health. As DisplayHealth and Shield are restored, the actor's actual health will climb back to the maximum.
With this method, it's possible to take damage equal to, or greater than, the actor's apparent health, without actually killing it, providing Shield is high enough. Of course, if there's damage equal to or greater that the actor's apparent health and shield combined, the actor dies. But then, that's what you'd expect anyway.
Let's assume that your actor is to have 100 maximum health, and 100 maximum shield.
So, let's create a couple of int variables: DisplayHealth and Shield, and set each to 100. We'll use these to update the HUD. Now, define the actor's actual maximum health to the sum of DisplayHealth and Shield.
Incoming damage will still be deducted by the game from the actor's actual health, but it also get's deducted from Shield and, if Shield hits zero, from DisplayHealth as well. We then recalculate the actor's actual health. As DisplayHealth and Shield are restored, the actor's actual health will climb back to the maximum.
With this method, it's possible to take damage equal to, or greater than, the actor's apparent health, without actually killing it, providing Shield is high enough. Of course, if there's damage equal to or greater that the actor's apparent health and shield combined, the actor dies. But then, that's what you'd expect anyway.
Re: Shields on a monster
You could certainly use that method as well, though I was envisioning an enemy which can't regenerate its HP, but can regenerate shields. So at that point you just have to make sure your script accounts for what part of the enemy's real HP is shield and which is health.
- David Ferstat
- Posts: 1113
- Joined: Wed Jul 16, 2003 8:53 am
- Location: Perth, Western Australia
- Contact:
Re: Shields on a monster
When I refer to DisplayHealth and Shield being restored, I don't think it matters whether they regenerate, or are improved by healthpacks & batteries. If they don't get restored at all, that also ok.
In fact, I'd probably separate out the script that handles shield regeneration from the one that keeps track of DisplayHealth and Shield. They are, after all, distinct functions.
Of course, you could also extend this script to allow for damage to leak through the shield, especially as it weakens. Instead of simply taking all the value of the incoming damage off Shield, with the overflow going to DisplayHealth, you could pass a portion of it straight through to DisplayHealth.
In fact, I'd probably separate out the script that handles shield regeneration from the one that keeps track of DisplayHealth and Shield. They are, after all, distinct functions.
Of course, you could also extend this script to allow for damage to leak through the shield, especially as it weakens. Instead of simply taking all the value of the incoming damage off Shield, with the overflow going to DisplayHealth, you could pass a portion of it straight through to DisplayHealth.
- David Ferstat
- Posts: 1113
- Joined: Wed Jul 16, 2003 8:53 am
- Location: Perth, Western Australia
- Contact:
Re: Shields on a monster
Oh, and just for the sake of completeness, and because one shouldn't assume that other people have read between the lines; when DisplayHealth hits zero, the script should kill the actor, even if the actor's actual health is above zero.
- DoomRater
- Posts: 8270
- Joined: Wed Jul 28, 2004 8:21 am
- Preferred Pronouns: He/Him
- Location: WATR HQ
- Contact:
Re: Shields on a monster
I was thinking of spawning an actor around the monster for the shield (essentially a multi part actor) but then I realized the monster would not be able to move if I did that. More than that, the monster would be limited to projectile attacks that spawn far enough away from the shield actor, otherwise the monster's own attacks would hit the shield.
Re: Shields on a monster
-Solid and +Shootable for the first problem (check the Darkness Rift on the Beastiary, it's non-solid, but shootable with hitscans and projectiles), +Ghost and +ThruGhost for the second problemDoomRater wrote:I was thinking of spawning an actor around the monster for the shield (essentially a multi part actor) but then I realized the monster would not be able to move if I did that. More than that, the monster would be limited to projectile attacks that spawn far enough away from the shield actor, otherwise the monster's own attacks would hit the shield.

- DoomRater
- Posts: 8270
- Joined: Wed Jul 28, 2004 8:21 am
- Preferred Pronouns: He/Him
- Location: WATR HQ
- Contact:
Re: Shields on a monster
Will thrughost work with hitscans? I've needed a solution for my mounted machinegun problem for a while and this would solve it (with a strange weakness- mounted machinegun shots would ignore other people's shields!)
Re: Shields on a monster
Oh, no, +ThruGhost likely doesn't work with hitscans (nice request, though, but might not be possible).
With shields on hitscan attackers, like that, you're better off using the method suggested above.
With shields on hitscan attackers, like that, you're better off using the method suggested above.
- DoomRater
- Posts: 8270
- Joined: Wed Jul 28, 2004 8:21 am
- Preferred Pronouns: He/Him
- Location: WATR HQ
- Contact:
Re: Shields on a monster
Well my solution didn't care whether the actor could move or not as the player would be immobilized while firing the gun anyway. My own hackish solution does the trick for now.