OpenXcom Forum

Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started by: The Martian on January 27, 2022, 05:34:07 pm

Title: [DONE] Armor that doesn't use energy when walking
Post by: The Martian on January 27, 2022, 05:34:07 pm
I'm trying to create an armor that does not decrease a soldier's energy when it walks.

A unit's armor can be set to recover their entire energy the next turn using armors: recovery.energy but I need the amount of energy on the unit to hold at whatever its current energy value is when the unit steps between tiles so that it doesn't change during the current turn when walking.


I've been through the openxcom.log with verboseLogging, but haven't spotted a scripting section for when the unit walks.

I did see selectMoveSoundUnit but I don't think that is quite right, I think that one triggers when a unit is given the order to move by clicking a tile. (If I'm wrong please let me know)


Best case would probably be to set the units current energy to its last previous value every time movement occured between tiles.

Does anyone have advice for going about this?
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: ohartenstein23 on January 28, 2022, 12:14:28 am
There is no "on walking" script hook, but you could give the armor a ridiculously high bonus to total energy and full energy recovery every turn to simulate movement's energy cost not mattering.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: Yankes on January 31, 2022, 02:47:57 pm
This is hard part to add scripts as AI require to know how to handle it, if even I would allow to change cost it would be special flag on unit to give multiplier for cost, like "this unit spend 2 time more TU per tile than other units".
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: The Martian on February 05, 2022, 06:49:49 am
(Sorry about my delayed response)

There is no "on walking" script hook, but you could give the armor a ridiculously high bonus to total energy and full energy recovery every turn to simulate movement's energy cost not mattering.

Your solution is very function. (https://openxcom.org/forum/Themes/InsidiousV1-k/images/post/thumbup.gif)

The only draw back is that in my case I have a few items that use energy as part of their use cost so if I give an armor an incredibly high max energy the equipped soldier would be able to spam the item without consequence.
Code: [Select]
- type: STR_EXAMPLE_ITEM
   costUse:
     energy: 20
   flatUse:
     energy: true

This is hard part to add scripts as AI require to know how to handle it, if even I would allow to change cost it would be special flag on unit to give multiplier for cost, like "this unit spend 2 time more TU per tile than other units".

It wouldn't bother me if it was only able to be used exclusively by player controlled units.

Either by a hard restriction that the AI (Alien/Civ) units can't wear armor with this variable or just by them ignoring it when present on an armor and losing energy as they normally do when walking.

So long as X-Com Soldier's can spend 0 energy when walking while wearing this specific armor, I would be perfectly happy with it.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: Yankes on February 05, 2022, 12:55:24 pm
It wouldn't bother me if it was only able to be used exclusively by player controlled units.

Either by a hard restriction that the AI (Alien/Civ) units can't wear armor with this variable or just by them ignoring it when present on an armor and losing energy as they normally do when walking.

So long as X-Com Soldier's can spend 0 energy when walking while wearing this specific armor, I would be perfectly happy with it.
Adding more special cases between Player VS AI logic is big NO NO. One of my goal in OXCE is make game more uniform and symmetrical, beside AI need still handle correctly units under MC.

If you need only "can spend 0 energy" then this could be handled by version I suggest, multiplier for energy and TU move cost, because it is stable and AI can plan moves ahead. I will look if this is easy to implement.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: Meridian on February 05, 2022, 01:07:55 pm
Maybe I missed something obvious, but which mod are we talking about?

If this is a request for personal use modding only, then my priority for it is very low.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: The Martian on February 07, 2022, 02:31:58 pm
Adding more special cases between Player VS AI logic is big NO NO. One of my goal in OXCE is make game more uniform and symmetrical, beside AI need still handle correctly units under MC.

If you need only "can spend 0 energy" then this could be handled by version I suggest, multiplier for energy and TU move cost, because it is stable and AI can plan moves ahead. I will look if this is easy to implement.

I wasn't thinking clearly and forgot about the AI controlling the player units via MC. >_<

Your adjustable method is definitely superior and allows much more armor variety than a hard movement cost toggle on/off.


Maybe I missed something obvious, but which mod are we talking about?

If this is a request for personal use modding only, then my priority for it is very low.

The mod in question had not yet been released as it wasn't working right. . . but since using Ohartenstein23's energy solution functions well enough with standard TFTD I'll post it:
[OXCE][UFO][TFTD][ARMOR] Ride Armor (https://openxcom.org/forum/index.php/topic,10360.0.html)

I'm still interested in updating it with a method that completely prevents energy loss from occurring when moving.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: Yankes on March 07, 2022, 01:17:14 am
In OXCE 7.5.7 you can have:
Code: [Select]
armors:
  - type: STR_NONE_UC
    moveCost:
      basePercent: [100, 100]
Where you can alter cost multiplier for armor move cost.
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: The Martian on March 07, 2022, 01:08:01 pm
That is great news! (https://openxcom.org/forum/Themes/InsidiousV1-k/images/post/thumbup.gif)

I see that OXCE 7.5.7 (https://lxnt.wtf/oxem/builds//Extended/Extended-7.5.7-853b42353-2022-03-06-bionic-x86_64.7z) is one of the 'bleeding edge OXCE nightly preview builds (https://lxnt.wtf/oxem/#/Extended)'.

Where can I find documentation on the use of the moveCost: settings, I tried searching the forum and the UFOpaedia Ruleset Reference Nightly (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)) but nothing came up. (Which is not surprising as it is a preview build)

From reading it I'm guessing that moveCost: basePrecent: [100, 100] works something like basePercent: [TU%, ENERGY%].
Title: Re: Armor that doesn't use energy when walking (Via scripting or other methods)
Post by: Yankes on March 07, 2022, 02:36:56 pm
Yes, exactly. I used less descriptive fields as we can only use TU and ENERGY but I plan add lot more configs in future for different move modes.