ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Fixing bug in Artifact Detector

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  19:20:43  30 March 2011
profilee-mailreply Message URLTo the Top
MrSeyker
Senior Resident
 

 
On forum: 03/21/2010
Messages: 433
Fixing bug in Artifact Detector

I'm trying to rewrite the Artifact Detector mod by Singapur22 to work as intended, but I'm having a problem with this part of code:


function det_super()
	for k,v in pairs(db.artefacts) do
		local art = level.object_by_id(k)
		if art then
			if not art:parent() then
				local dist = db.actor:position():distance_to_sqr(art:position())
				if dist < 1500^2 then
					if not v.spot then
						local ini = system_ini()
						local section = art:section()
						local name = ""
						if ini and section and ini:section_exist(section) then
							if ini:line_exist(section, "inv_name") then
								name = ini:r_string(section, "inv_name")
							end
						end
						level.map_add_object_spot(k, "artefact_location", "Artifact: " .. game.translate_string(name))
						db.artefacts[k].spot = true
					end
				else
					this.del_spot(k, v)
				end
			else
				this.del_spot(k, v)
			end
		end
	end
end



How can I make this detect offline artifacts?

Here's the original for comparison:


function det_super()
    for k,v in pairs(db.artefacts) do
	    local sobj = alife():object( k )
		if sobj then
			if game_graph():vertex(sobj.m_game_vertex_id):level_id() == alife():level_id() and sobj.parent_id == 65535 and not sobj.is_day_night then
				if not v.spot then
				    local ini = system_ini()
					local section = sobj:section_name()
					local name = ""
					if ini and section and ini:section_exist(section) then
					    if ini:line_exist(section, "inv_name") then
						    name = ini:r_string(section, "inv_name")
						end
					end
			        level.map_add_object_spot(k, "artefact_location", "àðòåôàêò: " .. game.translate_string(name))
				    db.artefacts[k].spot = true
			    end
			else
				this.del_spot(k, v)
			end
		end
	end
end



Any ideas?
  20:42:10  30 March 2011
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
as irony would have it, it would seem the original was indeed written for offline objects.
  21:03:45  30 March 2011
profilee-mailreply Message URLTo the Top
MrSeyker
Senior Resident
 

 
On forum: 03/21/2010
Messages: 433

---QUOTATION---
as irony would have it, it would seem the original was indeed written for offline objects.
---END QUOTATION---



Yeah, but only that part.

The other two detectors use the same method as my example, but that just bugs the hell out of the whole thing.

Doing some more tests, I'm finding more problems.

If I have the super detector attached when the artifact goes offline, it won't delete the marker when I change detectors as it's already out of the script's reach.

I think the solution would be to turn this process:


function det_indy()
	for k,v in pairs(db.artefacts) do
		local art = level.object_by_id(k)
		local art2 = alife():object(k)
		if art then
			if not art:parent() then
				local dist = db.actor:position():distance_to_sqr(art:position())
				if dist <= 40^2 and dist < time_global() - v.tim_beep then
					if not snd_obj:playing() then
						db.artefacts[k].tim_beep = time_global()
						snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
					end
				else
					this.del_spot(k, v)
				end
			else
				this.del_spot(k, v)
			end
		end
	end
end



Into the original I posted above.

