[SOLVED] Flame "afterburner" not working as intended

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
User avatar
MFG38
Posts: 414
Joined: Sun Apr 14, 2019 8:26 am
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland
Contact:

[SOLVED] Flame "afterburner" not working as intended

Post by MFG38 »

Today on "why must ZScript be such a pain in the ass?", we have my failed attempt at making a weapon altfire that fires a wall of flames that "stick" to enemies and burn them to death upon hitting one.

So yeah, here's a problem I tried fixing for the past 2 hours or so to no avail. Basically I have this flame actor fired by a weapon's altfire. The idea is that if the flame collides with a monster upon entering its Death state, it will "stick" to said monster, following its movements and slowly burning it to death. Problem is, I can't seem to get it to work as intended - I've tried several different checks to get it to enter the Afterburn state, but it never does. I did get it to enter the Afterburn state once, but even then, the flame was spawning at the location of a dead monster. And I can't rename the Afterburn state to Death either, because if I do, the flames will spawn at the player's location and burn them to death due to how the "target" pointer works for projectiles (which, BTW, is really fucking stupid).

At any rate, the code for the flame actor in its current state is below:

Code: Select all

class FlamethrowerFlameWallAfterburner : FlamethrowerFlameWall
{
	bool collided;
	
	Default
	{
		DamageFunction (1*8);
	}
	
	States
	{
	Spawn:
		FLME AABBCCDDEEFFGGHHIIJJKKLLMMNN 1 BRIGHT { if(GetCVar("sgd_spawntrails") == 1) { A_SpawnItemEx("FlamethrowerFinisherFlameTrail"); }}
		Loop;
	Death:
		TNT1 A 0
		{
			collided = CheckProximity("SGDMonster",15.0,1,CPXF_SETTARGET);  // The mod has "custom" monsters that all inherit from a base class named SGDMonster, in case you're wondering why this is here.
			if(collided)
			{
				SetStateLabel("Afterburn");
			}
		}
		Stop;
	Afterburn:
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(4,32,XF_NOTMISSILE);
			A_FadeOut(0.018);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			SetOrigin(target.pos,true);
			A_Explode(3,32,XF_NOTMISSILE);
			A_FadeOut(0.018);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2 A_FadeOut(0.018);
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2 A_FadeOut(0.018);
		Stop;
	}
}
What am I doing wrong?
Last edited by MFG38 on Fri May 01, 2020 3:17 am, edited 1 time in total.
User avatar
MFG38
Posts: 414
Joined: Sun Apr 14, 2019 8:26 am
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland
Contact:

Re: [ZScript] Flame "afterburner" not working as intended

Post by MFG38 »

Okay, so this wasn't the ideal solution, but I managed to rectify the problem by giving the actor the +SEEKERMISSILE flag and replacing all instances of "target" with "tracer". Here's the updated code for the curious:

Code: Select all

class FlamethrowerFlameWallAfterburner : FlamethrowerFlameWall
{	
	Default
	{
		DamageFunction (1*8);
		+SEEKERMISSILE;
	}
	
	States
	{
	Spawn:
		FLME AABBCCDDEEFFGGHHIIJJKKLLMMNN 1 BRIGHT
		{
			A_SeekerMissile(24,32,SMF_LOOK,180,6);
			if(GetCVar("sgd_spawntrails") == 1) { A_SpawnItemEx("FlamethrowerFinisherFlameTrail"); }
		}
		Loop;
	Death:
		TNT1 A 0 { if(tracer) { SetStateLabel("Afterburn"); }}
		Stop;
	Afterburn:
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			bFLOORHUGGER = false;
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(5,32,XF_NOTMISSILE);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(4,32,XF_NOTMISSILE);
			A_FadeOut(0.018);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2
		{
			if(tracer) { SetOrigin(tracer.pos,true); }
			A_Explode(3,32,XF_NOTMISSILE);
			A_FadeOut(0.018);
		}
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2 A_FadeOut(0.018);
		FLME A 0 A_PlaySound("fx/fireburn");
		FLME ABCDEFGHIJKLMN 2 A_FadeOut(0.018);
		Stop;
	}
}
Post Reply

Return to “Scripting”