[Solved]Pickup issues!

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[Solved]Pickup issues!

Postby R4L » Sun Jan 07, 2018 10:52 pm

Hey guys. I've made a custom shotgun that replaces the default shotgun in Doom. I really wanted to control the amount of ammo you get when picking it up from monsters. I have it so if you picked up my shotgun, you'd get 3 in the clip and 6 on reserve. Originally I had it so you got 6 in the clip and 6 in reserve, but I learned soon that picking up a lot of shotguns would just raise your ammo really high, really fast. It would also give ammo to the clip. For example, I killed a shotgunguy and now I have 5 left in the clip. If I pickup his shotgun, it adds 6 to my reserve and also 3 to my clip. Not ideal...

To combat that, I decided to make a dummy pickup that enemies drop. It only gives 4 to the reserve ammo type, and it works perfectly. I also like that I can have a different pickup message. However, if you kill a shotgunguy and you don't have the shotgun already, you do not get it from picking it up. It gives you ammo, but not the weapon itself.

My question is: How can I make it so if the player does not already have the shotgun, he acquires it upon picking up this dummy pickup? Here is my DECORATE code for my shotgun and ammo types:

Code: Select allExpand view
ACTOR BenelliM3S : Weapon replaces Shotgun
{
 //$Category weapons
 Scale 0.28
 Weapon.SelectionOrder 1000
 Weapon.AmmoType "ShotClip"
 Weapon.AmmoGive 6
 Weapon.AmmoUse   1
 Weapon.AmmoType2 "ShotShell"
 Weapon.AmmoUse2 0
 Weapon.AmmoGive2 6
 Weapon.SlotNumber 3
 Weapon.BobStyle "Alpha"
 AttackSound "sounds/weapons/benellim3s/"
 Inventory.Pickupmessage "You got the Benelli M3S."
 +AMMO_OPTIONAL
 +NOAUTOFIRE
 +NOEXTREMEDEATH
 +IGNORESKILL
 States
 {
 Ready:
  BENE A 1 A_WeaponReady(WRF_ALLOWRELOAD)
  Loop
 Deselect:
  BENE A 1 A_PlaySound("BUNEQUIP",1,1)
 DeselectLoop:
  BENE A 1 A_Lower
  Goto DeselectLoop
 Select:
  BENE A 1 A_PlaySound("BEQUIP",1,1)
  BENE A 1 A_Raise
  Goto Select+1
 Fire:
  BENE A 0 A_JumpIfNoAmmo("DryFire")
  BENE A 1 A_PlaySound("SGSHOT1",CHAN_WEAPON,1)
  BENE B 0 A_Recoil(1.0)
  BENE B 0 A_GunFlash
  BENE B 1
  BENE C 1 A_FireBullets(7,3,6,7,"BulletPuff",1)
  BENE D 1
  BENE D 0 A_SpawnDebris("12gdebris")
  BENE E 1 A_FireCustomMissile("BerettaSmokeSpawn",0,0,6,8)
  BENE F 1
  BENE GHIJK 1
  BENE L 6
  BENE A 1 A_WeaponReady
  Goto Ready
 DryFire:
  BENE A 1 Offset(1,30) A_PlaySound("DRYFIRE",1,1)
  BENE B 1 Offset(1,31)
  BENE B 1 Offset(1,32)
  BENE B 1 Offset(1,33)
  BENE A 3
  Goto Ready
 Reload:
  TNT1 A 0 A_JumpIfInventory("ShotClip",6,2) //Do nothing if full mag capacity
  TNT1 A 0 A_JumpIfInventory("ShotShell",1,2)
  BENE A 1
 Goto Ready
  BENR B 1 Offset(1,30) A_PlaySound("COCK",0,1)
  BENR C 1 Offset(2,31)
  BENR D 1 Offset(3,32)
  BENR E 1 Offset(4,33)
  BENR F 4 Offset(5,34)
  Goto ReloadWork
 ReloadWork:
  BENR F 0 A_TakeInventory("ShotShell",1)
  BENR F 0 A_GiveInventory("ShotClip",1)
  BENR F 2 Offset(4,33)
  BENR F 2 Offset(5,34)
  BENR F 4 Offset(6,35) A_PlaySound("INSERT",1,1)
  BENR F 2 Offset(5,34)
  BENR F 2 Offset(4,33)
  BENR FFFFFF 1 A_WeaponReady
  TNT1 A 0 A_JumpIfInventory("ShotClip",6,"ReloadFinish")
  TNT1 A 0 A_JumpIfInventory("ShotShell",1,"ReloadWork")
 ReloadFinish:
  BENR F 1 Offset(5,34) A_PlaySound("UNCOCK",0,1)
  BENR E 1 Offset(4,33)
  BENR D 1 Offset(3,32)
  BENR C 1 Offset(2,31)
  BENR B 1 Offset(1,30)
  Goto Ready
 Flash:
  BENF M 1 Bright A_Light2
  BENF N 1 Bright A_Light1
  Goto LightDone
 Spawn:
  BENE Z -1
  Stop
 }
}