But I don't know how to get the artifact's position that way.
  14:45:28  31 March 2011
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
I`m still not quite sure what you are trying to achieve.

Do you want a "normal" detector to detect only online artefacts (IE within switch_distance) and the "super" to detect all artefacts?

If so then when marking the item on the map, its probably better to use the offline id for all artefacts no matter what detector you are using, that way when the go offline, you have this id saved already and can be deleted.
  15:16:32  31 March 2011
profilee-mailreply Message URLTo the Top
MrSeyker
Senior Resident
 

 
On forum: 03/21/2010
 

Message edited by:
MrSeyker
03/31/2011 15:17:55
Messages: 433
The 1st detector is supposed to detect artifacts by audio within the 40mts range.

The 2nd detector beeps and shows them on the map and mini-map if they are in the 70mts range.

The 3rd is supposed to show them only in the maps (no sound) if they are within 1500mts.

So the first two detect only online artifacts, and the third both.


When I change the indy and normal detectors to use the method the super detector uses, the thing ctd because of of this:


art:position()



It doesn't work with alife().

And I have no idea what's the alternative.
  15:23:54  31 March 2011
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
OK, I get it now.

They will require a different function alltogether to use the online artefacts, just like the one you posted. Only difference should be that you mark the artefacts offline id instaed of the online, so do this instead :
local s_obj = alife():object(k)
level.map_add_object_spot(s_obj.id, "artefact_location", "Artifact: " .. game.translate_string(name))

  16:39:42  31 March 2011
profilee-mailreply Message URLTo the Top
MrSeyker
Senior Resident
 

 
On forum: 03/21/2010
 

Message edited by:
MrSeyker
03/31/2011 16:42:02
Messages: 433
Damn, this is so incredibly frustrating.

I kept the codes as they were originally, except for the call to each function:


		if item:section() == "det_artefact_indy" then
			this.iteration_del_spot()
			this.det_indy()
		elseif item:section() == "det_artefact_pro" then
			this.iteration_del_spot()
			this.det_pro()
		elseif item:section() == "det_artefact_super" then
			this.iteration_del_spot()
			this.det_super()
		else
			this.iteration_del_spot()
		end



First I remove previous spots, then I create them again.

But even if the spot gets added to the map, the lables are missing, and the mini-map shows nothing this way.

These are the functions that remove spots, and add them:


function iteration_del_spot()
	for k,v in pairs(db.artefacts) do
		local art = alife():object(k)
		if art then
			this.del_spot(k, v)
		end
	end
end

function add_spot(k, v, string)
	if not v.spot then
		local s_obj = alife():object(k)
		level.map_add_object_spot(s_obj.id, "artefact_location", string)
		db.artefacts[k].spot = true
	end
end

function del_spot(k, v)
	if v.spot then
		local s_obj = alife():object(k)
		level.map_remove_object_spot(s_obj.id, "artefact_location")
		db.artefacts[k].spot = false
	end
end



Indy function:


function det_indy()
	for k,v in pairs(db.artefacts) do
		local art = level.object_by_id(k)
		if art then
			if not art:parent() then
				local dist = db.actor:position():distance_to_sqr(art:position())
				if dist <= 40^2 and dist < time_global() - v.tim_beep then
					if not snd_obj:playing() then
						db.artefacts[k].tim_beep = time_global()
						snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
					end
				else
					this.del_spot(k, v)
				end
			else
				this.del_spot(k, v)
			end
		end
	end
end



Pro function:


function det_pro()
	for k,v in pairs(db.artefacts) do
		local art = level.object_by_id(k)
		if art then
			if not art:parent() then
				local dist = db.actor:position():distance_to_sqr(art:position())
				if dist < 70^2 then
					if not v.spot then
						local ini = system_ini()
						local section = art:section()
						local name = ""
						if ini and section and ini:section_exist(section) then
							if ini:line_exist(section, "inv_name") then
								name = ini:r_string(section, "inv_name")
							end
						end
						this.add_spot(k, v, "Artifact")
					end
					if v.tim_beep < time_global() and not snd_obj:playing() then
						db.artefacts[k].tim_beep = time_global() + 2500
						snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
					end
				else
					this.del_spot(k, v)
				end
			else
				this.del_spot(k, v)
			end
		end
	end
end



Super function:


function det_super()
	for k,v in pairs(db.artefacts) do
		local art = alife():object(k)
		if art then
			if game_graph():vertex(art.m_game_vertex_id):level_id() == alife():level_id() and art.parent_id == 65535 and not art.is_day_night then
				if not v.spot then
					local ini = system_ini()
					local section = art:section_name()
					local name = ""
					if ini and section and ini:section_exist(section) then
						if ini:line_exist(section, "inv_name") then
							name = ini:r_string(section, "inv_name")
						end
					end
					this.add_spot(k, v, "Artifact: " .. game.translate_string(name))
				end
			else
				this.del_spot(k, v)
			end
		end
	end
end

  16:26:37  1 January 2012
profilee-mailreply Message URLTo the Top
the_marked_one
Senior Resident
 

 
On forum: 11/21/2010
Messages: 647
Where can i find a copy of this artifact detector mod? could be just what im looking for
  21:32:06  1 January 2012
profilee-mailreply Message URLTo the Top
MrSeyker
Senior Resident
 

 
On forum: 03/21/2010
Messages: 433

---QUOTATION---
Where can i find a copy of this artifact detector mod? could be just what im looking for
---END QUOTATION---



I found this after lurking Russian forums for quite some time, but I lost the links.

A google search gave me this:

http://stalkerworld.ru/load/shadow_of_chernobyl/mods/detektory_artefaktov_v1_0/2-1-0-238

IIRC, this is the new version of the mod I mentioned in the original post.

Singapur22 rewrote the whole thing and now not only does it work as he intended, but he has made all artifacts invisible (and quite possibly un-pickable, can't recall) unless any detector is equiped, similar to how artifact hunting is done in CoP.

In that page I gave you, click in Скачать (use the browser's search function).

If you want to try your luck and search for other pages, search in Google for Детекторы артефактов v1.0.


This one here:

http://stalker-portal.ru/page.php?id=6127&d=20

Is the original version I was talking about in my posts.

Google search: Детекторы Артефактов 0.1
  22:48:08  1 January 2012
profilee-mailreply Message URLTo the Top
the_marked_one
Senior Resident
 

 
On forum: 11/21/2010
Messages: 647
Thanks i will have a look and see if i can get it working with my mod
 
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-2021 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.