Making a monster keep special and tag after death?
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.
Making a monster keep special and tag after death?
Is it possible to make a monster keep it's tag and action-special even after it dies? So that when it respawns it will have the same tag and special that be used again? Thanks. 
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: Making a monster keep special and tag after death?
Spoiler:^This depends on what point the inventory gets taken away from a dying actor, if at all. I'm not sure when or if inventory gets taken away ATM. There's also probably a better way to do it, I'm just spouting ideas here
Re: Making a monster keep special and tag after death?
I think the TID is kept (else, how would Thing_Raise work?), but I don't know about the special.
Re: Making a monster keep special and tag after death?
Excerpted from AActor::Die():
And so:
In case of death, special is set to 0.
The TID is left alone.
However, if you give the actor the THINGSPEC_NoDeathSpecial [wiki=Actor properties#Activation]activation flag[/wiki], then the special is not run and removed at death.
Code: Select all
// [RH] If the thing has a special, execute and remove it
// Note that the thing that killed it is considered
// the activator of the script.
// New: In Hexen, the thing that died is the activator,
// so now a level flag selects who the activator gets to be.
// Everything is now moved to P_ActivateThingSpecial().
if (special && (!(flags & MF_SPECIAL) || (flags3 & MF3_ISMONSTER))
&& !(activationtype & THINGSPEC_NoDeathSpecial))
{
P_ActivateThingSpecial(this, source, true);
}
Code: Select all
bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death)
{
bool res = false;
// Target switching mechanism
if (thing->activationtype & THINGSPEC_ThingTargets) thing->target = trigger;
if (thing->activationtype & THINGSPEC_TriggerTargets) trigger->target = thing;
// State change mechanism. The thing needs to be not dead and to have at least one of the relevant flags
if (!death && (thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate|THINGSPEC_Switch)))
{
// If a switchable thing does not know whether it should be activated
// or deactivated, the default is to activate it.
if ((thing->activationtype & THINGSPEC_Switch)
&& !(thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate)))
{
thing->activationtype |= THINGSPEC_Activate;
}
// Can it be activated?
if (thing->activationtype & THINGSPEC_Activate)
{
thing->activationtype &= ~THINGSPEC_Activate; // Clear flag
if (thing->activationtype & THINGSPEC_Switch) // Set other flag if switching
thing->activationtype |= THINGSPEC_Deactivate;
thing->Activate(trigger);
res = true;
}
// If not, can it be deactivated?
else if (thing->activationtype & THINGSPEC_Deactivate)
{
thing->activationtype &= ~THINGSPEC_Deactivate; // Clear flag
if (thing->activationtype & THINGSPEC_Switch) // Set other flag if switching
thing->activationtype |= THINGSPEC_Activate;
thing->Deactivate(trigger);
res = true;
}
}
// Run the special, if any
if (thing->special)
{
res = !! LineSpecials[thing->special] (NULL,
// TriggerActs overrides the level flag, which only concerns thing activated by death
(((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs))
|| (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers?
? thing : trigger),
false, thing->args[0], thing->args[1], thing->args[2], thing->args[3], thing->args[4]);
// Clears the special if it was run on thing's death or if flag is set.
if (death || (thing->activationtype & THINGSPEC_ClearSpecial && res)) thing->special = 0;
}
// Returns the result
return res;
}The TID is left alone.
However, if you give the actor the THINGSPEC_NoDeathSpecial [wiki=Actor properties#Activation]activation flag[/wiki], then the special is not run and removed at death.
Last edited by Gez on Mon May 17, 2010 11:23 am, edited 1 time in total.
- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Making a monster keep special and tag after death?
[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
Re: Making a monster keep special and tag after death?
Ah thanks, this is what I need.NeuralStunner wrote:[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
- Apothem
- Posts: 2070
- Joined: Sat Nov 29, 2003 7:13 pm
- Location: Performing open heart surgery on an ACS compiler.
Re: Making a monster keep special and tag after death?
Is there a Thing_GetSpecial? I have a feeling I may have asked this before, but it seems really weird you can set the information but you cant see what it is.NeuralStunner wrote:[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Making a monster keep special and tag after death?
The Special property (And Args[]) can be accessed via [wiki=DECORATE_expressions]Decorate Expressions[/wiki]. Not sure about ACS.
Re: Making a monster keep special and tag after death?
Not in ACS, nope.
- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Making a monster keep special and tag after death?
Weird.Gez wrote:Not in ACS, nope.
Re: Making a monster keep special and tag after death?
See this thread for a potential workaround.
(Also, keep in mind what I said earlier about THINGSPEC_NoDeathSpecial. May be simpler than resetting the special in the death states.)
(Also, keep in mind what I said earlier about THINGSPEC_NoDeathSpecial. May be simpler than resetting the special in the death states.)
- Apothem
- Posts: 2070
- Joined: Sat Nov 29, 2003 7:13 pm
- Location: Performing open heart surgery on an ACS compiler.
Re: Making a monster keep special and tag after death?
I'd rather there be a more direct way to access this information, via a Thing_GetSpecial(argnumber), but that fix covers what I need. Oh well.
Ty Gez
Ty Gez
