Author Topic: [DONE][Suggestion] Sell/Buy price coefficients for items  (Read 3966 times)

Offline Ethereal

  • Commander
  • *****
  • Posts: 672
    • View Profile
[DONE][Suggestion] Sell/Buy price coefficients for items
« on: March 15, 2024, 06:32:15 am »
sellPriceCoefficient:

I was trying to use the current implentation of sellPriceCoefficient and I was running into the exact same problem as stated here:
I can adjust the Sellprices but this largely effects the manufacturing money making machine I balanced the economy in Hardmode Expansion around.

May I suggest to add a nested list, of Items to which the sellPriceCoefficient should be applied to?
Code: [Select]
sellPriceCoefficient: [100, 85, 70, 60, 50]
sellPriceCoefficientAffectedItems:
  - STR_PLASMA_PISTOL
  - STR_PLASMA_RIFLE
  - STR_HEAVY_PLASMA
  - STR_MIND_PROBE

All other Items would still have their fixed price, and if the list is empty (as by default), then the sellPriceCoefficient would be applied to all available items.

This would this awesome feature for me exactly the thing I need to balance the economy in Hardmode Expansion for lower diffciulty levels (my goal is to enable players to also enjoy lower diffciculties, in case they wanna do so.)
I basically only want to have the sellPriceCoefficient effect collectable loot from aliens.

Hope this is going to be heared, you guys are awesome :)

hellrazor, I completely agree, but it would be better if such a modifier for the sale and purchase price, depending on the difficulty level, was a property of the item itself. That is, there is a global modifier “sellPriceCoefficient”, and there is an individual modifier in the item itself. Plus "buyPriceCoefficient".

As long as I can set it up so only a selections of Items gets the "sellPriceCoefficient", I would not mind this solution either.

Suggest entering "sellPriceCoefficient" and "buyPriceCoefficient" for items and ships.  :)
« Last Edit: March 20, 2024, 12:37:40 am by Ethereal »

Offline hellrazor

  • Commander
  • *****
  • Posts: 2025
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [Suggestion] Sell\Buy price coefficients for itmes.
« Reply #1 on: March 20, 2024, 03:15:32 pm »
Thanks mate for moving this over to here :)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #2 on: April 03, 2024, 08:53:22 am »
Removed offtopic posts.

Todolisted.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #3 on: April 28, 2024, 05:27:28 pm »
We have agreed with Yankes to skip this solution... and introduce Y-scripting for sell-prices (and later for buy-prices) directly instead.

Once implemented, I will paste a sample Y-script for hellrazor here.

Offline hellrazor

  • Commander
  • *****
  • Posts: 2025
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #4 on: May 14, 2024, 03:13:38 pm »
We have agreed with Yankes to skip this solution... and introduce Y-scripting for sell-prices (and later for buy-prices) directly instead.

Once implemented, I will paste a sample Y-script for hellrazor here.

Looking forward towards this ;) Thank you both for all the hard work.

Offline Yankes

  • Commander
  • *****
  • Posts: 3293
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #5 on: May 14, 2024, 03:57:29 pm »
This should be available in OXCE 7.12.6

Code: [Select]
extended:
  scripts:
    sellCostItem:
      - offset: 12
        code: |
          var ptr Time t;
          geoscape_game.getTime t;
          t.getDaysPastEpoch cost_current;
          mod cost_current 100;
          add cost_current 100;
          return cost_current;
This is very dumb version that set all items cost to values from 100 to 200 based on current day.

Offline hellrazor

  • Commander
  • *****
  • Posts: 2025
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #6 on: May 15, 2024, 08:45:09 am »
This should be available in OXCE 7.12.6

Code: [Select]
extended:
  scripts:
    sellCostItem:
      - offset: 12
        code: |
          var ptr Time t;
          geoscape_game.getTime t;
          t.getDaysPastEpoch cost_current;
          mod cost_current 100;
          add cost_current 100;
          return cost_current;
This is very dumb version that set all items cost to values from 100 to 200 based on current day.

Thanks. Is it possible to define the price reduction effect, for only a specific list of items (defined via strings in the script), and sell price reduction is then handled depending on difficultylevel, via a defined percentage?

Is there any description or help in regard of scripting parameters and valid syntax??

Offline Yankes

  • Commander
  • *****
  • Posts: 3293
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #7 on: May 15, 2024, 11:17:55 am »
Basic info about script is available here: https://www.ufopaedia.org/index.php?title=Script_(OpenXcom)

