Only issue I'm really happening is that I'm wanting it to automatically fire while charging depending on how much ammo is left in the battery.
Say for example, shooting with 75% charge will fire a pretty strong beam that costs 6 units of ammo to fire. A fully charged shot takes 10 units of ammo to shoot and has to charge to 100% charge before it can shoot a fully charged shot.
But what if you don't have 10 units of ammo? Ideally, the gun would continue to charge while the fire button is held, and as soon as it detects that you're at 75% charge and don't have enough ammo for a fully charged shot, would skip the charge phase and move directly to the mostly charged state.
I have been going at it for a while now and just haven't figured out a way to make that happen, but here's what I got so far.
Code: Select all
Fire:
RCHR A 0 A_JumpIfNoAmmo("Beep") //Beep is the dry firing state, playing a sound to let the player know they're out of ammo.
RCHR A 1 A_PlaySound("weapons/chargeriflecharge",0)
Proceed:
RCHR A 0 A_JumpIfNoAmmo("Beep")
RCHR A 0 A_Refire
RCHR A 0 A_JumpIfInventory("ChargeRifShot",10,2) //If the player has enough ammo for a fully charged shot, jump Two states
RCHR A 0 A_Jump(256,2) //Otherwise, skip the Fully Charged check and jump ahead to the next check
RCHR A 0 A_JumpIfInventory("ChargeCount",100,"Charge5") //Charge5 being the Fully Charged shot
RCHR A 0 A_JumpIfInventory("ChargeRifShot",6,2) //If the player has enough ammo for a mostly charged shot, jump Two states
RCHR A 0 A_Jump(256,2) //Otherwise, skip the Mostly Charged check and jump ahead to the next check
RCHR A 0 A_JumpIfInventory("ChargeCount",75,"Charge4") //Charge4 being the Mostly Charged shot
RCHR A 0 A_JumpIfInventory("ChargeRifShot",4,2) //You get it, yea yea
RCHR A 0 A_Jump(256,2)
RCHR A 0 A_JumpIfInventory("ChargeCount",50,"Charge3")
RCHR A 0 A_JumpIfInventory("ChargeRifShot",2,2)
RCHR A 0 A_Jump(256,2)
RCHR A 0 A_JumpIfInventory("ChargeCount",25,"Charge2")
RCHR A 0 A_JumpIfInventory("ChargeRifShot",1,2)
RCHR A 0 A_Jump(256,2)
RCHR A 0 A_JumpIfInventory("ChargeCount",1,"Charge1")
Goto Beep
Hold:
RCHR A 0 A_JumpIfNoAmmo("Beep")
RCHR A 1 A_GiveInventory("ChargeCount",1) //The Counter item which determines how much the gun is charged. Goes up to 100
Goto Proceed