Skip to content

Commit

Permalink
EXP: Adjust the price adjustment as you buy goods
Browse files Browse the repository at this point in the history
The scripts "game_event_buy_item" and "game_event_sell_item" are what
adjusts the price up/down as the player purchases things from the merchant.
This only kicks in for trade goods and not armor/weapons/horses.

The constant "price_adjustment" does not seem to be used anywhere
in the scripts and definitely not in the two game_event scripts.  It might
be used internally by the engine.

The math for this is:

1. Get the current price multiplier for the item at the party.  This
gives a value around 1000 (100% of the static item value) but
could range from 700-1300 (min is 100, max is 10000).

2. Always add/subtract a static value of 10-30 to the multiplier.
This has the effect that each additional item purchased is 1-3%
more expensive. This commit reduces it from 2-3% change to
a 1-2% change.

3. For items above 100 (now 150) item_value, subtract that from the
item_value, then divide by 15 (was 8).  Add/subtract this new value to
the multiplier.

OLD BUY:
1200 + 20 + (380 - 100)/8 = 1255 (4.5% increase)
1000 + 20 + (380 - 100)/8 = 1055 (5.5% increase)
800 + 20 + (380 - 100)/8 = 855 (6.9% increase)

NEW BUY:
1200 + 10 + (380 - 150)/15 = 1225 (2.1% increase)
1000 + 10 + (380 - 150)/15 = 1025 (2.5% increase)
800 + 10 + (380 - 150)/15 = 825 (3.1% increase)

The end result of this change is a slower change in the price
as you buy out the merchant's inventory.  Higher priced goods
are still more volatile, but not as much.
  • Loading branch information
