Making a monster keep special and tag after death?

Archive of the old editing forum
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.
Locked
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Making a monster keep special and tag after death?

Post by Amuscaria »

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. :)
User avatar
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?

Post by Cutmanmike »

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 :P
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Making a monster keep special and tag after death?

Post by Ghastly »

I think the TID is kept (else, how would Thing_Raise work?), but I don't know about the special.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Making a monster keep special and tag after death?

Post by Gez »

Excerpted from AActor::Die():

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); 
	}
And so:

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;
}
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.
Last edited by Gez on Mon May 17, 2010 11:23 am, edited 1 time in total.
User avatar
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?

Post by NeuralStunner »

[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Making a monster keep special and tag after death?

Post by Amuscaria »

NeuralStunner wrote:[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
Ah thanks, this is what I need.
User avatar
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?

Post by Apothem »

NeuralStunner wrote:[wiki]Thing_SetSpecial[/wiki] could help - If you need to, you can set it directly in Decorate.
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. :?
User avatar
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?

Post by NeuralStunner »

The Special property (And Args[]) can be accessed via [wiki=DECORATE_expressions]Decorate Expressions[/wiki]. Not sure about ACS.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Making a monster keep special and tag after death?

Post by Gez »

Not in ACS, nope.
User avatar
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?

Post by NeuralStunner »

Gez wrote:Not in ACS, nope.
Weird.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Making a monster keep special and tag after death?

Post by Gez »

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.)
User avatar
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?

Post by Apothem »

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 :)
Locked

Return to “Editing (Archive)”