A_JumpIf MeleeRange possible ? (Melee Weapon)

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze 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.
Post Reply
Narset
Posts: 4
Joined: Tue Apr 21, 2020 8:33 pm

A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Narset »

Hello,

With the function "A_JumpIf" or another jumps functions, jump X lines if a shootable thing is in the MeleeRange (128 in my CustomPunch)

Anyone have any idea how to do that ? (Decorate code)
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Jarewill »

You could fire a hitscan attack with a limited range that gives a dummy item if it hits an enemy and then add a jump into your weapon.
Something like this:
Spoiler:
Edit: Nevermind that above, A_JumpIfCloser is a better solution.
Narset
Posts: 4
Joined: Tue Apr 21, 2020 8:33 pm

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Narset »

That's what i did first,

Problem : The value of the Closer range is slightly different from the value of the CustomPunch
-> The value of the closer is smaller than the value of the CustomPunch, the Closer also varies depending on the Hitbox's thing (The Radius)

Here is the code :

Code: Select all

	Fire:
		FPCH B 4 Offset (5, 40)
		FPCH C 4 Offset (5, 40)
		FPCH D 0 A_JumpIfCloser(128, "Fist1")
		FPCH D 4 Offset (5, 40) A_CustomPunch(random(0, 0), 1, 0, "GauntletPuff", 128)
		FPCH C 4 Offset (5, 40) A_TakeInventory("FistCheck", 2)
		FPCH B 4 Offset (5, 40) A_ReFire
		Goto Ready
	Fist1:
		FPCH D 0 A_JumpIfInventory("FistCheck", 2, "Fist2")
		FPCH D 4 Offset (5, 40) A_CustomPunch(random(40, 55), 1, 0, "GauntletPuff", 128)
		FPCH C 4 Offset (5, 40) A_GiveInventory("FistCheck", 1)
		FPCH B 4 Offset (5, 40) A_ReFire
		Goto Ready
	Fist2:
		FPCH D 0 A_PlaySound ("*fistgrunt", CHAN_VOICE)
		FPCH D 0 A_CustomPunch(random(80, 110), 1, 0, "GauntletPuff", 128)
		FPCH DE 4 Offset (5, 40) A_TakeInventory("FistCheck", 2)
		FPCH E 1 Offset (15, 50)
		FPCH E 1 Offset (25, 60)
		FPCH E 1 Offset (35, 70)
		FPCH E 1 Offset (45, 80)
		FPCH E 1 Offset (55, 90)
		FPCH E 1 Offset (65, 90)
		FPCH E 10 Offset (0, 150)
		Goto Ready


ACTOR FistCheck : Inventory
{
	Inventory.Amount 1 
	Inventory.MaxAmount 2 
}
In that case, I can be far enough away to touch the Thing without jumping with the "A_JumpIfCloser"
And i can't change the value of the Closer to make it equivalent, since it also depends on the Hitbox of the targeted thing...

Thx for the answer above, it can help me, and i will give you my results !
Narset
Posts: 4
Joined: Tue Apr 21, 2020 8:33 pm

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Narset »

I kept looking, we can actually use other functions like "radius+128" : A_JumpIfCloser(radius+128, "Fist1"), but the problem persists.

If anyone possibly knows what I can put in to take into account the target's radius, that could be the solution
User avatar
neoworm
Posts: 1751
Joined: Fri Sep 23, 2005 9:17 am
Location: Czech Republic

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by neoworm »

Look at what HeXen weapons are using - Mage's frost spell and cleric's Serpent staff.
User avatar
Lagi
Posts: 683
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Lagi »

neoworm wrote:Look at what HeXen weapons are using - Mage's frost spell and cleric's Serpent staff.
that would be a very good advice, if the wiki dont look like below "school essay", but provide an actual code you could copy paste modify
https://zdoom.org/wiki/A_FireConePL1
https://zdoom.org/wiki/A_CStaffCheck
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Snarboo »

[wiki]A_JumpIfTargetInLOS[/wiki] might also work for melee weapons. You can even set the distance to be checked for, and how it behaves at close range.
Narset
Posts: 4
Joined: Tue Apr 21, 2020 8:33 pm

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Narset »

The problem, they have specific functions for the actor, and cannot be modified

This is how i did it :

Code: Select all

----------
	Fire: 
		FPCH B 4 Offset (5, 40)
		FPCH C 4 Offset (5, 40)
		FPCH D 1 Offset (5, 40) A_CustomPunch(0, 1, 0, "GauntletsPuff", 90)
		FPCH D 3 Offset (5, 40) A_JumpIfInventory("Punch1Check", 1, "Punch1")
		FPCH C 4 Offset (5, 40) A_TakeInventory("Punch2Check", 2)
		FPCH B 4 Offset (5, 40) A_ReFire
		Goto Ready
	Punch1:
		FPCH D 0 Offset (5, 40) A_JumpIfInventory("Punch2Check", 2, "Punch2")
		FPCH D 3 Offset (5, 40) A_CustomPunch(random(40, 55), 1, 0, "PunchPuffX", 110)
		FPCH C 4 Offset (5, 40) A_TakeInventory("Punch1Check", 1)
		FPCH B 4 Offset (5, 40) A_ReFire
		Goto Ready
	Punch2:
		FPCH D 0 A_PlaySound("*fistgrunt", CHAN_VOICE)
		FPCH D 0 A_CustomPunch(random(80, 110), 1, 0, 0, 110)
		FPCH D 3 Offset (5, 40) A_TakeInventory("Punch2Check", 2)
		FPCH E 4 Offset (5, 40)
		FPCH E 1 Offset (15, 50)
		FPCH E 1 Offset (25, 60)
		FPCH E 1 Offset (35, 70)
		FPCH E 1 Offset (45, 80)
		FPCH E 1 Offset (55, 90)
		FPCH E 1 Offset (65, 90)
		FPCH E 10 Offset (0, 150)
		Goto Ready
----------

ACTOR GauntletsPuff : PunchPuff replaces PunchPuff
{
	Radius 8
	Height 8
	Alpha 0.6
	VSpeed 1
	RenderStyle "Translucent"
	+NOGRAVITY
	+NOBLOCKMAP
	+PUFFONACTORS
	+PUFFGETSOWNER
	+NOEXTREMEDEATH
	+NOTIMEFREEZE
	SeeSound "FighterPunchHitThing"
	AttackSound "FighterPunchHitWall"
	ActiveSound "FighterPunchMiss"
	States
	{
	Spawn:
		FHFX S 0
		FHFX S 4 A_GiveToTarget("Punch1Check", 1)
		FHFX TUVW 4
		Stop
	Crash:
		FHFX STUVW 4
		Stop
	}
}


ACTOR Punch1Check : Inventory
{
	Inventory.Amount 1
	Inventory.MaxAmount 1
}


ACTOR PunchPuffX
{
	Radius 8
	Height 8
	+PUFFONACTORS
	+PUFFGETSOWNER
	+NOTIMEFREEZE
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1 A_GiveToTarget("Punch2Check", 1)
		Stop
	}
}


ACTOR Punch2Check : Inventory
{
	Inventory.Amount 1
	Inventory.MaxAmount 2
}
User avatar
Lagi
Posts: 683
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

Re: A_JumpIf MeleeRange possible ? (Melee Weapon)

Post by Lagi »

just for information

all hardcoded actor functions are here, code in Zscript
https://github.com/coelckers/gzdoom/tre ... rs/heretic

f.ex. A_CStaffCheck
https://github.com/coelckers/gzdoom/blo ... icstaff.zs
Post Reply

Return to “Assets (and other stuff)”