I am trying to create a simple shotgun that fires as normal but when reload is pressed (R) its reloads the weapon like a shotgun does. Ive got all the animations sorted its just not happening for me. Here is my code if anyone can help. Also I may put an alt fire in, but for now the fire and reload would be fine.
Shotgun is 7 bullets max loaded. Side note im trying to do the 1 bullet at a time reload so it loops till I get the full 7 bullets loaded.
Code:
Actor Shotty : Weapon replaces shotgun
{
Weapon.SelectionOrder 1900
Inventory.Pickupmessage "Picked up Shotty!"
Weapon.AmmoType1 "NewShottyLoaded"
Weapon.AmmoUse1 1
Weapon.AmmoGive 0
Weapon.AmmoType2 "Shell"
Weapon.AmmoGive2 14
Weapon.SlotNumber 3
+Weapon.Ammo_Optional
States
{
Ready:
HAND A 1 A_WeaponReady(WRF_ALLOWRELOAD)
Loop
Deselect:
HAND A 1 A_Lower
Loop
Select:
HAND A 1 A_Raise
Loop
Fire:
TNT1 A 1 A_JumpIfNoAmmo("Reload")
TNT1 A 1 A_PlaySound("weapons/shotgun/shoot")
MPN1 AB 2 bright A_FireBullets (4, 4, -1, 6)
MPN1 CDEDC 1
MPN1 F 8
MPN1 F 1 A_ReFire
Goto Ready
Reload:
MPN1 ABCDEF 2
MPN1 F 0 A_JumpIfInventory("NewShottyLoaded", 14, 2)
MPN1 F 0 A_JumpIfInventory("ShottyAmmo", 1, "ReloadWork")
MPN1 F 1
Goto Ready
ReloadWork:
SGR1 ABCDEF 2
ReloadLoop:
TNT1 A 0 A_TakeInventory("ShottyAmmo", 1)
TNT1 A 0 A_GiveInventory("NewShottyLoaded", 1)
TNT1 A 0 A_JumpIfInventory("NewShottyLoaded", 7, "ReloadFinish")
TNT1 A 0 A_JumpIfInventory("ShottyAmmo", 1, "ReloadLoop")
Goto ReloadFinish
ReloadFinish:
SGR2 ABC 3
SGR2 D 2 A_PlaySound("weapons/shotgun/insert")
SGR2 E 2
SGR1 FDCBA 2
Goto Ready
Spawn:
SGPU A -1
Stop
}
}
ACTOR Action_Reload : CustomInventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
-INVBAR
States
{
Use:
TNT1 A 0 A_GiveInventory("IsReloading",1)
Fail
}
}
ACTOR Action_ReloadCancel : CustomInventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
-INVBAR
States
{
Use:
TNT1 A 0 A_TakeInventory("IsReloading",1)
Fail
}
}
ACTOR IsReloading : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
-INVBAR
}
ACTOR ShottyAmmo : Ammo replaces shells
{
Inventory.Amount 14
Inventory.MaxAmount 56
Ammo.BackpackAmount 14
Ammo.BackpackMaxAmount 112
Inventory.Icon "SHELA0"
Inventory.PickupMessage "Picked up some Shotty ammo."
States
{
Spawn:
SHEL A -1
Stop
}
}
ACTOR ShottyAmmoSmall : ShottyAmmo
{
Inventory.Amount 7
Inventory.PickupMessage "Picked up a bit of Shotty ammo."
Inventory.PickupSound "Beretta/Drop"
+DROPPED
States
{
Spawn:
SHEL A -1
Stop
}
}
ACTOR NewShottyLoaded : Ammo
{
Inventory.MaxAmount 14
+IGNORESKILL
}
So going off Gunlabs Tutorial :
http://gunlabs.blogspot.com/2012/06/tutorial-new-ammo-types-and-weapons.html
I am trying to create a simple shotgun that fires as normal but when reload is pressed (R) its reloads the weapon like a shotgun does. Ive got all the animations sorted its just not happening for me. Here is my code if anyone can help. Also I may put an alt fire in, but for now the fire and reload would be fine.
Shotgun is 7 bullets max loaded. Side note im trying to do the 1 bullet at a time reload so it loops till I get the full 7 bullets loaded.
Code:
Actor Shotty : Weapon replaces shotgun { Weapon.SelectionOrder 1900 Inventory.Pickupmessage "Picked up Shotty!" Weapon.AmmoType1 "NewShottyLoaded" Weapon.AmmoUse1 1 Weapon.AmmoGive 0 Weapon.AmmoType2 "Shell" Weapon.AmmoGive2 14 Weapon.SlotNumber 3 +Weapon.Ammo_Optional States { Ready: HAND A 1 A_WeaponReady(WRF_ALLOWRELOAD) Loop Deselect: HAND A 1 A_Lower Loop Select: HAND A 1 A_Raise Loop Fire: TNT1 A 1 A_JumpIfNoAmmo("Reload") TNT1 A 1 A_PlaySound("weapons/shotgun/shoot") MPN1 AB 2 bright A_FireBullets (4, 4, -1, 6) MPN1 CDEDC 1 MPN1 F 8 MPN1 F 1 A_ReFire Goto Ready Reload: MPN1 ABCDEF 2 MPN1 F 0 A_JumpIfInventory("NewShottyLoaded", 14, 2) MPN1 F 0 A_JumpIfInventory("ShottyAmmo", 1, "ReloadWork") MPN1 F 1 Goto Ready ReloadWork: SGR1 ABCDEF 2 ReloadLoop: TNT1 A 0 A_TakeInventory("ShottyAmmo", 1) TNT1 A 0 A_GiveInventory("NewShottyLoaded", 1) TNT1 A 0 A_JumpIfInventory("NewShottyLoaded", 7, "ReloadFinish") TNT1 A 0 A_JumpIfInventory("ShottyAmmo", 1, "ReloadLoop") Goto ReloadFinish ReloadFinish: SGR2 ABC 3 SGR2 D 2 A_PlaySound("weapons/shotgun/insert") SGR2 E 2 SGR1 FDCBA 2 Goto Ready Spawn: SGPU A -1 Stop } } ACTOR Action_Reload : CustomInventory { Inventory.Amount 1 Inventory.MaxAmount 1 -INVBAR States { Use: TNT1 A 0 A_GiveInventory("IsReloading",1) Fail } } ACTOR Action_ReloadCancel : CustomInventory { Inventory.Amount 1 Inventory.MaxAmount 1 -INVBAR States { Use: TNT1 A 0 A_TakeInventory("IsReloading",1) Fail } } ACTOR IsReloading : Inventory { Inventory.Amount 1 Inventory.MaxAmount 1 -INVBAR } ACTOR ShottyAmmo : Ammo replaces shells { Inventory.Amount 14 Inventory.MaxAmount 56 Ammo.BackpackAmount 14 Ammo.BackpackMaxAmount 112 Inventory.Icon "SHELA0" Inventory.PickupMessage "Picked up some Shotty ammo." States { Spawn: SHEL A -1 Stop } } ACTOR ShottyAmmoSmall : ShottyAmmo { Inventory.Amount 7 Inventory.PickupMessage "Picked up a bit of Shotty ammo." Inventory.PickupSound "Beretta/Drop" +DROPPED States { Spawn: SHEL A -1 Stop } } ACTOR NewShottyLoaded : Ammo { Inventory.MaxAmount 14 +IGNORESKILL }
Share this post
Link to post