Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CTreasure:use(npc)
- printf("TREASURE USE")
- local se_obj = alife():object(npc:id())
- if se_obj.treasure_processed == true then
- return
- end
- se_obj.treasure_processed = true
- npc_rank_name_for_tr = ranks.get_obj_rank_name(npc)
- --' Íóæíî ðàíäîìíî âûáðàòü îäèí èç òàéíèêîâ.
- local avail = {}
- local tr_sum = 0
- for k,v in pairs(self.treasure_info) do
- if v.done == false then
- local treasure_prob = xr_logic.pick_section_from_condlist(db.actor, npc, v.condlist)
- if treasure_prob == "" or treasure_prob == nil then
- treasure_prob = 0
- end
- if tonumber(treasure_prob) >= 0 and
- v.community[npc:character_community()] == true and
- v.active == false
- then
- if tonumber(treasure_prob) == 100 then
- self:give_treasure(k)
- else
- table.insert(avail, {k = k, prob = treasure_prob})
- tr_sum = tr_sum + treasure_prob
- end
- end
- end
- end
- if tr_sum == 0 or
- amk.real_rand(100) < opt.tr_v -- 65 (à äëÿ òåñòà è âñå 10)
- then
- return
- end
- local tr_w = amk.real_rand(tr_sum)
- for k,v in pairs(avail) do
- tr_w = tr_w - v.prob
- if tr_w <= 0 then
- self:give_treasure(v.k)
- break
- end
- end
- if (npc and db.actor) then
- if has_alife_info("ui_car_body") then
- npc_community_loot = npc:character_community()
- npc_rank_loot = npc:rank()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement