tModLoader Capitalism

hamstar

Terrarian


Note: Requires Mod Helpers


This mod makes town NPCs stingy and adhere to the rule of supply & demand. As such, popular items will have their prices marked up. Also, don't let your vendor townsfolk die. Dying is expensive.

b=base value, t=total purchases:
  • b + ( (b * t)^0.8 ) / 50

If a tax collector is present, this price is further marked up by 2%.

Config settings available in "My Documents/Terraria/ModLoader/Mod Configs/Capitalism Config.json".

Source code available. API now available.


Installation

Requires tModLoader (+0.11). Copy the above .tmod file to your 'Documents/My Games/Terraria/ModLoader/Mods' folder to play.


Possible future additions
  • Selling items decreases their value (need to figure out how to implement this adequately).
  • Assorted favor or disfavor conditions for pricing.
  • Credit and loans! :merchantgrin:


v1.5.1
  • Updated to TML11.5
  • Config ranges defined
  • Set config float fields to use hybrid UI input
  • Added formula result display to config
v1.5.0
  • Updated to MHv5 and TML11
  • Added ranges to config fields
v1.4.2.3
  • Updated to MH v4.2.3.2 (with conventions)
  • Switched from snake case to camel case
  • Changed uses of WorldHelpers.GetUniqueIdWithSeed to GetUniqueId
v1.4.2
  • Updated to Mod Helpers v2.0.2
  • Added MP player load bug failsafe
v1.4.1
  • Added Mod.Call API
  • Added small bits of polish
  • Updated net code to use PacketProtocol
  • Possible fix for player issues
  • Set world ids to use new convention
  • Assorted internal freshness refactoring
  • Updated to HH v1.4.18
v1.4.0.1
  • Added mod icon
  • Added support for Hamstar Helpers v1.2.0 issue report
  • Minor internal refactoring
  • Added API
v1.3.3.3
  • Refactored internal code to newer standard
v1.3.3
  • Updated for TML 0.10
  • Offloaded utility/helper code to Hamstar's Helpers mod (now a dependency)
  • Numerous fixes and tweaks
v1.3.2.1
  • Added config setting 'Enabled' (allows disabling the mod instead of unloading it)
  • Added shop prices markup % indicators as item tooltips
v1.3.1
  • (Minor?) logic correction for bulk purchase detection
v1.3.0
  • New formula for item markup (b=base value, t=total purchases): b + ( (b * t)^0.8 ) / 50
  • Fixed semi-critical bulk purchases bug
v1.2.2
  • Altered some default config values
  • Changed markup formula (b=base value, t=total purchases, s=total spendings):
    b + ( b * t * 0.02 * (0.996 ^ ((t/4) + (s/10000))) )
v1.2.0
  • Updated config file location.
  • Cleaned up some code.
  • Smoothed out price markup decay for expensive items.
  • Added price markups for female townsfolk during a blood moon.
  • Added price reduction for lovestruck townsfolk of the opposite gender.
  • Added price markup for stinky players.
v1.1.6
  • Fixed config reloading between game sessions.
v1.1.5
  • Added failsafes.
v1.1.2-4
  • Fixed multiplayer bug.
v1.1.1
  • Modified the formula to the following (v=item's base value, t=total purchases):
    • v + (v * t * 0.1 * (0.996 ^ t))
  • More fixes.
v1.0.8-9
  • Fixed possible crash.
  • Fixed item buybacks erroneously adding to item markup.
v1.0.3-7
  • Fixed crashes.

Capitalism.png


 
Last edited:
so it can only go up ? thats kinda bad
I added a decay factor per day, but if you're buying tons of a given type of item it won't help much. Let's just see how it works out for the amount it's currently at, for now.

Also, fixed a (somewhat) major crash bug. Was a bit rushed to release this, but I think I'm back in control now.
 

Attachments

  • Capitalism v1.0.4.zip
    11.4 KB · Views: 299
Ni
I added a decay factor per day, but if you're buying tons of a given type of item it won't help much. Let's just see how it works out for the amount it's currently at, for now.

Also, fixed a (somewhat) major crash bug. Was a bit rushed to release this, but I think I'm back in control now.
Nice
 
Your mod crashes the game

Code:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Hamstar.Capitalism.CapitalismLogic.SaveVendors(TagCompound tags)
   at Hamstar.Capitalism.CapitalismPlayer.Save()
 
Your mod crashes the game

Code:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Hamstar.Capitalism.CapitalismLogic.SaveVendors(TagCompound tags)
   at Hamstar.Capitalism.CapitalismPlayer.Save()
I may not be a mod creator, but you should:
1.) Say which mods you have.
2.) Say when it crashed.
3.) Put the crash report in a spoiler.
This makes it more organized, easier to analyze and cleans up the page.
 
