Help for zooming in on a Weapon

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.

Help for zooming in on a Weapon

Postby ChaingunnerSlayer » Fri Feb 19, 2021 2:43 pm

it helps I want my assault rifle to have a zoom to shoot, like in brutal Doom, but I don't know how, please help me :D
ChaingunnerSlayer
 
Joined: 19 Feb 2021

Re: Help for zooming in on a Weapon

Postby Jarewill » Fri Feb 19, 2021 3:01 pm

If you are using DECORATE, you will have to first make a dummy inventory item:
Code: Select allExpand view
ACTOR RifleZoomed : Inventory {} 

This will be used to check if the rifle is currently zoomed in or not.
Then make an altfire state which will give or take this item and use the A_ZoomFactor function:
Spoiler:

Then with the ready state, you should also make a RifleZoomed check jump to change the ready state.
This can be skipped if you don't want to change the sprites.
Code: Select allExpand view
Ready:
    TNT1 A 0 A_JumpIfInventory("RifleZoomed",1,2)
    PISG A 1 A_WeaponReady //Replace with unzoomed rifle sprite
    Loop
    PISG B 1 A_WeaponReady 
//Replace with zoomed rifle sprite
    Loop

This should be enough to make a toggle zoom on a weapon.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Help for zooming in on a Weapon

Postby ChaingunnerSlayer » Fri Feb 19, 2021 5:27 pm

Thanks It served me as WONDERFUL, I just wanted to ask how I do it so that when it is in Zoom, the Animation of the shot is different, that is, with the sprites that "Supposedly" are for when you have zoom.

Beforehand thank you very much!.
ChaingunnerSlayer
 
Joined: 19 Feb 2021

Re: Help for zooming in on a Weapon

Postby Jarewill » Sat Feb 20, 2021 10:56 am

If you are talking about the Fire state while zoomed, it should be done like with the Ready state:
Code: Select allExpand view
    Fire:
        TNT1 A 0 A_JumpIfInventory("RifleZoomed",1,"FireZoomed")
        (....) //Rest of Fire state
    FireZoomed:
        (....) //Fire state while zoomed  
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Help for zooming in on a Weapon

Postby ChaingunnerSlayer » Sat Feb 20, 2021 1:14 pm

Thanks brother, your help has helped me a lot, I did something that (for me) was a problem.
Thanks!
ChaingunnerSlayer
 
Joined: 19 Feb 2021


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests