Jump to content
  • 0

Unlimited ammo error in altfire


Ani

Question

I'm making a doom weapons mod and I wanna use the beta BFG blast as an altfire. For whatever reason it won't behave like it would as a regular fire state. As an altfire, the weapon will not stop firing the beta blast even after the cell is gone. Almost like unlimited fire power. This is my decorate code and I dunno what I'm doing wrong here. What should I fix here?

 

Altfire:
    BFGG A 10 A_BFGSound
    BFGG A 0 A_TakeInventory("Cell", 40)
    BFGG A 0 A_JumpIfNoAmmo("ANoAmmoState")
    BFGG BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_FireOldBFG
    BFGG B 0 A_Light0
    BFGG B 20 A_ReFire
    Goto Ready

Edited by Ani

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

Post the entire DECORATE code you're using for your modified BFG in a code block

like this

There's not enough information for me to proceed without making assumptions, and I'd rather not do that.

Share this post


Link to post
  • 0

fuck it, assumptions it is.

 

I am working off of the guess that your DECORATE code for the weapon looks like the following:

Actor BFG2 : BFG9000 replaces BFG9000
{
  States
  {
  AltFire:
    BFGG A 10 A_BFGSound
    BFGG A 0 A_TakeInventory("Cell", 40)
    BFGG A 0 A_JumpIfNoAmmo("ANoAmmoState")
    BFGG BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_FireOldBFG
    BFGG B 0 A_Light0
    BFGG B 20 A_ReFire
    Goto Ready
  }
}

There are a few problems if your code looks like this. In order:

  1. You do not have an alt-fire ammo use amount defined. The original BFG9000 actor doesn't have any value set for it either (since the "OldFire" state isn't actually used) so it defaults to 0. In order for "A_FireOldBFG" to use ammo, you need to add this property in.
  2. "A_TakeInventory" will remove items even if the player doesn't have the full amount requested. For example, if the player has used the Plasma gun and dips to 32 cells before switching to this BFG and fires, the "A_TakeInventory" line you have there will remove the 32 cells. Using this to remove ammo is inadvisable since weapons already have multiple ways to natively handle this kind of check.
  3. Relating to number 1, "A_JumpIfNoAmmo" will only perform its jump if the player's current ammo is below the amount used in its current attack mode. For the Alt-fire, that amount is currently 0 since it's not defined, so the jump immediately fails.
  4. Furthermore, "A_JumpIfNoAmmo" will either jump by an offset value or to a specific state. "ANoAmmoState" does not seem to be some sort of internal alias or special value or whatever, and you didn't include a definition for a state named "ANoAmmoState", so even if the jump's ammo check worked it would still fail and fall through.
  5. The "A_FireOldBfg" function uses ammo, and will fail if there isn't ammo left to use. Conversely, since your alt-fire does not have an ammo use defined, it cannot fail - it doesn't use any ammo!

I get that this may seem like a lot, but the old BFG firing state is a bit weird to make good use of. There's a shit-ton to go over and probably a few different (and better) ways this could be handled, but based on what you've described this is probably how I would handle the DECORATE code for it:

Actor BFG2 : BFG9000 replaces BFG9000
{
  Weapon.Slotnumber 7		//Should now be selectable by pressing "7" like the original BFG
  Weapon.Ammotype2 "Cell"	//Ammo type for the alt fire
  Weapon.Ammouse2 1		//Amount of ammo used for each "A_FireOldBFG" that gets called in the alt fire
  States
    {
  AltFire:
    BFGG B 0 A_JumpIfInventory("Cell", 40, "AltFire2")	//If the player has at least 40 cells, fire. If not...
    BFGG B 0 A_SelectWeapon("PlasmaRifle", SWF_SELECTPRIORITY)	//Switch their weapon as if they were completely out of ammo.
  AltFire2:
    BFGG A 10 A_BFGSound
    BFGG B 0 A_GunFlash("Flash2")	//The "OldFire" state provided by the ZDoom wiki doesn`t have a gun flash defined. I gave it one.
    BFGG BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_FireOldBFG
    BFGG B 0 A_Light0
    BFGG B 0 A_JumpIfInventory("Cell", 40, "AltFire2")	//If the player has at least 40 cells after firing, allow them to return to the READY state or refire. 
    BFGG B 0 A_SelectWeapon("PlasmaRifle", SWF_SELECTPRIORITY)	//If not, switch their weapon.
    BFGG B 20 A_ReFire("AltFire")		//When re-firing, return to the initial check just in case.
    Goto Ready
  Flash2:
    BFGF ABABABABABABABABABABABABABABABABABABABAB 1  Bright		//wheeeee
    Goto LightDone
    }
}

Hopefully my comments make enough sense. This should work, but I haven't done extensive testing, so I apologize in advance if it misbehaves.

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
Answer this question...

×   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...