Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello Myth, I have 2 questions about CGC.

1. How do I implement ‘if this is the first card used, deal an extra 50 damage’?  I "used If user._firstFlag == true   draw 1 "from the demo to try to draw 1 card but for some reason it doesn't work in my game project

2. How to achieve the effect ‘Deal ✖10 damage to the type of attacking card used this turn’ 

Thank you

(1 edit)

Hello Gaji666,

1. You are on the right track. You need to make this check in the Damage Formula. It might look something like this:

var dmg = 10; if(!a._firstFlag){ dmg += 50; a._firstFlag == true;} ; dmg

In the above example, the Card's base DMG is 10, but if it is played first, it deals +50 DMG and then sets the first flag to true so no other cards can benefit from this effect this turn. Remember to set user._firstFlag to false in the End Turn Button Skill so that it can be available next turn.

2. Not sure I understand this effect. You are trying to deal Damage to the card itself (not currently possible in CGC) or are you trying to buff the DMG on the next type of Card played this turn?

Thanks,

MythAtelier Team

1.Thank you for your detailed response! I have understood! Also are there other useful flag words like lasttype, firstflag?

2.Sorry, my english is not very well. I apologize for any misunderstanding. I mean 10 times the number of card types used this turn on an enemy.

1. These are all local variables that we are declaring to keep track of a state. You can create as many as you want and call them whatever you want. In the Demo Project, we mostly use _firstFlag (for effects that trigger when the first Card is played) and _lethalFlag (for effects that trigger when an enemy dies). Just remember to reset these flags in the Notetags of the End Turn Skill.

2. This is a little tricky because you will need to keep track of the types of every card you play in a turn before this card is played. Luckily we are already tracking the primary Type of a Card with _lastType variable so this would just add onto that. Please add this Card Action directly under the Eval where user._lastType is set for EVERY card in your game.

Eval user._typesPlayed = user._typesPlayed || []; if(!user._typesPlayed.includes(user._lastType)) user._typesPlayed.push(user._lastType);

This creates a new array variable which contains a list of each type that has been played during a turn. It only records every new Type that is played, so if the same Type is played twice it is not added to the array. We can now use this in a damage formula like so:

var dmg = 10; user._typesPlayed = user._typesPlayed || []; dmg *= user._typesPlayed.length; dmg

This makes it such that the Damage a Card deals is equal to 10 x the number of types played before. This does not include the card itself only types played before this card is used. So, if this is the first card played then it will be 10 x 0 because no other Cards with Types have been played before this. If, however, 3 different Types have been played before this card, it will deal 10 x 3 = 30 DMG.

Lastly, we must clear out user._typesPlayed when the Turn ends so that next turn it can start over again. Please add this Eval to the Card Actions Notetag of your End Turn Skill.

Eval user._typesPlayed = undefined;

Note: this works if there is only one type per Card. If there are multiple Types, then the code will have to be a little different to track the total number of types. Let us know if you require that and we can provide that solution for you.