@program #3813 1 1000 d i $def notify ansi_notify $def notify_exclude ansi_notify_exclude $def rpsys "$rpsystem" match $def HR "^blue^>^yellow^--------------------------------------------------------------------^blu e^<^ ^" .tell $include #2123 $include $lib/rp $include $lib/alynna $include $muf/rp/utils ( Automated hunter and gatherer, code copyrighted to RedXIII AKA David Silver, do not port or modify ) lvar curr lvar target lvar stat lvar skill lvar subskill lvar field lvar roll : find-price ( s -- f ) skill ! rpsys "Materials/" skill @ strcat "/Cost" strcat getpropstr atoi 3.0 * 2.0 / #0 "Marketplace/" skill @ strcat getstatint 2 * 100 + 3 / / ; public find-price lvar number : scanner2 ( -- i ) #0 "Marketplace/" target @ strcat getstatint dup not if pop #0 "Minit/" target @ strcat getstatint if exit then #0 "Minit/" target @ strcat 1 setstat #0 "Marketplace/" target @ strcat random 200 % dup curr ! setstat curr @ then curr ! target @ 30 left "^yellow^|^ ^" strcat target @ find-price dup not if pop 2.0 then dup target @ "Bank-Note" smatch not if 2.0 else 1.1 then / stat ! 2 fchop 6 right strcat "^yellow^|^ ^" strcat stat @ 2 fchop 6 right strcat "^yellow^|^ ^" strcat curr @ intostr 6 center strcat .tell ; lvar reward : Searcher ( -- ) 0 number ! "You browse around and start asking for the latest prices.." .tell "Name" 30 center "^yellow^|^ ^" strcat " Buy " "^yellow^|^ ^" strcat strcat " Sell " "^yellow^|^ ^" strcat strcat "Number" strcat .tell "Material" "" RPUtils.nextItem target ! begin number @ 1 + number ! target @ 1 strcut swap toupper swap strcat target ! scanner2 "Material" target @ RPUtils.nextItem target ! target @ not until #0 "Totalitems" number @ 1 + setstat HR ; lvar cash lvar original : buyer ( s -- ) var mass var original2 dup not if "Type +market/buy (something)" .tell exit then target ! target @ "=" instring if target @ dup "=" instring strcut atoi mass ! dup strlen 1 - strcut pop target ! else 0 mass ! then mass @ #0 "Marketplace/" target @ strcat getstatint > if #0 "Marketplace/" target @ strcat getstatint mass ! mass @ 1 < if "There isn't any available to buy at this time" .tell exit then then target @ "Bank-Note" smatch if "Bank Notes are no longer for sale" .tell exit then me @ "gil" getstatfloat dup not if "You're broke!" .tell exit then cash ! rpsys "Materials/" target @ strcat "/cost" strcat getpropstr not if "That doesn't seem to be available" .tell exit then #0 "Marketplace/" target @ strcat getstatint not if "That doesn't seem to be available" .tell exit then target @ find-price original2 ! #0 "Marketplace/" target @ strcat getstatint mass @ 2 / - mass @ 2 % if 1 - then #0 "Marketplace/" target @ strcat rot setstat target @ find-price dup original ! curr ! me @ "Professionlist" getstatstr "artisan" instring if str curr @ dup 0.9 * curr ! curr @ - 1 fchop "You save " swap " gil(Artisan)" cat .tell then 5d5 me @ "Streetwise/Barter" getstatint 3.0 / me @ "Intelligence" getstatint 3.0 / + me @ "Perception" getstatint 3.0 / + 3 / + me @ "Professionlist" getstatstr "trader" instring if 3 + then me @ "Professionlist" getstatstr "merchant" instring if 5 + then me @ "Professionlist" getstatstr "upper class" instring if 5 + then me @ "Professionlist" getstatstr "noble" instring if 5 + then me @ "Faction" getstatint 11 = if 10 2.5 / + then roll ! roll @ 23.0 - 0.03 * roll ! target @ "bank-note" smatch not if me @ "Streetwise" getstatint dup if 5d5 + 20 > if "You manage to find an especially eager seller using your streetwise skills" .tell roll @ me @ "streetwise" getstatint 0.01 * roll @ + roll ! then else pop then 1.0 roll @ - curr @ * 100.0 * #0 "economy" getstatint / mass @ if mass @ * then 1.35 * curr ! then curr @ cash @ > if "You can't afford to buy any, even after haggling about it" .tell #0 "Marketplace/" target @ strcat getstatint mass @ 2 / + mass @ 2 % if 1 + then #0 "Marketplace/" target @ strcat rot setstat exit then cash @ curr @ - cash ! #2396 "Gil" getstatfloat curr @ curr @ 1.35 / - 2 / + #2396 "Gil" rot setstat #4020 "Gil" getstatfloat curr @ curr @ 1.35 / - 2 / + #4020 "Gil" rot setstat me @ "gil" cash @ setstat me @ target @ getstatint mass @ if mass @ else 1 then + me @ target @ rot setstat #0 "Marketplace/" target @ strcat getstatint mass @ if mass @ 2 / else 1 then - #0 "Marketplace/" target @ strcat rot setstat str "You buy " mass @ if mass @ else 1 then intostr strcat " unit" strcat mass @ 0 > if "s" strcat then " of " target @ " for " curr @ 2 fchop " gil." cat .tell original @ target @ find-price - fabs 0.2 > if #21 str "Market The price of " target @ " has risen from " original2 @ 2 fchop " to " target @ find-price 2 fchop "." cat force then ; : seller ( s -- ) var mass var original2 dup not if "Type +market/buy (something)" .tell exit then target ! target @ "=" instring if target @ dup "=" instring strcut atoi mass ! dup strlen 1 - strcut pop target ! else 0 mass ! then me @ target @ getstatint mass @ < if me @ target @ getstatint mass ! then mass @ 100 > if 100 mass ! then me @ "gil" getstatfloat cash ! rpsys "Materials/" target @ strcat "/cost" strcat getpropstr not if "No one seems to want it" .tell exit then me @ target @ getstatint not if "That doesn't seem to be available" .tell exit then target @ find-price original2 ! #0 "Marketplace/" target @ strcat getstatint mass @ 2 / + mass @ 2 % if 1 + then #0 "Marketplace/" target @ strcat rot setstat target @ find-price dup original ! curr ! 5d5 me @ "Streetwise/Barter" getstatint 3.0 / me @ "Professionlist" getstatstr "trader" instring if 3 + then me @ "Professionlist" getstatstr "merchant" instring if 5 + then me @ "Professionlist" getstatstr "upper class" instring if 5 + then me @ "Professionlist" getstatstr "noble" instring if 5 + then me @ "Intelligence" getstatint 3.0 / + me @ "Perception" getstatint 3.0 / + 3 / + roll ! roll @ 23.0 - 0.02 * roll ! target @ "Bank-Note" smatch not if me @ "Streetwise" getstatint 2.5 / dup if 5d5 + 20 > if "You manage to find an especially eager buyer using your streetwise skills" .tell roll @ me @ "streetwise" getstatint 0.01 * roll @ + roll ! then else pop then curr @ 1.0 roll @ + * #0 "economy" getstatint * target @ "Bank-Note" smatch not if 200.0 else 110.0 then / mass @ if mass @ * then 1.35 / curr ! then cash @ curr @ + cash ! me @ "gil" cash @ setstat #2396 "Gil" getstatfloat curr @ curr @ 1.35 * - 2 / 0 swap - + #2396 "Gil" rot setstat #4020 "Gil" getstatfloat curr @ curr @ 1.35 * - 2 / 0 swap - + #4020 "Gil" rot setstat me @ target @ getstatint mass @ if mass @ else 1 then - me @ target @ rot setstat #0 "Marketplace/" target @ strcat getstatint mass @ if mass @ 2 / else 1 then + #0 "Marketplace/" target @ strcat rot setstat curr @ not if "Your goods have depreciated beyond value, the merchant takes it off your hands" .tell exit then str "You sell " mass @ 1 + intostr strcat " unit" strcat mass @ 0 > if "s" strcat then " of " target @ " for " curr @ 2 fchop " gil." cat .tell original @ target @ find-price - fabs 0.2 > if #21 str "Market The price of " target @ " has fallen from " original2 @ 2 fchop " to " target @ find-price 2 fchop "." cat force then ; lvar max lvar change : randomtrader ( -- ) random #0 "totalitems" getstatint % 1 + max ! 1 number ! "" target ! begin "Material" target @ RPUtils.nextItem target ! number @ 1 + number ! number @ max @ = number @ max @ > or until target @ "Titanium" smatch if random 3 % if exit then then target @ "gil" smatch not if #0 "marketplace/" target @ strcat getstatint 170 swap - else 110 then rpsys "Materials/" target @ strcat "/renewable?" strcat getpropstr if 30 + then rpsys "Materials/" target @ strcat "/Cost" strcat getpropstr atoi 100 / - #0 "Economy" getstatint 100 swap - + target @ find-price original ! random 200 % 1 + > if #0 "economy" getstatint random 10 % 20 + * 100 / target @ find-price / dup 10 > if pop 10 then dup 1 < if pop 1 then #0 "Marketplace/" target @ strcat getstatint + #0 "Marketplace/" target @ strcat rot setstat str " An NPC sells some " target @ else #0 "economy" getstatint random 10 % 20 + * 100 / target @ find-price / dup 10 > if pop 10 then dup 1 < if pop 1 then #0 "Marketplace/" target @ strcat getstatint swap - dup 1 < if pop 1 then #0 "Marketplace/" target @ strcat rot setstat str " An NPC buys some " target @ then cat debug original @ target @ find-price - fabs 0.1 > if #21 str "Market The price of " target @ " has " original @ target @ find-price > if "fallen" else "risen" then " from " original @ 2 fchop " to " target @ find-price 2 fchop "." cat force then ; : repeater ( -- ) var target begin 60 random 120 % 1 + * 2.5 / int sleep systime #0 "Last Quarter" getstatint - 3110400 > if ( time to start a new fiscal quarter ) #0 "Last Quarter" systime setstat "Material" "" RPUtils.nextItem target ! begin number @ 1 + number ! target @ 1 strcut swap toupper swap strcat target ! #0 "Marketplace/" target @ strcat random 200 % rpsys "Materials/" target @ strcat "/cost" strcat getpropstr atoi random swap % 1 + 15 / - dup 1 < if pop 1 then dup curr ! setstat "Material" target @ RPUtils.nextItem target ! target @ not until #21 "market A new fiscal quarter has begun!(see +market)" force then #0 "Economy" getstatint random 100 % 1 + > if randomtrader then repeat ; : spender ( s -- ) "=" explode 2 = not if "Type +market/spend (type of material)=(quanitity to expend)" .tell exit then target ! atoi reward ! reward @ 1 < if 1 reward ! then me @ target @ getstatint curr ! curr @ reward @ < if "You can't afford to spend that many" .tell exit then curr @ reward @ - curr ! me @ target @ curr @ setstat str "^blue^<^yellow^Official^blue^>^ ^ " me @ name " spends " reward @ " points of " target @ "." cat dup .otell .tell ; lvar person : giver ( s -- ) "=" explode 3 = not if "Type +market/give (someone)=(type of material)=(quanitity to expend)" .tell exit then .pmatch dup player? not if pop "Invalid target" .tell exit then person ! target ! atoi reward ! reward @ 1 < if 1 reward ! then me @ target @ getstatint curr ! curr @ reward @ < if "You can't afford to give that many" .tell exit then curr @ reward @ - curr ! me @ target @ curr @ setstat person @ target @ getstatint reward @ + person @ target @ rot setstat str "^blue^<^yellow^Official^blue^>^ ^ " me @ name " gives " reward @ " points of " target @ " to " person @ ".(silent)" cat dup .tell person @ swap ansi_notify ; : main ( s -- ) command @ "Queued event." smatch if repeater exit then command @ "+market/buy" smatch if buyer exit then command @ "+market/sell" smatch if seller exit then command @ "+market/spend" smatch if spender exit then command @ "+market/give" smatch if giver exit then searcher ; . c q