Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Inline Params #13488

Closed
7H3LaughingMan opened this issue Feb 2, 2024 · 3 comments
Closed

Resolve Inline Params #13488

7H3LaughingMan opened this issue Feb 2, 2024 · 3 comments

Comments

@7H3LaughingMan
Copy link
Contributor

7H3LaughingMan commented Feb 2, 2024

Some inline rolls have the ability to parse parameters in such a way where elements of the roll are replaced with a flag set on an actor or something else.

For instance, @Damage[max(2,ceil(@actor.level/2))d4[@actor.flags.pf2e.dragonAncestry.breath.damageType]] replaces the @actor.flags.pf2e.dragonAncestry.breath.damageType with whatever the flag is set to by an ActiveEffectLike rule element.

@Check[type:reflex|dc:resolve(@actor.system.attributes.classOrSpellDC.value)|basic:true] replaces the resolve(@actor.system.attributes.classOrSpellDC.value) with whatever the actor's class or spell DC is.

I am requesting to expand on this and allow any inline parameter have the option to be resolved.

For example @Template[type:@actor.flags.pf2e.dragonAncestry.breath.shape|distance:@actor.flags.pf2e.dragonAncestry.breath.distance] would replace both the @actor.flags.pf2e.dragonAncestry.breath.shape and @actor.flags.pf2e.dragonAncestry.breath.distance with whatever the flag is set to by an ActiveEffectLike rule element.

Another example is something like @Check[type:@actor.flags.pf2e.dragonAncestry.breath.saveType|dc:resolve(@actor.system.attributes.classOrSpellDC.value)|basic:true] which would resolve @actor.flags.pf2e.dragonAncestry.breath.saveType as well as the DC.

I tracked down the function in the source code to #parseInlineParams in module/system/text-editor.ts, this is responsible for parsing the inline parameters. But I am not familiar enough with Foundry VTT to implement this myself and submit a pull request. My thought process is to allow both @ and resolve() where @ is just a simple replacement and resolve() is a more complex replacement using formulas and since it's implemented in the function that parses the inline parameters it would expand this to every inline action/roll/etc.

@TikaelSol
Copy link
Collaborator

This is already doable, but not in this way, and won't be doable in this way.

We can use the ItemAlteration rule element to dynamically replace the description. This, for example, does a lot of the work needed for dragons.

{
    "itemType": "feat",
    "key": "ItemAlteration",
    "mode": "override",
    "predicate": [
        "item:slug:dragon-breath"
    ],
    "property": "description",
    "value": [
        {
            "text": "You breathe in deeply and release the energy stored within you in a powerful exhalation. Your dragon breath is a @Template[type:{actor|flags.pf2e.dragonAncestry.breath.shape}|distance:{actor|flags.pf2e.dragonAncestry.breath.distance}], and deals @Damage[max(2,ceil(@actor.level/2)){actor|flags.pf2e.dragonAncestry.breath.dieSize}[@actor.flags.pf2e.dragonAncestry.breath.damageType]] damage of a type depending on your heritage. Each creature in the area must attempt a @Check[type:{actor|flags.pf2e.dragonAncestry.breath.saveType}|dc:resolve(@actor.system.attributes.classOrSpellDC.value)|basic:true] saving throw against the higher of your class DC or spell DC. You can't use this ability again for 10 minutes; starting at level 3, you instead can't use the ability again for [[/r 1d4 #Recharge Dragon Breath]] rounds."
        }
    ]
}

@TikaelSol TikaelSol closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@7H3LaughingMan
Copy link
Contributor Author

{
    "itemType": "feat",
    "key": "ItemAlteration",
    "mode": "override",
    "predicate": [
        "item:slug:dragon-breath"
    ],
    "property": "description",
    "value": [
        {
            "text": "You breathe in deeply and release the energy stored within you in a powerful exhalation. Your dragon breath is a @Template[type:{actor|flags.pf2e.dragonAncestry.breath.shape}|distance:{actor|flags.pf2e.dragonAncestry.breath.distance}], and deals @Damage[max(2,ceil(@actor.level/2)){actor|flags.pf2e.dragonAncestry.breath.dieSize}[@actor.flags.pf2e.dragonAncestry.breath.damageType]] damage of a type depending on your heritage. Each creature in the area must attempt a @Check[type:{actor|flags.pf2e.dragonAncestry.breath.saveType}|dc:resolve(@actor.system.attributes.classOrSpellDC.value)|basic:true] saving throw against the higher of your class DC or spell DC. You can't use this ability again for 10 minutes; starting at level 3, you instead can't use the ability again for [[/r 1d4 #Recharge Dragon Breath]] rounds."
        }
    ]
}

This does work if I open the description from the actor's sheet; however, if I use the option to send the action to the chat it sends the original and not the altered description. If I open an issue regarding that, would that be something that can be fixed so it sends the altered description instead.

@pedrogrullada
Copy link
Collaborator

It will in the next release #13479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants