Skip to content

Commit

Permalink
Crafting bug fix
Browse files Browse the repository at this point in the history
- Craft button was drawn on top of barter/dialog windows when they overlap it due to MOVEONTOP flag. Now should fix both issues with/without HRP.
- Disassembling multiple-item recipe had incorrect calculation of items, allowing to create infinite items.
  • Loading branch information
phobos2077 committed May 27, 2024
1 parent 7d8d145 commit 74812e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/ecco_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ v0.9.6:

> Balance:
- changed monster part quests requirements/rewards ratio to make economic sense
- reduced drugs in dead NPC's by further 40%
- minor weapon stat tweaks

> Installer:
Expand Down
4 changes: 2 additions & 2 deletions scripts_src/_pbs_craft/crafting.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ procedure display_item_options begin
if (max_batch > 0) then SayOption("1. " + mstr_craft(103), batch_one_item);
if (max_batch > 1) then SayOption("2. " + mstr_craft(108) + " (" + (max_batch * cur_recipe_batch_size) + ")", batch_all_items);
if (max_undo > 0) then SayOption("3. " + mstr_craft(104), undo_one_item);
if (max_undo > 1) then SayOption("4. " + mstr_craft(109) + mstr_craft(110) + max_undo + mstr_craft(111), undo_all_items);
if (max_undo > 1) then SayOption("4. " + mstr_craft(109) + mstr_craft(110) + (max_undo * cur_recipe_batch_size) + mstr_craft(111), undo_all_items);
SayOption("0: "+mstr_craft(102), items_list_mode);
if (use_categories) then
SayOption(mstr_craft(112), item_categories_mode);
Expand Down Expand Up @@ -750,7 +750,7 @@ procedure draw_item_properties begin
if not(hasTools and hasSkills and hasComponents) then max_batch := 0;

// Check if disassembly is possible.
max_undo := party_is_carrying_obj_pid(cur_recipe.pid)
max_undo := (party_is_carrying_obj_pid(cur_recipe.pid) / cur_recipe.qty)
if (cur_recipe.undo and hasTools and hasSkills)
else 0;

Expand Down
15 changes: 12 additions & 3 deletions scripts_src/_pbs_craft/gl_pbs_craft.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ procedure delete_button;
#include "crafting.h"

variable crafting_hotkey, schema_pids;
variable warning_msg, show_crafting_scheduled, crafting_button_shown;
variable warning_msg, show_crafting_scheduled, crafting_button_shown, crafting_button_top;

#define WIN_CRAFT_BTN "helwin"
#define SFX_BUTTON_DOWN "butin4"
Expand Down Expand Up @@ -132,16 +132,25 @@ end

// Create the button
procedure create_button begin
if crafting_button_shown then return;
// Mash's HRP has a bug when clicking on main interface - it goes on top (sfall doesn't have this).
// Workaround: delete and recreate button when going to/from these UI's with moveontop flag only when button is actually clickable.
variable onTop := not(get_game_mode bwand (BARTER bwor INVENTORY bwor DIALOG));
if crafting_button_shown then begin
if (crafting_button_top != onTop) then
DeleteWin(WIN_CRAFT_BTN);
else
return;
end
variable
x := get_interface_x(WINTYPE_IFACEBAR) + get_interface_width(WINTYPE_IFACEBAR) - BUTTON_RIGHT_OFFSET,
y := (get_screen_height - BUTTON_BOTTOM_OFFSET);
create_win_flag(WIN_CRAFT_BTN, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, WIN_FLAG_DONTMOVE bwor WIN_FLAG_MOVEONTOP);
create_win_flag(WIN_CRAFT_BTN, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, WIN_FLAG_DONTMOVE bwor (WIN_FLAG_MOVEONTOP if onTop else 0));
SelectWin(WIN_CRAFT_BTN);
AddButton("but", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
AddButtonGFX("but", PCX_BUTTON_DOWN, PCX_BUTTON_UP, PCX_BUTTON_UP);
AddButtonProc("but", do_on, do_off, do_down, do_up);
ShowWin;
crafting_button_top := onTop;
crafting_button_shown := true;
end

Expand Down

0 comments on commit 74812e9

Please sign in to comment.