A_WeaponOffset

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

A_WeaponOffset

Post by Major Cooke »

Pull Request

A_WeaponOffset(float x = 0, float y = 32, flags = 0)
  • WOF_KEEPX - Don't change the X offset.
  • WOF_KEEPY - Self explanatory.
  • WOF_ADD - Add instead of replace the offset.
This effect stacks with normal weapon movement bobbing. You can continue using the customized offsets by using WRF_NOBOB in A_WeaponReady. These offsets are not lost when firing either. You can really go to town using inventory items if you so wish and make some really complex bobbing scenes if coupled with velx/vely/velz and whatever else you want.

Code: Select all

Actor Tok : Inventory
{
	Inventory.MaxAmount 360
}

Actor RL2 : RocketLauncher
{
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	States
	{
	Ready:
		MISG A 1 
		{
			A_WeaponReady;
			A_GiveInventory("Tok",10);
			
			if (CountInv("Tok") >= 360)
			{	A_TakeInventory("Tok",1000,0);	}
			
			A_WeaponOffset(sin(CountInv("Tok")) * 10);
		}
		Loop
	
	Fire:
		MISG B 4 A_GunFlash
		MISG B 6 A_FireCustomMissile("Rocket",0,0)
		MISG B 1 A_Refire
		Goto Ready
	}
}
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: A_WeaponOffset

Post by Edward-san »

There's a typo in the name of the function.

Also, a small nit which is not fundamental: this branch is redundant, because there are not many operations or function calls which might affect performance before the flags check below.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponOffset

Post by Major Cooke »

A typo with a capital letter against a smaller letter. I thought I was a perfectionist. :P
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

Re: A_WeaponOffset

Post by DBThanatos »

Wait a second. Does that mean that we can have a custom bobbing too, completely separate from movebob? That'd be a dream come true.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponOffset

Post by Major Cooke »

If you want to go batshit bananas using trigonometry, velocity measurements and some sweet smooth jazz music that you just can't handle because it's too awesome for your ears, you certainly can do that too.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: A_WeaponOffset

Post by NeuralStunner »

Yes! We can finally deprecate clunky old offset(). :D
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponOffset

Post by Major Cooke »

Indeed, but just remember, due to the nature of what A_WeaponOffset is for, there's no user var usage with it. Get comfortable with items, because that's why I also made CountInv for. :P
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: A_WeaponOffset

Post by Ed the Bat »

Can it handle random()? I've been waiting for some four years now for a way to make random offsets.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponOffset

Post by Major Cooke »

If trigonometry functions work, so will (f)random and expressions of any kind. In short, yes.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: A_WeaponOffset

Post by Ed the Bat »

Solid. Once this is approved and appears in a dev build, I can go mark my existing feature suggestions for closure.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponOffset

Post by Major Cooke »

I can only wonder how many that count is. :P
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_WeaponOffset

Post by Graf Zahl »

Ed the Bat wrote:I can go mark my existing feature suggestions for closure.
Bring 'em on!
User avatar
Nash
 
 
Posts: 17494
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: A_WeaponOffset

Post by Nash »

Very cool, perhaps I can finally ditch the homebrew GunOffsetX/Y ACS commands and natively use this to do weapon sway/pitch shifting (that's seen in a lot of my videos) natively. Expect a code dump soon!

EDIT: Also, for plain offset animation authoring, I wouldn't ditch good ol' Offset(), it's still useful for those... and with highly specialized tools like Danimator outputting to Offset() format, I wouldn't really consider Offset() deprecated at all.
User avatar
Zhs2
Posts: 1300
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere
Contact:

Re: A_WeaponOffset

Post by Zhs2 »

Major Cooke wrote:Indeed, but just remember, due to the nature of what A_WeaponOffset is for, there's no user var usage with it. Get comfortable with items, because that's why I also made CountInv for. :P
>mfw people don't realize that the user variables have to be defined in the player to work with weapons
User avatar
arookas
Posts: 265
Joined: Mon Jan 24, 2011 6:04 pm
Contact:

Re: A_WeaponOffset

Post by arookas »

IIRC, you can make only weapons that modify player user variables (set only). You can't use them in expressions (or get their value in any way) or else it gets the value of that user variable on the weapon (and since it doesn't exist, reads out-of-bounds memory). Not particularly useful, especially not for A_WeaponOffset.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”