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 | Next 10 events »| All Messages
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.
 
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.