ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
How to check whether weapon has built-in scope

1 2 3 4
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  15:40:42  1 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
How to check whether weapon has built-in scope

Hi modders,

I did this years ago but entirely forgot how to check by script if a given weapon has a scope built-in (status flag 1 in .ltx). And unfortunately my personal wiki somehow got wrecked...

So what would be the easiest to do this by some script function?
  15:54:10  1 February 2012
profilee-mailreply Message URLTo the Top
ket
Senior Resident
 

 
On forum: 01/13/2006
Messages: 1432
Weapons that can have scopes fitted/removed;

AK74
Abakan
Groza
LR300
Sig550
Gauss (I think)
L85 (I think)
AS Val

While there are some other scoped weapons like the SVD/SVU, their scopes are not removable AFAIK. Set the paramater so the scope can be removed and the game will simply crash
  16:04:43  1 February 2012
profilee-mailreply Message URLTo the Top
Lijenstina
Doom metal in the shade of the flying radiators
(Resident)

 

 
On forum: 07/23/2005
Messages: 1902
Check Bak's AI pack.

rx_utils.script the function is addon_attached.
  16:33:38  1 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
02/01/2012 16:34:04
Messages: 1519

---QUOTATION---
Weapons that can have scopes fitted/removed;

AK74
Abakan
Groza
LR300
Sig550
Gauss (I think)
L85 (I think)
AS Val

---END QUOTATION---



Thanks, but I think you both got me wrong. What I want is a script that tells me if a weapon (e.g. the actor's current item) has a fixed scope, not an attachable one.


---QUOTATION---
While there are some other scoped weapons like the SVD/SVU, their scopes are not removable AFAIK.
---END QUOTATION---



Exactly those weapons I want to identify by script. And generally, i.e. not only for vanilla weapons (which could be simply listed) but also for unspecified additional ones from any mod.

Something like

if scope_type(weapon) == 0 then
   ... -- no scope at all
elseif  scope_type(weapon) == 1 then
   ... -- built-in scope, e.g. SVD, SVU, G36, FN2000
elseif  scope_type(weapon) == 2 then
   ... -- attachable scope, e.g. AK74, Abakan, Groza
end

  16:56:09  1 February 2012
profilee-mailreply Message URLTo the Top
ket
Senior Resident
 

 
On forum: 01/13/2006
Messages: 1432
What exactly are you trying to do? Just create a exception list?
  17:16:58  1 February 2012
profilee-mailreply Message URLTo the Top
LoNer1
Настоящий Cталкер, Русская Версия
(Resident)

 

 
On forum: 10/23/2009
Messages: 1890

---QUOTATION---
What exactly are you trying to do? Just create a exception list?
---END QUOTATION---



i think he wants to add a shader to the weapons with mounted scopes...but i am just guessing
  17:23:39  1 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
What exactly are you trying to do? Just create a exception list?
---END QUOTATION---



I'm trying to get my 1.1 Beta shaders upload-ready

My script controls some shader settings. For activating my nightvision scopes on-demand I need to know two things: First, if the player currently uses the scope, i.e. is in zoom/aim mode. That one I already got. And second, if the player's current weapon has a scope or not. That's what I'm looking for.

By packet_utils or xrs_utils I can easily determine whether a scope is currently attached to the weapon, however for weapons with built-in scope such as SVD that doesn't work. So I need another approach for those weapons.

And I do not just want a fixed list of those weapons because that's what I already got right now. Because that list would need to be expanded for every mod that adds weapons

Instead, I intend to make my script determine dynamically if the gun has a built-in scope, regardless whether it's a vanilla gun or not.

I know that's possible, but I forgot how...
  17:28:53  1 February 2012
profilee-mailreply Message URLTo the Top
Lijenstina
Doom metal in the shade of the flying radiators
(Resident)

 

 
On forum: 07/23/2005
 

Message edited by:
Lijenstina
02/01/2012 17:36:10
Messages: 1902
Still look at the rx_utils.
Don't know if this could do something haven't tested it what does that return.

get_weapon_data(alife():object(wpn:id())).addon_flags or 0 



One way is to do a section related search for the line the other is to read the weapon data like here.

EDIT:
Ah I see. Add a line in the weapon's ltx with the mod related entry. It's the simplest way. Done that for the scope textures UI.


function scud:pick_texture()
    if db.actor and level.present() then
	    local a_wpn = db.actor:active_item()
	    if a_wpn and (db.actor:active_slot() == 1 or db.actor:active_slot() == 2 or db.actor:active_slot() == 4) then
			local active_section = a_wpn:section()
			local c_sid = get_clsid(a_wpn)
			if active_section and ((sys_ini:section_exist(active_section) and isWeapon(a_wpn)) or active_section == "wpn_binoc") then
			    scope_tex = nil
				if rx_utils.addon_attached(a_wpn,"sc") or active_section == "wpn_binoc" then
					is_attached = true 
		            if sys_ini:line_exist(active_section, "scope_smp_hud") then
					    scope_tex = sys_ini:r_float(active_section,"scope_smp_hud") 
					else
					    scope_tex = 1
					end
				else 
				    is_attached = false
				end
				if is_attached then 
					if scope_tex then return scope_tex end
				end
			end		
		end
	end
end

  17:46:28  1 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Thanks. However I still believe there was a generic way without the need of modifying any .ltx. Will try again to figure it out...
  20:19:52  1 February 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6340
Just read the ltx file with the ini_file(...) function and methods and see if the scope_status parameter is 1.
  22:48:31  1 February 2012
profilee-mailreply Message URLTo the Top
mnn
Senior Resident
 

 
On forum: 06/12/2009
Messages: 2694
There's no need to do that, fluffy. Weapons configs are part of system config, so it's simpler to read required values from system_ini()...
  00:59:49  2 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
 

Message edited by:
Nuor
02/02/2012 4:20:57
Messages: 735

---QUOTATION---
There's no need to do that, fluffy. Weapons configs are part of system config, so it's simpler to read required values from system_ini()...
---END QUOTATION---



pretty much


function is_scope_attached()
local sys_ini = system_ini()
local active_weap = db.actor:active_item()
local active_section = active_weap and active_weap:section() or "none"
if sys_ini:section_exist(active_section) and
	sys_ini:line_exist(active_section, "scope_status") and
	sys_ini:r_string(active_section,"scope_status") == 1 then
		return true
end
return false
end



I think that should be close

edit: oops forgot something
  10:40:52  2 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Cool, thanks Nuor Will try asap!
  00:29:10  4 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Just wanted to let you now that Nuor's approach works like charm! That's exactly what I was after - and now I included it in my util.script so that I won't forget it again

However, just one little thing: The sys_ini:r_string function returns a string rather than a number (as its name implies), so tonumber() is required when comparing to a digit.

Thanks again to all for your help
  01:10:12  4 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---

However, just one little thing: The sys_ini:r_string function returns a string rather than a number (as its name implies), so tonumber() is required when comparing to a digit.

Thanks again to all for your help
---END QUOTATION---



yep that's what I get for not testing. I imagine "1" instead of 1 should work.
  01:49:55  5 February 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
My script controls some shader settings. For activating my nightvision scopes on-demand I need to know two things: First, if the player currently uses the scope, i.e. is in zoom/aim mode. That one I already got. And second, if the player's current weapon has a scope or not. That's what I'm looking for.
---END QUOTATION---



Wait, did you just mention that you're working on adding nightvision scopes?
  18:39:54  5 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
Wait, did you just mention that you're working on adding nightvision scopes?
---END QUOTATION---



Actually I've already done it

Will be part of version 1.1 of my Dynamic Shaders mod. I'm just trying to fix some issues and do some optimizations before I can upload...
  22:20:08  5 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---
Wait, did you just mention that you're working on adding nightvision scopes?

Actually I've already done it

Will be part of version 1.1 of my Dynamic Shaders mod. I'm just trying to fix some issues and do some optimizations before I can upload...
---END QUOTATION---



I created one a couple of years ago. I't will be interesting to see what route you took.
  22:31:14  5 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
I created one a couple of years ago.
---END QUOTATION---



Oh really? Interesting. Could you provide a link? Did you use ppe's or shaders?


---QUOTATION---
I't will be interesting to see what route you took.
---END QUOTATION---



Fairly easy one (but fairly powerful as well, if you ask me). You'll see soon
  23:09:48  5 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---
I created one a couple of years ago.

Oh really? Interesting. Could you provide a link? Did you use ppe's or shaders?


---END QUOTATION---



I just used an expanded set of ppe's.

It's triggered by checking conditions and can attach to a limited set of weapons as determined by ltx entry. It also makes use of a battery.

I haven't released it as I have it buried in the SMP2.5 along with a bunch of other new mods. I'm expecting the beta for that will be out soon. I've played with it for quite some time now and it seems to work fine.
  23:51:11  5 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
I just used an expanded set of ppe's.

It's triggered by checking conditions and can attach to a limited set of weapons as determined by ltx entry. It also makes use of a battery.

I haven't released it as I have it buried in the SMP2.5 along with a bunch of other new mods. I'm expecting the beta for that will be out soon. I've played with it for quite some time now and it seems to work fine.
---END QUOTATION---



I had started with ppe's as well, and first I was satisfied. Then I noticed that a shader-based approach gives more options on what's possible to implement, first of all, only processing the screen center while leaving the peripheral screen area untouched
  00:10:19  7 February 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
Wait, did you just mention that you're working on adding nightvision scopes?

Actually I've already done it

Will be part of version 1.1 of my Dynamic Shaders mod. I'm just trying to fix some issues and do some optimizations before I can upload...
---END QUOTATION---



I can see that. I wonder if I could get someone to port the 1PN58 and 1PN51 models from this mod to SoC. Although I don't suppose that's in your area of expertise.

http://www.gamebanana.com/cscz/skins/103880
  01:04:40  7 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---
http://www.gamebanana.com/cscz/skins/103880
---END QUOTATION---



I think we have that in Smp 2.5 at least something close. Models with actual night scopes additions are fairly rare.
  20:37:38  8 February 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
http://www.gamebanana.com/cscz/skins/103880

I think we have that in Smp 2.5 at least something close. Models with actual night scopes additions are fairly rare.
---END QUOTATION---



This might be a little much for me to ask, but, can I have them?

I'm working on drawing the proper reticles for these types of scopes as well.
  22:44:16  8 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
Wait, did you just mention that you're working on adding nightvision scopes?
---END QUOTATION---



I made some video demonstrating the effect:

http://www.moddb.com/mods/dynamic-shaders/videos
  23:00:45  8 February 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735
Overall I like it. It is a more realistic effect than the ppe's I am using.

I hate limited viewable area being a small circle, that is a result of the scope textures, (We have them also and I hate them when we use them).
I don't know who got the idea that you look through a scope from that far back.
  10:32:11  9 February 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
I hate limited viewable area being a small circle, that is a result of the scope textures, (We have them also and I hate them when we use them).
I don't know who got the idea that you look through a scope from that far back.
---END QUOTATION---



I know very well what you mean and I agree. It's fairly unrealistic that you actually see the outside of the scope when you look through it. Instead, you would press your eye onto the rubber that surrounds the scope lens (anybody who ever looked through a real gun scope knows what I mean).

However, I consider these textures not as an aim for realism. Instead, they should just look, let's call it, cool. And with the blurred periphery around the lens and the NV, that intention is fitted quite well if you ask me.

Besides, you could also just use my NV scopes with the classic scope textures if you like
  16:41:22  9 February 2012
profilee-mailreply Message URLTo the Top
gannebamm
has abondened XRay and uses Unity3D now
(Resident)

 

 
On forum: 05/02/2007
Messages: 1077
gj!
  17:37:17  9 February 2012
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349

---QUOTATION---
gj!

---END QUOTATION---


hey gb, good to see you around
  23:19:04  11 March 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
There's no need to do that, fluffy. Weapons configs are part of system config, so it's simpler to read required values from system_ini()...

pretty much


function is_scope_attached()
local sys_ini = system_ini()
local active_weap = db.actor:active_item()
local active_section = active_weap and active_weap:section() or "none"
if sys_ini:section_exist(active_section) and
	sys_ini:line_exist(active_section, "scope_status") and
	sys_ini:r_string(active_section,"scope_status") == 1 then
		return true
end
return false
end



I think that should be close

edit: oops forgot something
---END QUOTATION---




Wait, could this be adapted to .ppe files?

More specifically, is it possible for the script to tell not just that a scope is attached, but which scope is attached to the weapon?

So the root of my question is whether or not a script can tell the name of what attachment is equipped, and if not then is it possible to create an ini section specifying which weapons attach the type of scope in question? The latter idea might be something similar to Bak's dynamic_hud script.


You see where I'm going with this right? I'm looking to add .ppe-based nightvision for weapons equipped with certain scopes, no offense against Meltac, but I would rather use .ppe effectors for nightvision.

I know of a mod that already does this, so I'll just paste its respective script files.

nightvision.script
http://pastebin.com/pwykB8aj

item_effects.script
http://pastebin.com/SbQ96AFY

weap_data.script
http://pastebin.com/dQbsN402

and its bind_stalker.script
http://pastebin.com/qxdMUYr5

The author of the scripts above used in a mod is Kirag, I found it to be an alright mod, but a little too complicated for my tastes, this is why I'm wondering if something simpler could be created based on the same principle.
  22:29:30  12 March 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
You see where I'm going with this right? I'm looking to add .ppe-based nightvision for weapons equipped with certain scopes, no offense against Meltac, but I would rather use .ppe effectors for nightvision.
---END QUOTATION---



No offense taken. What you wanna do is possible - as you already said it has even be done before by someone else

However, the reason I decided to add shader-based nightvision to scopes rather than just applying .ppe's is that I have much more control that way. First of all, you won't be able to have a .ppe effect applied only to certain regions of the screen (such as the center) while leaving the rest untouched - it's all or nothing. So it's not a good option when using Gnomus' scopes and the like.

Second, you won't be able to make your .ppe adaptive, the way I do it with my shaders, i.e. react on environmental illumination and other things and tune the effect up or down respectively - again, .ppe is just all or nothing. Also I can add some distortion or magnification regionally.

So if you're not interested in having such amount of control, a .ppe based approach surely can do what you're looking for.
  04:11:04  13 March 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
However, the reason I decided to add shader-based nightvision to scopes rather than just applying .ppe's is that I have much more control that way. First of all, you won't be able to have a .ppe effect applied only to certain regions of the screen (such as the center) while leaving the rest untouched - it's all or nothing. So it's not a good option when using Gnomus' scopes and the like.

Second, you won't be able to make your .ppe adaptive, the way I do it with my shaders, i.e. react on environmental illumination and other things and tune the effect up or down respectively - again, .ppe is just all or nothing. Also I can add some distortion or magnification regionally.

So if you're not interested in having such amount of control, a .ppe based approach surely can do what you're looking for.
---END QUOTATION---



Yeah, I'm more than willing to make those sorts of compromises, my original scope textures had blacked out the periphery of vision. Your shader-based system works decently but it has this weird solarizing effect with light sources, doesn't work on static lighting (for obvious reasons,) and is a little too "clean" looking for my tastes.

My main reason for looking for a .ppe system is so that it can get washed out by light/explosions, has a grain effect, and vision can be of varying quality for the sake of game progression.

I dislike the way night vision is treated in SoC, I'm aware of the fact that in the original concepts, there were supposed to be goggles and separate NVDs for weapons, but in the final game night vision does not have any sort of weight or movement penalty by itself, and offers quite a decent FoV, that and the fact that it is almost ubiquitous for most of the suits, and even with the original night weathers it might not even be necessary.

I still await your next update.
  10:32:18  13 March 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
03/13/2013 10:33:40
Messages: 1519
No problem, just go with a .ppe based approach then, I had done that as well before moving to shaders and it worked quite fine with the advantages you describe. Either way it's better than the vanilla "NV" system.

I'm not sure what kind of solarizing effect you mean, but it might just be the effect of the adaptive residual light amplification system I implemented.

Btw, my next shader version won't have any changes regarding NV scopes as it's pretty intended as a feature release, bringing new stuff such as sun shafts, dynamic wet surfaces, visor reflections, dynamic rainbows, and lighting improvements (sorry for advertising )

Good luck with your mod!
  19:13:36  22 March 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
Good luck with your mod!
---END QUOTATION---



I'll need it, I'm almost done with the update but I have a few more things to finish. Do you still happen to have the AI merge you mentioned in this thread?

https://gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=56&thm_id=18136&page=2&sec_id=16
  22:08:28  22 March 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
03/22/2013 22:09:52
Messages: 1519

---QUOTATION---
Do you still happen to have the AI merge you mentioned in this thread?

https://gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=56&thm_id=18136&page=2&sec_id=16
---END QUOTATION---



Wow, that's quite some time back! Didn't even remember I wrote that much posts here those days That was definitively in my scripting era - long time ago...

But nope, don't think I have the original source (I'd have to dig, though). Maybe ask in that thread?
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2020 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.