aliens

Author Topic: [Suggestion] Unit sprite overlays  (Read 2433 times)

Offline just_dont

  • Sergeant
  • **
  • Posts: 47
    • View Profile
[Suggestion] Unit sprite overlays
« on: December 01, 2019, 05:45:20 pm »
Preface: I've honestly attempted to make a proof-of-concept PR around this idea, but after a few hours of bumbling around sources, I have to admit defeat: I'm not nearly enough of a C++ programmer to piece all the parts (rules' adjustments, script bindings, logic) together.

The rationale of this idea surfaced in a talk about driveable tanks (tanks as "armor"): one can make a custom damageUnit script for such a tank providing a "meatshield" - extra invisible HP on top of normal HP to simulate a concept of tank's bulk protecting the driver up to a point; but there is no good way to display the inner workings of the script to user and, for example, tell how much of the "meatshield" still remains.

So, I thought that it would be nice to have a way to display some sprites and/or text over the unit, driven by Yankes' script system. It could be something like this:
1) A new field inside armor definition, something like -
Code: [Select]
  overlays:
    - type: SPRITE (or TEXT)
      x: <number>
      y: <number>
      spriteSheet: <spritesheet name, only for SPRITE type>

2) When drawing unit sprite, if unit's armor have any overlays defined, an 'overlaySpriteUnit' or 'overlayTextUnit' script will be called for every overlay, with layer_index as argument (and obviously the script could get all the additional data via tags system as usual). If the script returns any valid sprite index, then a sprite with this index is taken from the spritesheet and drawn over the unit at given x/y offsets relative to unit. If the script returns invalid sprite index (e.g. <0), then nothing is drawn. Default script implementation always returns -1, not drawing anything anywhere.
Drawing text is probably out of question for the moment as Yankes' scripts don't support string type variables; although drawing numbers might be possible, by returning a number from a script. Although I'm totally not sure how to define a "no need to draw anything" return value in this case.

Potential uses:
1) Draw additional icons reflecting inner workings of other scripts/tags: if a unit has a buff or debuff given to it by scripts; if a unit has a shield remaining and approximately how much of it (in, say, XCOM: EU-styled 'pips' display)
2) Draw some flavor graphics over units! Like a "thought bubble" with curses for a unit that was hit by something invisible, or a "rape" "rage" icon for a chryssalid seeing an enemy.
3) (if displaying text) Draw any specific value from tags - exact value of shields remaining, etc. Even Jagged Alliance-style "floating damage numbers" would be possible with enough inter-script work between damageUnit script and overlays (although that would also require a way to change x/y offsets by script).

Anyways, text overlays might be too much at the moment as scripts currently can handle only numbers. But sprite overlays should be very doable.

Also, I'm not a modder and I have absolutely no idea if actual modmakers will find this worthy of use and take their time to write scripts for it (as by design it won't do anything without a custom script). So I'd very much like to hear any feedback from modmakers.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: [Suggestion] Unit sprite overlays
« Reply #1 on: December 01, 2019, 06:48:54 pm »
For long time I think abort doing some thing like this, but never have enough time to properly design it.

Some comments:

I would not link overlays with one armor, at least I would allow both, per armor and global.
Another is draw order, some times would be good to have determinism way to know it (like I did in script, `offset` that allow order scripts between mods).
Add tags to this overlays? It could be handily for script to recognise some specific usage based on some tags.
Right now I added simple string usage to scripts, for fixed text would it work fine now.
Scripts should alter `x` and `y` too, good for animations.

Offline Nord

  • Commander
  • *****
  • Posts: 1625
  • The Gate is open.
    • View Profile
Re: [Suggestion] Unit sprite overlays
« Reply #2 on: December 01, 2019, 07:47:17 pm »
Interesting, what will the game do if we order 2x2 unit to spawn 1x1 unit on death?

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: [Suggestion] Unit sprite overlays
« Reply #3 on: December 01, 2019, 08:59:36 pm »
I remember that recently Luke83 as for feature like this overlays (to display unit hp). Another place is replace Meridian stun indicators as this new functionality overlap with this.

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: [Suggestion] Unit sprite overlays
« Reply #4 on: December 01, 2019, 10:15:24 pm »
Im a modder, and i would love thos features if it can be done :P

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Unit sprite overlays
« Reply #5 on: December 02, 2019, 07:45:38 pm »
To be honest I don't see much need for the meatshield display. It would be perfectly fine if the extra HP buffer was invisible; so once I start taking visible damage, I know it's gone. I honestly wouldn't need anything else.

Just saying.