For functionality, yes, you can return arbitrary price, this mean disable default scaling, add custom scalling is possible too.
Scripts hooks itself expose:

`cost_current` -> current cost, after difficulty coefficient and possible change by other scripts hooks
`cost_base` -> original cost from item ruleset
`difficualty_coefficient` -> difficulty multiplier,

to have always control over default behavior.

[ps]

I see I make typo in `difficualty_coefficient`, I probaby soon push new version that will fix it as there is not lot of mods that depend on this.

Offline hellrazor

  • Commander
  • *****
  • Posts: 2025
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #8 on: May 15, 2024, 11:47:10 am »
Basic info about script is available here: https://www.ufopaedia.org/index.php?title=Script_(OpenXcom)

For functionality, yes, you can return arbitrary price, this mean disable default scaling, add custom scalling is possible too.
Scripts hooks itself expose:

`cost_current` -> current cost, after difficulty coefficient and possible change by other scripts hooks
`cost_base` -> original cost from item ruleset
`difficualty_coefficient` -> difficulty multiplier,

to have always control over default behavior.

[ps]

I see I make typo in `difficualty_coefficient`, I probaby soon push new version that will fix it as there is not lot of mods that depend on this.

Thanks but: https://www.ufopaedia.org/index.php?title=Script_(OpenXcom) is not really understandable for me.
User Perspective vs Programmer perspective I guess.

Offline Ethereal

  • Commander
  • *****
  • Posts: 672
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #9 on: May 18, 2024, 10:55:53 am »
is not really understandable for me.
User Perspective vs Programmer perspective I guess.

Yes, scripts in general are an extremely inconvenient thing. I have always advocated converting them into options built into the main game code. This will not change anything for the player, but will greatly help novice modmakers. Experienced - no difference. Well, they’ll growling, which is inconvenient, and then they’ll convert the script into hexadecimal code. To make it even more convenient.
« Last Edit: May 18, 2024, 10:57:45 am by Ethereal »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #10 on: May 18, 2024, 11:02:20 am »
Both novice and experienced modders have been requesting scripting functionality like crazy.

The consequences were known from the beginning and were very clearly communicated.

There is no way back.

You have what you asked for.
(And I don't mean you personally, but you as a modding community)

Offline Ethereal

  • Commander
  • *****
  • Posts: 672
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #11 on: May 18, 2024, 11:14:57 am »
There is no way back.

I agree, no. But there is a path in any other direction, and we happily march in all directions at the same time.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #12 on: May 18, 2024, 12:15:43 pm »
We have agreed with Yankes to skip this solution... and introduce Y-scripting for sell-prices (and later for buy-prices) directly instead.

Once implemented, I will paste a sample Y-script for hellrazor here.

Sample Y-script below and attached:

Spoiler:
extended:
  tags:
    RuleItem:
      HELLRAZOR_SUPERHUMAN_SELL_PRICE: int

  scripts:
    sellCostItem:
      - offset: 12
        code: |
          var int temp;

          geoscape_game.difficultyLevel temp;  # get difficulty
          if eq temp DIFF_SUPERHUMAN;
            item_rule.getTag temp Tag.HELLRAZOR_SUPERHUMAN_SELL_PRICE;  # custom item sell price
            if neq temp 0;
              set cost_current temp;
            end;
          end;

          return cost_current;

items:
  - type: STR_RIFLE
    tags:
      HELLRAZOR_SUPERHUMAN_SELL_PRICE: 999
  - type: STR_RIFLE_CLIP
    tags:
      HELLRAZOR_SUPERHUMAN_SELL_PRICE: 88

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #13 on: May 18, 2024, 12:20:12 pm »
screenshot

Offline Yankes

  • Commander
  • *****
  • Posts: 3293
    • View Profile
Re: [Suggestion] Sell/Buy price coefficients for items
« Reply #14 on: May 18, 2024, 12:46:18 pm »
I agree, no. But there is a path in any other direction, and we happily march in all directions at the same time.

I will simply not pollute game with hundreds configs that could even contradict each other because every one was demand by some modder.
Why not add `sellPriceCoefficient2` or `sellPriceCoefficient3`?
You wanted precise control over prices, here you have. You have near absolute control over what price are and only limits are to prevent breaking game.
If you do not want spend effort to learn basic of y-script, why we should spend our effort to fulfill your requests?

Beside any serious game engine have script capabilities.