actor AK47 : Weapon 6000
{
obituary "%o was shot by %k's AK47."
radius 20
height 16
attacksound "AK47/Fire"
inventory.pickupmessage "You got the AK47!"
weapon.selectionorder 700
weapon.kickback 100
Weapon.AmmoType1 "AKAmmo"
Weapon.AmmoType2 "AKCounter"
Weapon.AmmoUse1 1
Weapon.AmmoGive1 60
Weapon.AmmoUse2 0
Weapon.AmmoGive2 30
Decal Bulletchip
+WEAPON.AMMO_OPTIONAL
+WEAPON.NOALERT
states
{
Ready:
AKRF A 1 A_WeaponReady
loop
Deselect:
AKRF A 1 A_Lower
loop
Select:
AKRF A 1 A_Raise
loop
Fire:
TNT1 A 0 A_JumpIfNoAmmo ("DryFire")
TNT1 A 0 A_FireBullets (3, 3, 1, 6, "BulletPuff")
TNT1 A 0 radius_quake (1, 2, 0, 1, 0)
TNT1 A 0 A_AlertMonsters
TNT1 A 0 A_TakeInventory ("AKCounter", 1)
TNT1 A 5 A_GunFlash
TNT1 A 0 A_CheckForReload(30, "Reloaded")
AltFire:
AKRF A 0 A_JumpIfInventory (AKCounter, 30, "Ready")
AKRF A 1 offset (0, 40)
AKRF A 0 A_PlayWeaponSound ("AK47/Reload")
AKRF A 1 offset (0, 48)
AKRF A 1 offset (0, 56)
AKRF A 1 offset (0, 64)
AKRF A 1 offset (0, 72)
AKRF A 1 offset (0, 80)
AKRF A 1 offset (0, 88)
AKRF A 1 offset (0, 96)
AKRF A 1 offset (0, 112)
AKRF A 1 offset (0, 120)
AKRF A 1 offset (0, 128)
AKRF A 10 A_ResetReloadCounter
AKRF A 0 A_GiveInventory ("AKCounter", 30)
AKRF A 1 offset (0, 128)
AKRF A 1 offset (0, 120)
AKRF A 1 offset (0, 112)
AKRF A 1 offset (0, 96)
AKRF A 1 offset (0, 88)
AKRF A 1 offset (0, 80)
AKRF A 1 offset (0, 72)
AKRF A 1 offset (0, 64)
AKRF A 1 offset (0, 56)
AKRF A 1 offset (0, 48)
AKRF A 1 offset (0, 40)
Reloaded:
AKRF A 0
AKRF A 4 A_ReFire
goto Ready
DryFire:
AKRF A 20 A_PlayWeaponSound ("AK47/DryFire")
AKRF A 0 A_TakeInventory ("AKCounter", 30)
goto Ready
Flash:
AKMF A 2 bright A_Light1
AKMF B 3 bright A_Light2
AKMF A 1 bright A_Light0
stop
Spawn:
MGUN A -1
stop
}
}
ACTOR AKAmmo : Ammo 6001
{
Inventory.PickupMessage "Picked up an AK47 clip."
Inventory.Amount 30
Inventory.MaxAmount 180
Ammo.BackpackAmount 60
Ammo.BackpackMaxAmount 360
Inventory.Icon "CLIPA0"
States
{
Spawn:
CLIP A -1
Stop
}
}
ACTOR AKCounter : Ammo
{
Inventory.Amount 30
Inventory.MaxAmount 30
Inventory.Icon "CLIPA0"
}
Dodgy reloading weapon
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
-
- Posts: 3975
- Joined: Fri Jul 06, 2007 9:16 am
Dodgy reloading weapon
Can someone correct this code so that the weapon functions and reloads properly, it is supposed to fire 30 bullets then reload, and can be reloaded at any time except when full ammo using the alt fire button, but there are problems when the ammo runs out, the counter screws up.
-
- Posts: 3975
- Joined: Fri Jul 06, 2007 9:16 am
Re: Dodgy reloading weapon
Anyone? I will send the weapon to someone to alter if that helps, you could at least tell me what I'm doing wrong 

