[Heretic] Firemace without momentum preservation

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
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

[Heretic] Firemace without momentum preservation

Post by StroggVorbis »

In Heretic, the Firemace's and the tomed Phoenix Rod's projectiles inherit the velocity of the shooter, making it difficult to aim at a target while moving.
Can someone tell me how to make them behave more akin to say, all the other projectile based weapons in Doom, Hexen & Strife? :P
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: [Heretic] Firemace without momentum preservation

Post by StroggVorbis »

Code: Select all

action void A_FireMacePL1()
	{
		if (player == null)
		{
			return;
		}

		Weapon weapon = player.ReadyWeapon;
		if (weapon != null)
		{
			if (!weapon.DepleteAmmo (weapon.bAltFire))
				return;
		}

		if (random[MaceAtk]() < 28)
		{
			Actor ball = Spawn("MaceFX2", Pos + (0, 0, 28 - Floorclip), ALLOW_REPLACE);
			if (ball != null)
			{
				ball.Vel.Z = 2 - clamp(tan(pitch), -5, 5);
				ball.target = self;
				ball.angle = self.angle;
				ball.AddZ(ball.Vel.Z);
				ball.VelFromAngle();
				ball.Vel += Vel.xy / 2;
				ball.A_PlaySound ("weapons/maceshoot", CHAN_BODY);
				ball.CheckMissileSpawn (radius);
			}
		}
		else
		{
			player.GetPSprite(PSP_WEAPON).x = random[MaceAtk](-2, 1);
			player.GetPSprite(PSP_WEAPON).y = WEAPONTOP + random[MaceAtk](0, 3);
			Actor ball = SpawnPlayerMissile("MaceFX1", angle + (random[MaceAtk](-4, 3) * (360. / 256)));
			if (ball)
			{
				ball.special1 = 16; // tics till dropoff
			}
		}
	}
}
I'm not sure, but I believe it's the ball.VelFromAngle() function.

Can somebody confirm if I'm onto something or moving into the wrong direction?

Thx in advance
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: [Heretic]Firemace & PhoenixRod without momentum preserva

Post by StroggVorbis »

Quick note: Tried to make a custom PhoenixRod but I get the error message "Private member FlameCount not accessible".
Post Reply

Return to “Scripting”