So here's the situation and some of the code:
I'm currently working on a sort of a stand-alone gzdoom game, meaning it can obviously run independent of doom 2 and other doom games. The trouble I'm having with reloading is a couple of things
When a player presses a custom reload key I've set up in KEYCONF, this ACS script runs:
Code: Select all
Script "Reloadgun" (VOID) NET
{
GiveInventory("reloading", 1);
}
DECORATE CODE:
ACTOR reloading : Ammo
{
Inventory.MaxAmount 1
+IGNORESKILL
}
Now here's some code for the shotgun in my gzdoom game:
Code: Select all
Actor item_ammo_buckshot : Ammo 15005
{
Inventory.Amount 6
Inventory.MaxAmount 56
scale 0.5
Inventory.Icon "BUCKA0"
Inventory.PickupMessage "⠀"
Inventory.PickupSound "ammopickup/pickup"
States
{
Spawn:
BCKS A -1
Stop
}
}
ACTOR weapon_shotgunloading : Ammo
{
Inventory.MaxAmount 6
+IGNORESKILL
}
ACTOR weapon_shotgunisloading : Ammo
{
Inventory.MaxAmount 1
+IGNORESKILL
}
Actor weapon_shotgun : Weapon 15007
{
Weapon.SlotNumber 3
Weapon.SelectionOrder 700
Inventory.PickupMessage ""
Inventory.PickupSound "ammopickup/pickup"
Weapon.Kickback 100
Weapon.AmmoUse1 1
Weapon.AmmoGive1 6
Weapon.AmmoType1 "weapon_shotgunloading"
Weapon.AmmoType2 "item_ammo_buckshot"
Weapon.AmmoUse2 0
Weapon.AmmoGive2 15
+Weapon.Ammo_Optional
+WEAPON.ALT_USES_BOTH
+WEAPON.ALT_AMMO_OPTIONAL
+WEAPON.NOAUTOAIM
scale 0.3
States
{
Spawn:
WSOG A -1
Stop
Pickup:
TNT1 A 0 A_StartSound("ammopickup/pickup", 1, CHAN_ITEM, 1.0)
stop
Select:
TNT1 A 1 A_Raise
Wait
Deselect:
SPAS QPON 4
TNT1 A 1 A_Lower
Wait
Ready:
SPAS N 0 A_StartSound("weaponhl2beta/switch", 1, CHANF_OVERLAP , 0.5)
SPAS NOPQ 4
Goto Ready2
Ready2:
SPAS A 1 A_WeaponReady
SPAS A 0 A_JumpIfInventory("reloading",1, "Reload")
Loop
Fire:
SPAS A 0 A_JumpIfNoAmmo("Reload")
SPAS A 0 A_StartSound("shotgun/firenormal", 1, CHANF_DEFAULT, 0.5)
SPAS B 4 A_FireBullets(3,3,4,5,"hl2bulletpuff",1,950)
SPAS B 0 A_GunFlash
SPAS C 5
SPAS D 4 A_StartSound("shotgun/cock", 1, CHANF_OVERLAP, 1)
SPAS E 5
SPAS F 4
SPAS A 4
goto Ready2
// balls
AltFire:
SPAS A 0 A_JumpIfNoAmmo("Reload")
SPAS A 0 A_StartSound("shotgun/firesecondary", 1, CHANF_DEFAULT, 0.5)
SPAS A 0 A_TakeInventory("weapon_shotgunloading", 1)
SPAS S 3 A_FireBullets(3,3,9,5,"hl2bulletpuff",1,850)
SPAS S 0 A_GunFlash
SPAS T 4
SPAS U 3
SPAS V 4
SPAS W 3
SPAS X 3
SPAS Y 3 A_StartSound("shotgun/cock", 1, CHANF_OVERLAP, 1)
SPAS Z 3
SPAS U 3
SPAS V 3
SPAS A 4
goto Ready2
Flash:
1BLC A 4 Bright A_Light2
goto lightdone
Reload:
SPAS A 0 A_JumpIfInventory ("weapon_shotgunloading", 6, "Ready2")
SPAS A 0 A_JumpIfInventory ("item_ammo_buckshot", 1, "ReloadStarting")
goto Ready2
ReloadStarting:
SPAS A 0 A_GiveInventory("weapon_shotgunisloading", 1)
// We go to this state from this state
ReloadRoutine:
SPAS G 3
SPAS H 3 A_TakeInventory("item_ammo_buckshot", 1)
SPAS I 3
SPAS J 3 A_GiveInventory("weapon_shotgunloading", 1)
SPAS K 3
SPAS L 3 A_StartSound("shotgun/reload", 1)
SPAS L 3 A_JumpIfInventory("weapon_shotgunloading", 6, "ReloadFinish")
SPAS J 3 A_JumpIfInventory("item_ammo_buckshot", 1, "ReloadRoutine")
// We go to this state from this state
ReloadFinish:
SPAS I 0 A_TakeInventory("reloading", 1)
SPAS I 2 A_TakeInventory("weapon_shotgunisloading",1)
SPAS R 4
SPAS Q 4
goto Ready2
}
}
Now onto the problems.
This is the code for the pistol, this same problem also occurs with the smg in my mod as well:
Code: Select all
Actor item_ammo_pistol : Ammo 15002
{
Inventory.Amount 18
Inventory.MaxAmount 150
scale 0.4
Inventory.Icon "PSABA1"
Inventory.PickupMessage ""
Inventory.PickupSound "ammopickup/pickup"
States
{
Spawn:
PSAB A -1
Stop
}
}
ACTOR weapon_pistolloading : Ammo
{
Inventory.MaxAmount 18
+IGNORESKILL
}
ACTOR weapon_pistol : Weapon 10300
{
Weapon.SlotNumber 2
Weapon.SelectionOrder 1900
Weapon.Kickback 100
Weapon.AmmoUse1 1
Weapon.AmmoGive1 18
Weapon.AmmoType1 "weapon_pistolloading"
Weapon.AmmoType2 "item_ammo_pistol"
Weapon.AmmoUse2 0
Weapon.AmmoGive2 0
Inventory.PickupMessage ""
Inventory.PickupSound "ammopickup/pickup"
Scale 0.3
Inventory.Icon "TPUSA0"
+Weapon.Ammo_Optional
+WEAPON.NOAUTOAIM
States
{
Spawn:
PONG A -1
stop
Select:
TNT1 A 1 A_Raise
Wait
Deselect:
USPS QPONM 3
TNT1 A 1 A_Lower
Wait
Ready:
USPS M 0 A_StartSound("weaponhl2beta/switch", 1, CHANF_OVERLAP , 0.5)
USPS MNOPQ 3
goto Ready2
Ready2:
USPS A 1 A_WeaponReady
USPS A 0 A_JumpIfInventory("reloading",1, "Reload2")
loop // For some reason when I set it to Reload and not Reload2. The sprite violently shakes whenever it bobs, I've had this issue in the past when doing other things in my mod with DECORATE, but I completely forgot how I fixed it every time it //happened.
// I'm sure there's some reason and a way to fix it, I just kind of forgot because I didn't work on my mod in awhile.
// I think it's mostly likely because reload2 uses 0 for the frame durations
Flash:
1BLC A 4 Bright A_Light2 // 1 pixel sprite that the player can't really see (yes I know it's probably a bad way to do it like this)
goto lightdone
Fire:
USPS A 0 A_JumpIfNoAmmo("Reload") // normal weapon ready state
USPS A 3 A_StartSound("pistol/firenormal", 1)
USPS B 5 A_FireBullets(0,0,1,4,"hl2bulletpuff",1,8092) // begining to fire
USPS C 3 A_GunFlash
USPS C 8
Goto Ready2
Reload2:
USPS A 0 A_JumpIfInventory ("weapon_pistolloading", 18, "Ready2")
USPS A 0 A_JumpIfInventory ("item_ammo_pistol", 1, "ReloadWork")
goto Ready2 // The reason why I have two reload states here instead of one is because I thought the reload state itself had something to do with this
// So I copy and pasted the code from the shotgun, and made a separate reloading state, but that Idea didn't work. It did solve the problem of the sprite shaking, but other than that still can't reload.
Reload:
USPS A 0 A_JumpIfInventory("weapon_pistolloading", 18, 2)
USPS A 0 A_JumpIfInventory("item_ammo_pistol", 1, "ReloadWork")
USPS A 1
Goto Ready2
ReloadWork:
USPS D 4
USPS E 4 A_StartSound("pistol/reload", 1)
USPS F 4
USPS G 4
USPS H 4
USPS I 4
USPS J 4
USPS K 4
USPS L 4
ReloadLoop:
USPS L 0 A_TakeInventory("reloading", 1) // I have a gut feeling that's not where that line is supposed to go
USPS L 0 A_TakeInventory("item_ammo_pistol", 1)
USPS L 0 A_GiveInventory("weapon_pistolloading", 1)
USPS L 0 A_JumpIfInventory("weapon_pistolloading", 18, "Ready2")
USPS L 0 A_JumpIfInventory("item_ammo_pistol", 1, "ReloadLoop")
Goto Ready2
}
}
Currently the pistol and smg, DO NOT reload AT all. And I just can't figure out why. As mentioned in the comment of the pistol reload state, sometimes it would either shake the sprite and duplicate itself around whenever I bobbed (which was really annoying and looked awful I know there's a fix for stuff like that but I completely forgot how to fix that sprite shaking thing).
If anyone can help me at all, I would greatly appreciate it. Thank you for reading my post.