Andrettin / Wyrmsun

Strategy game based on history, mythology and fiction
http://andrettin.github.io/
GNU General Public License v2.0
301 stars 47 forks source link

Can Affixes work as Conditions for Item Variations? Edit: Now they will #217

Closed J-Caju closed 4 months ago

J-Caju commented 4 months ago

Hey, Andrettin! It's John here.

I have been experimenting with dynamic Custom Items. In this case, an Oil Lamp, with two pairs of variations: a "Normal" and a "Mystic" variation sets.

The variations should change icons to make the lamp appear lit if equipped, or even display blue flames if the item has magical properties:

unit_custom_item_oil_lamp = {
    name = "Oil Lamp"
    parent = unit_template_item
    item_class = trinket
    icon = roman_oil_lamp_unlit
    night_sight_range_bonus = 1
    [...]

    variations = { #Makes the lamp appear lit when equipped

    #Normal Lamp
    lamp_unlit = {
        icon = roman_oil_lamp_unlit
            conditions = {
                not = {
                    upgrade = upgrade_item_prefix_fiery
                    }
                and = {
                    equipped = false
                    }
                }
            }
    lamp_lit = {
        icon = roman_oil_lamp
            conditions = {
                not = {
                    upgrade = upgrade_prefix_fiery
                    }
                and = {
                    equipped = true
                    }
                }
            }

    #Mystical Lamp
    lamp_ethereal_unlit = { #Makes the flames a sinister blue and colors the lamp silver
        icon = icon_custom_oil_lamp_ethereal_unlit
            conditions = {
                and = {
                    upgrade = upgrade_prefix_fiery
                    equipped = false
                }
            }
        }
    lamp_ethereal_lit = {
        icon = icon_custom_oil_lamp_ethereal
        weight = 1
            conditions = {
                and = {
                    upgrade = upgrade_prefix_fiery
                    equipped = true
                    [...]

Despite all my tries, I couldn't make the "Mystic Variants" work, while the "Normal Variants" function just fine.

Looking at how variations are coded for Gryphon Riders, I noticed certains Traits / "Upgrades" function as conditions. That made me believe Affixes could be conditions for item related coding - but this doesn't seem to be the case.

unit_dwarven_gryphon_rider = { [...]
        brown_hair_blue_feathers = {
            image_file = "dwarf/units/gryphon_rider_brown_hair_blue_feathers.png"
            icon = icon_dwarven_gryphon_rider_brown_hair
            weight = 4
            tags = { brown_hair }
            conditions = {
                not = {
                    upgrade = upgrade_old
[...]

I feel this might be because an Unit cannot be spawn w/o Traits. But an item can spawn w/o Affixes, as they are applied later and can bypass the conditions check(?).

So, I'd appreciate your help to know if there is any coding error from me, or if this function is not supported by the game.

P.S.: Mystic Oil Lamps actually require the "of Ethereal Vision" suffix, which I already partially converted from .Lua to C++ in my mod files. But I am citing the "Fiery" prefix here for easiness.

Andrettin commented 4 months ago

Hello! The "upgrade" condition unfortunately does not current check affixes, for technical reasons: each unit has a list of "individual upgrades", but affixes are kept track of separately, and are not added to the item's list of "individual upgrades". I've changed this now with this commit, since this seems like a good change, to do things like you mean:

https://github.com/Andrettin/Wyrmgus/commit/44e9c267506ac3234fc280775675987c219dd280

J-Caju commented 4 months ago

[...] The "upgrade" condition unfortunately does not current check affixes, for technical reasons: each unit has a list of "individual upgrades", but affixes are kept track of separately [...] - Andrettin/Wyrmgus@44e9c26

Thanks you much, Andrettin! I imagined something like this could be the case!

IIRC new Custom [Personality] Traits are automatically added to the available pool. While new Custom Affixes need to be added for each Item Type, before they're available to roll there.

I feel this idea was pushing the limits on how Variations work with items. They mostly feel meant for "Unit-Units" - despite Items being tecnically an Unit Type, right?


A cool bonus: This funtionally should enable "Items with Elemental Colors". I would like to make this addition later, so we can have things like a Red Amulet with Bonus Fire Damage / Resistance:

amulet = {
[...]   variations = {
        amulet_red_1 = {
        icon = light_red_amulet
        weight = 4
            conditions = {
                or = {
                    upgrade_prefix_fiery
                    upgrade_prefix_flaming [...]
                    }
    [...]   amulet_red_2 = {
        icon = dark_red_amulet
        weight = 2 [...]