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!)
2 posts
• Page 1 of 1
DenTheUA
Posts: 41
Joined: Fri Jun 09, 2017 4:06 am
Location: Land of salo, gorilka and borsch (a.k.a. Ukraine)
So I am actually working on a project, and I've done a weapon with sights.
The problem is that when I press the altfire button first time, gun becames aimed, but when I press Altfire second time, it doesn't go to Ready state, but instead it flickers and stays aimed.
Here's my lump:
Spoiler:
ACTOR Sights: Inventory
{
Inventory.MaxAmount 1
}
ACTOR BioPistol: Weapon
{
Weapon.AmmoType "Clip"
Weapon.AmmoGive 60
Weapon.AmmoUse 1
AttackSound "Pestol/pew"
Weapon.SelectionOrder 10
Weapon.SlotNumber 1
Inventory.PickupMessage "Got a Broadsider pistol!"
States
{
Spawn:
PSTP A -1
Stop
Ready:
PSTL A 0 A_JumpIfInventory("Sights", 1, "ReadyA")
PSTL A 1 A_WeaponReady
loop
Select:
PSTL A 1 A_Raise
loop
Deselect:
PSTL A 0 A_TakeInventory("Sights",1)
PSTL A 0 A_ZoomFactor(1)
PSTL A 1 A_Lower
wait
Fire:
PSTL A 0 A_JumpIfInventory("Sights", 1, "FireZ")
PSTL B 3 A_FireBullets(5,5,1,10)
PSTL CD 3
PSTL A 0 A_Refire
goto Ready
Altfire:
PSTL A 3 A_JumpIfInventory("Sights", 1, "ZoomN")
PSTL A 3 A_GiveInventory ("Sights", 1)
PSTL A 0 A_ZoomFactor(3)
goto Ready
ReadyA:
AIMP A 1 A_WeaponReady
loop
ZoomN:
TNT1 A 0 A_TakeInventory ("Sights",1)
TNT1 A 0 A_ZoomFactor(1)
goto Ready
FireZ:
AIMP A 3
AIMP B 3 A_FireBullets(3,3,1,15)
AIMP C 3
AIMP C 0 A_ReFire
Goto ReadyA
}
}
Two things I can tell you right away. First, man, this formatting is really hard to read. Second, it's not a good idea to make the zooming state a 0-tic one (and in your case your zoom out state's length is 0). If you hold a button even for a bit, it'll zoom out, go into ready state and then right into zoom in state. Can't say anything else definite , but I threw together this and it works fine: