Author Topic: [MOD] Turret Selling Fix - easy money turret exploit is no more (update)  (Read 230 times)

Rinart73

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    214
  • Discord: Rinart73#7304
    • View Profile
Currently the biggest problem in the Avorion economy balance is the exploit that allows to construct turrets that cost billions and trillions. I'm totally not against the idea of making turrets for profit, but this profit should be reasonable.
And while devs are working on the global balance (which is a hard work), I came up with a local solution of this problem.

This mod allows the game to 'remember' a cost of all ingredients of a player-made turret and assembly price, so selling price will be based on that instead of vanilla price. It will only affect turrets that were created after this mod was installed.

Should be compatible with 0.17.1-0.18.3.

By default mod has settings that result in non-profitable turrets that cost 25% of their production price at maximum. If you want to adjust settings, look at "Configuration" section.

Installation
  • Unpack mod archive into "Avorion" folder
  • Add following line in the end of the file "data/scripts/entity/merchants/equipmentdock.lua":
Code: [Select]
if not pcall(require, "mods.TurretSellingFix.scripts.entity.merchants.equipmentdock") then print("[ERROR][TurretSellingFix]: Failed to extend equipmentdock.lua!") end
  • Add this line in the end of the file "data/scripts/entity/merchants/turretfactory.lua":
Code: [Select]
if not pcall(require, "mods.TurretSellingFix.scripts.entity.merchants.turretfactory") then print("[ERROR][TurretSellingFix]: Failed to extend turretfactory.lua!") end
  • And this line in the end of the file "data/scripts/entity/merchants/researchstation.lua":
Code: [Select]
if not pcall(require, "mods.TurretSellingFix.scripts.entity.merchants.researchstation") then print("[ERROR][TurretSellingFix]: Failed to extend researchstation.lua!") end
Uninstallation
Spoiler: show
  • Remove the lines that you added during the installation
  • Delete "TurretSellingFix" folder from the "mods" folder


Known issues
Spoiler: show
  • (Minor UI) Empty line will appear in the turret descriptions. There is no way to hide it or fixate it's position


Compatibility (2, new info as of 16.09.18)
Spoiler: show

  • Extended Turret Factory - should be compatible if Turret Selling Fix will be installed after it.
    If you're using version 0.1.1, you'll need to install a patch from this post.
  • Auto Research - should be compatible if Turret Selling Fix will be installed after it.

Incompatible with any mod that allows to change turrets after they were built (Weapon Engineering for example). Please message me if you're dev of the mod.

Mod overrides following functions:
data/scripts/entity/merchants/turretfactory.lua
  • buildTurret
data/scripts/entity/merchants/equipmentdock.lua
  • EquipmentDock.shop:updateBuyGui
  • EquipmentDock.shop:updateBuybackGui
  • EquipmentDock.shop:buyFromPlayer
  • EquipmentDock.shop:buyTrashFromPlayer
  • EquipmentDock.shop:sellBackToPlayer
data/scripts/entity/merchants/researchstation.lua
  • transform

Mod extends following functions:
data/scripts/entity/merchants/turretfactory.lua
  • makeTurret
data/scripts/entity/merchants/equipmentdock.lua
  • EquipmentDock.initialize - client only


Configuration
Spoiler: show

Ingredient price is how much all plasma cells and steel tubes that were used to create a turret cost.
Assembly price is additional credit cost that players pay when they build a turret.
Quote
Production price = (Ingredient price + Assembly price)
mod Selling Price = (Ingredient price * ingredientPriceMultiplier) + (Assembly price * assemblyPriceMultiplier)
Profit is possible if the resulting Selling price is greater than Production price.

File "mods/TurretSellingFix/config/TurretSellingFix.lua" has a few parameters that will let you adjust how the mod works:
  • config.useMinimalValue = true/false — Determines which price mod will use.
    If true, mod will choose minimal value between (Vanilla price * 0.25) and Selling price
    If false, mod Selling price will always be used
  • config.ingredientPriceMultiplier = float (0.25, 1.02..) — A multiplier for Ingredient price.
    Multiplier 0.25  will result in a vanilla-like behavior - it will be completely non-profitable to make money via turrets.
    Multiplier 1.0+  will allow people to make money with turrets (it also depends on assemblyPriceMultiplier)
  • config.assemblyPriceMultiplier = float (0.25, 1.02..) — A multiplier for Assembly price.
    Multiplier 0.25  will result in a vanilla-like behavior - it will be completely non-profitable to make money via turrets.
    Multiplier 1.0+  will allow people to make money with turrets (it also depends on ingredientPriceMultiplier)
  • config.maxProfit = -1/number — Allows to limit maximal profit that player can get from selling a turret.
    Example:
    Ingredient price = 500 000, Assembly price = 200 000 => Production price = 700 000
    ingredientPriceMultiplier = 1.4, assemblyPriceMultiplier = 1.3; maxProfit is 100 000
    Selling price will be 100 000 instead of 260 000
    -1  means no limit


Changelog
Spoiler: show

1.1.1
  • Fixed: Vanilla exploit that allowed to build high-rarity turrets (thanks to Hammelpilaw)
1.1.0
  • Fixed: Vanilla exploit that allowed to build turrets with any (but usually 0) amount of ingredients
  • Added: Now when research of player-made turrets produces a turret, mod will ensure that this turret is following the same rules as a player-made turret.
    The resulting turret "ingredientPrice" will be the sum of researched player-made turrets "ingredientPrice"-s.
    And "assemblyPrice" will consist of researched player-made turrets "assemblyPrice"-s + other turrets/upgrades prices.
1.0.1
  • Fixed: It appears that players always have to pay credits to build a turret - so now the resulting Selling price is based on Ingredient Price and Assembly price (credit cost)
  • Added: 'assemblyPriceMultiplier' config option
  • Changed: Renamed config parameter 'priceMultiplier' to 'ingredientPriceMultiplier'
1.0.0
  • Initial release


Credits
  • Devious - for reporting component amount 0 exploit
  • Hammelpilaw - for reporting high-rarity exploit
« Last Edit: September 16, 2018, 11:35:22 PM by Rinart73 »



Hammelpilaw

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    473
    • View Profile
    • Scrap Yard - Avofactory
on: September 07, 2018, 07:53:50 AM
Good idea to fix it that way. Isnt it possible to calculate before creating the turret at turret factory to change the cration price?
My mods and tools

If you find an bug in my mods please pm me, answer on related topic or open new issue on GitLab



Rinart73

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    214
  • Discord: Rinart73#7304
    • View Profile
on: September 07, 2018, 09:16:15 AM
Hammelpilaw, Hi. Can you explain please?
Do you mean:
  • To calculate production price with modifiers, compare it with vanilla price and just save final price?
  • Or to change turret creation price somehow?



Rinart73

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    214
  • Discord: Rinart73#7304
    • View Profile
on: September 07, 2018, 12:11:52 PM
1.0.1
  • Fixed: It appears that players always have to pay credits to build a turret - so now the resulting Selling price is based on Ingredient Price and Assembly price (credit cost)
  • Added: 'assemblyPriceMultiplier' config option
  • Changed: Renamed config parameter 'priceMultiplier' to 'ingredientPriceMultiplier'
« Last Edit: September 07, 2018, 12:18:48 PM by Rinart73 »



Rinart73

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    214
  • Discord: Rinart73#7304
    • View Profile
on: September 16, 2018, 04:17:54 AM
1.1.0
  • Fixed: Vanilla exploit that allowed to build turrets with any (but usually 0) amount of ingredients
  • Added: Now when research process of player-made turrets produces a turret, mod will ensure that this turret will follow the same rules as a player-made turret (so people couldn't research several player-made turrets into something that costs billions).
    The resulting turret "ingredientPrice" will be the sum of researched player-made turrets "ingredientPrice"-s.
    And "assemblyPrice" will consist of researched player-made turrets "assemblyPrice"-s + other turrets/upgrades prices.

Also, if you're using Extended Turret Factory version 0.1.1, here is the patch for it. Future versions of that mod should already include this patch.
You still need to install both Extended Turret Factory and this mod.
« Last Edit: September 16, 2018, 04:29:40 AM by Rinart73 »



Devious

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    559
  • Have you seen Rusty?
    • View Profile
    • Rusty's Universe and Community
on: September 16, 2018, 12:17:23 PM
1.1.0
  • Fixed: Vanilla exploit that allowed to build turrets with any (but usually 0) amount of ingredients
  • Added: Now when research process of player-made turrets produces a turret, mod will ensure that this turret will follow the same rules as a player-made turret (so people couldn't research several player-made turrets into something that costs billions).
    The resulting turret "ingredientPrice" will be the sum of researched player-made turrets "ingredientPrice"-s.
    And "assemblyPrice" will consist of researched player-made turrets "assemblyPrice"-s + other turrets/upgrades prices.

Boxelware should hire you!
I mentioned the component exploit to you yesterday, and you have a good fix already, again awesome work :)

Also, if you're using Extended Turret Factory version 0.1.1, here is the patch for it. Future versions of that mod should already include this patch.
You still need to install both Extended Turret Factory and this mod.



Rinart73

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    214
  • Discord: Rinart73#7304
    • View Profile
on: September 16, 2018, 02:54:54 PM
Devious, thank you for reporting this exploit so I could fix it. Well I'm still bad at C/C++ so they can't hire me :)

1.1.1
  • Fixed: Vanilla exploit that allowed to build high-rarity turrets (thanks to Hammelpilaw)
« Last Edit: September 16, 2018, 04:49:20 PM by Rinart73 »