Alt fire by holding the main attack button?

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!)

Alt fire by holding the main attack button?

Postby TwistedBean » Mon Jun 20, 2022 9:10 am

i did not realise it would be this hard for me to figure out, is there a way to trigger an alternative attack by pressing the main fire button ? to have a regular attack and the entirely different one be triggered by holding down the first ? the best example i could think of is how it is in skyrim or elderborn
User avatar
TwistedBean
 
Joined: 08 Nov 2019

Re: Alt fire by holding the main attack button?

Postby MFG38 » Mon Jun 20, 2022 9:44 am

You can define it in a weapon's Hold state.
User avatar
MFG38
 
Joined: 14 Apr 2019
Location: Finland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: Alt fire by holding the main attack button?

Postby TwistedBean » Mon Jun 20, 2022 10:10 pm

I could never figure how to make it work properly, maybe im testing it in the wrong file format
User avatar
TwistedBean
 
Joined: 08 Nov 2019

Re: Alt fire by holding the main attack button?

Postby Virathas » Mon Jun 20, 2022 11:46 pm

You could always do something simple/hacky like:
Code: Select allExpand view
Ready:
FRAM A 2
Loop
Fire:
FRAM A 2
FRAM A 0 A_ReFire("SuperFire")
RegularFire:
FRAM BCD 2
FRAM E 2 A_CustomPunch(random(1,2))
Goto Ready
SuperFire:
FRAM FGH 10
FRAM I 5 A_CustomPunch(random(100,200))
Goto Ready

Code obviously untested, but the main gist of it is to use an "A_Refire" close to the start of firing sequence.
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Alt fire by holding the main attack button?

Postby Dan_The_Noob » Tue Jun 21, 2022 12:40 am

would an altfire attack triggered by the fire button just be an attack?
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Alt fire by holding the main attack button?

Postby TwistedBean » Tue Jun 21, 2022 5:53 am

Virathas wrote:You could always do something simple/hacky like:
Code: Select allExpand view
Ready:
FRAM A 2
Loop
Fire:
FRAM A 2
FRAM A 0 A_ReFire("SuperFire")
RegularFire:
FRAM BCD 2
FRAM E 2 A_CustomPunch(random(1,2))
Goto Ready
SuperFire:
FRAM FGH 10
FRAM I 5 A_CustomPunch(random(100,200))
Goto Ready

Code obviously untested, but the main gist of it is to use an "A_Refire" close to the start of firing sequence.



Well thats the thin I was doing, but i cant seem to make imput differentiate between regular fire and super fire, maybe i should tweak the animation a bit for that
User avatar
TwistedBean
 
Joined: 08 Nov 2019

Re: Alt fire by holding the main attack button?

Postby Matt » Fri Jun 24, 2022 1:22 pm

[content warning: ZScript]

I've had a few situations like this where I had to manage a whole bunch of different button combos and the usual assumptions behind hold/althold/refire were getting in the way.

When this happens I end up writing a custom ready script which:

1. calls A_WeaponReady but disables anything that I don't want going to another weapon state (and thus stop calling this script) - basically only really needed so you can still switch weapons

2. then explicitly checks for player.cmd.buttons (and player.oldbuttons) for which buttons are being pressed (and which were being pressed or not pressed in the previous tic)

3. and once we have that information, calls a bunch of if/elses to check for specific combinations (note that you can also do things like get player.cmd.pitch/yaw to see if someone's trying to, say, drag from left to right or whatever)

The weapon can have its own internal trackers to see how long someone's holding down which button.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests