[HELP]Issue with GetPlayerInput in ZScript

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
Ozymandias81
Posts: 2069
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

[HELP]Issue with GetPlayerInput in ZScript

Post by Ozymandias81 »

Long time I don't show up here, I decided some days ago to work a bit on Hexed Underworld and still didn't figure out a thing, so better ask here.

While I am using the Hexen's fighter A_TryPunch action function to let this work (a copy of it, not overridden), but somehow the BT_ALTATTACK doesn't work at all and I don't want to use USER# entries or movement buttons (movements works, already implemented over weapons, I just need to figure out this Punch to change into Shield if I press altfire). Little snippet of my ZScript here:

Code: Select all

	//============================================================================
	//
	// From Hexen's Fighter TryPunch
	//
	// Returns true if an actor was punched, false if not, adapt it for HUW
	//
	//============================================================================

	action bool A_UWPunchInit()
	{
		if((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK)) //works
		{
			player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState("Punch"));
			A_StartSound ("*fistgrunt", CHAN_VOICE);
			return true;
		}
		else if((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK)) /does nothing
		{
			player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState("ShieldRaise"));
			return true;
		}
		return false;
	}
I am not fond with ZScript, so I wonder if there is also a different approach (easy) for this thing to let it work. You can check the full code here for the Base code and the Weapon
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: [HELP]Issue with GetPlayerInput in ZScript

Post by Jarewill »

This function gets called in the first frame of your Fire state, which is entered when the player presses the Fire button, which is why the first check will always pass and not allow the second check to do its thing.
User avatar
Ozymandias81
Posts: 2069
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: [HELP]Issue with GetPlayerInput in ZScript

Post by Ozymandias81 »

Well that seems to not be the problem, since before my recent changes (now it just randomly pick states for non-Fist weapons) the function UWWeapInit was working fine on all other weapons, even Fists (which had left/right attack by checking the moveleft/right buttons).

My bad, you are right, that way I said works ONLY if I add directions btw (by keeping even the first attack with BT_ATTACK). I just moved the call on Ready state and it works nicely. :3:
Post Reply

Return to “Scripting”