Item repair based on part's condition?

Posts: 6
Joined: 17 Jan 2016, 18:20

Item repair based on part's condition?

Postby Axebeardbeardaxe » 16 Feb 2017, 14:58

I'm looking at mod for Call of Misery that lets you disassemble weapons into spare parts. I understand how the "if item is a weapon, then give a spare part" code works, but what I can't figure out is how to get the condition of the weapon in question. How can I get the condition of the weapon and have the game give X amount of spare parts based on it?

Ideally, weapons would give 0-4 spare parts based on their condition.
I looked at the ui_itm_repair scripts in CoC and CoM and they are 95% the same, so I was hoping you'd be able to help me out here. Here's the relevant block of code: (I cut out the huge list of weapons between "wpn_bm16_full" and "wpn_ppsh41")

Code: Select all

index = self.list_box_parts:GetSelectedIndex()
      if (index ~= -1) then
         item = self.list_box_parts:GetItemByIndex(index)
         local se_parts = item and item.item_id and alife():object(item.item_id)
         if (se_parts) then
            local sec = se_parts:section_name()
            bonus = system_ini():r_float_ex(sec,"repair_part_bonus") or self.part_bonus
            -- swiss knife
            -- crowbar
            -- hammer
            if(se_parts)and(se_parts:section_name()=="wpn_pm") or se_parts:section_name()=="wpn_bm16" or       se_parts:section_name()=="wpn_bm16_full"  ...
             se_parts:section_name()=="wpn_ppsh41" then

User avatar
Posts: 1266
Joined: 26 May 2012, 22:26

Re: Item repair based on part's condition?

Postby Alundaio » 17 Feb 2017, 02:19

That is because 90% of CoM and Misery scripts are my code, with edits to them.

Code: Select all

local cond = 1
local part = item and item.item_id and level.object_by_id(item.item_id)
if (part) then
   cond = part:condition() -- Will be a number between 0 and 1

probably want to put that after if (se_parts) then
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

Return to “General Discussion”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest