Page 1 of 1

methods to hook dead_body_search_wnd_closed event plus another q?

Posted: 23 Jun 2017, 06:38
by sLoPpYdOtBiGhOlE
Hi,

I'd like to catch the event when player exits a container inventory preferably without editing the vanilla scripts that ship with CoC..
I saw in actor_menu.script there is a function that fires when the player exits the container menu.

Code: Select all

function dead_body_search_wnd_closed()
   --printf("---:>DeadBodySearch closed")
   dead_body_searching = false
   bind_container.curBoxID = nil
end


So I added a SendScriptCallback("dead_body_search_wnd_closed") to the function.

Code: Select all

function dead_body_search_wnd_closed()
   --printf("---:>DeadBodySearch closed")
   dead_body_searching = false
   bind_container.curBoxID = nil
   SendScriptCallback("dead_body_search_wnd_closed")
end


I added dead_body_search_wnd_closed to axr_main.intercepts

I registered for the event in my own script and it works as expected.

Is there a method for me to hook dead_body_search_wnd_closed event without me editing the vanilla scripts that come with CoC?

Edit:
Another question...
How do I access an offline container inventory list from se_obj id?
For online inv_box I use something like:
eg:

Code: Select all

if (IsInvbox(nil,se_obj:clsid())) then
   if (se_obj.online) then
      local box = level.object_by_id(se_obj.id)
      if (box) then
         if not (box:is_inv_box_empty()) then
            local function show_me(inv_box,item)
               printf("iterate item %s", item)
            end
            box:iterate_inventory_box(show_me,box)
         end
      end
   else
      -- get offline box inventory list?
   end
end

This works fine for an online inv_box.
So how do I access the same info for an offline inv_box that is in a different level to the player?

Re: methods to hook dead_body_search_wnd_closed event plus another q?

Posted: 24 Jun 2017, 18:25
by Alundaio
Not possible to check inventory of offline objects directly. You have to check all objects parent id in a loop, like

Code: Select all

for id=1,65534 do
     local se_obj = alife():object(id)
     if (se_obj and se_obj.parent_id == YOUR_ID) then

     end
end


Is there a method for me to hook dead_body_search_wnd_closed event without me editing the vanilla scripts that come with CoC?
nope

Re: methods to hook dead_body_search_wnd_closed event plus another q?

Posted: 24 Jul 2017, 02:43
by sLoPpYdOtBiGhOlE
Thank you for taking the time to explain once again :)
I have another question(s), not quite related to the above.
So instead of posting a new thread I continue here...

Basically I've made an Unload All Weapons in inventory function.
But there are some basic things I'm unsure of.

How to tell if my loaded wpn_abakan is using ammo_5.45x39_fmj or ammo_5.45x39_ap?
Could be any weapon, just an example of what I'm asking.
I had no problem finding a count of ammo or the types of ammo the weapon can use.
But just didn't see an example of how to tell which type of ammo the weapon has loaded.