making a weapon still work with no ammo

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Virtue
Posts: 919
Joined: Sun Nov 19, 2006 8:15 am
Location: Manchester UK

making a weapon still work with no ammo

Post by Virtue »

Im having trouble with my weapon, Im using the doom alpha rifle as a weapon and you can toggle the bayonet with secondary fire (either on or off), however you cant use the bayonet when there is no ammo in the standard rifle, is there any way to make it so you can use the bayonet WITHOUT ammo? ive had a crack at it with jumpifnoammo but so far no results. Heres the code:

Code: Select all

actor Rifle : Weapon 10014
{
  obituary "%o was shot by %k's rifle."
  inventory.pickupmessage "You got the Rifle!"  
  weapon.selectionorder 1900
  weapon.kickback 100
  weapon.ammotype "Clip"
  weapon.ammouse 1
  weapon.ammogive 10
  +WEAPON.WIMPY_WEAPON
 
  states
  {
  Ready: 
    PRIF A 0 A_JumpIfInventory("bayonetready",1,3)
    PRIF A 0 A_jumpifnoammo (2)     
    PRIF A 1 A_WeaponReady 
    goto ready
    PBAY B 1 A_WeaponReady
    goto ready+5    
  Deselect:
    PRIF A 1 A_Lower
    loop
  Select:
    PRIF A 1 A_Raise
    loop
  Fire:
    PRIF A 0 A_jumpifnoammo (8)
    PRIF A 0 A_JumpIfInventory("bayonetready",1,7)
    PRIF A 3
    PRIF A 0 A_playweaponsound("grunt/attack")
    PRIF B 0 A_FireBullets (0, 0, 1, 5, "BulletPuff")
    PRIF B 3 A_GunFlash
    PRIF C 2
    PRIF B 4 A_ReFire
    goto Ready
    PBAY B 4
    PBAY C 4 
    PBAY D 5 A_CustomPunch(5,0,0,"puff")
    PBAY C 4
    PBAY B 5 A_ReFire
    goto ready   
  Flash:
    PSHO E 3 bright A_Light1
    PSHO F 2 bright A_Light0
    stop
  Altfire:
    PBAY A 0 A_JumpIfInventory("bayonetready",1,18)
    PBAY A 0 A_GiveInventory("bayonetready",1)
    PRIF BCDEFGH 1 
    PBAY MLKJIHGFE 1 
    goto Ready
    PBAY A 0 A_TakeInventory("bayonetready",1)
    PBAY EFGHIJKLM 1 
    PRIF HGFEDCB 1
    goto Ready  
  Spawn:
    RIFL A -1 
    stop
  }
}
User avatar
phi108
Posts: 976
Joined: Sat Dec 01, 2007 6:28 pm

Re: making a weapon still work with no ammo

Post by phi108 »

Is this for SVN? If so, you can make a new state with the code.

Bayonet:
PBAY B 4
PBAY C 4
PBAY D 5 A_CustomPunch(5,0,0,"puff")
PBAY C 4
PBAY B 5 A_ReFire
goto ready

And then make the A_Jumpifnoammo ("bayonet")
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Re: making a weapon still work with no ammo

Post by TheDarkArchon »

That won't work either: The weapon will lower as soon as it's out of ammo. You need the AMMO_OPTIONAL flag. Also, have the check for the BayonetReady item at the A_JumpIfNoAmmo destination, else you'll be able to bayonet without attaching it first.
CaptainToenail
Posts: 3975
Joined: Fri Jul 06, 2007 9:16 am

Re: making a weapon still work with no ammo

Post by CaptainToenail »

Couldn't you just use take_inventory or whatever to make it use ammo?
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: making a weapon still work with no ammo

Post by Enjay »

I don't know if it's because I use an althold state or what, but all the weapons in my own TC (most of which are also in my Burghead release) have a secondary fire that uses no ammo. Each weapon has it's normal primary fire but the secondary fire shoots a constant stream of invisible, no ammo projectiles with a dynamic light attached to work as a flashlight. You can switch to any of the weapons, even when they have no ammo, and use alt fire without the weapon switching away to something else. If you are using primary fire when the weapon runs out of ammo, it will switch away though. So maybe that's not what is requied?

Anyway, I don't remember doing anything particularly special to make it happen.
User avatar
Virtue
Posts: 919
Joined: Sun Nov 19, 2006 8:15 am
Location: Manchester UK

Re: making a weapon still work with no ammo

Post by Virtue »

well secondary fire "selects" the bayonet, it doesnt fire it. you fire the bayone with normal fire. Basically i took inspiration from Eriance and his alt weapons, where by you select a different fire mode with secondary fire. The problem is without any ammo you cant fire the bayonet cus technically its still on primary fire.
User avatar
Virtue
Posts: 919
Joined: Sun Nov 19, 2006 8:15 am
Location: Manchester UK

Re: making a weapon still work with no ammo

Post by Virtue »

anyone?
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: making a weapon still work with no ammo

Post by Enjay »

Is there any reason why you don't want to have the bayonet actually "fire" on secondary rather than using secondary to select it and primary to fire?
User avatar
Juan "JacKThERiPPeR
Posts: 931
Joined: Sun Jun 03, 2007 7:25 am
Location: SPAIN
Contact:

Re: making a weapon still work with no ammo

Post by Juan "JacKThERiPPeR »

You forgot [wiki]SetWeapon[/wiki].
You place that on a frame after getting the "bayonetready" and I guess It'll work. I GUESS. If it doesn't, blame me. I can't think of anything else.
CaptainToenail
Posts: 3975
Joined: Fri Jul 06, 2007 9:16 am

Re: making a weapon still work with no ammo

Post by CaptainToenail »

You could permantly have the bayonet on the rifle and alt fire makes you thrust it forward and stab things. Use Take_inventory to take ammo from you every time you fire bullets from the rifle. Should work fine
User avatar
Virtue
Posts: 919
Joined: Sun Nov 19, 2006 8:15 am
Location: Manchester UK

Re: making a weapon still work with no ammo

Post by Virtue »

Enjay wrote:Is there any reason why you don't want to have the bayonet actually "fire" on secondary rather than using secondary to select it and primary to fire?
if youve seen the graphics, they are completly different, it would look stupid to have it suddenly switch to the bayonet.
You could permantly have the bayonet on the rifle and alt fire makes you thrust it forward and stab things. Use Take_inventory to take ammo from you every time you fire bullets from the rifle. Should work fine
I want it to be authentic to the beta doom.

Im probibly going to make a custom pickup which has both weapons as seperate, thanks for you help guys anyway.
Locked

Return to “Editing (Archive)”