Re: Dodgy reloading weapon
I'm not sure if that's how A_CheckForReload is supposed to work, but I don't know that much about it, in the first place.
Try using the method in the Doom 3 weapons mod. The Pistol's probably the easiest of them to work off of.
Try using the method in the Doom 3 weapons mod. The Pistol's probably the easiest of them to work off of.
Re: Dodgy reloading weapon
I'm not even sure what [wiki]A_CheckForReload[/wiki] and [wiki]A_ResetReloadCounter[/wiki] are for. Your best bet is to stick with common inventory tricks for reloading.
- TheDarkArchon
- Posts: 7656
- Joined: Sat Aug 07, 2004 5:14 am
- Location: Some cold place
Re: Dodgy reloading weapon
Are you sure the A_CheckForReload jump is supposed to go to the Reloaded state?
Re: Dodgy reloading weapon
This is all I've ever done and my reloading weapons work fine. I can see you want to make it so the player can reload any time, but with a clip weapon, that doesn't make much sense anyway. And it's a bitch to do with inventory tricks.Snarboo wrote:I'm not even sure what [wiki]A_CheckForReload[/wiki] and [wiki]A_ResetReloadCounter[/wiki] are for. Your best bet is to stick with common inventory tricks for reloading.
- DBThanatos
- Posts: 3101
- Joined: Fri Apr 14, 2006 3:17 pm
- Location: in "the darkness that lurks in our mind"
Re: Dodgy reloading weapon
AFAIK, those functions are only for simple reloads (like the DukeNukem 3D pistol or ShadowWarrior Uzi, where you have a limited clip, but there is no visible counter).
Probably was a only luck, but here is what I did for a 4 shots-then-reload shotgun, with no need of A_ResetReloadCounter.
Only pay attention to the Altfire, because all other code is a regular minigun
Probably was a only luck, but here is what I did for a 4 shots-then-reload shotgun, with no need of A_ResetReloadCounter.
Only pay attention to the Altfire, because all other code is a regular minigun
Code: Select all
ACTOR Minigun : Weapon 6006
{
+FLOORCLIP
Weapon.AmmoType "Clip"
Weapon.AmmoType2 "Shell"
Weapon.AmmoGive 50
Weapon.AmmoGive2 8
Weapon.AmmoUse 2
Weapon.AmmoUse2 1
Inventory.PickupSound "misc/w_pkup"
Inventory.PickupMessage "Picked up the mini-riotgun?."
Obituary "%o was shredded by %k's minigun."
States
{
Spawn:
MINN A -1
Loop
Ready:
MING A 1 A_WeaponReady
Loop
Deselect:
MING A 1 A_Lower
NULL AA 0 A_Lower
Loop
Select:
MING A 1 A_Raise
NULL AA 0 A_Raise
Loop
Fire:
MINF A 0 A_GunFlash
DPIS A 0 A_Recoil(0.25)
TNT1 A 0 ACS_Execute(851,0,18,random(-4,4),0)
TNT1 A 0 A_FireCustomMissile("GunSmallSmokeSpawner",0,0,6,7)
TNT1 A 0 A_PLayWeaponSound("human/minigun")
MINF A 2 Bright A_FireBullets(5, 3, 2, 5, 0, 1)
TNT1 A 0 ACS_Execute(851,0,-18,0,0)
NULL A 0 A_FireCustomMissile("ChGunCasing",-45+random(-15,15),0,2,3)
MING B 2
MINF A 0 A_GunFlash
DPIS A 0 A_Recoil(0.25)
TNT1 A 0 ACS_Execute(851,0,18,random(-4,4),0)
TNT1 A 0 A_FireCustomMissile("GunSmallSmokeSpawner",0,0,6,7)
TNT1 A 0 A_PLayWeaponSound("human/minigun")
MINF B 2 Bright A_FireBullets(5, 3, 2, 5, 0, 1)
TNT1 A 0 ACS_Execute(851,0,-18,0,0)
NULL A 0 A_FireCustomMissile("ChGunCasing",-45+random(-15,15),0,2,3)
MING B 2
MING AABB 1 A_ReFire
MING AAABBB 1 A_ReFire
MING AAAABBBB 1 A_ReFire
MING AAAAABBBBB 1 A_ReFire
MING AAAAAABBBBBB 1 A_ReFire
MING AAAAAAABBBBBBB 1 A_ReFire
goto Ready
AltFire:
TNT1 A 0 A_CheckForReload(5,"AltFireSuccesful") //the 5th time this is called, will NOT jump to "AltFireSuccesful"
TNT1 A 0 A_PlayWeaponSound("weapons/d3rocklr") //this is the "reloading sequence"
MING A 3 offset(5,35)
MING A 3 offset(15,40)
MING A 3 offset(25,45)
MING A 15 offset(35,50)
TNT1 A 0 A_PlayWeaponSound("weapons/rifleup")
MING A 5 offset(35,47)
MING A 4 offset(35,50)
MING A 3 offset(25,45)
MING A 3 offset(15,40)
MING A 3 offset(5,35)
Goto Ready
AltFireSuccesful: //when it actually shots
TNT1 A 0 A_GunFlash
TNT1 A 0 ACS_Execute(851,0,60,random(-20,20),0)
TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,6,7)
TNT1 A 0 A_PLayWeaponSound("weapons/riflefre")
MINF A 3 Bright A_FireBullets(5, 5, 10, 6, 0, 1)
MINF BBB 1 Bright ACS_Execute(851,0,-15,0,0)
MING B 8
MING A 8 A_FireCustomMissile("ShotgunCasing",-45+random(-15,15),0,2,3)
Goto Ready
Flash:
TNT1 A 1 BRIGHT A_Light2
TNT1 A 2 BRIGHT A_Light1
TNT1 A 3 BRIGHT A_Light0
Stop
}
}