Weapon with scope fixes? (Has 3 zoom modes, only want 1.)

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!)
Post Reply
User avatar
Graaicko
Posts: 532
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Weapon with scope fixes? (Has 3 zoom modes, only want 1.)

Post by Graaicko »

So I made an assault rifle that has a scope, I used the code from TODM's Hunting rifle over at Realm667. I made a sniper from it that has the three zoom variables. I only want this weapon to have one zoom mode. Easiest way to describe the weapon I'm going for is the SIG 552 from counter-strike. One zoom mode.

There is also the issue of whenever zooming in, it resets the weapons ammo count to maximum capacity due to the reloading stage. (I want to personally thank wildweasel for the straight forward tutorial he provided for weapon reloading.)
I still consider myself an amateur coder for these types a things. As I tried to do all this myself, but am completely stumped.
Anyways I provided the weapon code I am currently working with. It is down below.
Spoiler:
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Weapon with scope fixes? (Has 3 zoom modes, only want 1.

Post by Jarewill »

I don't know about setting the ammo to maximum capacity, but your rifle gives the SIGScope weapon on altfire, but that weapon still gives 556Magazine ammo with Weapon.Ammogive2 20 property.
Any reason you did it this way instead of, for example, using SisterWeapons?

For having only one zoom mode, you could simply change the following lines of the SIGScope weapon:
Spoiler:
User avatar
Graaicko
Posts: 532
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Weapon with scope fixes? (Has 3 zoom modes, only want 1.

Post by Graaicko »

Because I didn't really know how that works. btw the code you provided just breaks the scope altfire. It appears for half a second than goes back to default...
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Weapon with scope fixes? (Has 3 zoom modes, only want 1.

Post by Jarewill »

Right, the select state is instant....
I don't have the proper files to test it, so I can only guess.
But maybe this will work?

Code: Select all

AltFire:
ASCO A 0 A_JumpIfInventory("SIGToken2",1,"Ready")
Goto AltFireDeselect
The main rifle gives SIGToken2 on altfire, so it shouldn't jump to deselect instantly.
User avatar
Graaicko
Posts: 532
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Weapon with scope fixes? (Has 3 zoom modes, only want 1.

Post by Graaicko »

Yep, that did it. Also figuredout why it was giving the weapon ammo when this function played, there was a 'weapon.giveammo' line on the SIGOptic weapon, giving it 20 rounds. Cleared that, now I have a functioning scoped weapon. Thanks for the help Jarewill. :D
Post Reply

Return to “Scripting”