It is currently 29 Oct 2025, 18:13
   
Text Size

Implementing new Ability Factories and Card Support Code

Post MTG Forge Related Programming Questions Here

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

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 11:21

OK, uploading the initial implementation of AF ChooseSource and the circles and runes of protection to go with it. My testing, as far as I could do it, showed it's working fine (at least in about 20 scenarios I tested it in), but I'm sure there will be some unexpected bugs or behavior to tweak/fix.

A couple things to note that maybe someone can take a look at:
- I ran both OracleScript and SetInfoScript on the CoP/RoP scripts, but the Oracle text doesn't show up correctly for some obscure reason (for Circles of Protection there is nothing shown at all, and for Runes of Protection the only line shown is the one about Cycling, even though the full text is present in the card scripts for all cards). Could not find a reason of this strange behavior, and other cards seem to show the Oracle text just fine. :\ - FIXED!
- If you activate a CoP or a RoP card but there are no sources of the appropriate color, nothing will happen even though the effect resolves and a blank "Effect" card is created (that does nothing). Maybe it's somehow possible to make the "Effect" card not appear in case nothing is chosen? Not a big deal, but still. :) - FIXED!
- There used to be a part in the code that iterated over getSpellAbility().getTargetList() in search of referenced objects (among other routines), but it looks like getTargetList() is not available anymore in the latest implementation of AF code, not sure how useful it was before - did it return any useful information before, and if so, has it been moved elsewhere? - SOLVED!

And a little question:
Is it possible to implement Circle of Protection: Shadow without resorting to hard-coding a selection of Shadow cards? It needs to reference a creature with shadow, but I haven't found a way to limit the choices (e.g. "Choices$ Creature") to only creatures with Shadow. If there's a way to limit card/source selection by keyword ability, I'd love to know what it is, and if there's no such way, I may implement a custom parameter for AF ChooseSource for that purpose (by the way, since CoP:Shadow should be able to prevent non-combat damage, it should use AF ChooseSource, not AF ChooseCard, right?)

Anyway, I hope you enjoy using the new ability factory and find it useful! :)
- Agetian
Last edited by Agetian on 10 Nov 2012, 14:07, edited 2 times in total.
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Sloth » 10 Nov 2012, 12:22

Agetian wrote:OK, uploading the initial implementation of AF ChooseSource and the circles and runes of protection to go with it. My testing, as far as I could do it, showed it's working fine (at least in about 20 scenarios I tested it in), but I'm sure there will be some unexpected bugs or behavior to tweak/fix.
Good work Agetian. =D>

Agetian wrote:- I ran both OracleScript and SetInfoScript on the CoP/RoP scripts, but the Oracle text doesn't show up correctly for some obscure reason (for Circles of Protection there is nothing shown at all, and for Runes of Protection the only line shown is the one about Cycling, even though the full text is present in the card scripts for all cards). Could not find a reason of this strange behavior, and other cards seem to show the Oracle text just fine. :\
I've added the necessary SpellDescription to Circle of Protection: Artifacts as an example.

Agetian wrote:- If you activate a CoP or a RoP card but there are no sources of the appropriate color, nothing will happen even though the effect resolves and a blank "Effect" card is created (that does nothing). Maybe it's somehow possible to make the "Effect" card not appear in case nothing is chosen? Not a big deal, but still. :)
I think i know a way to do this. I will tinker with Circle of Protection: Artifacts some more.

Agetian wrote:- There used to be a part in the code that iterated over getSpellAbility().getTargetList() in search of referenced objects (among other routines), but it looks like getTargetList() is not available anymore in the latest implementation of AF code, not sure how useful it was before - did it return any useful information before, and if so, has it been moved elsewhere?
I think this list wasn't used.

Agetian wrote:And a little question:
Is it possible to implement Circle of Protection: Shadow without resorting to hard-coding a selection of Shadow cards? It needs to reference a creature with shadow, but I haven't found a way to limit the choices (e.g. "Choices$ Creature") to only creatures with Shadow. If there's a way to limit card/source selection by keyword ability, I'd love to know what it is, and if there's no such way, I may implement a custom parameter for AF ChooseSource for that purpose (by the way, since CoP:Shadow should be able to prevent non-combat damage, it should use AF ChooseSource, not AF ChooseCard, right?)
CoP:Shadow should use AF ChooseCard. It does not mention "source" and a creature has to be on the battlefield to be a creature, otherwise it's a "creature card".
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 12:43

Thanks, Sloth! Will now work on updating the other circles/runes to behave properly according to how you modded CoP: Artifacts (EDIT: Done!). As for CoP: Shadow, is there a way to reference only Shadow creatures with the current AF ChooseCard, or does that need to be coded in?

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Sloth » 10 Nov 2012, 13:15

Agetian wrote:Thanks, Sloth! Will now work on updating the other circles/runes to behave properly according to how you modded CoP: Artifacts (EDIT: Done!). As for CoP: Shadow, is there a way to reference only Shadow creatures with the current AF ChooseCard, or does that need to be coded in?
Use "Choices$ Creature.withShadow".
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 13:17

Awesome, will work on implementing it then!

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 13:36

OK, I added Circle of Protection: Shadow, now we've gotten a full set of CoPs and RoPs in Forge (well, except CoP: Art, but uh... that's another story :D :D).

