Page 1 of 1

making a weapon still work with no ammo

Posted: Thu Feb 14, 2008 11:11 am
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
  }
}

Re: making a weapon still work with no ammo

Posted: Thu Feb 14, 2008 11:19 am
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")

Re: making a weapon still work with no ammo

Posted: Fri Feb 15, 2008 4:40 am
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.

Re: making a weapon still work with no ammo

Posted: Fri Feb 15, 2008 5:05 am
by CaptainToenail
Couldn't you just use take_inventory or whatever to make it use ammo?

Re: making a weapon still work with no ammo

Posted: Fri Feb 15, 2008 7:07 am
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.

Re: making a weapon still work with no ammo

Posted: Fri Feb 15, 2008 10:25 am
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.

Re: making a weapon still work with no ammo

Posted: Thu Feb 21, 2008 9:11 am
by Virtue
anyone?

Re: making a weapon still work with no ammo

Posted: Thu Feb 21, 2008 9:44 am
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?

Re: making a weapon still work with no ammo

Posted: Thu Feb 21, 2008 11:03 am
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.

Re: making a weapon still work with no ammo

Posted: Thu Feb 21, 2008 11:40 am
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

Re: making a weapon still work with no ammo

Posted: Thu Feb 21, 2008 12:09 pm
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.