ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Treasure Manager Hack to Reduce Stash Spam

1 2 3 4 5 6 7 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  20:28:38  8 July 2007
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4263
Treasure Manager Hack to Reduce Stash Spam

When you save and then reload the saved game, the game engine remembers the spots, but the script engine doesn't (so to speak), so you get the same novice bandit secrets all over again. This means that you get the same "A good place"* secret with three medkits over and over on the beginning Escape level, or the "Drunkard's backpack" secret with the 10 bottles of vodka in Agroprom, over and over. If you don't clear the stashes, you get a really laggy game after a bit, with long freezing pauses.

The best answer to this is a persistent treasure manager like the one implemented in bardak's patch, but it does involve changes to three different files and it renders any save-games that use it incompatible with future changes/patches.

Here's a workaround for either patch 1.0001 or patch 1.0003 to keep stashes from becoming overpopulated. It works by keeping the script engine in sync with the game engine. Save-games are not affected by this change.

In new games, or for new secrets in current games, it should also fix that annoyance whereby you remove the items from a stash, but the stash marker stays. (The workaround if it doesn't in older marked stashes is to keep putting an item in the stash and then taking it out until the spot goes away.)

Drawback: Once you remove all from a stash, the marker is removed. A reload of a game saved after the marker is removed doesn't know not to use the stash again. But you will still get it only once each time after cleaning out the stash. You can exploit this by not completely clearing junk stashes (leave the marker) and clearing cool stashes...

In gamedata\scripts\treasure_manager.script, at the end of the function CTreasure:__init(), change this code:


	self.treasure_by_target = {}
	for k,v in pairs(self.treasure_info) do
		self.treasure_by_target[v.target] = k	
	end


to this:

	self.treasure_by_target = {}
	if alife ~= nil then
		for k,v in pairs(self.treasure_info) do
			self.treasure_by_target[v.target] = k
			local obj = alife():story_object(v.target)
			if obj ~= nil then
				if tonumber(level.map_has_object_spot(obj.id, "treasure" )) > 0 then
					v.done = true
				end
			end
		end
	else
		for k,v in pairs(self.treasure_info) do
			self.treasure_by_target[v.target] = k
		end
	end


How it works: If there's a spot, the secret associated with it is marked "done" during the game load. This is the part that's forgotten when a game is saved/reloaded.

While this is not optimized code, I don't think you'll have any trouble with it.

*Most of the time when they say "cellar" in the English translation, they mean the attic.
  21:04:42  9 July 2007
profilee-mailreply Message URLTo the Top
SiriusStarr
Senior Resident
 

 
On forum: 06/21/2007
Messages: 207
Thanks, NatVac. Implementing now...
  07:04:56  10 July 2007
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4263
Feedback is welcomed.

I've been playing with this for a couple of days now, and I have a couple of observations myself:

1) If you get a stash secret you know you've seen before, you really aren't getting the same secret unless you've cleared out that stash in a previous save. Some stashes have the same name, at least in the English translation. For example, "Secret stash" is used for nine stashes, while "Secret stash under the cross" names six different stashes.

2) If you do not completely clear stashes*, you will get more stashes than you ever saw before. Previously, this was only true if you played non-stop; reloading a saved game meant getting the same beginning secrets again.

I think the game devs intended you to find each secret only once, but the persistence stuff doesn't work as of version 1.0003. This meant you could get the first bandit secret 10 times while never getting the last.

*Tip: The stash marker remains if the stash is not completely emptied. To reduce list-processing lag even further, you can put a useless item in the stash, then remove the rest, or take all but one item.
  18:28:15  10 July 2007
profilee-mailreply Message URLTo the Top
Ceano
Senior Resident
 

 
On forum: 03/02/2006
Messages: 4820
Well i did rely looked forward to use this mod...but when i did the changes in the ltx file the game wont start, i get an error message.

  19:14:21  10 July 2007
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4263
Ceano, what changes in what ltx file? This change is only to the script file; I think that's what you meant.

What error message? The "attempt to index global 'treasure_manager' (a nil value)" message is usually due to a syntax error, as D_akbar found out.

This code block is meant to replace the four lines shown, at the end of the CTreasure:__init() function, but that does not include the closing "end" of the function itself. When the replacement is done, there are three "end" statements in a row, before the comment that separates the CTreasure:__init() function from the function CTreasure:use(npc) that follows.

Now I know you have a lot of other modifications in your stuff, Ceano. But I wouldn't think this change would be affected by anything else out there except for other persistent treasure manager code like that in bardak's patch, which already (as I pointed out in the original post) fixes the problem. If that's the case, you don't need this patch.

If that's not the case: What is in the treasure_manager.script file you are using that's different from the 1.0001/1.0003 file?
  21:47:18  10 July 2007
profilee-mailreply Message URLTo the Top
SiriusStarr
Senior Resident
 

 
On forum: 06/21/2007
Messages: 207
Works great for me! Thanks!
  12:44:16  11 July 2007
profilee-mailreply Message URLTo the Top
Ceano
Senior Resident
 

 
On forum: 03/02/2006
Messages: 4820

---QUOTATION---
Ceano, what changes in what ltx file? This change is only to the script file; I think that's what you meant.
---END QUOTATION---



Sorry i did mean the treasure_manager.script file
I use the original file from the 1.0003 patch.

Here is the error message:


FATAL ERROR
 
[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : D:xray-svnxr_3daxrGamescript_engine.cpp
[error]Line          : 74
[error]Description   : <no expression>
[error]Arguments     : LUA error: d:s.t.a.l.k.e.rgamedatascripts_g.script:1233: attempt to index global 'treasure_manager' (a nil value)

  13:11:29  11 July 2007
profilee-mailreply Message URLTo the Top
D_akbar
Youngblood
(Resident)

 

 
On forum: 04/06/2007
Messages: 1295

---QUOTATION---
Ceano, what changes in what ltx file? This change is only to the script file; I think that's what you meant.

Sorry i did mean the treasure_manager.script file
I use the original file from the 1.0003 patch.

Here is the error message:


FATAL ERROR
 
[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : D:xray-svnxr_3daxrGamescript_engine.cpp
[error]Line          : 74
[error]Description   : <no expression>
[error]Arguments     : LUA error: d:s.t.a.l.k.e.rgamedatascripts_g.script:1233: attempt to index global 'treasure_manager' (a nil value)


---END QUOTATION---




thats the same error as i got, the problem here is that there is 1 end missing at the end of the command line (confusing ain't it?)

natvac fixed my file so if have any problems fixing it yourself check your email
  13:43:51  11 July 2007
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4263
D_akbar's right; it is easy to replace one "end" too many. And I can't edit the original post to make it clearer. So here is a repost of the critical section with clarifications:

In gamedata\scripts\treasure_manager.script, at the end of the function CTreasure:__init(), replace this code block:

	self.treasure_by_target = {}
	for k,v in pairs(self.treasure_info) do
		self.treasure_by_target[v.target] = k
	end
end
--' Þçàíèå èíèöèàòîðà (âîçìîæíîñòü âûäàòü òàéíèê)


with this code block:

	self.treasure_by_target = {}
	if alife ~= nil then
		for k,v in pairs(self.treasure_info) do
			self.treasure_by_target[v.target] = k
			local obj = alife():story_object(v.target)
			if obj ~= nil then
				if tonumber(level.map_has_object_spot(obj.id, "treasure" )) > 0 then
					v.done = true
				end
			end
		end
	else
		for k,v in pairs(self.treasure_info) do
			self.treasure_by_target[v.target] = k
		end
	end
end
--' Þçàíèå èíèöèàòîðà (âîçìîæíîñòü âûäàòü òàéíèê)


I hope that helps make it easier to implement.
  15:25:43  11 July 2007
profilee-mailreply Message URLTo the Top
Ceano
Senior Resident
 

 
On forum: 03/02/2006
Messages: 4820
Yes...thanks to both natVac and D_akbar.
 
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-2019 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.