ACTOR ShotShell : Ammo replaces Shell
{
   //$Category ammunition
   Inventory.MaxAmount 150
   Inventory.PickupMessage "12 gauge shells"
   Inventory.Amount 4
   Inventory.PickupSound "SGPUMP"
   Inventory.Icon "SHELA0"
   Ammo.DropAmount 4
   Ammo.BackpackAmount 24
   Ammo.BackpackMaxAmount 150
   Scale 0.75
   -DROPPED
   +IGNORESKILL
   States
   {
   Spawn:
          SHEL A -1
          STOP
   }
}

ACTOR ShotClip : Ammo 30000
{
   Inventory.MaxAmount 6
   Inventory.Icon "SHELA0"
   -DROPPED
   +IGNORESKILL
}

ACTOR ShotShellBox : ShotShell 30003
{
   Inventory.PickupMessage "A box 12 gauge shells."
    Inventory.Amount 12
   -DROPPED
   -IGNORESKILL
    States
    {
      Spawn:
      SBOX A -1
      Stop
  }
}

ACTOR 12gdebris
{
  health 1
  scale 0.3
  Radius 1
  Height 1
  AttackSound "sounds/weapons/benellim3s/"
  +FORCEYBILLBOARD
  +DOOMBOUNCE
  -SOLID
  States
  {
  Spawn:
    TNT1 A 1
    BRS5 ABCDEFGHIJKL 1
   BRS5 M 1 A_PlaySound("SLDRP",1,1)
   BRS5 NOPQRST 1
   BRS5 I -1
    Loop
  }
}

ACTOR BenelliPickup : ShotShell 30004 //dummy pickup
{
//$Category ammunition
   Inventory.PickupMessage "You empty the Benelli M3S."
   Inventory.Amount 4
   Inventory.PickupSound "SGPUMP"
   Inventory.Icon "BENEZ0"
   Ammo.DropAmount 4
   Scale 0.28
   -DROPPED
   +IGNORESKILL
   States
   {
   Spawn:
          BENE Z -1
          STOP
   }
}
Last edited by R4L on Wed Jan 10, 2018 7:01 am, edited 1 time in total.
User avatar
R4L
Ordinary Vanity
 
Joined: 03 Mar 2017
Discord: R4L#4655
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: ATI/AMD with Vulkan Support

Re: Pickup issues!

Postby Blue Shadow » Mon Jan 08, 2018 4:19 am

With something like this:

Code: Select allExpand view
actor ShotgunPickup : CustomInventory
{
    Inventory.PickupMessage "Picked up shotgun."

    States
    
{
    Spawn:
        SHOT A -1
        Stop

    Pickup
:
        // If you have a shotgun, go to HaveShotgun state, and give four shells.
        // If not, give shotgun.
        TNT1 A 0 A_JumpIfInventory("Shotgun", 1, "HaveShotgun")
        TNT1 A 0 A_GiveInventory("Shotgun")
        Stop

    HaveShotgun
:
        TNT1 A 0 A_GiveInventory("Shell", 4)
        Stop
    
}

CustomInventory
A_JumpIfInventory
A_GiveInventory
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Pickup issues!

Postby R4L » Mon Jan 08, 2018 7:32 am

Ah, wow. I totally knew about those, don't know why I didn't consider it... Thanks!

EDIT: Thanks BlueShadow, I got it working. 8-)
User avatar
R4L
Ordinary Vanity
 
Joined: 03 Mar 2017
Discord: R4L#4655
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: ATI/AMD with Vulkan Support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 3 guests