[CODE] Reveal and Scry

All code submission.
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

[CODE] Reveal and Scry

Post by excessum »

My IP has been banned for some random erroneous infraction and I have to resort to using a proxy IP which prevents the uploading of files so the raw source code is listed at the bottom of the post. Please post a reply if you cannot figure out how to use it.

This is a working workaround for the Reveal and Scry (and probably Fateseal) mechanics, minus the actual revealing part since it would involve messing with the GUI. There is a lot of code-fu involved to minimise unnecessary triggers, mainly hand->graveyard. The exile->somewhere and library->exile/hand triggers are liberally used since there are no cards in recent memory that checks those triggers anyway. When targeted cards are "moveto"-ed zones, they should not allow for interrupts but the engine does not set this by default so you CAN interrupt the move to the top/bottom of library and mess them up.

Anyway, the mechanics involved in the example card code given are pretty involved so it is best for me to entertain queries rather than try to explain everything here.

Code: Select all

[card]
name=Temple of Abandon
auto=tap
auto={T}:add{R}
auto={T}:add{G}
auto=all(*[pos=1]|mylibrary) moveto(exile) and!( transforms((,newability[choice name(top of library) moveto(mylibrary)],newability[choice bottomoflibrary])) oneshot )!
text=Temple of Abandon enters the battlefield tapped. -- When Temple of Abandon enters the battlefield, scry 1. (To scry 1, look at the top card of your library, then you may put that card on the bottom of your library.) -- {T}: Add {R} or {G} to your mana pool.
type=Land
[/card]
[card]
name=Magma Jet
target=creature,player
auto=damage:2 
auto=all(*[pos=2]|mylibrary) moveto(myhand)
auto=name(scry 2) target(<2>*[pos=2]|myhand) moveto(exile) and!( transforms((,newability[choice name(top of library) moveto(mylibrary)],newability[choice bottomoflibrary])) oneshot )!
text=Magma Jet deals 2 damage to target creature or player. -- Scry 2. (To scry 2, look at the top two cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)
mana={1}{R}
type=Instant
[/card]
[card]
name=Grisly Salvage
auto=if type(*[creature;land;pos=5]|mylibrary)~morethan~0 then target(*[creature;land;pos=5]|mylibrary) transforms((,newability[choice name(put into hand) moveto(myhand) && deplete:4 controller],newability[choice name(cancel) deplete:5 controller)) oneshot else deplete:5 controller
text=Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard.
mana={B}{G}
type=Instant
[/card]
[card]
name=Borborygmos Enraged
abilities=trample
auto=aslongas(land|myhand) {discard(land|myhand)}:damage:3 target(creature,player)
auto=@combatdamaged(player) from(this):all(*[pos=3]|mylibrary) transforms((,newability[if cantargetcard(land|*) then moveto(myhand) else moveto(mygraveyard)]))
text=Trample -- Whenever Borborygmos Enraged deals combat damage to a player, reveal the top three cards of your library. Put all land cards revealed this way into your hand and the rest into your graveyard. -- Discard a land card: Borborygmos Enraged deals 3 damage to target creature or player.
mana={4}{R}{R}{G}{G}
type=Legendary Creature
subtype=Cyclops
power=7
toughness=6
[/card]
[card]
name=Domri Rade
auto=counter(0/0,3,loyalty)
auto={C(0/0,1,Loyalty)}:name(reveal) all(creature[pos=1]|mylibrary) moveto(myhand)
auto={C(0/0,-2,Loyalty)}:name(fight) target(creature|mybattlefield) transforms((,newability[target(other creature) dynamicability<!powerstrike eachother!>])) ueot
auto={C(0/0,-7,Loyalty)}:name(emblem) emblem transforms((,newability[lord(creature|mybattlefield) double strike],newability[lord(creature|mybattlefield) trample],newability[lord(creature|mybattlefield) opponentshroud],newability[lord(creature|mybattlefield) haste])) forever dontremove
text=+1: Look at the top card of your library. If it's a creature card, you may reveal it and put it into your hand. -- -2: Target creature you control fights another target creature. -- -7: You get an emblem with "Creatures you control have double strike, trample, hexproof, and haste."
mana={1}{R}{G}
type=Planeswalker
subtype=Domri
[/card]
[card]
name=Garruk, Caller of Beasts
auto=counter(0/0,4,loyalty)
auto={C(0/0,1,Loyalty)}:name(reveal) all(*[pos=5]|mylibrary) moveto(exile) and!( transforms((,newability[if cantargetcard(creature|exile) then moveto(myhand) else bottomoflibrary])) )!
auto={C(0/0,-3,Loyalty)}:moveto(mybattlefield) target(creature[green]|myhand)
auto={C(0/0,-7,Loyalty)}:name(emblem) emblem transforms((,newability[@movedto(creature|mystack):may moveto(mybattlefield) target(creature|mylibrary)])) forever dontremove
text=+1: Reveal the top five cards of your library. Put all creature cards revealed this way into your hand and the rest on the bottom of your library in any order. -- -3: You may put a green creature card from your hand onto the battlefield. -- -7: You get an emblem with "Whenever you cast a creature spell, you may search your library for a creature card, put it onto the battlefield, then shuffle your library."
mana={4}{G}{G}
type=Planeswalker
subtype=Garruk
[/card]

Code: Select all

CardDescriptor.h
line 50: int zonePosition;

CardDescriptor.cpp
line 15: zonePosition = 0;
line 191:
	//Position in zone for reveal
	if ( zonePosition ) {
		vector< MTGCardInstance* > zoneCards = card->currentZone->cards;
		int nZoneCards = static_cast< int >( zoneCards.size() );
		bool posFound = false;
		for ( int i = 1; i <= zonePosition; i++ ) {
			if ( zoneCards[ nZoneCards - i ] == card ) {
				posFound = true;
				break;
			}
		}
		if ( !posFound ) {
			return NULL;
		}
	}

TargetChooser.cpp
line 361:
				if ( attribute.find( "pos" ) != string::npos ) {
					cd->zonePosition = comparisonCriterion;
					continue;	//prevent "pos" from being added as a type
				}
Tacoghandi
Posts: 1197
Joined: Thu Apr 28, 2011 11:34 pm

Re: [CODE] Reveal and Scry

Post by Tacoghandi »

Ill be finally getting around to checking this out in the next couple of days. Awesome add
!!Check out My Created Sets and other Stuff!!

viewtopic.php?f=22&t=3380
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Reveal and Scry

Post by excessum »

Here are more Theros cards using the Scry mechanic. Xenagos was bugging me because of a bug in the parser with "if blah then may blah" that I had to fix in the source code. Read the Bones is an example of how to combine the multiline Scry/Reveal mechanics with other abilitiesby manipulating the stack so that the "then draw" effect resolves after the Scry. Thassa obviously requires the devotion mechanic source update and is an example of coding Scry as a triggered effect.

I have uploaded the source files that I fixed onto Google Drives. The link can be found in my forum profile.

Code: Select all

[card]
name=Xenagos, the Reveler
auto=counter(0/0,3,loyalty)
auto={C(0/0,1,Loyalty)}:name(add mana) foreach(creature|mybattlefield) ability$!choice name(add red) add{R} _ choice name(add green) add{G} !$ controller
auto={C(0/0,0,Loyalty)}:token(Satyr,Creature Satyr,2/2,red,green,haste)
auto={C(0/0,-6,Loyalty)}:all(*[pos=7]|mylibrary) moveto(exile) and!( transforms((,newability[ if cantargetcard(*[creature;land]|exile) then may moveto(myhand)])) oneshot )!
text=+1: Add X mana in any combination of Red and/or Green to your mana pool, where X is the number of creatures you control. -- 0: Put a 2/2 red and green Satyr creature token with haste onto the battlefield. -- -6: Exile the top seven cards of your library. You may put any number of creature and/or land cards from among them onto the battlefield.
mana={2}{G}{R}
type=Planeswalker
subtype=Xenagos
[/card]
[card]
name=Read the Bones
auto=life:-2
auto=ability$!choice draw:2!$ controller
auto=all(*[pos=2]|mylibrary) moveto(myhand)
auto=name(scry 2) target(<2>*[pos=2]|myhand) moveto(exile) and!( transforms((,newability[choice name(top of library) moveto(mylibrary)],newability[choice bottomoflibrary])) oneshot )!
text=Scry 2, then draw two cards. You lose 2 life. (To scry 2, look at the top two cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)
mana={2}{B}
type=Sorcery
[/card]
[card]
name=Thassa, God of the Sea
abilities=indestructible
auto=@each myupkeep:all(*[pos=1]|mylibrary) moveto(exile) and!( transforms((,newability[choice name(top of library) moveto(mylibrary)],newability[choice bottomoflibrary])) oneshot )!
auto={1}{U}:target(creature|mybattlefield) unblockable
auto=this(variable{type:manau}>4) transforms((Creature,setpower=5,settoughness=5))
text=Indestructible -- As long as your devotion to blue is less than five, Thassa isn't a creature. (Each {U} in the mana costs of permanents you control counts toward your devotion to blue.) -- At the beginning of your upkeep, scry 1. -- {1}{U}: Target creature you control can't be blocked this turn.
mana={2}{U}
type=Legendary Enchantment
subtype=God
[/card]
pankdm
Posts: 50
Joined: Tue Sep 17, 2013 6:34 am

Re: [CODE] Reveal and Scry

Post by pankdm »

I started looking at this piece of code and I am really surprised on how small is the change. Awesome!
But when revealing the card lets you see the entire library and know which cards will come next. So this looks more like a workaround.. Can it be done in the way that the cards except the first "pos" are shown from their backs?

Or probably we should think about introducing a gui for it.. I also dont want to mess with GUI, but workarounds are not great solutions
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Reveal and Scry

Post by excessum »

Any effect that "target()"s the library will force a shuffle immediately after the target is selected which is why I use so many "all()"s and "moveto"s. I only use targeting of the library directly as a last resort to avoid this extra shuffle. The annoying use of "any number of blah", "may choose a blah" and even more fancy examples (Xenagos...) means a serious amount of code-fu to ensure the choice(s) are presented. Pretty much all of the "Reveal" cards require specific effects and I have presented a number of examples that should be sufficient to code the others with some creativity...

It is possible to force the engine to only display "n" cards but it requires a massive amount of tinkering since it involves working through every #$@% layer from GameObserver down to the actual cards themselves. After displaying them correctly, comes the fun part of deciding when to revert to displaying the "hidden" cards since the effects that trigger the targeting operate off a different layer/thread. As a bonus, all the "any/may" choices still present the problem of deciding how many and which cards to send to exile/top/bottom/blah so the GUI solution is only really effective for "Scry" which I believe the current workaround is acceptable anyway.
afrikas
Posts: 3
Joined: Wed Sep 04, 2013 4:07 pm

Re: [CODE] Reveal and Scry

Post by afrikas »

excessum wrote:Any effect that "target()"s the library will force a shuffle immediately after the target is selected which is why I use so many "all()"s and "moveto"s. I only use targeting of the library directly as a last resort to avoid this extra shuffle. The annoying use of "any number of blah", "may choose a blah" and even more fancy examples (Xenagos...) means a serious amount of code-fu to ensure the choice(s) are presented. Pretty much all of the "Reveal" cards require specific effects and I have presented a number of examples that should be sufficient to code the others with some creativity...

It is possible to force the engine to only display "n" cards but it requires a massive amount of tinkering since it involves working through every #$@% layer from GameObserver down to the actual cards themselves. After displaying them correctly, comes the fun part of deciding when to revert to displaying the "hidden" cards since the effects that trigger the targeting operate off a different layer/thread. As a bonus, all the "any/may" choices still present the problem of deciding how many and which cards to send to exile/top/bottom/blah so the GUI solution is only really effective for "Scry" which I believe the current workaround is acceptable anyway.

excessum i tried to patch all your files into the wagic source but it gives an error when i try to compile:


"src/AllAbilities.cpp: In member function 'virtual int GenericPaidAbility::resolve()':
src/AllAbilities.cpp:1150: error: comparison between signed and unsigned expressions
make: *** [ojs/AllAbilities.o] Error 1"

can you tell me whats wrong?
or can you give an eboot already compiled whith your patches?

Thanks
sandman423
Posts: 806
Joined: Thu Sep 10, 2009 8:59 pm

Re: [CODE] Reveal and Scry

Post by sandman423 »

I am in the same boat...I updated my sources and having trouble compiling for PSP...Devotion mechanic has been working for Grey Merchant of Asphodel (THS) which is awesome. I would love Fanatic of Mogis as well as the others.

I would love Scry....Scry would be sweet and Reveal would be sweet. we could have a TON more cards added..

It would be sweet to establish cards in the game like Warp World, Genesis Wave, Primal Surge, Possibility Storm, Grip of Chaos, Planar Chaos, etc.

I know a lot of these are really hard due to specific coding, but I feel like we are moving toward a better game we now have a version of Scy, Reveal, Devotion...Now we just need to work on Compatibility a little. I work on a PSP Mainly because I love having the portable device for Wagic but I do feel like it tends to freeze up a lot on my PSP where you will play a few games and then the game will just start slowing down to the point where it freezes up and I have to restart PSP.
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Reveal and Scry

Post by excessum »

If you have compiler errors, please quote the entire line here because I have no idea what your source files look like. The most likely guess is that you applied the "Fizzle unless pay x" patch and the error is with this line:

Code: Select all

if ( isFake && findPayN != string::npos ) {
You can simply declare findPayN as a size_t instead of int to fix that, assuming this IS the line you have the error...

I recommend that you revert your project to the current (r4876) SVN and then reapply the patch(s). I have verified that this works 100% on VS2010 on Windows 7. Note that the "Fizzle to zone" patch has been removed as it is already in the latest SVN.
sandman423
Posts: 806
Joined: Thu Sep 10, 2009 8:59 pm

Re: [CODE] Reveal and Scry

Post by sandman423 »

can you explain how to patch it currently I am at v4876 and I never touch my SVN Files because I will always usually get a Red Exclamation mark on my "WagTheSource" File.
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Reveal and Scry

Post by excessum »

The red exclamation means that you have file(s) that are different from those in the repository. I would advise for you to do a clean install (green arrow on project) by "revert"ing to r4876 which will change those different file(s) back to the "official" version.

After you have a clean install, you can use the "Apply a patch" command in TortoiseSVN's right-click context menu and select the desired patch file(s) (available from my Google Drive on my forum profile) and "patch all files". It should be smooth sailing from there since the patches are mainly code additions, after which you can compile and run.
Locked