Weapon can be picked up, but can't be restored from inv?

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Weapon can be picked up, but can't be restored from inv?

Post by PixelWAD »

I have replaced a standard Shotgun with custom 3D model with custom animations. Everything works great so far (working of properly placing the gun atm) but after switching back to Pistol for example, I can't switch back to the replaced shotgun, which works good with autopickup. What am I doing wrong?

// MD3 model weapons weapon hud

EDIT: and now somehow I have broke my ammunition...

I have 2 actors for shotgun shellbox and shell, one big ammo pack, and one smaller, they both display fine, they can be both picked up as MD3 model, but they do not add ammo to the shotgun anymore.. WTF?

actors\pickups.shotgun.decorate

Code: Select all

// REPLACES OG D2 SHOTGUN WITH DN3D SHOTGUN
// NOTE THE "SHOTGUN " WITH EXTRA SPACE AT THE END
actor DukeShotgun : Weapon replaces Shotgun
{
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 2
//  Weapon.AmmoType "DukeShotgunAmmo"
//  Weapon.AmmoType1 "DukeShotgunAmmoShell"
  Weapon.AmmoType "Shell"
  Weapon.AmmoType1 "ShellBox"
//  Weapon.AmmoType2 "ShellBox"
  Inventory.PickupMessage "Shotgun"
  Inventory.PickupSound "duke/weaponup"
  Obituary "$OB_MPSHOTGUN"
  Tag "$TAG_SHOTGUN"
  States
  {
  Ready:
    MOD1 A 1 A_WeaponReady
    Loop
  Deselect:
    MOD1 A 1 A_Lower
    Loop
  Select:
    MOD1 A 1 A_Raise
    Loop
  Fire:
    MOD1 A 3
    MOD1 A 7 A_FireShotgun
    MOD1 BC 5
    MOD1 D 4
    MOD1 E 5
    MOD1 F 3
    MOD1 G 7 A_ReFire
    Goto Ready
  Flash:
    MOD1 A 4 Bright A_Light1
    MOD1 B 3 Bright A_Light2
    Goto LightDone
  Spawn:
    MOD9 A -1
    Stop
  }
}
actors\pickups.shotgunammo.decorate

Code: Select all

// REPLACES Doom 2 Shellbox 
Actor DukeShotgunAmmo : Ammo replaces ShellBox
//actor DukeShotgunAmmo : Ammo 10471
{
  Inventory.PickupMessage "+10 SHOTGUN AMMO"
  Inventory.Amount 10
  Inventory.MaxAmount 50
  +INVENTORY.IGNORESKILL
  Inventory.Icon "AAMOA0"
  Ammo.BackpackAmount 10
  Ammo.BackpackMaxAmount 100
  states
  {
  Spawn:
    MOD1 A -1
    stop
  }
}
actors\pickups.shotgunammoshell.decorate

Code: Select all

// REPLACES Doom 2 Shell
Actor DukeShotgunAmmoShell : Ammo replaces Shell
{
  Inventory.PickupMessage "+3 SHOTGUN SHELLS"
  Inventory.Amount 3
  Inventory.MaxAmount 50
  Ammo.BackpackAmount 10
  Ammo.BackpackMaxAmount 100
  +INVENTORY.IGNORESKILL
  Inventory.Icon "SHGAM0"
//  Inventory.PickupSound "duke/weaponup"
  States
  {
  Spawn:
    MOD1 A -1
    Stop
  }
}
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Weapon can be picked up, but can't be restored from inv?

Post by PixelWAD »

This is really getting out of hand.. One moment something works, the other one it stops, and I haven't really changed anything.

Long story short, my custom Shotgun model is displayed properly, and so are randomized spawners for Shell and ShellBox, even PickUp message is correct, but it does not add anything to my shotgun ammo.
I tried to define my custom shotgun as Shotgun Ammo type Shell Ammo1 ShellBox, and also my new actors but it does nothing...

I love modding Doom, but things like this make me feel bad for asking for such simple thing online..

Looking forward for any tips.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Weapon can be picked up, but can't be restored from inv?

Post by Enjay »

You have to also set things up so that the player weapon slots reflect the fact that there are new weapons. Unless you do that, you will switch to it when picking it up, but after that the game doesn't have any instructions on how to let you select the weapon.

There are a couple of ways of doing this, and I'm not sure what the best current method is.

There is "Player.WeaponSlot" which is used your player character definition.
[wiki]Classes:DoomPlayer[/wiki]
[wiki]Actor_properties#Player.WeaponSlot[/wiki]