WuphonsReach committed Apr 20, 2021
1 parent 53ebe33 commit 90c578f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
3 changes: 2 additions & 1 deletion quick_strings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
6285
6286
qstr_Breaking_camp... Breaking_camp...
qstr_{!}{s3}_commander_of {!}{s3}_commander_of_party_#{reg4}_which_is_not_his_troop_leaded_party_{reg5}
qstr_{!}_Commanded_party_ {!}_Commanded_party_#{reg4}_is_{s3},_troop_leaded_party_#{reg5}_is_{s65}
Expand Down Expand Up @@ -6284,3 +6284,4 @@ qstr_Target_amount_2_{reg Target_amount_2_{reg0}
qstr_Target_amount_3:_{re Target_amount_3:_{reg0}
qstr_realm realm
qstr_{s9}_of_{s3}_asked_you_ {s9}_of_{s3}_asked_you_to_deliver_{reg5}_units_({reg6}_slots)_of_{s6}_to_the_tavern_in_{s4}_in_7_days.
qstr_{!}DEBUG:_start_mult {!}DEBUG:_start_multipler_{reg10},_item_value_{reg11},_resulting_multiplier_{reg12}.
4 changes: 2 additions & 2 deletions scripts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ game_get_item_sell_price_factor -1
get_trade_penalty -1
2 21 1 1224979098644774912 1 5 644 1224979098644774912 144115188075856273 0 144115188075855987
game_event_buy_item -1
23 21 1 1224979098644774912 22 1 1224979098644774913 4 0 33 3 1224979098644774912 91 125 2121 3 1224979098644774914 1224979098644774912 91 2105 2 1224979098644774914 250 521 3 1224979098644774915 144115188075856273 1224979098644774914 4 0 31 2 1224979098644774913 0 2105 2 1224979098644774915 20 5 0 2105 2 1224979098644774915 30 3 0 2230 2 1224979098644774916 1224979098644774912 4 0 30 2 1224979098644774916 100 2121 3 1224979098644774917 1224979098644774916 100 2123 3 1224979098644774918 1224979098644774917 8 2105 2 1224979098644774915 1224979098644774918 3 0 2110 2 1224979098644774915 10000 501 3 144115188075856273 1224979098644774914 1224979098644774915 3 0
30 21 1 1224979098644774912 22 1 1224979098644774913 4 0 33 3 1224979098644774912 91 125 2121 3 1224979098644774914 1224979098644774912 91 2105 2 1224979098644774914 250 521 3 1224979098644774915 144115188075856273 1224979098644774914 2133 2 72057594037927946 1224979098644774915 4 0 31 2 1224979098644774913 0 2105 2 1224979098644774915 10 5 0 2105 2 1224979098644774915 20 3 0 2230 2 1224979098644774916 1224979098644774912 2133 2 72057594037927947 1224979098644774916 4 0 30 2 1224979098644774916 150 2121 3 1224979098644774917 1224979098644774916 150 2123 3 1224979098644774918 1224979098644774917 15 2105 2 1224979098644774915 1224979098644774918 3 0 2110 2 1224979098644774915 10000 2133 2 72057594037927948 1224979098644774915 4 0 31 2 144115188075856163 1 1106 1 1585267068834420880 3 0 501 3 144115188075856273 1224979098644774914 1224979098644774915 3 0
game_event_sell_item -1
23 21 1 1224979098644774912 22 1 1224979098644774913 4 0 33 3 1224979098644774912 91 125 2121 3 1224979098644774914 1224979098644774912 91 2105 2 1224979098644774914 250 521 3 1224979098644774915 144115188075856273 1224979098644774914 4 0 31 2 1224979098644774913 0 2106 2 1224979098644774915 30 5 0 2106 2 1224979098644774915 20 3 0 2230 2 1224979098644774916 1224979098644774912 4 0 30 2 1224979098644774916 100 2121 3 1224979098644774917 1224979098644774916 100 2123 3 1224979098644774918 1224979098644774917 8 2106 2 1224979098644774915 1224979098644774918 3 0 2111 2 1224979098644774915 100 501 3 144115188075856273 1224979098644774914 1224979098644774915 3 0
30 21 1 1224979098644774912 22 1 1224979098644774913 4 0 33 3 1224979098644774912 91 125 2121 3 1224979098644774914 1224979098644774912 91 2105 2 1224979098644774914 250 521 3 1224979098644774915 144115188075856273 1224979098644774914 2133 2 72057594037927946 1224979098644774915 4 0 31 2 1224979098644774913 0 2106 2 1224979098644774915 20 5 0 2106 2 1224979098644774915 10 3 0 2230 2 1224979098644774916 1224979098644774912 2133 2 72057594037927947 1224979098644774916 4 0 30 2 1224979098644774916 150 2121 3 1224979098644774917 1224979098644774916 150 2123 3 1224979098644774918 1224979098644774917 15 2106 2 1224979098644774915 1224979098644774918 3 0 2111 2 1224979098644774915 100 2133 2 72057594037927948 1224979098644774915 4 0 31 2 144115188075856163 1 1106 1 1585267068834420880 3 0 501 3 144115188075856273 1224979098644774914 1224979098644774915 3 0
start_wedding_cutscene -1
198 23 2 144115188075856918 1 23 2 144115188075856919 2 2133 2 1224979098644774912 72057594037927936 2133 2 1224979098644774913 72057594037927937 1 3 627 144115188075856918 144115188075856919 2133 2 1224979098644774914 72057594037927936 2133 2 1224979098644774915 72057594037927937 4 0 31 2 1224979098644774915 0 2147483679 2 1224979098644774914 0 2133 2 72057594037927936 144115188075856919 2133 2 144115188075856919 144115188075856918 2133 2 144115188075856918 72057594037927936 5 0 31 2 1224979098644774915 1224979098644774914 31 2 144115188075856919 0 2133 2 144115188075856919 144115188075856918 2133 2 144115188075856918 0 3 0 2133 2 144115188075856921 849 4 0 33 3 144115188075856287 14 21 2147484190 3 144115188075856287 11 144115188075856918 2147484190 3 144115188075856287 11 144115188075856919 522 3 1224979098644774916 144115188075856287 11 2147483679 2 1224979098644774916 144115188075856919 2147483679 2 1224979098644774916 144115188075856918 1 2 625 1224979098644774916 1073741855 2 72057594037927936 0 1073741855 2 1224979098644774914 1224979098644774915 30 2 144115188075856199 2 2147483679 2 1224979098644774916 144115188075856919 2147484188 3 144115188075856919 31 1224979098644774916 2147484188 3 144115188075856919 32 1224979098644774916 2147483679 2 1224979098644774916 144115188075856918 2133 2 144115188075856921 1224979098644774916 5 0 31 2 144115188075856287 14 542 3 144115188075856287 11 0 32 2 144115188075856021 0 1 2 625 144115188075856021 1073741855 2 72057594037927936 0 1073741855 2 1224979098644774914 1224979098644774915 30 2 144115188075856199 2 2147483679 2 144115188075856021 144115188075856918 2133 2 144115188075856921 144115188075856021 3 0 2133 2 144115188075856920 849 4 0 2147483679 2 144115188075856919 0 4 0 520 3 1224979098644774917 144115188075856919 31 32 2 1224979098644774917 0 2147484208 3 1224979098644774917 2 11 1 2 625 1224979098644774917 1073741855 2 1224979098644774915 0 31 2 72057594037927936 0 2147483679 2 1224979098644774917 144115188075856918 2147483679 2 1224979098644774917 144115188075856921 2133 2 144115188075856920 1224979098644774917 5 0 520 3 1224979098644774918 144115188075856919 33 32 2 1224979098644774918 0 2147484208 3 1224979098644774918 2 11 1 2 625 1224979098644774918 1073741855 2 1224979098644774915 0 31 2 72057594037927936 0 1 2 625 1224979098644774918 2147483679 2 1224979098644774918 144115188075856918 2147483679 2 1224979098644774918 144115188075856921 2133 2 144115188075856920 1224979098644774918 5 0 520 3 1224979098644774919 144115188075856919 32 32 2 1224979098644774919 0 2147484208 3 1224979098644774919 2 11 2147483679 2 1224979098644774919 144115188075856918 2147483679 2 1224979098644774919 144115188075856919 2147483679 2 1224979098644774919 144115188075856921 2133 2 144115188075856920 1224979098644774919 5 0 33 3 144115188075856919 194 210 520 3 1224979098644774920 144115188075856919 75 30 2 1224979098644774920 194 560 3 1224979098644774920 5 1 2147484208 3 1224979098644774920 2 11 1073742364 3 1224979098644774920 2 2 1073742364 3 1224979098644774920 2 5 1073742364 3 1224979098644774920 2 7 540 3 1224979098644774920 2 6 2147484208 3 1224979098644774920 2 11 2147483679 2 1224979098644774920 144115188075856918 2147483679 2 1224979098644774920 144115188075856919 2147483679 2 1224979098644774920 144115188075856921 3221226032 3 1224979098644774920 52 8 1073742384 3 1224979098644774920 52 21 2133 2 144115188075856920 1224979098644774920 5 0 2133 2 1224979098644774921 0 6 3 1224979098644774920 194 463 2147483679 2 1224979098644774920 144115188075856918 2147483679 2 1224979098644774920 144115188075856919 2147483679 2 1224979098644774920 144115188075856921 2147483679 2 1224979098644774920 342 2147483679 2 1224979098644774920 193 2147484208 3 1224979098644774920 2 11 1 3 506 1224979098644774920 144115188075856919 2133 2 1224979098644774922 72057594037927936 1 3 653 1224979098644774920 144115188075856919 2133 2 1224979098644774923 72057594037927936 2120 3 1224979098644774924 1224979098644774922 1224979098644774923 32 2 1224979098644774924 1224979098644774921 2133 2 1224979098644774921 1224979098644774924 2133 2 144115188075856920 1224979098644774920 3 0 3 0 5 0 6 3 1224979098644774925 194 210 1073742364 3 1224979098644774925 2 5 540 3 1224979098644774925 2 2 1 2 625 1224979098644774925 1073741855 2 72057594037927936 0 31 2 1224979098644774915 0 2147483679 2 1224979098644774925 144115188075856918 2147483679 2 1224979098644774925 144115188075856921 2133 2 144115188075856920 1224979098644774925 3 0 31 2 144115188075856920 849 6 3 1224979098644774925 194 210 1073742364 3 1224979098644774925 2 5 540 3 1224979098644774925 2 2 2147483679 2 1224979098644774925 144115188075856918 2147483679 2 1224979098644774925 144115188075856921 2133 2 144115188075856920 1224979098644774925 3 0 31 2 144115188075856920 849 2133 2 1224979098644774921 -100 6 3 1224979098644774920 194 463 2147484188 3 1224979098644774920 5 0 1073742364 3 1224979098644774920 2 7 1073742364 3 1224979098644774920 2 5 1073742364 3 1224979098644774920 2 6 540 3 1224979098644774920 2 2 2147483679 2 1224979098644774920 144115188075856918 2147483679 2 1224979098644774920 144115188075856921 2147483679 2 1224979098644774920 342 2147483679 2 1224979098644774920 193 1 2 271 1224979098644774920 2133 2 1224979098644774924 72057594037927936 30 2 1224979098644774924 0 1 2 610 1224979098644774920 1073741854 2 1224979098644774924 20 30 2 72057594037927936 1 32 2 1224979098644774924 1224979098644774921 2133 2 1224979098644774921 1224979098644774924 2133 2 144115188075856920 1224979098644774920 3 0 3 0 1261 1 517 1262 1 0 1263 2 0 144115188075856918 1263 2 1 144115188075856919 1263 2 2 144115188075856920 1263 2 3 144115188075856921 2133 2 1224979098644774926 4 2133 2 1224979098644774927 0 2173 2 1224979098644774928 144115188075856918 2173 2 1224979098644774929 144115188075856919 6 3 1224979098644774920 194 463 2147483678 2 1224979098644774926 32 2147483679 2 1224979098644774920 144115188075856918 2147483679 2 1224979098644774920 144115188075856919 2147483679 2 1224979098644774920 144115188075856920 2147483679 2 1224979098644774920 144115188075856921 2173 2 1224979098644774930 1224979098644774920 1073741855 2 1224979098644774928 1224979098644774930 31 2 1224979098644774929 1224979098644774930 1073742364 3 1224979098644774920 2 5 1073742364 3 1224979098644774920 2 2 540 3 1224979098644774920 2 6 1 2 625 1224979098644774920 2133 2 1224979098644774931 72057594037927936 2133 2 1224979098644774932 1 4 0 31 2 1224979098644774931 0 2133 2 1224979098644774932 0 2147483678 2 1224979098644774927 16 2133 2 1224979098644774932 1 2105 2 1224979098644774927 1 3 0 31 2 1224979098644774932 1 1263 2 1224979098644774926 1224979098644774920 2105 2 1224979098644774926 1 3 0 2133 2 72057594037927936 1224979098644774912 2133 2 72057594037927937 1224979098644774913 1911 1 28 1910 1 517 2048 0
game_get_troop_wage -1
Expand Down
2 changes: 1 addition & 1 deletion source/module_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@


#Additions
price_adjustment = 25 #the percent by which a trade at a center alters price
price_adjustment = 25 #the percent by which a trade at a center alters price (based on 1000, so 25 = 2.5%)

fire_duration = 4 #fires takes 4 hours

Expand Down
50 changes: 33 additions & 17 deletions source/module_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4606,22 +4606,30 @@ def keys_array():
(is_between, ":item_kind_id", trade_goods_begin, trade_goods_end),
(store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin),
(val_add, ":item_slot_no", slot_town_trade_good_prices_begin),
(party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"),
(try_begin),
(party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"), # gets a value around 800-1200 (where 1000 = 100% of the item_value)
(assign, reg10, ":multiplier"),
(try_begin), # increase multiplier by +X (roughly 1%)
(eq, ":reclaim_mode", 0),
(val_add, ":multiplier", 20),
(val_add, ":multiplier", 10),
(else_try),
(val_add, ":multiplier", 30),
(val_add, ":multiplier", 20),
(try_end),

(store_item_value, ":item_value", ":item_kind_id"),
(try_begin),
(ge, ":item_value", 100),
(store_sub, ":item_value_sub_100", ":item_value", 100),
(store_div, ":item_value_sub_100_div_8", ":item_value_sub_100", 8),
(val_add, ":multiplier", ":item_value_sub_100_div_8"),
(assign, reg11, ":item_value"),
(try_begin), # for things with a value under X, make no further adjustments (high priced goods are more volatile)
(ge, ":item_value", 150),
(store_sub, ":adjusted_item_value", ":item_value", 150),
(store_div, ":multiplier_delta", ":adjusted_item_value", 15),
(val_add, ":multiplier", ":multiplier_delta"),
(try_end),
(val_min, ":multiplier", maximum_price_factor),
(assign, reg12, ":multiplier"),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}DEBUG: start multipler {reg10}, item_value {reg11}, resulting multiplier {reg12}."),
(try_end),

(party_set_slot, "$g_encountered_party", ":item_slot_no", ":multiplier"),
(try_end),
Expand All @@ -4639,22 +4647,30 @@ def keys_array():
(is_between, ":item_kind_id", trade_goods_begin, trade_goods_end),
(store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin),
(val_add, ":item_slot_no", slot_town_trade_good_prices_begin),
(party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"),
(try_begin),
(party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"), # gets a value around 800-1200 (where 1000 = 100% of the item_value)
(assign, reg10, ":multiplier"),
(try_begin), # decrease multiplier by +X (roughly 2%)
(eq, ":return_mode", 0),
(val_sub, ":multiplier", 30),
(else_try),
(val_sub, ":multiplier", 20),
(else_try),
(val_sub, ":multiplier", 10),
(try_end),

(store_item_value, ":item_value", ":item_kind_id"),
(assign, reg11, ":item_value"),
(try_begin),
(ge, ":item_value", 100),
(store_sub, ":item_value_sub_100", ":item_value", 100),
(store_div, ":item_value_sub_100_div_8", ":item_value_sub_100", 8),
(val_sub, ":multiplier", ":item_value_sub_100_div_8"),
(ge, ":item_value", 150), # for things with a value under X, make no further adjustments (high priced goods are more volatile)
(store_sub, ":adjusted_item_value", ":item_value", 150),
(store_div, ":multiplier_delta", ":adjusted_item_value", 15),
(val_sub, ":multiplier", ":multiplier_delta"),
(try_end),
(val_max, ":multiplier", minimum_price_factor),
(assign, reg12, ":multiplier"),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}DEBUG: start multipler {reg10}, item_value {reg11}, resulting multiplier {reg12}."),
(try_end),

(party_set_slot, "$g_encountered_party", ":item_slot_no", ":multiplier"),
(try_end),
Expand Down

0 comments on commit 90c578f

Please sign in to comment.