ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Permabody detection?

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  04:09:21  26 March 2021
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
Messages: 2832
Permabody detection?

1. Where can I find the setting that decides that a corpse is permanent?
2. Is it possible to check it from Lua code?
  08:19:30  27 March 2021
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
You can check for story_id < 10000, and for all.spawn assignments of upd:health = 0 to NPCs. The latter isn't supported by Lua; I use a table with a few names obtained by searching the alife_*.ltx files extracted from the all.spawn.

Example, in a file called zz.script:

permabodies = { -- these are bodies that are dead on the level to start
    esc_stalker,
    gar_stalker_0005,
    agr_stalker_0004,
    bar_stalker,
    yantar_dead_scientist_01,
    mil_stalker_0001,
    rad_stalker_dead
}

-- I've only used this for local objects
function is_permabody(npc)
    return zz.permabodies[npc:name()] or npc:story_id() < 10000
end

  21:24:05  3 April 2021
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
Messages: 2832

---QUOTATION---
You can check for story_id < 10000, and for all.spawn assignments of upd:health = 0 to NPCs. The latter isn't supported by Lua; I use a table with a few names obtained by searching the alife_*.ltx files extracted from the all.spawn.

Example, in a file called zz.script:

permabodies = { -- these are bodies that are dead on the level to start
    esc_stalker,
    gar_stalker_0005,
    agr_stalker_0004,
    bar_stalker,
    yantar_dead_scientist_01,
    mil_stalker_0001,
    rad_stalker_dead
}

-- I've only used this for local objects
function is_permabody(npc)
    return zz.permabodies[npc:name()] or npc:story_id() < 10000
end


---END QUOTATION---


Cool. Does this mean that they need to be online in order to be checked?
  05:29:47  4 April 2021
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
> Does this mean that they need to be online in order to be checked?

No, although that code as written won't work with offline NPCs. (I've not needed to know about permabodies on other maps; I'm just wanting to know if this body is a permabody when searched and when exiting from search.)

NPCs with story_ids assigned are generally alive in the game initially. Therefore they are not yet permabodies, and marking them for making a map of permabodies might not work in some cases if they can move around. And there are some story_id NPCs that are switched offline at some point in their existence (example: Mole) and therefore are useless as permabodies for storage.

With that said, you can simply qualify the NPC object as online or offline by checking the type of npc.story_id. If a function, then the NPC is online and you can obtain the story_id with the function as in the example above. Otherwise, just use the value of npc.story_id:

function is_permabody(npc)
    -- some cheap protection; if used, I recommend a log message
    if not npc or not (type(npc) == "userdata") then return false end
    if zz.permabodies[npc:name()] then return true end
    if type(npc.story_id) == "function" then
        return npc:story_id() < 10000
    else
        return npc.story_id < 10000
    end
end


You might also want to determine if the NPC is alive, if that is important to your application.

If you are not intending your work for existing games, something that might be of use is the ability to keep storage containers online on the current level by setting a flag in their all.spawn entries*. This eliminates the lag they cause when you come within switch_distance (or within about 120-125 meters with the default switch_distance of 150) of them. They are treated like permabodies in this case: their contents are processed only once during the synchronizing phase when starting a game session.

The only advantages of permabodies remaining would be their portability and their relative nearness to level changers compared with most stashes.

And if anyone is wondering, NPCs with unassigned story_id attributes have a default of -1 (signed integer), which the Lua interpreter understands as the largest unsigned int (4294967295) in the comparison.


---QUOTATION---
*See the ZRP thread, page 370:
https://www.gsc-game.com/main.php?t=community&s=forums&s_game_type=xr&thm_id=11786&page=370&sec_id=16&lang=en
---END QUOTATION---

  15:58:33  4 April 2021
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
 

Message edited by:
notanumber
04/04/2021 21:42:58
Messages: 2832
I'm more interested in locating all NPCs (dead or alive) that make permanent corpses.
So, if story_id < 10000 is a reliable method then a function checking all objects with story_id between 0 and 9999 if they are stalkers should work as well?

Something like this:
local function check_conditions(obj)
    local sp = obj:spawn_ini()
    if sp and sp:section_exist("spawner") then
        local condlist = utils.cfg_get_string(sp, "spawner", "cond", nil, false, "")
        if condlist then
            local cond = xr_logic.parse_condlist(nil, "spawner", "cond", condlist)
            return xr_logic.pick_section_from_condlist(db.actor, nil, cond) ~= nil
        end
    end
    return true
end

local function locate_permabodies()
    for story_id = 0, 9999, 1 do
        local obj = alife():story_object(story_id)
        if obj and is_stalker(obj) and check_conditions(obj) then
            level.map_add_object_spot(obj.id, "red_location", obj:name())
        end
    end
end


I believe that Mole is the only one to be switched offline at some point?
  10:21:22  5 April 2021
profilee-mailreply Message URLTo the Top
Tejas Stalker
Veteran of the Psychic Wars
(Resident)

 

 
On forum: 05/12/2007
Messages: 29162
Permabody detection?

I've always wondered why Mole is one of the few single named important NPCs that is not a permabody. As he is destined to keep running back and forth from the Agroprom complex and the opening among the trees to the underground, he is destined to die rather quickly.

The oncoming Military will get him ( or later Military or Bandit respawns ) which GSC uses to encourage the Player to go underground. I never do that, choosing to stay and take out all the helicopter delivered soldiers. There's lots of good loot. Plus since Mole's not a permabody, you've got to grab the unique Walker 9x18 from him before it disappears with him.

TS
  16:11:20  5 April 2021
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
Messages: 2832
Yo TS!

Rather than going to the underground I just run off far enough to trigger new behavior when I return and than spectate while the soldiers put some holes in him. Yeah, his gun is both collectible and useful, depending on the state that you find it in.

Anyway, has anyone encountered other NPCs that vanish into thin air like Mole?
  05:31:13  6 April 2021
profilee-mailreply Message URLTo the Top
Tejas Stalker
Veteran of the Psychic Wars
(Resident)

 

 
On forum: 05/12/2007
Messages: 29162
Permabody detection?

This Duty collaborator's body disappeared later after I killed him. ( No Mods )
https://i.imgur.com/s9SJ4rq.jpg

TS
  08:53:58  12 April 2021
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
> I believe that Mole is the only one to be switched offline at some point?

Other temporary NPCs with story_ids: Fox (in vanilla), one of the mercs in Cordon that attack Fanatic and company, Doc (even if you join Freedom in vanilla, TS), WT Kruglov, Wolfhound, rostok_stalker_0004 (profile=bar_Killer_sniper_on_enter, one of the four on the second floor of the building tunnel), and four of Wolfhound's mercs (in vanilla).

And I'm not sure about the military guys on the south side of the CNPP, the ones wearing the dark Skat-9M armor. They have story_ids but I don't yet know if they stick around. This is normally moot in vanilla.

The vanilla enemies that can switch offline in vanilla are kept online in ZRP in new games, because they have a tendency to join gulags while offline, thus making certain side tasks impossible to complete without script-based methods to force them online. I also keep Fox online but this choice might be re-examined in the future as it was a personal choice based on 1) existing support for his presence, and 2) his guaranteed death sentence in vanilla (due to the dogs continually respawning right inside the ruins of that house) was commuted in ZRP. Those dogs also tended to kill Guide before you could talk to him.

Poker AKA val_kocherga (which notanumber might recall in another life as a problematic offline member of a task target gulag; see the ZRP thread's page 113) does not have a story_id.
  03:06:59  21 April 2021
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
Messages: 2832
Thanks a lot, NatVac!
 
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-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.