Jump to content

Hello, i am new to dehacked and i need help changing the weapon switch speed


Recommended Posts

Posted (edited)

I've been playing this doom mod called boiled doom(more specifically the aldente fork) and I want to make a minor edit that makes the weapon switching faster similarly to mods like d4v or the actual brutal doom, but I don't know how. any help is greatly appreciated

Edited by DOOMMALE

Share this post


Link to post

There are multiple ways to achieve this, depending on the specific behavior you're after. Examples below will be in DECOHack syntax, but you can do all of these using WhackEd too.

 

Instant weapon switching is relatively simple to do by using 0-duration A_Raise and A_Lower states:

weapon 1 {
	states {
		select:
			PISG A 0 A_Raise
			loop
		deselect:
			PISG A 0 A_Lower
			loop
	}
}

However as of writing only a few source ports (GZDoom and Eternity out of ones I tested) prevent holding down the weapon select key from constantly swapping between weapons in the same slot. This makes SSG and shotgun for example a pain to swap between.

 

If you prefer a smooth, non-instant weapon switching and aren't state-limited, you can simply duplicate the A_Raise and A_Lower states:

weapon 1 {
	states {
		select:
			PISG AAAA 0 A_Raise
			PISG A 1 A_Raise
			loop
		deselect:
			PISG AAAA 0 A_Lower
			PISG A 1 A_Lower
			loop
	}
}

You can adjust the speed of the weapon switch by changing the number of 0-duration states. More states means more speed. This of course consumes more codepointers, so it's not that good for vanilla (although it does work).

 

Another way to do fast and smooth-ish weapon switching if you're state-limited is to set the Raise state to go directly to the Ready state and use sprite offsets to speed things up. The following example is from 1000 Lines 3, and is based on previous work on fast weapon switching by antares031.

weapon 0
{
	states
	{
		select:
			PISG A 1 Offset(1,52) A_Raise
			goto ready
		deselect:
			PISG A 1 Offset(1,92)
			PISG A 1 A_Lower
			wait
	}
}

By adjusting the offsets you adjust the speed and overall look of the transition.

 

In addition, if your weapon switch is quick enough (or you use invisible sprites for deselecting), you can save some more states by sharing one Lower state for all weapons:

weapon 0
{
	states
	{
		select:
			//chosen method for Raise behavior
		deselect:
			//chosen method for Lower behavior
	}
}


weapon 1 {
  	state deselect weapon 0 deselect
	states {
		select:
			//chosen method for Raise behavior
	}
}

...

 

Share this post


Link to post
10 hours ago, Aurelius said:

There are multiple ways to achieve this, depending on the specific behavior you're after. Examples below will be in DECOHack syntax, but you can do all of these using WhackEd too.

 

Instant weapon switching is relatively simple to do by using 0-duration A_Raise and A_Lower states:


weapon 1 {
	states {
		select:
			PISG A 0 A_Raise
			loop
		deselect:
			PISG A 0 A_Lower
			loop
	}
}

However as of writing only a few source ports (GZDoom and Eternity out of ones I tested) prevent holding down the weapon select key from constantly swapping between weapons in the same slot. This makes SSG and shotgun for example a pain to swap between.

 

If you prefer a smooth, non-instant weapon switching and aren't state-limited, you can simply duplicate the A_Raise and A_Lower states:


weapon 1 {
	states {
		select:
			PISG AAAA 0 A_Raise
			PISG A 1 A_Raise
			loop
		deselect:
			PISG AAAA 0 A_Lower
			PISG A 1 A_Lower
			loop
	}
}

You can adjust the speed of the weapon switch by changing the number of 0-duration states. More states means more speed. This of course consumes more codepointers, so it's not that good for vanilla (although it does work).

 

Another way to do fast and smooth-ish weapon switching if you're state-limited is to set the Raise state to go directly to the Ready state and use sprite offsets to speed things up. The following example is from 1000 Lines 3, and is based on previous work on fast weapon switching by antares031.


weapon 0
{
	states
	{
		select:
			PISG A 1 Offset(1,52) A_Raise
			goto ready
		deselect:
			PISG A 1 Offset(1,92)
			PISG A 1 A_Lower
			wait
	}
}

By adjusting the offsets you adjust the speed and overall look of the transition.

 

In addition, if your weapon switch is quick enough (or you use invisible sprites for deselecting), you can save some more states by sharing one Lower state for all weapons:


weapon 0
{
	states
	{
		select:
			//chosen method for Raise behavior
		deselect:
			//chosen method for Lower behavior
	}
}


weapon 1 {
  	state deselect weapon 0 deselect
	states {
		select:
			//chosen method for Raise behavior
	}
}

...

 

Thanks for the help man this will be a game changer, literally.

Share this post


Link to post
Posted (edited)

As I stated I use nugget doom, which supports infinite states so method 2 will be the one I use for now.

Edited by DOOMMALE

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...