ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
My Condition not working

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  16:58:20  16 April 2014
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
 

Message edited by:
insanelazarez
04/16/2014 17:04:09
Messages: 1070
My Condition not working

Hi guys, i have two functions here. This first works ok, but the second... is useless. Btw, both functions are execute in a new npc's logic. And i need to check 'name' not the SID...


Logic for function 'npc_see_wolf_name'


---QUOTATION---

on_info = {=npc_see_wolf_name} %=aes_kill_actor =kill%

---END QUOTATION---



The function 'npc_see_wolf_name' in xr_conditions:


---QUOTATION---

function npc_see_wolf_name(actor, npc)
local object_seen = level.object_by_id ("esc_wolf"
return npc:see(object_seen)

end

---END QUOTATION---



Better in pastebin:

[link]

http://pastebin.com/4qELsKrp

[/link]

See? It's ok... when the new guy sees wolf... script kills me, and he dies.


Now i need the same npc to check if he sees 'esc_wolf' name again, but i want the string 'esc_wolf' in the logic itself... not in the function.

Logic for function 'npc_see_name'


---QUOTATION---

on_info = {=npc_see_name(esc_wolf)} %=aes_kill_actor =kill%

---END QUOTATION---



And the non-working function 'npc_see_name'

Btw, i tried several possibilities... This is the lastest one:


---QUOTATION---


function npc_see_name(actor, npc, p)

if npc and p[1] then

local se_obj = alife() bject(p[1])
if se_obj then
local npc = level.object_by_id(se_obj.id)

if npc and npc:alive() then

return npc:see(p[1])
end
end
end

end


---END QUOTATION---



Pastebin here:

[link]

http://pastebin.com/FK8rL277

[/link]


So, Any Idea? Thanks In Advance.
  19:14:40  16 April 2014
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
 

Message edited by:
Alundaio
04/16/2014 21:57:17
Messages: 2230
level.object_by_id only takes number values and is not to be confused with story ids. I'm not sure how that first function is working.

It is not possible to directly grab a game_object by it's name; That is why story ids exist. You need to assign wolf a story id. You may be confused with how story ids are like in CS/CoP, where they are strings and not numbers; Story IDs in SoC are number values and they need to be pre-defined in game_story_ids.ltx. In CoP there is a condition function that is check_npc_name, but it doesn't check the object name, it checks the story object name.

You will probably need to give wolf a story id in gamedata\config\ game_story_ids.ltx if he doesn't have one already. Then you can find wolf's server object with alife():story_object(story_id).


function npc_see_story_object(actor,npc,p)
	if not (p and p[1]) then 
		return false
	end 
	
	local se_obj = alife():story_object(tonumber(p[1]))
	if not (se_obj) then 
		return false 
	end

	local obj = level.object_by_id(se_obj.id)
	return obj and obj:alive() and npc:see(obj)
end

  20:30:14  16 April 2014
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
 

Message edited by:
insanelazarez
04/16/2014 20:33:40
Messages: 1070

---QUOTATION---
level.object_by_id only takes number values and is not to be confused with story ids. I'm not sure how that first function is working.

It is not possible to directly grab an object by it's name; That is why story ids exist. You need to assign wolf a story id. You may be confused with how story ids are like in CS/CoP, where they are strings and not numbers; Story IDs in SoC are number values and they need to be pre-defined in game_story_ids.ltx. In CoP there is a condition function that is check_npc_name, but it doesn't check the object name, it checks the story object name.

You will probably need to give wolf a story id in gamedata\config\ game_story_ids.ltx if he doesn't have one already. Then you can find wolf's server object with alife():story_object(story_id).


function npc_see_story_object(actor,npc,p)
	if not (p and p[1]) then 
		return false
	end 
	
	local se_obj = alife():story_object(tonumber(p[1]))
	if not (se_obj) then 
		return false 
	end

	local obj = level.object_by_id(se_obj.id)
	return obj and obj:alive() and npc:see(obj)
end


---END QUOTATION---




Alundaio, 'level.object_by_id' is calling a name. 'level.object_by_sid' is calling a number. In short the first function is correct.


Name can be used as a effect too. Example:


This Function was fixed by Vintar, btw...

logic:

on_timer = 10000 | nil %=kill_name(esc_wolf)%


---QUOTATION---


function kill_name(actor, npc, p)
if p[1] then
local se_obj = alife() bject(p[1])
if se_obj then
local obj = level.object_by_id(se_obj.id)
if obj and obj:alive() then
obj:kill(obj)
end
end
end
end



---END QUOTATION---




Pastebin:

[link]

http://pastebin.com/2bPsVX7w

[/link]

Trust me, Alundaio this works ok. Your function seems ok, but assuming it works, it needs a story number... that's exacty what i want to avoid.

Thanks Alundaio, but sooner or later i will fix the function. Eventually not today. I mean, i just need to make sure the function calls 'P' instead of 'esc_wolf'. It has to work...
  21:29:31  16 April 2014
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
 

Message edited by:
Vintar
04/16/2014 21:34:40
Messages: 6349
just had a quick look at your function, seems like you are checking if wolf sees wolf, and there aint no mirrors in stalker

return npc:see(p[1])



Better try :
return actor:see(p[1])



try this function :
function npc_see_name(actor, npc, p)
	if p[1] then
		local se_obj = alife():object(p[1])
 		if se_obj then
 			local obj = level.object_by_id(se_obj.id)
 			if obj and obj:alive() then
 				return npc:see(obj)
 			end
 		end 
 	end
end

  21:29:55  16 April 2014
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
 

Message edited by:
Alundaio
04/17/2014 8:31:01
Messages: 2230

---QUOTATION---
Alundaio, 'level.object_by_id' is calling a name. 'level.object_by_sid' is calling a number. In short the first function is correct.
---END QUOTATION---



I was referring directly to this:

---QUOTATION---
function npc_see_wolf_name(actor, npc)
local object_seen = level.object_by_id ( "esc_wolf" )
return npc:see(object_seen)

end
---END QUOTATION---



level.object_by_id does not take string values. The example you are showing that Vintar 'fixed' is not using level.object_by_id. It's using alife's object method which takes either name or id. I suggest not using it though, it's slow; that's why GSC doesn't use it. Using story ids is much faster.


Here is TKGP saying the same thing.: https://www.gsc-game.com/main.php?t=community&s=forums&s_game_type=xr&thm_page=202&thm_id=22331&sec_id=16&page=1#379233


EDIT:

If he all he wanted to do was to have wolf see actor then all he needs to do is this:

function see_actor(actor, npc)
	return npc:alive() and npc:see(actor)
end



If this is running from wolf's logic than he is npc.
  22:21:57  16 April 2014
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070
Well Vintar Saves The Day Again

Hey Vintar, Your option works ok...


Now with both fixes you made (condition SEE NAME, and effect KILL NAME)... like this:

on_info = {=npc_see_name(esc_wolf)} %=kill_name(esc_wolf)%


So... he just needs to see wolf and wolf dies.
 
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-2022 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.