Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

[BombasticPerks] A new playstyle perk: Enchanting Master

Open PipeYume opened this issue 1 year ago • 2 comments

Summary

Mods "[BombasticPerks] A new playstyle perk: Enchanting Master"

Purpose of change

Enchanting Master will get a spell to enchant the weapon you wield.

After using 500 Mana, you can choose from three enchantments. Most of enchantments have limited trigger counts.

The names and descriptions of these enchantments are from another my favorite game Shattered Pixel Dungeon. https://pixeldungeon.fandom.com/wiki/Shattered_Pixel_Dungeon/Enchantments_%26_Glyphs

"Blazing: This enchantment causes flames to spit forth from a weapon, burning enemies and terrain alike.",
"Chilling: Enemies struck with this enchantment are chilled, slowing their movement and attacks.",
"Shocking: Electricity arcs from a shocking weapon, dealing extra damage to all nearby enemies.",
"Kinetic: When an enemy is killed with a kinetic weapon, any excess force is stored in the weapon and will be applied to the next successful attack.",
"Projecting: With this enchantment melee weapons will gain extra reach.",
"Lucky: This powerful enchantment increases the fortune of whoever wields it. Enemies which are killed with a lucky weapon have a chance to drop extra loot.",
"Grim: This powerful enchantment possesses the power to instantly execute an enemy (deal damage equal to 90% of its hp.). The effect is more likely to occur the weaker the enemy is.",
"Vampiric: This powerful enchantment leeches life force from enemies with each blow, funneling it back into the wearer.",
"Corrupting: This powerful enchantment possesses the ability to turn enemies to your will. When an enemy is killed with this weapon, there is a chance they will become corrupted instead of dying.",
image image image image

Describe the solution

  • Use flag to add suffixes/prefixes to item names.

With blazing enchantment, the name of an item can be converted to item name (Blazing)

  {
    "id": "ITEM_ENCHANTMENT_BLAZING",
    "type": "json_flag",
    "info": "<color_pink>Blazing Enchantment</color>",
    "item_suffix": " (Blazing)"
  }

When loading flags, item_suffix and item_prefix were added.

In item.cpp, I use prefix_tags_cache and suffix_tags_cache to store prefix/suffix flags. (May be faster then iterate all item flags and type flags and inherited flags every time to get all prefix/suffix flags in item_tname.cpp) then I update prefix_tags_cache and suffix_tags_cache by update_prefix_suffix_flags function when set_flags, unset_flags, update_inherited_flags and initializing item are called.

In the item_tname.cpp, CUSTOM_ITEM_PREFIX and CUSTOM_ITEM_SUFFIX segments were added to display the prefix and suffix. I placed them around TYPE and CATEGORY (hoping this order is appropriate).

Also, I made some other changes:

  • add an condition "u_exists", "npc_exists" to check whether alpha/beta talker is null in a dialogue This is because I observed that when I kill a monster and a spell in "hit_you_effect" is cast, if the effect of that spell is EOC, the alpha talker of this EOC becomes null since that monster does not exist.

  • add a new u_val: u_val('count'), which returns the count of an item talker. By this, I can avoid enchanting multiple items at the same time.

  • let run_eoc_selector support the inline eoc as a entry

Describe alternatives you've considered

Testing

Additional context

It may be necessary to consider the balance issue(

In the future, more enchantments will be added (maybe including the enchantments of the item you wear).

PipeYume avatar Feb 11 '24 20:02 PipeYume

As andrei mentioned this will need an in repo use case, the example is helpful but it really needs something actually making use of this feature not just an example.

Maleclypse avatar Feb 16 '24 05:02 Maleclypse

Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details.

Click to expand
  • You're not sure who orders takeout when the world's ending, but that doesn't matter. Evacuation doesn't matter. Nothing, indeed, matters, save for safely delivering your precious cargo to its destination: a remote mansion. May Foodperson watch over you, soldier.

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

github-actions[bot] avatar Feb 23 '24 04:02 github-actions[bot]