In this lesson, we will be looking at the process of creating custom item cards and using them in Hero Realms Lua games. This lesson will flow very similarly to lesson #2 because items and action cards are very similar. They both get played from the hand and go to the discard pile after play. The only difference is how they are implemented. Item cards are typically only starter/treasure cards and actions can be both starters and available to purchase in the market deck. Of course, this is just by design and not a hard fast rule.

The premade Lua file for this lesson can be found at the link below. You can use it to start fresh or to add the custom item card portion to one of your existing scripts. The comments on the file have been repointed again to focus on the custom item card so if you need more detail on a section without comments, it’s probably covered in one of the previous lessons. Since items/actions are similar, this lesson will also cover how to give custom cards ally abilities as well as trigger them on other cards.

Designing the Item Card

The only thing visually different about an item card vs an action card is what displays at the top of the card saying “Item” instead of “Action.” So you can use the same process of taking an example card from the Lua doc and reworking it with the card designer (Covered in lesson #2) to fit what you are trying to make. For this lesson, I once again started with this because I wanted the 3 vertical row layout to use with the ally abilities.

Accounting for Ally Abilities

When picking a card frame to use, you should pick one that supports the card having a faction so the faction icon displays on the card. If you don’t, the card will still work but players won’t know about it. You can find the ones to use in the Lua doc in the frames section. There are more than just these but I wanted to point out that items=actions when it comes to frames.

  • frames/HR_CardFrame_Action_Guild 
  • frames/HR_CardFrame_Action_Imperial 
  • frames/HR_CardFrame_Action_Necros 
  • frames/HR_CardFrame_Action_Wild 

Here is the layout portion of the Lua file. There is not a ton of difference here than for the custom action except for the “cardTypeLabel” which sets up the top part of the card to say “Item.”

Getting the Item to Function

For this lesson, the result of all of that layout code looks like this. It shows the item label correctly and the guild faction color/icon is displayed on the card. The next step is to handle the functionality of the card.

  • The on-play effect (Gain 4 combat)
  • The Imperial ally ability (Gain 5 health)
  • The Necros ally ability (Draw a card)
  • The ability to trigger other Guild ally abilities (Since it is a Guild faction card)

Below is the card definition for the custom item. You will notice this time the function to create the card is “createItemDef” instead of “createActionDef.” This is so the game engine knows it is an item and it will work alongside any other abilities/buffs that interact with items. The “cardTypeLabel” is once again set to say “Item” for display purposes. The types array has “itemType” inside so that will show up in the game to the right of the card when someone clicks on the card to see more detail. Doing this also sets up more type-specific handling when other cards reference items. Lastly, the factions array has “guildFaction” in it and that is what tells the game engine that this card belongs to the guild faction. It will now trigger guild ally abilities on other cards.

Now to set up all of the abilities for the card. Below you can see 3 different abilities with different triggers and effects. Cards and theoretically have an infinite number of abilities but it gets messy quick. Just make sure each one has its own unique ID. Also, if any of the abilities have a “sacrificeSelf” cost, the entire card gets sacrificed not just the ability so keep that in mind when designing your cards. The first ability here is the main ability, it is triggered every time the card is played. The second ability requires an Imperial faction (see the allyFactions array) card in pay to trigger but will automatically trigger when that criterion is met. By the Hero Realms Rulebook, gaining health is mandatory so that is why this ability is an auto trigger and not a UI trigger like the third ability. For the third ability, you need a Necors faction (see the allyFactions array) card in play with it to trigger but it is a UI trigger so the player can decide when to activate it.

The Final Steps

The card’s visual design and function are now complete. The last two steps are to declare the new item card definition in the game setup like this (this is the case for any new card.)

Lastly, add the card to a player’s starting deck like we did for the action card.

You can now run the Lua script and see your new item card in action. As always, feel free to reach out with any questions and I hope to see you back for Lua Lesson #4

Leave a comment

Trending

A WordPress.com Website.