ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Drop condition by specific community.

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  19:45:06  9 March 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133
Drop condition by specific community.

I would assume this is possible, because in some mods I've played, zombified stalkers would drop weapons in a significantly worse condition than other NPCs, but out of curiosity, what particular files or sections would have to be edited/created in order to alter drop condition for a specific faction?
  20:22:34  9 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
Messages: 240
when you will edded that a special faction lose anything you must be go in the folder gamedat/config/misc/ in the data death_items_by_communities.ltx

in this can you add all your weapons or object a special faction.
  03:40:06  10 March 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
when you will edded that a special faction lose anything you must be go in the folder gamedat/config/misc/ in the data death_items_by_communities.ltx

in this can you add all your weapons or object a special faction.
---END QUOTATION---



I see... I don't know why I didn't check that one earlier, it seemed like it was just the file I should edit. I have a bad habit of asking fairly obvious questions here that I can fix myself with a little attention to detail.
  03:57:52  10 March 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4286
Also check death_manager.script in those mods and compare it with the vanilla version. The vanilla version just sets the weapon condition in a random range without regard to the faction.
  04:57:33  19 January 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
Also check death_manager.script in those mods and compare it with the vanilla version. The vanilla version just sets the weapon condition in a random range without regard to the faction.
---END QUOTATION---



A question regarding death_manager.script. I took a look at it and noticed this portion of it:


function init_drop_settings()
        local community_list = { "stalker", "dolg", "freedom", "bandit", "military", "zombied", "ecolog", "killer", "monolith", "arena_enemy", "actor_dolg" }

    for k,v in pairs(community_list) do
        --' Необходимо заполнить таблицу
        item_by_community[v] = {}
        if death_ini:section_exist(v) then
                    local n = death_ini:line_count(v)
                    local id, value = "", ""
                    for i=0,n-1 do
                            result, id, value        = death_ini:r_line(v,i,"","")
                --item_by_community[v][id] = 1000 * tonumber(value)
                                if tonumber(value) >= 0.4 then value = 0.2 end
                                item_by_community[v][id] = 1000 * tonumber(value)
                    end
        end
    end



Now I know that it mentions community, but this isn't really all that relevant to me anymore, since I'm working on random weapon spawns for NPCs now, each with specifically defined conditions.

Rather, my current question pertains more to this part of the script:


    local item_id = item:id()
    local item_in_slot = npc:item_in_slot(1)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
                --' Тут надо уменьшить кондишн оружия
                item:set_condition((math.random(15)+75)/100)
        return true
    end
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
                --' Тут надо уменьшить кондишн оружия
                item:set_condition((math.random(15)+75)/100)
        return true
    end



My particular question here relates to "item:set_condition((math.random(15)+75)/100)"

Does this in any way relate to a max condition, or could I put a cap value on the maximum condition a weapon could be, say 50% condition, or hell, eliminate the math.random variable entirely from the equation?

Since I already have conditions defined in most weapons, I am seeking to either set the randomization of drops to either a mean condition, or eliminate it.
  01:06:20  9 February 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4286
>> item:set_condition((math.random(15)+75)/100)

item:set_condition(value) will set the item's condition between 0 and 1.0 according to value.

math.random(15) generates a random integer between 1 and 15 inclusive. That is added to 75 to make the value range from 76 to 90. This is then divided by 100 to give you a condition value between 0.76 and 0.9.

You could set that 75 value to be a variable based on faction. Here is a crude example:
__________
local base_condition = 75

if npc:character_community() == "dolg" or npc:character_community() == "miltary" then
    base_condition = 82
end
item:set_condition((math.random(15)+base_condition)/100)

¯¯¯¯¯¯¯¯¯¯
You could conceivably use the community_list stuff (hoist it out of the init() function) to create a table of values, perhaps using base_condition set to, say, 50 and making the different factions have different deltas that you add to the base. Just make sure the total is less than or equal to 100 before the division by 100.
  21:36:54  14 February 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
 

Message edited by:
FatalFunnel
02/14/2013 21:48:23
Messages: 133

---QUOTATION---
math.random(15) generates a random integer between 1 and 15 inclusive. That is added to 75 to make the value range from 76 to 90. This is then divided by 100 to give you a condition value between 0.76 and 0.9.
---END QUOTATION---



I see, so the first number is a randomized integer added to the second number, which is the base value, which is then divided by 100.

So If I changed the middle number to say 40, it would give it a possible condition range of 41-55%, correct?


                item:set_condition((math.random(15)+40)/100)






---QUOTATION---
You could set that 75 value to be a variable based on faction. Here is a crude example:
__________
local base_condition = 75

if npc:character_community() == "dolg" or npc:character_community() == "miltary" then
    base_condition = 82
end
item:set_condition((math.random(15)+base_condition)/100)

¯¯¯¯¯¯¯¯¯¯
You could conceivably use the community_list stuff (hoist it out of the init() function) to create a table of values, perhaps using base_condition set to, say, 50 and making the different factions have different deltas that you add to the base. Just make sure the total is less than or equal to 100 before the division by 100.
---END QUOTATION---



So something like this?


    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
                --' Тут надо уменьшить кондишн оружия
                item:set_condition((math.random(15)+40)/100)
        return true
    end
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
            local base_condition = 40
            if npc:character_community() == "killer" then
               base_condition = 75
            elseif npc:character_community() == "dolg" then
               base_condition = 70
            elseif npc:character_community() == "ecolog" then
               base_condition = 68
            elseif npc:character_community() == "freedom" then
               base_condition = 65
            elseif npc:character_community() == "military" then
               base_condition = 60
            elseif npc:character_community() == "stalker" then
               base_condition = 45
            elseif npc:character_community() == "bandit" then
               base_condition = 35
            elseif npc:character_community() == "monolit" then
               base_condition = 25
            elseif npc:character_community() == "zombied" then
               base_condition = 15
            end
                item:set_condition((math.random(15)+40)/100)
        return true
    end



It's somewhat crude, but you did mention something about community_list, can you elaborate?

Ah, I see, it's in the same script file.
  05:32:30  17 February 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4286
I take it the first part applies to slot 1 with something like the following before it:

item_in_slot = npc:item_in_slot(1)

Yes, that weapon will always be set to a value between 41 and 55%.

The second part is fine, except that you have to use what you have set. Change the "40" to "base_condition" (without quotes, of course) to get the equation to use the faction-based setting.

I'd also simplify it just a bit to save a little processing time:
__________
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        local base_condition = 40
        local npc_community = npc:character_community()
        if npc_community == "killer" then
           base_condition = 75
        elseif npc_community == "dolg" then
           base_condition = 70
        elseif npc_community == "ecolog" then
           base_condition = 68
        elseif npc_community == "freedom" then
           base_condition = 65
        elseif npc_community == "military" then
           base_condition = 60
        elseif npc_community == "stalker" then
           base_condition = 45
        elseif npc_community == "bandit" then
           base_condition = 35
        elseif npc_community == "monolith" then
           base_condition = 25
        elseif npc_community == "zombied" then
           base_condition = 15
        end
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end

¯¯¯¯¯¯¯¯¯¯
You could pull that base_condition assignment out of the test so that you could use it for both weapons if you wanted (not necessary):
__________
    local base_condition = 40
    local npc_community = npc:character_community()
    if npc_community == "killer" then
       base_condition = 75
    elseif npc_community == "dolg" then
       base_condition = 70
    elseif npc_community == "ecolog" then
       base_condition = 68
    elseif npc_community == "freedom" then
       base_condition = 65
    elseif npc_community == "military" then
       base_condition = 60
    elseif npc_community == "stalker" then
       base_condition = 45
    elseif npc_community == "bandit" then
       base_condition = 35
    elseif npc_community == "monolith" then
       base_condition = 25
    elseif npc_community == "zombied" then
       base_condition = 15
    end

    local item_id = item:id()
    local item_in_slot = npc:item_in_slot(1)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end

¯¯¯¯¯¯¯¯¯¯
Note the change to "monolit"; vanilla uses "monolith" for the community. Keep "monolit" if that is what your base mod uses.

You can also adjust each slot weapon even more by varying the math.random() argument or add/subtract some small offset value to base_condition. Just make sure that the values don't exceed the logical limits so that the total is between 0.0 and 1.0.
  20:09:38  17 February 2013
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133

---QUOTATION---
I take it the first part applies to slot 1 with something like the following before it:

item_in_slot = npc:item_in_slot(1)

Yes, that weapon will always be set to a value between 41 and 55%.

The second part is fine, except that you have to use what you have set. Change the "40" to "base_condition" (without quotes, of course) to get the equation to use the faction-based setting.

I'd also simplify it just a bit to save a little processing time:
__________
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        local base_condition = 40
        local npc_community = npc:character_community()
        if npc_community == "killer" then
           base_condition = 75
        elseif npc_community == "dolg" then
           base_condition = 70
        elseif npc_community == "ecolog" then
           base_condition = 68
        elseif npc_community == "freedom" then
           base_condition = 65
        elseif npc_community == "military" then
           base_condition = 60
        elseif npc_community == "stalker" then
           base_condition = 45
        elseif npc_community == "bandit" then
           base_condition = 35
        elseif npc_community == "monolith" then
           base_condition = 25
        elseif npc_community == "zombied" then
           base_condition = 15
        end
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end

¯¯¯¯¯¯¯¯¯¯
You could pull that base_condition assignment out of the test so that you could use it for both weapons if you wanted (not necessary):
__________
    local base_condition = 40
    local npc_community = npc:character_community()
    if npc_community == "killer" then
       base_condition = 75
    elseif npc_community == "dolg" then
       base_condition = 70
    elseif npc_community == "ecolog" then
       base_condition = 68
    elseif npc_community == "freedom" then
       base_condition = 65
    elseif npc_community == "military" then
       base_condition = 60
    elseif npc_community == "stalker" then
       base_condition = 45
    elseif npc_community == "bandit" then
       base_condition = 35
    elseif npc_community == "monolith" then
       base_condition = 25
    elseif npc_community == "zombied" then
       base_condition = 15
    end

    local item_id = item:id()
    local item_in_slot = npc:item_in_slot(1)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end
    item_in_slot = npc:item_in_slot(2)
    if item_in_slot ~= nil and item_in_slot:id() == item_id then
        item:unload_magazine()
        item:set_condition((math.random(15)+base_condition)/100)
        return true
    end

¯¯¯¯¯¯¯¯¯¯
Note the change to "monolit"; vanilla uses "monolith" for the community. Keep "monolit" if that is what your base mod uses.

You can also adjust each slot weapon even more by varying the math.random() argument or add/subtract some small offset value to base_condition. Just make sure that the values don't exceed the logical limits so that the total is between 0.0 and 1.0.
---END QUOTATION---



I see, From my tests it appears to be working fine, I don't know about the community assignment yet, but I'll see the evidence when coming across military or duty corpses.

Thank you so much for your help, really appreciated.
 
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.