Okay, you guys.. I need your help again.
My current script is causing me issues.
Don't laugh at the code. I've been messing around with it a lot.
I'm experimenting with HOOK_REMOVEINVENOBJ for an entire day now. It seems it fires up more times then it should. I will explain:
At first, I thought the script goes crazy because it can't handle "/", "%","*" when calculating integers, but this was strange to me, since I have a few different scripts which, as far as I know, are working fine. So, I got rid of these functions, and just used this simple script.
Now, look at the results: This is the first stimpak move. Working as intended. (sorry, cant figure out how to upload straight to here)
https://ibb.co/DWDHyDc
The second time I transfered one stimpak, this happened:
https://ibb.co/gDLm5LN
https://ibb.co/hYVfNYD
Its running 7 times, until it finally (8th try) reaches the desired "stim amount after34". From there on, 8 tries each time.
Now, again, I'm not sure if this is actually a problem or it's just me, but this seems to mess up the function's other calculations, and the variables become weird. Like negative and stuff. So when I try to use "/" or "%" to find the amount of weight I should add, the items and variables goes crazy.
So, please help me out. Did I break the script somehow?
My current script is causing me issues.
Code:
procedure start begin
variable orig_owner;
variable the_item;
variable num_removed_objects;
variable reason_removed;
variable dest_obj;
// variable item_extra_weight;
variable extra_weight_ground_obj;
variable amount_to_destroy;
variable stimpaks_amount_before;
variable stimpaks_amount_after;
variable stimpaks_weight;
variable i;
if (game_loaded) then begin
register_hook(HOOK_REMOVEINVENOBJ);
end
else begin
orig_owner := get_sfall_arg;
the_item := get_sfall_arg;
num_removed_objects := get_sfall_arg;
// reason_removed := get_sfall_arg;
// dest_obj := get_sfall_arg;
//checks how many stimpaks in dude's inver originally
stimpaks_amount_before:= obj_is_carrying_obj_pid(dude_obj, PID_STIMPAK);
//checks how many extra_weight items are in dude's inven
amount_to_destroy:= obj_is_carrying_obj_pid(dude_obj, PID_EXTRA_WEIGHT);
//when moving from dude's inven
if orig_owner == dude_obj then begin
//if has extra weight
if amount_to_destroy > 0 then begin
// remove all extra weight items
restock_amt := rm_mult_objs_from_inven(dude_obj, obj_carrying_pid_obj(dude_obj, PID_EXTRA_WEIGHT), amount_to_destroy);
end
//checks how much total amount after transfer
stimpaks_amount_after := (stimpaks_amount_before - num_removed_objects);
//checks to see if stimpaks_amount_after divides by 4 (currently not enabled "4")
display_msg("stim amount before" + obj_is_carrying_obj_pid(dude_obj, PID_STIMPAK));
display_msg("stim amount after" + stimpaks_amount_after);
//checks total stimpak weight after transfer
stimpaks_weight := (stimpaks_amount_after);
//adds extra weight items according to stimpaks weight
give_pid_qty(dude_obj, PID_EXTRA_WEIGHT, stimpaks_weight)
end
restock_amt := 0;
restock_obj := 0;
extra_weight_ground_obj:= 0;
amount_to_destroy:= 0;
stimpaks_amount_before:= 0;
stimpaks_amount_after:= 0;
stimpaks_weight:= 0;
end
end
Don't laugh at the code. I've been messing around with it a lot.
I'm experimenting with HOOK_REMOVEINVENOBJ for an entire day now. It seems it fires up more times then it should. I will explain:
At first, I thought the script goes crazy because it can't handle "/", "%","*" when calculating integers, but this was strange to me, since I have a few different scripts which, as far as I know, are working fine. So, I got rid of these functions, and just used this simple script.
Now, look at the results: This is the first stimpak move. Working as intended. (sorry, cant figure out how to upload straight to here)
https://ibb.co/DWDHyDc
The second time I transfered one stimpak, this happened:
https://ibb.co/gDLm5LN
https://ibb.co/hYVfNYD
Its running 7 times, until it finally (8th try) reaches the desired "stim amount after34". From there on, 8 tries each time.
Now, again, I'm not sure if this is actually a problem or it's just me, but this seems to mess up the function's other calculations, and the variables become weird. Like negative and stuff. So when I try to use "/" or "%" to find the amount of weight I should add, the items and variables goes crazy.
So, please help me out. Did I break the script somehow?
Last edited: