Closed phylll closed 2 years ago
So we can easily generate and display a list of a character's available weapons:
!mmm script
!mmm for weaponLabelAttr in findattr(sender, "Angriff", "Waffe")
!mmm do whisperback(getattr(sender, weaponLabelAttr))
!mmm end for
!mmm end script
weaponLabelAttr
is the internal ID for the weapon label entry in the attack table, so we can get all the weapon's other attributes by looking it up like this:
!mmm set weaponDamage = getattr(sender, findattr(sender, "Angriff", "Waffe", getattr(sender, weaponLabelAttr), "WaffeSchaden"))
Now we have a problem, though. How do we transmit the weapon ID if a chat menu can only call static commands/scripts, and MMM cannot generate scripts (if it could write into abilities rather than just attributes, we could easily generate a customize script, for example).
Building a chat menu generator that would take a particular character, pull out all the weapons and build the chat menu is easy.
Expanding the attack/defense scripts such that they take a stored weapon ID to determine the weapon details is equally easy.
But how to get the weapon ID from the chat menu into some place where it can be retrieved...?
One somewhat ugly but functional solution, at least temporarily, would be to manually create a centralized batch of config scripts per weapon that can be used for any NPC. Like this:
!rem // ~MacroSheet|npcAttackWeapon_Magierstecken
!mmm customize
!mmm set cWeaponLabel = "Magierstecken"
!mmm set cWeaponType = "Stabwaffe"
!rem // the following is generic for NPC tokens & could also be encapsulated in another config script
!mmm set cHealthAttr = "bar3"
!mmm set cEnduranceAttr = "bar2"
!mmm set cOwnID = "@{selected|token_id}"
!mmm end customize
%{MacroSheet|meleeAttack}
We would need probably two dozen of those to cover everything including natural weapons (claws etc.) that our GM's NPCs use to kill us, and occasionally the GM would have to copy & paste this for a new weapon.
Once we had those, we could build a chat menu for weapon selection like this:
!mmm script
!mmm set token = "@{selected|token_id}"
!mmm combine chat
!mmm chat: /w GM ${"&"}{template:default} {{name=${token.token_name}: Angriff mit...}}
!mmm for weaponLabelAttr in findattr(token, "Angriff", "Waffe")
!mmm chat: {{ [${token.(weaponLabelAttr)}](~MacroSheet|npcAttackWeapon_${token.(weaponLabelAttr)}) }}
!mmm end for
!mmm end combine
!mmm end script
This works already for the weapon Magierstecken
in our TEST game (all the druid tokens have access to it). Need to find a solution to deal with spaces in weapon labels, though...
I don't see a solution for weapon labels with spaces, without https://github.com/michael-buschbeck/mychs-macro-magic/issues/31 to escape/replace them somehow.
This blocks the temporary solution, too, since even a "light crossbow" won't be possible to use across different NPC character sheets this way.
We implemented an ugly but workable workaround for now in which our GM created all these scripts and renamed his NPC's weapons without using spaces.
Check if new features allow for auto-selecting only weapons if just one is available for a particular type of attack (melee, ranged) or defense. Might depend on syntax for manipulating struct
data types, but maybe not.
fafcb1638228d729f03d7cf45dd6f42af178420a (defense 1.10.0
) automates defense weapon selection for standard cases:
Abwehr ohne Schild
a968d48f9dce2e461a6e1f96f6c3fa18be120a9a (meleeAttack 1.12.0
) simply picks the only melee attack weapon if there is just one. Since ranged attack weapons need more information (ranges, a place to find the number of ammunition left), no further default behavior in rangedAttack
so far.
Generating selection menus requires that for each menu item, a separate customize
script is available and assigned. For players, given the problem with spaces identified above, I'm leaving this to everyone's own initiative and liking.
So there is another idea. MMM scripts can write attributes, and attributes can contain executable user controls of the ?{...}
variety. Every player's autorun script could generate a set of weapons selector dropdowns this way and store them in an attribute used by the respective attack script to ask the player to select their weapon of choice. Would relieve us of the need for manually maintained config scripts per weapon if a single weapon identifier would be sufficient to grab all the weapon info -- and since some weapons have quite a few complicated pieces of data attached to them, this might work
/dev/mgd/weapons-selectors has the beginnings of an implementation:
buildWeaponSelector
puts together three separate Roll20 weapons selector dropdowns for defense, melee and ranged attacks, and stores them in the linked character's attributes m3mgd_defense_weapon_selector
, m3mgd_melee_weapon_selector
and m3mgd_ranged_weapon_selector
. For generic NPCs, this means that you only need to select a random token based on that generic NPC sheet, and the sheet will get its weapon selector attribute.weaponType
according to the lists of valid weapon types. For ranged attack weapons, the code returns a list including the type, low/mid/far range and a standard name for an ammunition attribute.TODO:
Per bfb57bc3971ae0b0c0d8cf1c3120ec15cf951607, there is a better system of weapons selection implemented that does not need selector attributes in every character sheet. All the above-described functionality is available, except for the automatic check for (N)PC sheets if ranged attack ammunition attributes are present. charCombatValidator
could easily expand in that direction, though.
Ready to close with next PR.
Instead of requiring an individual config script per weapon, it would be much easier -- in particular for the busy GM with his hordes of NPCs -- if there was a generic weapon selection script that could be called for any token/character sheet. It would
Barbarian 2
may have already lost his battleaxe even though it would still be listed in theGeneric Barbarian
character sheet, as indicated by an appropriate status marker);