Extended A_SkullAttack Function?

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!)
User avatar
LolaHThicc
Posts: 7
Joined: Wed Dec 10, 2025 1:08 pm
Preferred Pronouns: She/Her

Extended A_SkullAttack Function?

Post by LolaHThicc »

I have an enemy that i would like to jump at you as an attack, and found the simplest way to get it to happen is using A_SkullAttack, but its behevior i find to be unideal.
The catch here is that I want this enemy to be non-flying, and whlie the function works, it has some weird beheviour that i would like to be able to tweak. Things like the classic lost soul jankiness of being able to shoot it mid attack and the enemy just kinda awkwardly slides backwards, not being able to modify the tragectory of the attack, the way it can just keep charging at you from across the map when you enter it's attack range, then retreat.
I'm very sure there's a way to impliment a much more robust zcript solution, but ya know, newbie here, i barely know what i'm doing xD
I guess i wanted to check if there's a zdoom extended function first before asking for help with code. There's extended zdoom functions for all kinds of attacks and i'm beginning to realise how much more flexible they are compared to the vanilla doom functions. there's no mention of such existing for A_SkullAttack, but maybe I missed it. Any insight would be greatly appriciated as always x

I guess you can see the code for the enemy in question too:

Code: Select all

class TinySlimelvl1 : actor
{
	Default
	{
	Tag "Tiny Slime lvl.1";
	Monster;
	Speed 14;
	Health 65;
	PainChance 256;
	Radius 12;
	Height 26;
	DamageFunction Random(5,15);
	MaxTargetRange 256;
	Mass 80;
	RenderStyle "Translucent";
	Alpha 0.8;
	SeeSound "";
	PainSound "skull/pain";
	DeathSound "skull/death";
	ActiveSound "pain/active";
	BloodColor "55FF55";
	Species "Slime";
	MinMissileChance 200;
	}
	States
	{
	Spawn:
	SSLI AA 10 A_Look;
	Loop;
	See:
	SSLI AAAA 4 A_Chase;
	Loop;
	Missile:
	SSLI AA 10 A_FaceTarget;
	SSLI A 4 A_SkullAttack(30);
	SSLI AA 10;
	Goto See;
	Pain:
	SSLI A 8 A_Pain;
	Goto See;
	Death:
	SSLI Z 6 A_ScreamAndUnblock;
	SSLI ZZ 6;
	Stop;
	}
}
Heisanevilgenius
Posts: 116
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Extended A_SkullAttack Function?

Post by Heisanevilgenius »

I found some success in creating a similar effect using A_ChangeVelocity. Just give him a sudden lurch towards you and probably upwards as well. It won't automatically damage you on impact like with A_SkullAttack but there are plenty of ways you can work around that.
User avatar
LolaHThicc
Posts: 7
Joined: Wed Dec 10, 2025 1:08 pm
Preferred Pronouns: She/Her

Re: Extended A_SkullAttack Function?

Post by LolaHThicc »

Oh hey, heisanevilgenius!
Okay so i've had a look at A_ChangeVelocity, and i've managed to get the enemy to jump about, it's kinda cute to see the slime fella jump around, but I'm not quite there yet:

1. how can I get the enemy to calculate a jump towards its target?
2. I've tried using A_JumpIfInTargetLOS to have it jump to A_CustomMeleeAttack, but in the way i've attempted to impliment, it either only hurts on the first frame as it jumps, or it doesn't do anything. I would guess i need to put in some kind of check every tick of the jump to check for LOS?

the very not-functional state code in question:

Code: Select all

	...
	Missile:
	MSLI AA 12 A_FaceTarget;
	MSLI A 4
	{
	A_ChangeVelocity(10,0,10,CVF_RELATIVE);
	}
	MSLI A 0 A_JumpIfTargetInLOS(3,0,0,44);
	MSLI AA 12;
	Goto See;
	MSLI A 4 A_CustomMeleeAttack(random(10, 25));
	MSLI AA 12;
	Goto See;
Heisanevilgenius
Posts: 116
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Extended A_SkullAttack Function?

Post by Heisanevilgenius »

1. A_Facetarget should make the enemy face its target when it jumps. Maybe 12 frames is long enough that the player is able to move out of the way before the jump happens. Maybe add one more A_Facetarget within the brackets.
2. From the code you posted, the A_Jump only happens on the first frame and then the attack only happens on the first frame, and then there's 24 frames of nothing happening.

Maybe do something like:

Code: Select all

	MSLI AAAAAAAAAAAA 2 A_JumpIfTargetInLOS(3,0,0,44);
	Goto See;
	MSLI A 4 A_CustomMeleeAttack(random(10, 25));
	MSLI AA 12;
	Goto See;
Then it checks every 2 frames for the 24 jumping frames. Also, maybe A_JumpIfTargetInsideMeleeRange might be better so it checks to see if the target is close enough before jumping to the attack frame. I left the AA12 after the attack in, which doesn't completely sync up and the monster might end up staying still for up to 24 frames after landing.

One alternative you can do is have it do a loop and break the loop if the monster's Z coordinate is equal to the floor. Then the monster prepares to attack endlessly until it is close enough or it lands. And if it's close enough, it will attack once and then wait until it hits the ground. You might even be able to jump to a frame where the monster crouches or kneels when landing to give it a nice animation before it returns to chasing.
User avatar
LolaHThicc
Posts: 7
Joined: Wed Dec 10, 2025 1:08 pm
Preferred Pronouns: She/Her

Re: Extended A_SkullAttack Function?

Post by LolaHThicc »

Okay i've messed about with it and i've arrived to a solution that works, using a state jump do distinguish between a regular melee attack, and a jump attack. I wanted the slime enemy to not be too aggro and have a brief cooldown period after a jump, that was the intent behind the AA 12, but i did shorten it here:

Code: Select all

Missile:
	MSLI AA 12 A_FaceTarget;
	MSLI A 4
	{
	A_FaceTarget(0);
	A_ChangeVelocity(24,0,5,CVF_RELATIVE);
	}
	MSLI AAAAAAAAAAAAAAA 2 A_JumpIfTargetInsideMeleeRange("JumpMelee");
	Goto See;
	JumpMelee:
	MSLI A 4 A_CustomMeleeAttack(random(10, 25));
	MSLI A 12;
	Goto See;
	Melee:
	MSLI A 6;
	MSLI A 4 A_CustomMeleeAttack(random(10, 25));
	MSLI A 6;
	Goto See;
Now i have pretty much exactly what i need for this attack, Thanks for the insight and help! :D
Heisanevilgenius
Posts: 116
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Extended A_SkullAttack Function?

Post by Heisanevilgenius »

:D

Return to “Scripting”