It is currently 27 Apr 2024, 11:24
   
Text Size

spDamageTgt - enhanced damage spell code

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: spDamageTgt - enhanced damage spell code

Postby mtgrares » 20 Oct 2009, 19:28

Very impressive stuff. (I only understand about half of of it, lol.) I bow to the script king, King Rob. :D
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: spDamageTgt - enhanced damage spell code

Postby Sloth » 21 Oct 2009, 06:22

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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 22 Oct 2009, 14:13

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby Sloth » 23 Oct 2009, 06:05

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 23 Oct 2009, 14:03

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....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 30 Nov 2009, 21:25

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?
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby DennisBergkamp » 30 Nov 2009, 21:38

Nice! Sure, go ahead, if stuff stops working for one reason or another we can always revert it. Or better yet, just fix it :)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 01 Dec 2009, 18:19

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 29 Dec 2009, 20:10

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby DennisBergkamp » 29 Dec 2009, 20:39

Ok, added new cards, deleted duplicates and committed.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: spDamageTgt - enhanced damage spell code

Postby Chris H. » 29 Dec 2009, 21:08

Thank you, Rob. 8)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: spDamageTgt - enhanced damage spell code

Postby Chris H. » 01 Jan 2010, 18:24

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.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: spDamageTgt - enhanced damage spell code

Postby Rob Cashwalker » 02 Jan 2010, 02:54

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: spDamageTgt - enhanced damage spell code

Postby Chris H. » 02 Jan 2010, 12:10

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. :)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 120 guests


Who is online

In total there are 120 users online :: 0 registered, 0 hidden and 120 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 120 guests

Login Form