Tooltip Renders Default Values for per_buff_memory_declaration

Published on Sunday, August 27, 2023 By Volt_Cruelerz In Sins II Bug Reports

I'd previously mentioned this to jseward on discord, but figured I ought to make a post here as well, if only for bookkeeping.

In playing around with attempting to improve tooltips for missiles (eg modding them to display their damage, penetration, and lifetime) and Warpath (display how many stacks you have), I believe I stumbled across a bug.

Below, you'll see what is otherwise a standard missile from a level 1 Marza, modded to list those three traits in its tooltip:

Here's what was added to standard_torpedo.buff:

{
    "gui": {
        "hud_icon": "trader_missile_weapon_damage_0_research_subject_hud_icon",
        "name": "weapon_tag_name.missile",
        "is_visible_within_unit_tooltip": true,
        "tooltip_line_groups": [
            {
                "lines": [
                    {
                        "label_text": "tooltip.ability.impact_damage",
                        "value_id": "damage_value",
                        "value_float_format": "one_decimal_place"
                    },
                    {
                        "label_text": "tooltip.ability.armor_penetration",
                        "value_id": "hull_armor_penetration_value",
                        "value_float_format": "no_decimal_place"
                    },
                    {
                        "label_text": "tooltip.ability.duration",
                        "value_id": "duration_value",
                        "value_float_format": "one_decimal_place"
                    }
                ]
            }
        ]
    }
}

which should have referenced the unmodified data source...

{
    "version": 0,
    "per_buff_memory_declaration":
    {
        "float_variable_ids": [
            "damage_amount",
            "duration_amount",
            "hull_armor_penetration_amount"
        ]
    },
    "action_values": [
    {
        "action_value_id": "damage_value",
        "action_value":
        {
            "transform_type": "current_buff_memory_value",
            "memory_float_variable_id": "damage_amount",
            "values": [1.0]
        }
    },
    {
        "action_value_id": "duration_value",
        "action_value":
        {
            "transform_type": "current_buff_memory_value",
            "memory_float_variable_id": "duration_amount",
            "values": [1.0]
        }
    },
    {
        "action_value_id": "hull_armor_penetration_value",
        "action_value":
        {
            "transform_type": "current_buff_memory_value",
            "memory_float_variable_id": "hull_armor_penetration_amount",
            "values": [1.0]
        }
    }]
}

I believe that should have displayed the values of 22.8/200/18, but instead displayed 1/1/1. I assume this is due to the tooltip getting set on unit creation or something, before the values are initialized by the weapon's torpedo_firing_definition code, thus leading to it rendering the defaults (and I have confirmed it's the default values that render by setting them to other values, like 11).

It's possible that I'm misunderstanding how per_buff_memory_declaration is to be referenced in the gui definition as there were no examples of it, but this felt like a bug.