Is it possible to dynamically change morph duration?

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Heisanevilgenius
Posts: 100
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Is it possible to dynamically change morph duration?

Post by Heisanevilgenius »

What I'm trying to do is have a morph projectile where the duration of the morph effect is based on an inventory item of the monster who fired it.

To give a similar example, I already created a projectile that uses DamageFunction (CountInv("BossLevel",AAPTR_TARGET)*3);
This makes the projectile do more damage, the more levels the boss has.

I want to do something similar but change the morph duration of a morph projectile. Please let me know if this is possible. Thanks :)
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Is it possible to dynamically change morph duration?

Post by Jarewill »

MorphProjectiles morph the hit actor in their DoSpecialDamage override, so you can override it in your projectile to change for how long the morph stays:

Code: Select all

	//Code copied directly from the MorphProjectile definition with some changes to the duration
	override int DoSpecialDamage (Actor target, int damage, Name damagetype)
	{
		int morph_dur = /* Your calculation here */
		if (target.player)
		{
			// Voodoo dolls forward this to the real player
			target.player.mo.MorphPlayer (NULL, PlayerClass, morph_dur, MorphStyle, MorphFlash, UnMorphFlash);
		}
		else
		{
			target.MorphMonster (MonsterClass, morph_dur, MorphStyle, MorphFlash, UnMorphFlash);
		}
		return -1;
	}
Heisanevilgenius
Posts: 100
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Is it possible to dynamically change morph duration?

Post by Heisanevilgenius »

Brilliant! Thank you so much!
Post Reply

Return to “Scripting”