Problem with the Critter_inven_obj2 function.

Mulligun

Still Mildly Glowing
Having the following mouse click handle:
Code:
procedure my_mouse_click begin
   variable event := get_sfall_arg_at(0);
   variable button := get_sfall_arg_at(1);

   if event == 1 then begin
      if button == 1 then begin
         variable ttt := get_weapon_ammo_pid(dude_obj);
       
         variable leftHand   := obj_pid(critter_inven_obj(dude_obj, INVEN_TYPE_LEFT_HAND));
         variable rightHand  := obj_pid(critter_inven_obj(dude_obj, INVEN_TYPE_RIGHT_HAND));
         variable msg := string_format("1 rightHand: %d, leftHand: %d", rightHand, leftHand);

         display_msg(msg);

         leftHand   := obj_pid(critter_inven_obj2(dude_obj, INVEN_TYPE_LEFT_HAND));
         rightHand  := obj_pid(critter_inven_obj2(dude_obj, INVEN_TYPE_RIGHT_HAND));
         msg := string_format("2 rightHand: %d, leftHand: %d", rightHand, leftHand);

         display_msg(msg);
      end
   end
end

changing the active player item (by pressing B key) the pid of the player holding weapon doesn't change - it reports the same pid for left and right hand regardless of swapping hands by pressing the B key.
 
Hm, I think I misread the code.
Post your whole script.
Also, for inspiration, take a look at ammobox code.
Code:
procedure my_mouse_click begin
   variable event := get_sfall_arg_at(0);
   variable button := get_sfall_arg_at(1);

   if event == 1 then begin
      if button == 1 then begin
         variable ttt := get_weapon_ammo_pid(dude_obj);

         variable leftHand   := obj_pid(critter_inven_obj(dude_obj, INVEN_TYPE_LEFT_HAND));
         variable rightHand  := obj_pid(critter_inven_obj(dude_obj, INVEN_TYPE_RIGHT_HAND));
         variable msg := string_format("HOOK_MOUSECLICK 1 rightHand: %d, leftHand: %d", rightHand, leftHand);

         display_msg(msg);

         leftHand   := obj_pid(critter_inven_obj2(dude_obj, INVEN_TYPE_LEFT_HAND));
         rightHand  := obj_pid(critter_inven_obj2(dude_obj, INVEN_TYPE_RIGHT_HAND));
         msg := string_format("HOOK_MOUSECLICK 2 rightHand: %d, leftHand: %d", rightHand, leftHand);

         display_msg(msg);
      end
   end
end
...
procedure start begin
   variable who, cur_dmg_thresh, cur_dmg_resist, color, msg, m, obj;

   if(game_loaded) then begin
      set_global_script_repeat(1);
      register_hook_proc(HOOK_MOUSECLICK, my_mouse_click);

   end

end
 
Errm... you don't switch items in inventory. You change active hand. Item positions are the same.
 
Back
Top