Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
odysseyofnoises

Implementing a Super-Chaingun in DeHackEd

Recommended Posts

I'm attempting to implement the chaingun from Valiant in my vanilla wad, but something is wrong. Whenever I fire the weapon, the chainsaw is superimposed on top of it, which makes no sense whatsoever, since the chainsaw isn't referenced anywhere in the DeHackEd code. The new chaingun replaces the rocket launcher (there is a legit reason, but that's beyond the scope of this post) and must work in vanilla DeHackEd. What's going on here, and how do I correct this ridiculous issue?

chaingunfail.zip

Share this post


Link to post

In vanilla Doom, the function FireCGun has quirky hardcoded behavior for its muzzle flash animation. Every time FireCGun is called, the weapon starts its muzzle flash animation from a state whose index is defined by the following formula:

		  weaponinfo[player->readyweapon].flashstate
		  + psp->state
		  - &states[S_CHAIN1]

 

The value of "weaponinfo[player->readyweapon].flashstate" is the index of the weapon's muzzle flash state as defined in the Weapon table. The value of "psp->state" is the index of the current state that calls FireCGun. The value of "&states[S_CHAIN1]" is the index of the first state of the original, unmodified chaingun's firing animation (that is, number 52, a constant).

 

Knowing these values, you should be able to arrange the states of your weapon's firing and muzzle flash animations to sync properly in vanilla Doom. However, beware that some source ports may not (and, from my experience, indeed do not) keep the vanilla behavior as is, so your weapon will end up not working properly in those ports.

 

The safest thing to do is to avoid using FireCGun in any other states than the ones where the original, unmodified chaingun uses it, while also keeping the muzzle flash animation in its original place. Consider using FirePistol instead, which always calls muzzle flash animation from its very first frame as defined in the Weapon table.

Edited by scifista42

Share this post


Link to post

Thanks for the explanation. I had no idea FireCGun was such a pain, so I instead re-engineered the weapon to use FirePistol (knowing that two pistol shots is equivalent to one chaingun shot). I'm even closer now, but there still seems to be a problem with the muzzle flash animation: It only displays one frame whilst the gun is firing instead of alternating between two as it should. In addition, the muzzle flash displays while the gun is winding down, which isn't supposed to be the case. How do I sort through this mess now? Attached is my current best attempt.

chaingun_almost.zip

Share this post


Link to post

As I already said, every time FirePistol is called, the muzzle flash animation restarts from its first frame as defined in the Weapon table. If you don't want that, you have to use FireCGun, and if you want to use FireCGun safely, you have to keep the FireCGun states and the muzzle flash states in their original places. That's all.

Share this post


Link to post

Sorry, I didn't quite understand your explanation the first time around. Anyways, I ended up figuring out how to solve all of my problems, and the weapon works as intended. The only outstanding bug is that, in Chocolate Doom, the weapon will not switch to the fist/chainsaw if you run of out ammo and have no other weapons, but I'm afraid there's no solution to that problem (that I can envision).

vanillamod.zip

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×