A little note about the AI implementation in the future: I believe the AI needs to be made aware of Circles of Protection, so that, for example, the AI won't attack with a creature that already has a CoP activated on it hoping to deal damage to the player (currently it does - for instance, it has a 1/1 Raging Goblin; in the M1 phase of my opponent, I activate CoP:Red on the Raging Goblin, the AI will still attack with it despite the fact that it won't deal any damage to me). I added a little note about that to the TODO section of the AI part of AF ChooseSource for the future reference.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby friarsol » 10 Nov 2012, 14:03

Agetian wrote:- I ran both OracleScript and SetInfoScript on the CoP/RoP scripts, but the Oracle text doesn't show up correctly for some obscure reason (for Circles of Protection there is nothing shown at all, and for Runes of Protection the only line shown is the one about Cycling, even though the full text is present in the card scripts for all cards). Could not find a reason of this strange behavior, and other cards seem to show the Oracle text just fine. :\
I'll try to take a look at this later. I'm guessing the Colon is causing a problem with the script
Last edited by friarsol on 10 Nov 2012, 14:05, edited 1 time in total.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 14:04

friarsol wrote:
Agetian wrote:- I ran both OracleScript and SetInfoScript on the CoP/RoP scripts, but the Oracle text doesn't show up correctly for some obscure reason (for Circles of Protection there is nothing shown at all, and for Runes of Protection the only line shown is the one about Cycling, even though the full text is present in the card scripts for all cards). Could not find a reason of this strange behavior, and other cards seem to show the Oracle text just fine. :\
I'll try to take a look at this later. It looks like the PerSetTracking script can't see the COPs either. I'm guessing the Colon is causing a problem with the script
Umm the original problem was solved by adding a SpellDescription (Sloth solved it), the PerSetTracking script problem is likely to be a standalone problem... (though I'm not sure).

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby friarsol » 10 Nov 2012, 14:06

Ah, I'm not sure if there is a problem I just forgot to update on this machine. So ignore all that.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 14:10

Oh, OK, no problem - I tried PerSetTracking and it seems to work fine.

EDIT: One more question: I noticed that RemRandomDeck was added to most CoPs, should the same be done to Runes of Protection? I decided not to go for it without a prior consultation in case there was a reason why RoPs weren't flagged as RemRandomDeck.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 16:20

And one more question: I might also look into implementing the Java code side of Drain Life. Can someone please brief me on what is already possible and what is impossible from the Drain Life mechanics? As far as I understand, it's currently not possible to limit the X part of the mana cost to purely black mana, but I'm not sure if the remainder of the card mechanics is already doable (e.g. deal X damage and gain X life but no more than the creature's toughness / player's life). Is it possible for someone, when and if you have time, to come up with a mock script of Drain Life? Or, if everything is already doable except for the "black X mana" part of the cost and there are similar cards already implemented in Forge, can you please tell me what card scripts to look at?

- Agetian
Last edited by Agetian on 11 Nov 2012, 04:19, edited 1 time in total.
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Sloth » 10 Nov 2012, 23:23

Agetian wrote:A little note about the AI implementation in the future: I believe the AI needs to be made aware of Circles of Protection, so that, for example, the AI won't attack with a creature that already has a CoP activated on it hoping to deal damage to the player (currently it does - for instance, it has a 1/1 Raging Goblin; in the M1 phase of my opponent, I activate CoP:Red on the Raging Goblin, the AI will still attack with it despite the fact that it won't deal any damage to me). I added a little note about that to the TODO section of the AI part of AF ChooseSource for the future reference.
This has been taken care of in a more general way.

Agetian wrote:EDIT: One more question: I noticed that RemRandomDeck was added to most CoPs, should the same be done to Runes of Protection? I decided not to go for it without a prior consultation in case there was a reason why RoPs weren't flagged as RemRandomDeck.
Basically any card with Cycling is never a dead card, so i left them in random decks.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 11 Nov 2012, 04:17

Nice, thanks for clarifications, Sloth, and thanks for starting to work on the AI support!

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 14 Nov 2012, 17:09

I committed the initial implementation of the "Spend only <color> mana when paying X" limitation to SVN. Hopefully, if I didn't break anything big time with that (I shouldn't have - it's surprisingly non-invasive), it can be used as a starting point for the implementation of cards like Drain Life, Consume Spirit, and others that require colored mana spent on X mana costs. Currently it is controlled with a SVar - in particular, SVar:ColorX. For example:

SVar:XColor:B - limit the X mana cost to black mana only.
SVar:XColor:R - limit the X mana cost to red mana only.

etc.
Feel free to test and correct this implementation if necessary.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Considerations and Questions: Ability Factories

Postby friarsol » 14 Nov 2012, 18:11

Agetian wrote:I committed the initial implementation of the "Spend only <color> mana when paying X" limitation to SVN. Hopefully, if I didn't break anything big time with that (I shouldn't have - it's surprisingly non-invasive), it can be used as a starting point for the implementation of cards like Drain Life, Consume Spirit, and others that require colored mana spent on X mana costs. Currently it is controlled with a SVar - in particular, SVar:ColorX. For example:

SVar:XColor:B - limit the X mana cost to black mana only.
SVar:XColor:R - limit the X mana cost to red mana only.

etc.
Feel free to test and correct this implementation if necessary.

- Agetian
Does have the potential to do multiple colors? Like for Soul Burn
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 7 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 7 guests

Login Form