Actor Pointers & Melee attacks

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
Ultimate Freedoomer
Posts: 218
Joined: Fri Jan 30, 2015 10:32 pm
Location: Pittman Center
Contact:

Actor Pointers & Melee attacks

Post by Ultimate Freedoomer »

Out of curiosity, how do melee attacks handle actor pointer calls compared to projectiles & ranged hitscans? I ask because I'm updating my "customization-friendly Strife weapon code" mod, & 1 of the changes is that a pointer with a flag check is used so the appropriate "hit" sound is made with the Punch Dagger based on if the hit actor has the "+NOBLOOD" flag or not. Here's the code, since I just want to make sure I use the right pointer & would like to be made aware of whether or not I'm using the wrong pointer so I can correct that mistake if that is the case:

Code: Select all

ACTOR SimplePunchDagger : StrifeWeapon replaces PunchDagger
{
	Weapon.SelectionOrder 3900
	+WEAPON.NOALERT
	+WEAPON.NOAUTOAIM
	Obituary "$OB_MPPUNCHDAGGER" // "%o was unwittingly backstabbed by %k."
	Tag "$TAG_PUNCHDAGGER" // "Dagger"
	States
	{
	Ready:
		PNCH A 1 A_WeaponReady(0)
		Loop
	Deselect:
		PNCH A 1 A_Lower(6)
		Loop
	Select:
		PNCH A 1 A_Raise(6)
		Loop
	Fire:
		TNT1 A 0
		{
		A_CheckFlag("NOBLOOD","Fire.noblood",AAPTR_TRACER); // checks punched actor for "noblood" flag, so as to jump to state with appropriate "hit" sound
		A_JumpIfInventory("SVETALISMANPOWERUP",1,"UltimatePunch",aaptr_default); // checks for "Veteran Edition Super Strength"
		A_JumpIfInventory("PowerStrength",1,"FireStrong",aaptr_default); // Checks for "PowerStrength" item, like vanilla "A_JabDagger". Seriously, check the Zscript code
		}
		PNCH B 4
		PNCH C 4 A_CustomPunch(((stamina/10)+2)*random(0,(stamina/10)+7),true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/meathit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	FireStrong: // "PowerStrength" punch
		TNT1 A 0 A_CheckFlag("NOBLOOD","FireStrong.noblood",AAPTR_TRACER)
		PNCH B 4
		PNCH C 4 A_CustomPunch(((stamina/10)+20)*random(0,(stamina/10)+70),true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/meathit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	ULTIMATEPUNCH: // "Talisman Berserk" punch
		TNT1 A 0 A_CheckFlag("NOBLOOD","ULTIMATEPUNCH.noblood",AAPTR_TRACER)
		PNCH B 4
		PNCH C 4 A_CustomPunch(1000,true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/meathit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	Fire.noblood:
		PNCH B 4
		PNCH C 4 A_CustomPunch(((stamina/10)+2)*random(0,(stamina/10)+7),true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/metalhit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	FireStrong.noblood:
		PNCH B 4
		PNCH C 4 A_CustomPunch(((stamina/10)+20)*random(0,(stamina/10)+70),true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/metalhit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	ULTIMATEPUNCH.noblood:
		PNCH B 4
		PNCH C 4 A_CustomPunch(1000,true,CPF_DAGGER,"CustomStrifeSpark",64.0,0.0,100,"armorbonus","misc/metalhit","misc/swish")
		PNCH D 5
		PNCH C 4
		PNCH B 5 A_ReFire
		Goto Ready
	}
}
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Actor Pointers & Melee attacks

Post by Blue Shadow »

A player's melee attack is just a short-ranged hitscan attack. Hitscan attacks have [wiki=Classes:BulletPuff]puffs[/wiki]. Puffs can make use of the [wiki=Actor_flags#HITTARGET]HIT flags[/wiki].
Ultimate Freedoomer
Posts: 218
Joined: Fri Jan 30, 2015 10:32 pm
Location: Pittman Center
Contact:

Re: Actor Pointers & Melee attacks

Post by Ultimate Freedoomer »

Blue Shadow wrote:A player's melee attack is just a short-ranged hitscan attack. Hitscan attacks have [wiki=Classes:BulletPuff]puffs[/wiki]. Puffs can make use of the [wiki=Actor_flags#HITTARGET]HIT flags[/wiki].
Just to be clear, I was aware of that, I'm just unsure of if there's any special rules with "melee" damage functions compared to a_FireBullets, a_RailAttack, a_CustomBulletAttack, or a_CustomRailgun (as well as the numerous obsolete hitscan attack functions).
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Actor Pointers & Melee attacks

Post by Arctangent »

The special rules are the effects you can add via the function flags and the fact that a melee attack will mess with a player's facing angle and velocity, exactly how so differing on Punch-like melees and Saw-like melees.
Post Reply

Return to “Scripting”