ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Need help for a script

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  17:05:45  1 September 2013
profilee-mailreply Message URLTo the Top
Darimar
(Senior)
 
On forum: 07/03/2008
Messages: 57
Need help for a script

Hi all, just a little question.
I'm looking for a script that make it possibile to put the artifact "X" into belt ONLY IF the character is wearing the outfit "Y". Do you know how to build it?
  17:45:45  1 September 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
I think the only way to do it is to create two items: the normal artifact, and a copy that is identical except it can't be equipped. Keep track of what the actor is wearing, if it's the outfit Y, replace all fake artifacts with the equippable one, and vice versa if he removes the outfit.
If you need help with implementation let me know.
  19:10:18  1 September 2013
profilee-mailreply Message URLTo the Top
Darimar
(Senior)
 
On forum: 07/03/2008
Messages: 57

---QUOTATION---

Keep track of what the actor is wearing, if it's the outfit Y, replace all fake artifacts with the equippable one, and vice versa if he removes the outfit.
---END QUOTATION---



Indeed I need help, thx! I'm able to create a fake artefact but I don't know very much about scripts language...
  17:14:18  2 September 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
 

Message edited by:
TKGP
09/02/2013 17:15:12
Messages: 454
OK, here is some code I whipped up. It all goes in bind_stalker.script. At the top right under "local weapon_hide = false" insert:

local actorOutfit = nil
local removeObj = nil


Then add this block to the end of function actor_binder n_item_take:

local section = obj:section()
if ( section == "af_blood" and actorOutfit and actorOutfit == "novice_outfit" ) or ( section == "af_medusa" and ( not actorOutfit or actorOutfit ~= "novice_outfit" ) ) then
	removeObj = obj
end


Finally, place these lines at the end of function actor_binder:update:

actorOutfit = db.actor:item_in_slot( 6 ) and db.actor:item_in_slot( 6 ):section()
if removeObj then
	if removeObj:section() == "af_blood" then
		alife():create( "af_medusa", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), db.actor:id() )
	elseif removeObj:section() == "af_medusa" then
		alife():create( "af_blood", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), db.actor:id() )
	end
	alife():release( alife():object( removeObj:id() ) )
	removeObj = nil
elseif actorOutfit and actorOutfit == "novice_outfit" and db.actor:object( "af_blood" ) then
	removeObj = db.actor:object( "af_blood" )
elseif ( not actorOutfit or actorOutfit ~= "novice_outfit" ) and db.actor:object( "af_medusa" ) then
	removeObj = db.actor:object( "af_medusa" )
end


Basically, when you pick up an item it checks what outfit you're wearing and changes it if necessary. It also keeps track of what you're wearing and if you remove it or put something else on, it updates all the artifacts to be the correct version. For testing I just used "novice_outfit" as the trigger, "af_medusa" as the "real" artifact, and "af_blood" as the "fake" artifact. So replace those with the section names of whatever you intend to use.
Hope that all made sense.
  22:06:43  3 September 2013
profilee-mailreply Message URLTo the Top
Darimar
(Senior)
 
On forum: 07/03/2008
Messages: 57

---QUOTATION---
OK, here is some code I whipped up.
---END QUOTATION---



Tha a lot, for your help and your time.
I'm using a mod based on the Freeplay Start 1.21, and the bind.stalker.script is very different from the vanilla one: the part in the actor_binder n_item_take seems to be not compatible with starting a new game.
Np, I'll make some test...
  22:16:17  4 September 2013
profilee-mailreply Message URLTo the Top
Darimar
(Senior)
 
On forum: 07/03/2008
Messages: 57
Ok, tests done and... it works! Thx a lot, friend, you are the man!

Now I should need to complete the job, so I ask for helping again, for the last time, I hope.
The script must works for more artifacts and more outfits: the character must be able to use ONE (only one at a time!) artifact belonging to a list of artifacts (x, y, z, ...) only if he is wearing an outfit (whatever, it does no matter) belonging to a list of outfits (k, n, t, ...).
Uhm... my English sux, so I hope to have explained well my purpouse...
 
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.