mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Add string_find metarule
- lib.inven.h: Updated remove_items_pid to return actually removed quantity
This commit is contained in:
@@ -51,13 +51,15 @@ procedure remove_items_pid(variable invenObj, variable itemPid, variable quantit
|
||||
variable begin
|
||||
item;
|
||||
toRemoveQty;
|
||||
actualQty;
|
||||
end
|
||||
if (not(invenObj)) then return;
|
||||
toRemoveQty := obj_is_carrying_obj_pid(invenObj, itemPid);
|
||||
if (quantity < toRemoveQty and quantity != -1) then begin
|
||||
toRemoveQty := quantity;
|
||||
actualQty := obj_is_carrying_obj_pid(invenObj, itemPid);
|
||||
if (quantity > actualQty or quantity < 0) then begin
|
||||
quantity := actualQty;
|
||||
end
|
||||
while (toRemoveQty > 0) do begin
|
||||
toRemoveQty := quantity;
|
||||
while (quantity > 0) do begin
|
||||
item := obj_carrying_pid_obj(invenObj, itemPid);
|
||||
if (obj_type(invenObj) == OBJ_TYPE_CRITTER) then begin
|
||||
if (critter_inven_obj(invenObj, INVEN_TYPE_WORN) == item) then begin
|
||||
@@ -66,9 +68,10 @@ procedure remove_items_pid(variable invenObj, variable itemPid, variable quantit
|
||||
inven_unwield(invenObj);
|
||||
end
|
||||
end
|
||||
toRemoveQty -= rm_mult_objs_from_inven(invenObj, item, toRemoveQty);
|
||||
quantity -= rm_mult_objs_from_inven(invenObj, item, quantity);
|
||||
destroy_object(item);
|
||||
end
|
||||
return toRemoveQty;
|
||||
end
|
||||
|
||||
procedure remove_item_obj(variable invenObj, variable item) begin
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
// sort map in descending order by key value
|
||||
#define sort_map_reverse(array) resize_array(array, -7)
|
||||
// remove element from map or just replace value with 0 for list
|
||||
#define unset_array(array, item) set_array(array, item, 0)
|
||||
#define unset_array(array, key) set_array(array, key, 0)
|
||||
|
||||
// same as "key_pressed" but checks VK codes instead of DX codes
|
||||
#define key_pressed_vk(key) (key_pressed(key bwor 0x80000000))
|
||||
@@ -391,6 +391,7 @@
|
||||
#define spatial_radius(obj) sfall_func1("spatial_radius", obj)
|
||||
#define string_compare(str1, str2) sfall_func2("string_compare", str1, str2)
|
||||
#define string_compare_locale(str1, str2, codePage) sfall_func3("string_compare", str1, str2, codePage)
|
||||
#define string_find(haystack, needle, pos) sfall_func3("string_find", haystack, needle, pos)
|
||||
#define string_format1(format, a1) sfall_func2("string_format", format, a1)
|
||||
#define string_format2(format, a1, a2) sfall_func3("string_format", format, a1, a2)
|
||||
#define string_format3(format, a1, a2, a3) sfall_func4("string_format", format, a1, a2, a3)
|
||||
|
||||
Reference in New Issue
Block a user