ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Clear Sky Forum » Mod discussion
Spawn NPC through script

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  14:26:16  4 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Spawn NPC through script

Is there any way to give this npc a unique story id ?

I have try this out, it is from amk mod for shoc.


---QUOTATION---

function spawn_npc()
local obj = alife():create("esc_bad_boy",vector():set(-120.48091125488,-9.0397319793701,-147.6286315918),137299,633)
local params=amk.read_stalker_params(obj)
params.custom="[logic]\ncfg = scripts\\bth\\bad_boy_script.ltx"
params.sid=3001
amk.write_stalker_params(params,obj)
end
---END QUOTATION---



I have add the needed script parts from amk mod and the npc spawn and his logic script works also, but his story id doest work.
  16:56:44  4 November 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
Packet layout is different between games. Try using smoq2's update to barin's excellent packet_utils.script.
https://gsc-game.com/main.php?t=community&s=forums&s_game_type=xr2&thm_page=1&thm_id=22609&sec_id=21#304267
  17:37:45  4 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Hm...thanks for this.
But i`m not a scripter and maybe someone can tell me how i write the spawn script, that the npc is spawned with an story id ?
  17:42:37  4 November 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

function spawn_npc()
	local obj = alife():create("esc_bad_boy",vector():set(-120.48091125488,-9.0397319793701,-147.6286315918),137299,633)
	local params = packet_utils21.get_object_data( obj )
	params.custom_data = "[logic]\ncfg = scripts\\bth\\bad_boy_script.ltx"
	params.story_id = 3001
	packet_utils21.set_object_data( obj, params )
end

  18:46:20  4 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Thanks but it doesnt works

After i spawn the npc and then i try to activate a new tasks, with this npc as target the game crash.

And the log file tells that the story id not exist.


---QUOTATION---
! [LUA][ERROR] ERROR: Target for storyline task doesnt exist. Story id [3001]

FATAL ERROR

[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\priquel\sources\engine\xrServerEntities\script_engine.cpp
[error]Line : 180
[error]Description : <no expression>
[error]Arguments : LUA error: ....t.a.l.k.e.r. - clear sky\gamedata\scripts\_g.script:975: bad argument #2 to 'format' (string expected, got nil)


stack trace:
---END QUOTATION---

  19:00:12  4 November 2014
profilee-mailreply Message URLTo the Top
Decane
Senior Resident
 

 
On forum: 04/04/2007
Messages: 1706
You probably need to register the story ID in configs\game_story_ids.ltx.
  19:24:13  4 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
I have already register the sory id

3001 = "esc_bad_boy"
  20:34:55  4 November 2014
profilee-mailreply Message URLTo the Top
Decane
Senior Resident
 

 
On forum: 04/04/2007
 

Message edited by:
Decane
11/04/2014 20:37:00
Messages: 1706
Your error gets invoked by task_objects.script iff _G.id_by_sid(3001) evaluates to nil. There are three possible ways this could come about, but in your case the only credible candidate seems to be that alife():story_object(3001) is nil. This happens when the game does not recognize that your spawned NPC has the relevant story ID. Maybe try setting the story ID in a different way, e.g.:
function spawn_npc()
	local sim = alife()
	local position = vector():set(-120.48091125488, -9.0397319793701, -147.6286315918)
	local obj = sim:create("esc_bad_boy", position, 137299, 633)
	sim:object(obj.id).m_story_id = 3001
end

I have no idea if the above is a valid way of doing it or even if it differs from the way it's done in packet_utils, but it may be worth a try.

EDIT: Formatting.
  18:15:05  5 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Thanks for this, but it happens the same crash like before
  17:13:34  18 November 2014
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
I want to spawn a NPC only when it is night.
I create a dialog and add this script function to the dialog.


---QUOTATION---
function spawn_pripyat_informant()
if level.get_time_hours() > 23 then
create("pri_informant",-109.68873596191,0.49251154065132,-257.56219482422,82111,2069)
end
end
---END QUOTATION---



But the npc doesn`t spawn at night

how i can make the script so that the npc spawn when it is night ?
 
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.