ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Check if a stalker is a commander in xr_conditions?

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  19:19:40  13 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070
Check if a stalker is a commander in xr_conditions?

Hi, guys.

I am expanding the number of patrolers in stalker. By default the game supports only 7 npcs (1 commander + 6 patrolers). Now i have 14 patrolers + 1 commander. I also added a new formation type. For the modding community this update is eventually obsolete, because nobody wants to work with the AI. But guess what... i love to work with the AI. It's possible to create amazing things with the stalker logic files. However i have huge limitations with scripts.

So in this case, i have the new patrol with 15 npcs (one of them is always assigned by the game as a commander). All new npcs have specific logic. But i need to connect a new 'xr_conditions' function to return true if the stalker ID is used as a commander in xr_patrol.script... OR return false if he is patroling but not commanding.


The idea for the logic is simple:


---QUOTATION---


path_walk = esc_nimble_assault_walk
path_look = esc_nimble_look
formation = very_close;new type here
move_type = raid
def_state_moving1 = assault
def_state_moving2 = assault
def_state_moving3 = assault
def_state_standing = hide
combat_ignore_cond = {-esc_bandits_actor_enemy =fighting_actor}
danger = ignore_corpses
meet = default_meet
on_info = {=is_commander} %=aes_kill_actor%
on_info2 = {!is_commander} %=kill%


---END QUOTATION---



So for quick testing the idea is... the npc logic kills actor if the npc is commanding... or the npc dies if he is not a commander.

xr_conditions.script:


---QUOTATION---


function is_commander(actor, npc)
--connection to xr_patrol.script here... somehow

--NEW STUFF HERE...

return true
else

return false

end


---END QUOTATION---




in xr_patrol:


---QUOTATION---


Somewhere in this script (in some commander support)

if npc_list id is commander then
return xr_conditions.is_commander ()
end
else

return not xr_conditions.is_commander ()


---END QUOTATION---



For me this is impossible... but for Lijenstina, Barin, Natvac, Vintar, gannebamm (among others)... this is easy for sure.

So anyone knows how to solve this? I give credits on a youtube video, i promisse.

That's it guys, thanks in advance.
  23:34:16  13 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
You can try like this in xr_conditions but not 100% sure
function is_commander(actor, npc)
    if npc and npc:alive() then
        local com = xr_patrol.PatrolManager:get_commander(npc)
        if com then
            return npc:id() == com:id()
        end
    end
    return false
end

  01:30:22  14 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
You can try like this in xr_conditions but not 100% sure
function is_commander(actor, npc)
    if npc and npc:alive() then
        local com = xr_patrol.PatrolManager:get_commander(npc)
        if com then
            return npc:id() == com:id()
        end
    end
    return false
end


---END QUOTATION---



Ok, Vintar. Thanks for your help, but when my commander is using the function... ctd.


---QUOTATION---


FATAL ERROR

[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\stalker\patch_1_0004\xr_3da\xrGame\script_engine.cpp
[error]Line : 73
[error]Description : <no expression>
[error]Arguments : LUA error: ...hadow of chernobyl\gamedata\scripts\xr_patrol.script:365: attempt to index field 'npc_list' (a nil value)


stack trace:


---END QUOTATION---



My updated xr_patrol is bigger than the default script... so my line 365 is here (I added a comment in the fuction so check it out please):


---QUOTATION---


function PatrolManager:get_commander (npc)
if npc == nil then
abort ("Invalid NPC on call PatrolManager:get_npc_command in PatrolManager[%s]", self.path_name)
end

--çàêåøèðóåì àéäèøíèê íåïèñÿ
local npc_id = npc:id ()
--ïðîâåðêà íåïèñÿ íà ïðèñóòñâèå â ñïèñêå
if self.npc_list[npc:id ()] == nil then --HERE IS LINE 365
abort ("NPC with name %s can't present in PatrolManager[%s]", npc:name (), self.path_name)
end
--ïðîâåðêà, ÷òîáû êîìàíäèð íå âçäóìàë çàäàâàòü ãëóïûõ âîïðîñîâ
if npc:id () == self.commander_id then
abort ("Patrol commander called function PatrolManager:get_npc_command in PatrolManager[%s]", self.path_name)
end
--ïîëó÷èì äàííûå êîìàíäèðà
local commander = self.npc_list[self.commander_id].soldier
if commander == nil then
abort ("Patrol commander not present in PatrolManager[%s]", self.path_name)
end
return commander
end



---END QUOTATION---



I think you are very close, Vintar. But for now... not working.

You think it's easy to fix?

Thanks again, Vintar.
  12:12:24  14 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
I saw an even easier function in xr_patrol that may work :
function is_commander(actor, npc)
    if npc and npc:alive() then
        return xr_patrol.PatrolManager:is_commander(npc:id())
    end
    return false
end

  16:04:00  14 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
I saw an even easier function in xr_patrol that may work :
function is_commander(actor, npc)
    if npc and npc:alive() then
        return xr_patrol.PatrolManager:is_commander(npc:id())
    end
    return false
end


---END QUOTATION---



Sorry Vintar, but the new function in 'xr_conditions' doesn't produce anything. Well, but it doesn't crash... and no errors in console.
  07:05:55  15 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349

---QUOTATION---
I saw an even easier function in xr_patrol that may work :
function is_commander(actor, npc)
    if npc and npc:alive() then
        return xr_patrol.PatrolManager:is_commander(npc:id())
    end
    return false
end



Sorry Vintar, but the new function in 'xr_conditions' doesn't produce anything. Well, but it doesn't crash... and no errors in console.
---END QUOTATION---



Not sure what you mean "doesnt produce anything".
If your guy is not commander then it wont do anything (return false)
  13:47:00  15 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
I saw an even easier function in xr_patrol that may work :
function is_commander(actor, npc)
    if npc and npc:alive() then
        return xr_patrol.PatrolManager:is_commander(npc:id())
    end
    return false
end



Sorry Vintar, but the new function in 'xr_conditions' doesn't produce anything. Well, but it doesn't crash... and no errors in console.

Not sure what you mean "doesnt produce anything".
If your guy is not commander then it wont do anything (return false)
---END QUOTATION---



Vintar, the npc was a commander... because he was alone. If a patroler is patroling alone... he is always a commander.
  12:10:23  16 February 2013
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
Messages: 2230
I'm interested what sort of formations you've made. Can I see them?
  17:04:44  16 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
 

Message edited by:
insanelazarez
02/16/2013 17:13:12
Messages: 1070

---QUOTATION---
I'm interested what sort of formations you've made. Can I see them?
---END QUOTATION---




Alundaio, it's a variation of 'line' formation.

Read the commented sections in the script itself

Name of formation: 'very_close'

Full support for 14 Patrolers + 1 Commander

Link:

[link]http://www.filefactory.com/file/282rakcswwip/xr_patrol.script[/link]

But you need to create the spawns and logic for testing (the logic module must be 'patrol')

But you already know that...

Have fun.

Btw, if you are still modding CoP... i think you can use the same aproach... but i don't have the CoP unpacked files now. I think Patrol Cop scheme, as the requirement of the 7 npc limit too...
  18:02:41  16 February 2013
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
 

Message edited by:
Alundaio
02/16/2013 18:06:43
Messages: 2230
xr_reach_task uses formations for alife squads. It's basically just an altered xr_patrol. Just curious to see what it would look like to see an army of NPCs walking around, lol. Thanks.
 
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-2020 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.