[ZScript] Smooth scaling of weapon/psprite animation speed

Post your example zscripts/ACS scripts/etc here.

[ZScript] Smooth scaling of weapon/psprite animation speed

Postby argv » Thu Nov 09, 2017 12:11 pm

The attached pk3 adds three new weapons to the game (which you'll have to “give” yourself from the console): “SpeedScalingPistol”, “SpeedScalingShotgun”, and “SpeedScalingChaingun”. The rate of fire of these weapons is controlled by the CVar “weapon_speed_scale”. If set to a negative number, then for each tic of animation, that many tics will be skipped. If set to a positive number, then for each tic of animation, that many tics will be added. This can be a fraction; “weapon_speed_scale -0.5” makes the weapons fire at 1.5× their normal rate.

If you think you could use this in your mod, take a look inside the pk3. You'll need to copy the class “PSpriteSpeedScaler” and the struct “PSpriteSpeedScalerSet” into your mod. Then, on your weapon classes, add a PSpriteSpeedScalerSet field, and call it from the Tick method as shown.

The main use case I had in mind for this is RPG-like mods, where attack speed is affected by the player character's skills and attributes.

Hope it helps!
Attachments
speedscale.pk3
(1.81 KiB) Downloaded 68 times
argv
 
Joined: 30 Aug 2016

Re: [ZScript] Smooth scaling of weapon/psprite animation spe

Postby Nash » Thu Nov 09, 2017 2:33 pm

Very useful! Thanks for sharing.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [ZScript] Smooth scaling of weapon/psprite animation spe

Postby argv » Thu Nov 09, 2017 2:35 pm

I've done some additional work on this code, which you can track in my Bitbucket repository.

Specifically, I've made the following changes:
  • Slight optimization.
  • Split into two ZScript files: one with the actual mod, and one with the demonstration weapons.
  • Improve the way it interacts with PowerDoubleFiringSpeed.
argv
 
Joined: 30 Aug 2016


Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest