ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Clear Sky Forum » Mod discussion
Need alittle help concerning spawning items into inventory

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  19:17:16  7 July 2014
profilee-mailreply Message URLTo the Top
tsf00181
(Senior)
 
On forum: 07/20/2013
Messages: 60
Need alittle help concerning spawning items into inventory

I'm trying to set the medical supplies up in my mod similar to what Zone of alienation as done. When you use a medkit it spawns individual medical items into your inventory.

I tried copying it directory from ZoA with no success in clear sky. It doesn't crash the game, but it doesn't spawn items either.

Here is the current code I have in the script:

---QUOTATION---

function spawn_medical_supplies(obj)
elseif obj:section()=="medkit_scientic" then --scientific medkit
alife():create("hemostat", db.actor osition(), 1, db.actor:game_vertex_id(), db.actor:id())
amk.spawn_item_in_inv("antiseptic"
amk.spawn_item_in_inv("gauze"
amk.spawn_item_in_inv("sutures"

elseif obj:section()=="medkit_scientic" then --scientific medkit
alife():create("hemostat", db.actor osition(), 1, db.actor:game_vertex_id(), db.actor:id())
amk.spawn_item_in_inv("antiseptic"
amk.spawn_item_in_inv("gauze"
amk.spawn_item_in_inv("sutures"
amk.spawn_item_in_inv("saline"
amk.spawn_item_in_inv("painkiller"
amk.spawn_item_in_inv("p-iodine"
amk.spawn_item_in_inv("cblb502"

elseif obj:section()=="medkit_army" then --army medkit
alife():create("hemostat", db.actor osition(), 1, db.actor:game_vertex_id(), db.actor:id())
amk.spawn_item_in_inv("antiseptic"
amk.spawn_item_in_inv("gauze"
amk.spawn_item_in_inv("sutures"
amk.spawn_item_in_inv("saline"
amk.spawn_item_in_inv("painkiller"
amk.spawn_item_in_inv("zeolite"
amk.spawn_item_in_inv("steroid"

end
return true
end

---END QUOTATION---



The first line in each section was just a test. I copied over Amk and amk_spawn.script and its method of spawning doesn't seem to work in CS, so I was trying something else.

This is what I added on bind?stalker.script

---QUOTATION---
function actor_binder:use_object( obj )
RL_medkit.spawn_medical_supplies( obj )
end
---END QUOTATION---



Anyone have any tips or pointers for this? Or a solution?

Thanks
  19:35:36  7 July 2014
profilee-mailreply Message URLTo the Top
Steelyglint
Senior Resident
 

 
On forum: 06/06/2009
Messages: 5171
Surely if it wasn't in the game to start with you'll be missing all the models for the individual items, the things you see in your inventory when you use it.

It would be like adding a HK416 assault rifle to a trader's inventory when there is no such rifle anywhere in the files for it to point to.

.
  20:19:18  7 July 2014
profilee-mailreply Message URLTo the Top
nashathedog
Senior Resident
 

 
On forum: 01/31/2011
Messages: 8354
So you want a box of goodies that you open and get several smaller goodies from it? Kind of like the SGM Medical parcels that contain all the different items. If so have a look at there's. I planned on doing it myself and had a look at SGM to pinch there code but failed miserably, If I remember right Angrydog explained how I should do it but I still failed miserably.

It's kind of my thing

COP is closer to CS so look there for what you want rather than trying to use SOC resources.
  21:16:59  7 July 2014
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: 6342
Here's a tip: Use the 'pre' tags instead of the quote 'tags' when posting code. Prevents smiley spam.

Also, open bind_stalker.script, and add the following lines to the indicated functions.

-- add to actor_binder:net_destroy() below self.object:set_callback(callback.take_item_from_box, nil)
self.object:set_callback(callback.use_object, nil)

-- add to actor_binder:reinit() below self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
self.object:set_callback(callback.use_object, self.use_object, self)

-- add somewhere in the file further down
function actor_binder:use_object(obj)
	error_log("Item used")
	-- replace myscript with the name of your script
	myscript.spawn_medical_supplies(obj)
end


If your script is set up properly, this should spawn the medical items when you use a medkit.
  21:29:38  7 July 2014
profilee-mailreply Message URLTo the Top
Decane
Senior Resident
 

 
On forum: 04/04/2007
Messages: 1706
In addition to registering the callbacks as SetaKat advised, I would suggest using this code instead of what you have:


function spawn_medical_supplies(obj)

	local sect = obj:section()

	if sect == "medkit" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)

	elseif sect == "medkit_scientic" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)
		sim:create("saline", vector(), 0, 0, act_id)
		sim:create("painkiller", vector(), 0, 0, act_id)
		sim:create("p-iodine", vector(), 0, 0, act_id)
		sim:create("cblb502", vector(), 0, 0, act_id)

	elseif sect == "medkit_army" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)
		sim:create("saline", vector(), 0, 0, act_id)
		sim:create("painkiller", vector(), 0, 0, act_id)
		sim:create("zeolite", vector(), 0, 0, act_id)
		sim:create("steroid", vector(), 0, 0, act_id)
	end
end



Much better optimized, especially in respect of i/o activity (no references to other script files!). Also, I fixed the duplicate "medkit_scientic" check.
  23:14:32  7 July 2014
profilee-mailreply Message URLTo the Top
tsf00181
(Senior)
 
On forum: 07/20/2013
Messages: 60
Thanks. Got it working, I'll make sure you and Setakat get proper credit in the script.

Now I just got to search through the gigabytes of mods I have for some models.


---QUOTATION---
In addition to registering the callbacks as SetaKat advised, I would suggest using this code instead of what you have:


function spawn_medical_supplies(obj)

	local sect = obj:section()

	if sect == "medkit" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)

	elseif sect == "medkit_scientic" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)
		sim:create("saline", vector(), 0, 0, act_id)
		sim:create("painkiller", vector(), 0, 0, act_id)
		sim:create("p-iodine", vector(), 0, 0, act_id)
		sim:create("cblb502", vector(), 0, 0, act_id)

	elseif sect == "medkit_army" then

		local sim, act_id = alife(), db.actor:id()
		sim:create("hemostat", vector(), 0, 0, act_id)
		sim:create("antiseptic", vector(), 0, 0, act_id)
		sim:create("gauze", vector(), 0, 0, act_id)
		sim:create("sutures", vector(), 0, 0, act_id)
		sim:create("saline", vector(), 0, 0, act_id)
		sim:create("painkiller", vector(), 0, 0, act_id)
		sim:create("zeolite", vector(), 0, 0, act_id)
		sim:create("steroid", vector(), 0, 0, act_id)
	end
end



Much better optimized, especially in respect of i/o activity (no references to other script files!). Also, I fixed the duplicate "medkit_scientic" check.
---END QUOTATION---

  19:09:33  9 July 2014
profilee-mailreply Message URLTo the Top
tsf00181
(Senior)
 
On forum: 07/20/2013
 

Message edited by:
tsf00181
07/09/2014 19:09:48
Messages: 60
Directed towards Decane and Setakat.

Would either of you be interested in doing scripting for a mod? I can muddle through it, but not very well so I think I need someone who knows lua. I'm not trying to reinvent the wheel with scripting, just trying to enable some stuff that'll give CS a more RPG feel.

If your interested send me a msg on moddb.
[link]http://www.moddb.com/mods/the-road-to-limansk[/link]
 
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.: Clear Sky 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.