Problem with aiming

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.

Problem with aiming

Postby DenTheUA » Sat Dec 16, 2017 3:48 am

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:
User avatar
DenTheUA
ウクライナ人のお宅
 
Joined: 09 Jun 2017
Location: Land of salo, gorilka and borsch (a.k.a. Ukraine)
Discord: DenTheUA#9586

Re: Problem with aiming

Postby Jekyll Grim Payne » Sun Dec 17, 2017 10:50 am

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:

Code: Select allExpand view
actor PistolZoom : Pistol
{
Weapon.SlotNumber 2
states
      {
      AltFire:
         TNT1 A 0 A_JumpIfInventory("Zoomed",1,3)
         PISG A 5 A_ZoomFactor(3)
         TNT1 A 0 A_GiveInventory("Zoomed",1)
         goto ready
         TNT1 A 0 A_ZoomFactor(1)
         PISG A 5 A_TakeInventory("Zoomed",1)
         goto ready
      }
}
         


Actor Zoomed : Inventory
{
   inventory.maxamount 1
   -COUNTITEM
}
User avatar
Jekyll Grim Payne
 
Joined: 21 Jul 2008


Return to Scripting

Who is online

Users browsing this forum: MauiBot and 2 guests