But there is further advice here:
[wiki]Weapon_slots[/wiki]
The keyconf lump is mentioned there - don't use it. It is outdated can can cause clashes.
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Weapon can be picked up, but can't be restored from inv?

Post by PixelWAD »

I have added line Weapon.SlotNumber 3 and now it works, I can switch between the weapons.
However the ammo type still does not work.

I am able to pick up an actor that replaces ShellBox with 10 shotgun ammo.
I have replaced "shell" with another model that is supposed to give less ammo. It can be picked up, but it has no connection to my shotgun.

I have already defined shotgun with AmmoType and AmmoType1 but it still does not accept my same type of ammo, only with smaller number.

actors\pickups.shotgun.decorate

Code: Select all

// REPLACES OG D2 SHOTGUN WITH DN3D SHOTGUN
actor DukeShotgun : Weapon replaces Shotgun
{
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 2
  Weapon.AmmoType "DukeShotgunAmmoShell"
  Weapon.AmmoType1 "DukeShotgunAmmo"
  Weapon.SlotNumber 3
  
//  Weapon.AmmoType "DukeShotgunAmmo"
//  Weapon.AmmoType1 "DukeShotgunAmmoShell"
//  Weapon.AmmoType "Shell"
//  Weapon.AmmoType1 "ShellBox"
//  Weapon.AmmoType2 "ShellBox"

  Inventory.PickupMessage "Shotgun"
  Inventory.PickupSound "duke/weaponup"
  Obituary "$OB_MPSHOTGUN"
  Tag "$TAG_SHOTGUN"
  States
  {
  Ready:
    MOD1 A 1 A_WeaponReady
    Loop
  Deselect:
    MOD1 A 1 A_Lower
    Loop
  Select:
    MOD1 A 1 A_Raise
    Loop
  Fire:
    MOD1 A 3
    MOD1 A 7 A_FireShotgun
    MOD1 BC 5
    MOD1 D 4
    MOD1 E 5
    MOD1 F 3
    MOD1 G 7 A_ReFire
    Goto Ready
  Flash:
    MOD1 A 4 Bright A_Light1
    MOD1 B 3 Bright A_Light2
    Goto LightDone
  Spawn:
    MOD9 A -1
    Stop
  }
}
actors\pickups.shotgunammo.decorate - this type works for my shotgun

Code: Select all

// REPLACES Doom 2 Shellbox 
Actor DukeShotgunAmmo : Ammo replaces ShellBox
{
  Inventory.PickupMessage "+10 SHOTGUN AMMO"
  Inventory.Amount 10
  Inventory.MaxAmount 50
  +INVENTORY.IGNORESKILL
  Ammo.BackpackAmount 10
  Ammo.BackpackMaxAmount 100
//  Inventory.PickupSound "duke/weaponup"
//  Inventory.Icon "AAMOA0"
  states
  {
  Spawn:
    MOD1 A -1
    stop
  }
}
actors\pickups.shotgunammoshell.decorate - this one does not work. it does spawn randomly as intended, but this small ammo pickup does not give ammo to my shotgun

Code: Select all

// REPLACES Doom 2 Shell
Actor DukeShotgunAmmoShell : Ammo replaces Shell
{
  Inventory.PickupMessage "+3 SHOTGUN SHELLS"
  Inventory.Amount 3
  Inventory.MaxAmount 50
  Ammo.BackpackAmount 10
  Ammo.BackpackMaxAmount 100
  +INVENTORY.IGNORESKILL
//  Inventory.Icon "SHGAM0"
//  Inventory.PickupSound "duke/weaponup"
  States
  {
  Spawn:
    MOD1 A -1
    Stop
  }
}
in other words, my gun G is using ammo A. default A is 10 ammo for your inventory, with an option to find A-small containing only 3 bullets.
User avatar
phantombeta
Posts: 2088
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Weapon can be picked up, but can't be restored from inv?

Post by phantombeta »

DukeShotgunAmmoShell needs to inherit from DukeShotgunAmmo to give you DukeShotgunAmmo.

This is [wiki=Classes:Ammo]explained in the wiki[/wiki]:
The wiki wrote:
  • Only items that inherit directly from Ammo are separate types. All items that inherit from a subclass of Ammo define new pickup items for that ammo type
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Weapon can be picked up, but can't be restored from inv?

Post by PixelWAD »

I tried to tackle it other way around I guess.

I have modified a single line to
Actor DukeShotgunAmmoShell : DukeShotgunAmmo 23301 and now it works. thanks!
Post Reply

Return to “Scripting”