Your mod crashes the game

Code:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Hamstar.Capitalism.VendorLogic.UpdateShop(Chest shop)
   at Hamstar.Capitalism.CapitalismPlayer.HookUpdateCurrentShop(Int32 type, Chest shop, Int32& nextSlot)
   at Hamstar.Capitalism.CapitalismNPC.SetupShop(Int32 type, Chest shop, Int32& nextSlot)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Hamstar.Capitalism.CapitalismLogic.SaveVendors(TagCompound tags)
   at Hamstar.Capitalism.CapitalismPlayer.Save()

What version of the mod? I believe I just recently fixed this very issue. I'm a bit surprised and confused to see it pop up again.
 
Last edited:
Object reference not set to an instance of an object.
at Capitalism.CapitalismPlayer.Load(TagCompound tag)
at Terraria.ModLoader.IO.PlayerIO.LoadModData(Player player, IList`1 list)
 
Another amazing mod by yourself.

Wanna knwo something? Before meeting you, I was agaisnt modding in Terraria, because most people do unbalanced trashy mods, or mods that just "look awesome" but don't "feel awesome" (Cough Thorium cough).

I will give this mod a try. The only mod of yours that I haven't tried is wormholes, because I think that does more good to me than harm, lol.
 
Another amazing mod by yourself.

Wanna knwo something? Before meeting you, I was agaisnt modding in Terraria, because most people do unbalanced trashy mods, or mods that just "look awesome" but don't "feel awesome" (Cough Thorium cough).

I will give this mod a try. The only mod of yours that I haven't tried is wormholes, because I think that does more good to me than harm, lol.
why your bashing mod devs
 
Another amazing mod by yourself.

Wanna knwo something? Before meeting you, I was agaisnt modding in Terraria, because most people do unbalanced trashy mods, or mods that just "look awesome" but don't "feel awesome" (Cough Thorium cough).

I will give this mod a try. The only mod of yours that I haven't tried is wormholes, because I think that does more good to me than harm, lol.
Wormholes is more a convenience mod than a difficulty alleviating one. It's designed to shave off a big chunk of the usual back and forth traveling, but without completely eliminating the need for map traversing and adventure (especially to not encroach on the roles of teleporters, rails, asphalt roads, etc.).
 
Last edited:
why your bashing mod devs

Not bashing. Just giving my opinion.
I know that, in today's SJW culture that's not well looked at.

Wormholes is more a convenience mod than a difficulty elevating one. It's designed to shave off a big chunk of the usual back and forth traveling, but without completely eliminating the need for map traversing and adventure (especially to not encroach on the roles of teleporters, rails, asphalt roads, etc.).

I guess that's not just my cup of tea, but it could be grand for some people who want fun. Like a controllable Teleportation potion on the field.
Anyway, a suggestion here: Don't you think you should make a megathread for all your mods? You have quite some good ones now.
Also, explaining and expanding on them would help some people to understand more what they are about. There are lots of sellpoints you could mention about them.
 
Not bashing. Just giving my opinion.
I know that, in today's SJW culture that's not well looked at.



I guess that's not just my cup of tea, but it could be grand for some people who want fun. Like a controllable Teleportation potion on the field.
Anyway, a suggestion here: Don't you think you should make a megathread for all your mods? You have quite some good ones now.
Also, explaining and expanding on them would help some people to understand more what they are about. There are lots of sellpoints you could mention about them.
What your starting with SJW for that is uncalled for and weak
 
Back
Top Bottom