Page 2 of 2

Re: spDamageTgt - enhanced damage spell code

PostPosted: 20 Oct 2009, 19:28
by mtgrares
Very impressive stuff. (I only understand about half of of it, lol.) I bow to the script king, King Rob. :D

Re: spDamageTgt - enhanced damage spell code

PostPosted: 21 Oct 2009, 06:22
by Sloth
Rob Cashwalker wrote:But the great part of the structure is that we don't necessarily need to fully support Snow Mana (though I just saw the title of your post before clicking in to this one) or Splice onto Arcane in order for them to be somewhat relevant at some level.
That's right: In quest mode Skred and Ire of Kaminari might be playable, if you're lucky enough to get some support cards (since burn is always powerful in limited). But in a generated Deck the probability that Skred is useful is almost nil.

I also have a feature request rob: I found some cards that count cards of the targeted player like Storm Seeker and Chaotic Backlash. Is it possible for you to add TgtCtrl, InTgtYard, InTgtHand as locations?

Re: spDamageTgt - enhanced damage spell code

PostPosted: 22 Oct 2009, 14:13
by Rob Cashwalker
No, I don't think it would work, because the target isn't chosen for the AI until after the count is executed.

There's a similar logical order problem with spells that deal damage to a target creature equal to its own power or toughness...

Count$ is intended for counting all instances of a criteria in the game state. To handle variables based on target would require not just a different syntax of the string, but also a new xCount function to handle the extra parameters for the target card and target player. Then the AI would need to pre-process some of the Count$ parameter string in order to know the difference, so that it could pick the target ahead of the function call. (the result of the Count$ is used for the target selection)

Nothing terribly complicated I guess, but when I considered it during my code writing, I ignored the effect in order to finish off the more popular variations.

I also have another similar problem associated with converting the spDraw keyword, because the AI should take into account the drawback of the spell. (like damage/life-loss might kill itself, or draw too many cards over 7) But during the AI decision code, I don't want to start parsing for those variations of the drawback string, which may involve an X variable before the AI has chosen any conditions in order for X to have value.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 23 Oct 2009, 06:05
by Sloth
OK Rob.

Another Thing: At the moment there is no card that uses the locations OppCtrl, InOppYard, InOppHand for count$. I think the only cards that could use OppCtrl are cards that only target opponents like Eternal Flame and Jovial Evil. (the other locations are not usable on any card).

So is it possible to have the keyword spDamageTgtO (O for Opponent).

spDamageTgtO could also be used for some simple cards like Burning Fields and Searing Flesh, as well as some not entirely accurately implemented cards like Kiss of Death, Stolen Grain and Vampiric Touch.

To be honest I just mentioned all cards (7) that could use the keyword spDamageTgtO, so it's not really that important.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 23 Oct 2009, 14:03
by Rob Cashwalker
Sloth wrote:OK Rob.

Another Thing: At the moment there is no card that uses the locations OppCtrl, InOppYard, InOppHand for count$. I think the only cards that could use OppCtrl are cards that only target opponents like Eternal Flame and Jovial Evil. (the other locations are not usable on any card).

So is it possible to have the keyword spDamageTgtO (O for Opponent).

spDamageTgtO could also be used for some simple cards like Burning Fields and Searing Flesh, as well as some not entirely accurately implemented cards like Kiss of Death, Stolen Grain and Vampiric Touch.

To be honest I just mentioned all cards (7) that could use the keyword spDamageTgtO, so it's not really that important.
Ahh, now we're getting somewhere. I could just as easily look for "Opp" in place of Tgt, and make a slight modification to the AI.
On the other hand, the AI for "damage target player" will always choose the opponent. However, I realize I do need to make a change - the AI logic waits until the player is half-dead before pointing burn directly at it, which is sensible for deciding whether to target a creature OR a player, but if it's a player-only spell, then it shouldn't wait....

Re: spDamageTgt - enhanced damage spell code

PostPosted: 30 Nov 2009, 21:25
by Rob Cashwalker
I just committed a change in CardFactory for spDamageTgt. As I realized above, a player-only spell shouldn't require the human's life to be under 10.
Code: Select all
               if (TgtPlayer[0] == true)
                {
                   setTargetPlayer(Constant.Player.Human);
                   return true; //shouldTgtP();
                }
I was also looking through the cards.txt for the latest release. I see that the simple damage cards are still using the older keyword. I revised them to use the new one, so we can remove the now redundant code.

Code: Select all
Flame Jet
1 R
Sorcery
no text
spDamageTgtP:3
Cycling:2

Ember Shot
6 R
Instant
Draw a card.
spDamageTgtCP:3
Cantrip

Zap
2 R
Instant
Draw a card.
spDamageTgtCP:1
Cantrip

Breath of Malfegor
3 B R
Instant
no text
spDamageTgtP:5

Flame Javelin
2/R 2/R 2/R
Instant
no text
spDamageTgtCP:4

Lava Axe
4 R
Sorcery
no text
spDamageTgtP:5

Bee Sting
3 G
Sorcery
no text
spDamageTgtCP:2

Cinder Storm
6 R
Sorcery
no text
spDamageTgtCP:7

