1.5.1 and RC23 working. Press a button to take off your scope, then press again to equip the scope back.
(also RC18, 19, 21, 22 should work)
[BUG NOW FIXED for mod only working if you save/reload your game. Now you can just put a scope on the gun and it should work fine.]
This mod makes it possible to quickly toggle on and off the scope. The game will remember what scope you last equipped on the gun, then when you press the button, take it off. Press the button again, to put the scope back on.
If you want toggle a different scope, manually attach the scope to your weapon by using inventory before pressing the button.
-----
Only working for main weapon slot!
--------
HOW TO INSTALL:
Open the folder til you see "gamedata", drag the gamedata folder into your root install directory for anomaly. Then load the game.
You must go into the game and see Setting and Keybinds (look for weapon keybinds) and put a keybind for kb_scope
------
WARNING:
conflict with ANY mod which gives you a ui_keybinding.xml for it, but you can merge the changes to fix, as long as you don't care about your kCUSTOM25 keybind (keybind for silencer toggle)
--------
TO FIX CONFLICT:
open config\ui\ui_keybinding.xml with a text editor, and find:
<command id="kb_suppressor" exe="custom13"/>
Put a new line below:
<command id="kb_scope" exe="custom25"/>
And save the file.
Then you must go to gamedata\script\quick_scope_equipping and where you see "key_bindings.kCUSTOM25"
If you already have custom25 in use from some other mod, you can try custom24 instead when editing the ui_keybinding.xml and quick_scope_equipping.script.
Then save the file.
You must go into Setting and Keybinds (look for weapon keybinds) and put a keybind for kb_scope
If other mods are taking ALL your keybinds from 20 to 25, then you can't do it. The game is only supporting custom commands until custom25 currently.
------
Good idea, thanks.
I'll add something to remember the fire mode also soon.
Your mods are great, can you make the starting equipment for the RC22?
great
When I press the key, it eats loaded grenades from the grenade launcher. I also use Anomaly Magazines, it that matters. AEK attached grenade launcher, didn't try an integrated one.
It might do something to the ammo (setting it to 1), but that could be problems between RC22 & Anomaly Magazines.
It's a problem in vanilla also, because when you equip the gun again it's giving you an unloaded grenade launcher, even if you put a grenade into it. I'll look into this
Yeah, I think I remember something like that in the series. And the ammo eating bug might be an issue on my side (R22 or who knows), so I prefer not complain about something that's not your fault and might lead you to waste time.
If you can solve the grenade-eating bug, you will be remembered as a god among men, sir. Because I switch often between scopes, and I always use rifle with grenade launcher, this (vanilla) bug it's like a curse. Because of that, I often stick with groza, which isn't great, but at least it's immune to this bug (because grenade launcher is not removable).
Hi, the ammo counter system is dealt with by the game engine. Not something I can change with a script yet. As soon as it is available, I will fix it. I already asked one of the engine devs
maybe a script that remembers when you had a grenade in place, and puts it back if it detects the correct missing grenade conditions, like a dirty fix of sorts?
That's a problem that came with the 1.5.1 update and not caused directly by mods. It also happens with magazines only when (un)equipping a scope. In fact when the weapon stays in the slot while (un)equipping the scope, the mag won't be lost. But if it gets removed from the slot due to changing the scope, it will delete the mag incl. all ammo inside of it.
Currently there is no script functions to control ammo counter in any way, I have asked the engine devs to implement something, if they do it I will update it asap. Ammo counter (for grenade launcher too) is all controlled by the game engine
On Rc 19 didn't work. I also did what suggested on "try to fix" section but it didn't work :(
Did you bind the key ingame? And do you have any other mod using the custom keybinds?
1) Yes 2) No
Show me your gamedata/configs/ui/ui_keybinding.xml in a pastebin or something
I didn't even have an"ui" folder before your mod. Anyway, here it's the pastebin: Pastebin.com
Your file looks different to mine, mine is all like in Pastebin.com
PSA - in order for this mod to work you need to save with a scope on your gun and reload that save, otherwise it wont work
This comment is currently awaiting admin approval, join now to view.
Works perfectly, now. Yes, you must put a scope, then save and reload. Thank you!
(Sorry for the double post, I forgotten to log in)
You can just put on a gun with a scope before pressing the key, shouldn't need to ssave or reload
Yes, I can confirm: it works like you said
That said, sometimes, the hotkey doesn't works and even other hotkeys stop to work, until you do a save&reload;.
It's happens about 5-10% of cases, after a change of map.
EDIT: NO, IT HAPPENS ONLY IF YOU PRESS THE BUTTON WITHOUT A SCOPE ON YOUR (PRIMARY) GUN. Sorry, my mistake
Hi, I have fixed this bug with the hotkey not working. Now if you just put a scope on your gun, the hotkey will work again, no need to reload game. I will upload new file shortly.
Hi, I have fixed this bug with the hotkey not working. Now if you just put a scope on your gun, the hotkey will work again, no need to reload game. I will upload new file shortly.
Great, man! Your mod it's already good, but that update will make it perfect!
I can't say if it's a vanilla bug or if it's related to your mod, but, if you put a scope (using a hotkey at least) when the rifle mode is on "grenade launcher" then the gun switch back to rifle mode, but with an empy magazine and so you lost ammo every time. Yes, you can avoid that, but it's annoying, because, in the heat of a combat, you can push the key in the wrong moment. :(
I just had a crash on 1.5.1 version while accidentally pressing the hotkey with SPAS12 (which has no ability to mount scopes) in left slot and no weapon in right slot.
! [SCRIPT ERROR]: ...maly-1.5.1\gamedata\scripts\quick_scope_equipping.script:19: attempt to index local 'weapon' (a nil value)
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_error
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 191
[error]Description : fatal error
[error]Arguments : LUA error: ...maly-1.5.1\gamedata\scripts\quick_scope_equipping.script:19: attempt to index local 'weapon' (a nil value)
Hi, the mod works only with main weapon slot (not really my fault, the weapon slots are hardcoded to be different from each other, and the right slot is the "main" one, I have already looked for a way around this)
Sadly I'm not able to make this work with the PU scope of my SKS. It works with the ps1 scopa of the SVD or the AK rifles though.
I think it has to do with the fact that the "addons_table" list doesn't cover all of the scopes in the game.
Doesn't work for me. Though I only tried it with Karabiner 98 Kurz with ZF-4 scope.
It worked with AK-72N though...
Yeah you are right, i wanted to bitch about you not doing something right, but i checked and it indeed doesent work on kar98 for some reason. valve please fix
can you please tell me if Kar98 only has 1 scope for it, the ZF-4? Maybe the scope is not in addons_table because the gun only has 1 scope.
This worked after saving the game with the desired scope equipped and reloading. Every time I died (and loaded a new game file again) I would have to repeat this process. Cool concept. I don't know if this is a limitation of the engine or not but I wanted to bring it to your attention. As it currently stands this mod is too cumbersome for me to use, but don't take that as a criticism of your work. Just a preference of mine.
Hi, I have fixed this bug with the hotkey not working. Now if you just put a scope on your gun, the hotkey will work again, no need to reload game. I will upload new file shortly.
thank you for that mod. The scopes are so intrusive and obsucre half of my screen. It was such a chore to equip/unequip it all the time, i cant thank you enough
This is on of my favorite addons. Along with this addon, I put a kobra/red dot and a tulip/acog on two of my quick slots so that I can quickly change scopes with just two keyboard presses!
10/10
Hi! A CTD happened when i tried to switch off a BaS scope (never happened before, but it's the first time that i use the updated version of your mod).
!ALIFE OBJECT ID IS 65535!
condition 93 [3651]
! [SCRIPT ERROR]: ...maly 1.5.1\gamedata\scripts\quick_scope_equipping.script:22: attempt to index local 'weapon' (a nil value)
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_error
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 191
[error]Description : fatal error
[error]Arguments : LUA error: ...maly 1.5.1\gamedata\scripts\quick_scope_equipping.script:22: attempt to index local 'weapon' (a nil value)
stack trace:
I use BaS, Blindside reanimation and other mods, but only the first 2 touch weapons.
Might be quickly fixed by dding a nil check for that local var inside the script - if it's NOT a mod conflicting somewhere.
Btw, the new BaS version already includes blindside animations, at least for BaS weapons.
Yep, but both mods are still compatible togeter.
yes the latest version added a nil check, that's what fixed the annoying bug of having to save/reload. I added elseif (scopename ~= nil) then..., I think his problem is maybe if BAS doesn't add the scopes to the addons_table, but I never used that mod so I'm not sure
ok, if that can help you, i've uploaded both weapons_addons.ltx and weapons_scope.ltx of BaS (there are scopes on both files). Ufile.io
Not sure why this is happening, the latest version of the mod adds in a nil check to stop most issues, but I have never tried BAS. Maybe worth checking if the scope for your weapon is in addons_table, as I don't know how or where BAS puts the scopes for its weapons
I made a quick patch for Weapon Parts Overhaul (using the guide in the description) if anyone wanna use it.
Gofile.io
Now both the "unjam" and "scope" equip function are in the keybinding UI
Must have mod. Kinda wish it took longer to do though. Feels inhumanly quick.
I set the key command but it doesn't do anything in game. I don't have any conflicts and I'm using 1.5.1. I tried to use another toggle scope addon from a different author and that works fine but I'd like to use yours because it's compatible with a companion teleport you just made. Any ideas why?
EDIT - Never mind, I had to have the gun in the right hand slot to use it. Works great along with the teleport companion. Thanks!
Nice mod! Just what i needed.
But dont you think that it happens a little too fast? Maybe you can find the way to use same sequence that quick silencer equiping uses? Would look a little more "natural"
EDIT: Also i cant quick equip scope if i save and load game with scope off. And also after changing locations without equiped scope...