[DECORATE] [SOLVED] Weapon uses 2 ammo instead of 1

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Fabysk
Forum Regular
Posts: 469
Joined: Sat Sep 22, 2012 8:17 pm
Location: In a house...duhh

[DECORATE] [SOLVED] Weapon uses 2 ammo instead of 1

#1

Post by Fabysk » Tue Sep 10, 2019 9:13 pm

I am unsure as to why this is happening. I do have a total of 20 weapons in my next project, but they all use the same DECORATE code. Does anyone have any idea as to why this is happening? I did remove the AltFire and ADS actor states to see if it fixed it, but it continues to use 2 ammo. What am I doing wrong here?

Code: Select all

ACTOR Sparrow_Ammo : Ammo
{
  Inventory.PickupMessage "Picked up Sparrow Ammo"
  Inventory.Amount 10
  Inventory.MaxAmount 80
  Ammo.BackpackAmount 20
  Ammo.BackpackMaxAmount 110
  Inventory.Icon "CLIPA0"
  States
  {
  Spawn:
    CLIP A -1
    Stop
  }
}

ACTOR Sparrow : Weapon 13015
{
  Game Doom
  SpawnID 215
  Weapon.AmmoUse 1
  Weapon.AmmoGive 100
  Weapon.AmmoType "Sparrow_Ammo"
  Obituary "%k <Sparrow> %o"
  Inventory.Pickupmessage "Picked up the Sparrow"
  Decal "BulletChip"
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.7
  Weapon.BobSpeed 1.6
  Radius 4
  Height 1
  Scale 0.15
  +NOAUTOFIRE
  States
  {
  Spawn:
    SPR0 A -1
    Stop
  Ready:
	TNT1 A 0 A_ZoomFactor(1.0)
	TNT1 A 0 A_JumpIfInventory("ADS", 1, "ReadyADS")
    SPR1 A 1 A_WeaponReady
	TNT1 A 0 A_SetCrosshair(2)
    Loop
  Deselect:
	TNT1 A 0 A_ZoomFactor(1.0)
	TNT1 A 0 A_TakeInventory("ADS", 1)
	TNT1 AAAAA 0 A_Lower 
    SPR1 A 1 A_Lower
    Loop
  Select:
	TNT1 A 0 A_ZoomFactor(1.0)
	TNT1 A 0 A_TakeInventory("ADS", 1)
    TNT1 AAAAA 0 A_Raise 
    SPR1 A 1 A_Raise
    Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("ADS", 1, "Fire_ADS")
	SPR1 A 2
	TNT1 A 0 A_SetPitch (pitch-1.2)
	TNT1 A 0 Offset(2,37)
	TNT1 A 0 Offset(1,36)
	TNT1 A 0 Offset(0,33)
	TNT1 A 0 A_PlaySound("weapon/Sparrow", 127)
	SPR1 B 1 Bright A_FireBullets(6, 6, 1, 13, "BulletPuff")
	TNT1 A 0 A_SpawnItem("SMG_Bullet_Casing", -10, 40)
	SPR1 A 1
    Goto Ready
  AltFire:
	TNT1 A 0 A_JumpIfInventory("ADS", 1, "RemoveADS")
    TNT1 AAAAA 0 A_Lower 
    SPR1 A 1 A_Lower
	TNT1 A 1 A_GiveInventory("ADS", 1)
	TNT1 AAAAA 0 A_Raise
    SPR1 C 1 A_Raise
	Goto ReadyADS
  RemoveADS:
    TNT1 AAAAA 0 A_Lower 
    SPR1 C 1 A_Lower
	TNT1 A 1 A_TakeInventory("ADS", 1)
	TNT1 AAAAA 0 A_Raise
    SPR1 A 1 A_Raise
	Goto Ready
  ReadyADS:
    TNT1 A 0 A_ZoomFactor(1.5)
    SPR1 C 1 A_WeaponReady
	TNT1 A 0 A_SetCrosshair(0)
	Loop
  Fire_ADS:
	SPR1 C 2
	TNT1 A 0 A_SetPitch (pitch-1.2)
	TNT1 A 0 Offset(2,37)
	TNT1 A 0 Offset(1,36)
	TNT1 A 0 Offset(0,33)
	TNT1 A 0 A_PlaySound("weapon/Sparrow", 127)
	SPR1 D 1 Bright  A_FireBullets(4, 4, 1, 13, "BulletPuff")
	TNT1 A 0 A_SpawnItem("SMG_Bullet_Casing", -10, 40)
	SPR1 C 1
    Goto Ready
  }
}
Last edited by Fabysk on Wed Sep 11, 2019 8:08 pm, edited 1 time in total.

User avatar
Ænima
Addicted to Zandronum
Posts: 3523
Joined: Tue Jun 05, 2012 6:12 pm

[DECORATE] Re: Weapon uses 2 ammo instead of 1

#2

Post by Ænima » Tue Sep 10, 2019 10:15 pm

Add a fourth argument to your a_spawnitem call and make it “0”.

ex:

TNT1 A 0 A_SpawnItem("SMG_Bullet_Casing", -10, 40, 0)
­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­
Doom64: Unabsolved: New weapons, monsters, and gameplay features for coop !


ZandroSkins
: a pack made by our community

User avatar
Fabysk
Forum Regular
Posts: 469
Joined: Sat Sep 22, 2012 8:17 pm
Location: In a house...duhh

[DECORATE] Re: Weapon uses 2 ammo instead of 1

#3

Post by Fabysk » Tue Sep 10, 2019 10:43 pm

Ænima wrote:
Tue Sep 10, 2019 10:15 pm
Add a fourth argument to your a_spawnitem call and make it “0”.

ex:

TNT1 A 0 A_SpawnItem("SMG_Bullet_Casing", -10, 40, 0)
Much appreciated! I never thought about that since I thought the fourth argument would always be 0 if left empty. I moved the code I provided to a separate wad file and worked normally which I through was strange. Thanks for the simple fix!

User avatar
-Jes-
Frequent Poster Miles card holder
Posts: 975
Joined: Fri Aug 03, 2012 9:55 am
Location: Void Zone

[DECORATE] Re: Weapon uses 2 ammo instead of 1

#4

Post by -Jes- » Wed Sep 11, 2019 6:33 pm

When in doubt, consult the zdoom wiki!

Of course, remember that Zandy is a bit behind in terms of code, so if you really want to use a function on the wiki, check the history page it's on for updates a few years back and check if it's still there. If it is, you're good to go.

User avatar
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

[DECORATE] Re: [SOLVED] Weapon uses 2 ammo instead of 1

#5

Post by TDRR » Wed Sep 18, 2019 4:06 am

To be more specific, you might want to check the history for August 2014, but early 2015 probably is safe too.
"I will find joy in Yahweh. I will delight in my Elohim. He has dressed me in the clothes of salvation. He has wrapped me in the robe of righteousness like a bridegroom with a priest’s turban, like a bride with her jewels."
-Isaiah 61:10 (Names of God Bible)

Post Reply