Fire Ambush
1 R
Sorcery
no text
spDamageTgtCP:3

Ghostfire
2 R
Instant
no text
spDamageTgtCP:3
Ghostfire is colorless.

Lightning Blast
3 R
Instant
no text
spDamageTgtCP:4

Scorching Spear
R
Sorcery
no text
spDamageTgtCP:1

Searing Wind
8 R
Instant
no text
spDamageTgtCP:10

Tarfire
R
Tribal Instant Goblin
no text
spDamageTgtCP:2

Unyaro Bee Sting
3 G
Sorcery
no text
spDamageTgtCP:2

Lava Spike
R
Sorcery
no text
spDamageTgtP:3

Lightning Bolt
R
Instant
no text
spDamageTgtCP:3

Volcanic Hammer
1 R
Sorcery
no text
spDamageTgtCP:3

Shock
R
Instant
no text
spDamageTgtCP:2
Dennis - I made the changes in my freshly updated SVN copy should I go ahead and commit it?

Re: spDamageTgt - enhanced damage spell code

PostPosted: 30 Nov 2009, 21:38
by DennisBergkamp
Nice! Sure, go ahead, if stuff stops working for one reason or another we can always revert it. Or better yet, just fix it :)

Re: spDamageTgt - enhanced damage spell code

PostPosted: 01 Dec 2009, 18:19
by Rob Cashwalker
I put in a CardFactory with the spDamageP and spDamageCP keywords commented, a CardFactoryUtil with spellAbility_spDamageP and spellAbility_spDamageCP commented.
Trying to commit cards.txt threw an error that I had to update my version with the SVN. (Busy last night huh?) Then I was able to commit it.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 29 Dec 2009, 20:10
by Rob Cashwalker
I added the Opp feature and added math to the Drawback X value.

I was able to commit the source code no problem, but cards.txt was giving me issues. here's the change:

cards.txt
Code: Select all
Burning Fields
4 R
Sorcery
no text
spDamageTgtOpp:5

Searing Flesh
6 R
Sorcery
no text
spDamageTgtOpp:7

Kiss of Death
4 B B
Sorcery
no text
spDamageTgtOpp:4:Drawback$YouGainLife/4:Kiss of Death deals 4 damage to target opponent. You gain 4 life.:Kiss of Death - deals 4 damage; you gain 4 life.

Stolen Grain
4 B B
Sorcery
no text
spDamageTgtOpp:5:Drawback$YouGainLife/4:Stolen Grain deals 5 damage to target opponent. You gain 5 life.:Stolen Grain - deals 5 damage; you gain 5 life.

Vampiric Touch
2 B
Sorcery
no text
spDamageTgtOpp:2Drawback$YouGainLife/2:Vampiric Touch deals 2 damage to taqrget opponent and you gain 2 life.:Vampiric Touch - deals 2 damage and you gain 2 life.

Eternal Flame
2 R R
Sorcery
no text
spDamageTgtOpp:Count$NumTypeYouCtrl.Mountain:Drawback$DamageYou/X.HalfUp:Eternal Flame deals X damage to target opponent where X is the number of mountains you control. It deals half X damage, rounded up, to you.:Eternal Flame - deals X damage and half X damage to you.

Jovial Evil
2 B
Sorcery
no text
spDamageTgtOpp:Count$NumTypeWhiteOppCtrl.Creature/Twice:Jovial Evil deals X damage to target opponent, where X is twice the number of white creatures that player controls.:Jovial Evil - deals twice X damage.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 29 Dec 2009, 20:39
by DennisBergkamp
Ok, added new cards, deleted duplicates and committed.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 29 Dec 2009, 21:08
by Chris H.
Thank you, Rob. 8)

Re: spDamageTgt - enhanced damage spell code

PostPosted: 01 Jan 2010, 18:24
by Chris H.
I have been busy moving cards from code to keyword. I am down to the last two that I can find. Spark Spray appears to work correctly and I plan to merge this into the SVN:

Code: Select all
Spark Spray
R
Instant
no text
spDamageTgtCP:1:Spark Spray deals 1 damage to target creature or player.
:Spark Spray - deals 1 damage
Cycling:R
`
I was curious to see if I could also change this one over:

Code: Select all
Sunlance
W
Sorcery
no text
spDamageTgtC:3:Creature.nonWhite:Sunlance deals 3 damage to target nonwhite creature.:Sunlance - deals 3 damage
`
Sunlance will do 3 damage to target creature and will not restrict this to non-White creatures. I suspect that the spDamageTgt keyword does not handle the restrictions that I find in spDestroyTgt.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 02 Jan 2010, 02:54
by Rob Cashwalker
Um... no, that is not a feature. I did consider it.

When/if I revise the entire keyword system, I'll make sure to include a target restriction clause to just about everything.

Re: spDamageTgt - enhanced damage spell code

PostPosted: 02 Jan 2010, 12:10
by Chris H.
Rob Cashwalker wrote:Um... no, that is not a feature. I did consider it.

When/if I revise the entire keyword system, I'll make sure to include a target restriction clause to just about everything.
`
That is OK. I have been able to move several dozen of the older cards from code over to keyword status and the old code has been commented out. :)