Page 57 of 253

Re: Community Wad

PostPosted: 21 Jun 2015, 04:51
by Xander9009
cenarius wrote:
Xander9009 wrote:I fixed that error (because I noticed it) but apparently only corrected my local copy and not the copy in my post. Should be MTG():GetNthStartingPlayer().
I'm sorry, i was so focused on "Withdraw" that i forgot to test your code for "Static Orb".

It's tested now, but it doesn't work, it still remains asking for me to do something, but now i don't know because i can't do anything now, before i was able to select things, now nothing.

Here's the code, with some syntaxis errors fixed, tough i don't know if my corrections are ok (for example, on the "filter" block there was an "end" missing for the "if" you used so i just putted it on the lowest part). That, and the log system of the game doesn't give me any messages so i can "dig". Please take a look at this:

Code: Select all
<STATIC_ABILITY linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Si l’Orbe statique est dégagée, les joueurs ne peuvent pas dégager plus de deux permanents pendant leur étape de dégagement.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Mientras la Esfera estática esté enderezada, los jugadores no pueden enderezar más de dos permanentes durante su fase de enderezar.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Wenn die Statische Sphäre nicht getappt ist, können Spieler nicht mehr als zwei bleibende Karten während ihres Enttappsegments enttappen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Se il Globo della Staticità è STAPpato, i giocatori non possono STAPpare più di due permanenti durante il proprio STAP.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
        <FILTER filter_id="0">
             local NumPlayers = MTG():GetNumberOfStartingPlayers()
             local PlayerID = -1
             for i=0,NumPlayers-1 do
                if MTG():GetNthStartingPlayer(i) ~= nil and MTG():GetNthStartingPlayer(i):MyTurn() then
                   PlayerID = i
                end
             end
             if PlayerID &gt;= 0 then
            local filter = ClearFilter()
            filter:Add(FE_TEAM, OP_IS, MTG():GetNthStartingPlayer(PlayerID):GetTeam())
            local subfilter = filter:AddSubFilter_Or()
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_LAND)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER)
          end
          </FILTER>
          <CONTINUOUS_ACTION layer="8" filter_id="0">
             local Card = FilteredCard()
             if Card ~= nil and EffectSource() ~= nil and EffectSource():IsTapped() == false then
                local Found = false
                local IgnoreChest = LinkedDC()
                for i=0,3 do
                   local IgnoredPlayerChest = IgnoreChest:Get_Chest(i)
                   if IgnoredPlayerChest ~= nil then
                      local IgnoredCardZero = IgnoredPlayerChest:Get_CardPtr(0)
                      local IgnoredCardOne = IgnoredPlayerChest:Get_CardPtr(1)
                      if ( (IgnoredCardZero ~= nil and IgnoredCardZero == Card) or (IgnoredCardOne ~= nil and IgnoredCardOne == Card) ) then
                         Found = true
                      end
                   end
                end
                if Found == false then
                   Card:GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_DOESNT_UNTAP, 1 )
                end
             end
          </CONTINUOUS_ACTION>
</STATIC_ABILITY>
<TRIGGERED_ABILITY linked_ability_group="1" replacement_effect="1" priority="-10">
          <TRIGGER value="BEGINNING_OF_PLAYERS_STEP" >
             return TriggerPlayer() ~= nil and MTG():GetStep() == STEP_UNTAP and EffectSource() ~= nil and EffectSource():IsTapped() == false
          </TRIGGER>
          <RESOLUTION_TIME_ACTION>
             local player = TriggerPlayer()
             local filter = ClearFilter()
             filter:Add(FE_CONTROLLER, OP_IS, player)
             local subfilter = filter:AddSubFilter_Or()
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_LAND)
             subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER)
             local Count = filter:Count()
             if Count &gt; 0 then
                player:SetItemCount(2)
                player:SetItemPrompt( 0, "CARD_QUERY_CHOOSE_PERMANENT_TO_UNTAP" )
                player:SetItemPrompt( 1, "CARD_QUERY_CHOOSE_PERMANENT_TO_UNTAP" )
                player:ChooseItems( EffectDC():Make_Targets(0), QUERY_FLAG_UP_TO )
             end
          </RESOLUTION_TIME_ACTION>
          <RESOLUTION_TIME_ACTION>
             local TargetChest = EffectDC():Get_Targets(0)
             if TriggerPlayer() ~= nil and TargetChest ~= nil then
                local NumPlayers = MTG():GetNumberOfStartingPlayers()
                local PlayerID = -1
                for i=0,NumPlayers-1 do
                   if MTG():GetNthStartingPlayer(i) ~= nil and MTG():GetNthStartingPlayer(i) == TriggerPlayer() then
                      PlayerID = i
                   end
                end
                if PlayerID &gt;= 0 then
                   local IgnoreChest = LinkedDC():Make_Chest(PlayerID)
                   local TargetZero = TargetChest:Get_CardPtr(0)
                   if TargetZero ~= nil then
                      IgnoreChest:Set_CardPtr(0, TargetZero)
                   end
                   local TargetOne = TargetChest:Get_CardPtr(1)
                   if TargetOne ~= nil then
                      IgnoreChest:Set_CardPtr(1, TargetOne)
                   end
                end
             end
          </RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
There is no rush just take your time. I would have given a fight but you use the "chest" method and i really don't know how to handle them.
Alright, so after some testing, it appears the game can't handle (or I was doing it wrong) the idea of performing a card query before untapping during the player's turn. No matter how I handled it, it always untapped the cards, and THEN asked which ones to untap. This does basically the same thing as the code I posted before, but with two alterations.

1: It triggers at the end of every turn rather than the beginning. It simply asks the next player which cards they want to untap, and stores those cards (and everyone else's) in the LinkedDC().

2: It grants the ability at all times to all cards not in the LinkedDC(). This way, the cards DO have the doesn't untap characteristic by the time the player's turn rolls around. (Otherwise, even though it's a static ability, it doesn't take effect until after the untap has already happened. It's almost like the game untaps everything before sending out triggers and updates for the turn change.)

It's now in the CW since it works, but yeah, this card turned out a bit more complicated than it first seemed. Either way, my original idea remains the same, with the only real problems being untapping fewer than necessary permanents and probably 2HG games.

Static Orb - Tested | Open
Code: Select all
<STATIC_ABILITY linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Si l’Orbe statique est dégagée, les joueurs ne peuvent pas dégager plus de deux permanents pendant leur étape de dégagement.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Wenn die Statische Sphäre nicht getappt ist, können Spieler nicht mehr als zwei bleibende Karten während ihres Enttappsegments enttappen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[If Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[As long as Static Orb is untapped, players can’t untap more than two permanents during their untap steps.]]></LOCALISED_TEXT>
     <FILTER filter_id="0">
         local filter = ClearFilter()
         local subfilter = filter:AddSubFilter_Or()
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_LAND)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER)
      </FILTER>
      <CONTINUOUS_ACTION layer="8" filter_id="0">
         if EffectSource():IsTapped() == false then
            local filteredCard = FilteredCard()
            local NumPlayers = MTG():GetNumberOfStartingPlayers()
            local Found = false
            for i=0,NumPlayers-1 do
               if MTG():GetNthStartingPlayer(i) ~= nil then
                  local IgnoreChest = LinkedDC():Get_Chest(i)
                  if IgnoreChest ~= nil then
                     local Count = IgnoreChest:Get_Int(0)
                     if Count &gt; 0 then
                        for j=1,Count do
                           local Card = IgnoreChest:Get_CardPtr(j)
                           Found = Found or ( Card ~= nil and Card == filteredCard)
                        end
                     end
                  end
               end
            end
            if Found == false then
               filteredCard:GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_DOESNT_UNTAP, 1 )
            end
         end
      </CONTINUOUS_ACTION>
   </STATIC_ABILITY>
   <TRIGGERED_ABILITY linked_ability_group="1" replacement_query="1">
      <TRIGGER value="BEGINNING_OF_PLAYERS_STEP">
         return TriggerPlayer() ~= nil and TriggerPlayer():GetNextPlayer() ~= nil and EffectSource() ~= nil and EffectSource():IsTapped() == false and MTG():GetStep() == STEP_CLEANUP
      </TRIGGER>
      <RESOLUTION_TIME_ACTION>
         local player = TriggerPlayer():GetNextPlayer()
         local filter = ClearFilter()
         filter:Add(FE_CONTROLLER, OP_IS, player)
         local subfilter = filter:AddSubFilter_Or()
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_LAND)
         subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER)
         local Count = filter:CountStopAt(2)
         if Count &gt; 0 then
            player:SetItemCount(Count)
            for i=0,Count-1 do
               player:SetItemPrompt(i, "CARD_QUERY_CHOOSE_PERMANENT_TO_UNTAP")
            end
            player:ChooseItems(EffectDC():Make_Targets(0))
         end
      </RESOLUTION_TIME_ACTION>
      <RESOLUTION_TIME_ACTION>
         local TargetChest = EffectDC():Get_Targets(0)
         local Player = TriggerPlayer():GetNextPlayer()
         if Player ~= nil and TargetChest ~= nil then
            local NumPlayers = MTG():GetNumberOfStartingPlayers()
            for i=0,NumPlayers-1 do
               if MTG():GetNthStartingPlayer(i) ~= nil then
                  local IgnoreChest = LinkedDC():Make_Chest(i)
                  if MTG():GetNthStartingPlayer(i) == Player then
                     local TargetZero = TargetChest:Get_CardPtr(0)
                     if TargetZero ~= nil then
                        IgnoreChest:Set_Int(0, 1)
                        IgnoreChest:Set_CardPtr(1, TargetZero)
                     end
                     local TargetOne = TargetChest:Get_CardPtr(1)
                     if TargetOne ~= nil then
                        IgnoreChest:Set_Int(0, 2)
                        IgnoreChest:Set_CardPtr(2, TargetOne)
                     end
                  else
                     local filter = ClearFilter()
                     filter:Add(FE_CONTROLLER, OP_IS, MTG():GetNthStartingPlayer(i))
                     local subfilter = filter:AddSubFilter_Or()
                     subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT)
                     subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
                     subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT)
                     subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_LAND)
                     subfilter:Add(FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER)
                     local Count = filter:EvaluateObjects()
                     IgnoreChest:Set_Int(0, Count)
                     for j=0,Count-1 do
                        local Card = filter:GetNthEvaluatedObject(j)
                        if Card ~= nil then
                           IgnoreChest:Set_CardPtr(j+1, Card)
                        end
                     end
                  end
               end
            end
         end
      </RESOLUTION_TIME_ACTION>
      <RESOLUTION_TIME_ACTION>
         MTG():ReevaluateContinuousEffects()
      </RESOLUTION_TIME_ACTION>
   </TRIGGERED_ABILITY>

Re: Community Wad

PostPosted: 21 Jun 2015, 10:09
by cenarius
Bug report.
"Rhystic Tutor" allows me to search my deck for a card but it doesn't put it in my hand. I'm sorry, forgot to test this one too.

@Xander9009 the orb works nicely and is realy nasty way, you did it, thank god i mentioned i was working on it :p

I would have never figure it out man, thanks. Now the merfolk deck has a purpose, tried to make it work only with "Rising Waters" but nah, it didn't worked out well, it was more like you struggling to make it work and sweating every turn for doing so.

Now, i'm sorry, but here i go again. I don't know what i'm doing wrong in here because well again i don't know how to code. I'm trying to do "Rishadan Cutpurse" for my Rising Waters deck, but can't make her work.

Here is the code:
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="RISHADAN_CUTPURSE_512019566" />
  <CARDNAME text="RISHADAN_CUTPURSE" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Carterista rishadana]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Rishadan Cutpurse]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="512019566" />
  <ARTID value="512019566" />
  <ARTIST name="Christopher Moeller" />
  <CASTING_COST cost="{2}{U}" />
  <TYPE metaname="Creature" />
  <SUB_TYPE metaname="Human" />
  <SUB_TYPE metaname="Pirate" />
  <EXPANSION value="MM" />
  <RARITY metaname="C" />
  <POWER value="1" />
  <TOUGHNESS value="1" />
   <FLAVOURTEXT>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Cuanto más grande es la bolsa, mayor es el tonto.
—Dicho Rishadano]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[The bigger the purse, the greater the fool.
—Rishadan saying]]></LOCALISED_TEXT>
   </FLAVOURTEXT>
 
<TRIGGERED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Cuando la carterista rishadana entre en juego, cada oponente sacrifica un permanente a menos que pague {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Quando il Tagliaborse di Rishada entra nel campo di battaglia, ogni avversario sacrifica un permanente a meno che paghi {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[When Rishadan Cutpurse enters the battlefield, each opponent sacrifices a permanent unless he or she pays {1}.]]></LOCALISED_TEXT>
   <TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_BATTLEFIELD" />

   <RESOLUTION_TIME_ACTION repeating="1">
    local num_Players = MTG():GetNumberOfPlayers()

   for i = 0, (num_Players-1) do
            local player = MTG():GetNthPlayer(i)
            if player:GetTeam() ~= EffectController():GetTeam() then
               if player ~= nil then
                  player:BeginNewMultipleChoice()
                  player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1")
                  player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
                  player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
               end
            end
   end   
   </RESOLUTION_TIME_ACTION >
      
   <RESOLUTION_TIME_ACTION>
   local num_Players = MTG():GetNumberOfPlayers()
 
   for i = 0, (num_Players-1) do
         local player = MTG():GetNthPlayer(i)
         if player:GetTeam() ~= EffectController():GetTeam() then
            if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
               player:PayResourceCost(1)
            else
               local filter = ClearFilter()
               filter:Add( FE_IS_PERMANENT, true )
               player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(i) )
               local ChoosenCard = EffectDC():Get_Targets(i):Get_CardPtr(0)
                  if ChoosenCard ~= nil then
                     MTG():GetNthPlayer(i):Sacrifice( ChoosenCard )
                  end
            end
         end
   end
    </RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
   
 
  <SFX text="COMBAT_BLUNT_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
  <SFX text="COMBAT_BLUNT_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
</CARD_V2>
I hope someone can give me a hand in here please.

Re: Community Wad

PostPosted: 21 Jun 2015, 10:39
by Xander9009
This will be moderately complex as well. That's because the choice needs to be reacted to before moving onto the next player, which means you need to do everything in a single RTA. But in order to do so, you need to first have them choose to pay or sacrifice, then have them pay or choose a permanent, and then sacrifice the permanent if they didn't pay.

To do that, you'll need a repeating action like you have. The thing with a repeating action is that it repeats if you call "return true" and doesn't if you call "return false". You can see how many times it's repeated so far by calling MTG():GetActionRepCount(). It'll return 0 when it first runs, 1 when repeats for the first time, and so on. (I think. It might start at 1.)

So, the first time it runs, you need to ask the first player if they want to pay or sacrifice. The second time it runs, you need to make the first player pay or choose a permanent. The third time, if they chose a permanent, that permanent needs to be sacrificed. The fourth time, you need to ask the second player...

You can manage that by using something like this:
local n = MTG():GetActionRepCount()
local Parity = n%3
local Index = n/3
Parity will cycle. It'll go 0,1,2,0,1,2,0,1,2,... because n % 3 is the remainder when dividing n by 3.
Index will be 0, 0.333, 0.666, 1, 1.333, 1.666, 2,... If you round that down with math.floor(x), you'll get the player you should be working with. So, that line should actually be:
local Index = math.floor(n/3). This way, it'll go 0,0,0,1,1,1,2,2,2,...

Now, you've got a variable (Index) that tells you which player to work on with MTG():GetNthPlayer(Index) and a variable (Parity) to tell you whether you should be asking to pay or sacrifice (0), paying or choosing a sacrifice target (1), or sacrificing the chosen target (2).

Return true as long as Index is less than the number of players, and return false at the end of it all. That'll all go inside a single RTA. I'm sure that was confusing, but have a look at some of the cards in the Deck Builder that call GetRepActionCount (use the advanced filtering) and see if you can make sense of it.

Re: Community Wad

PostPosted: 21 Jun 2015, 12:29
by cenarius
@Xander9009

Ok, this was fun... in a really terifying way. Don't take your hand away now dude because i'm hanging in here.

I understood that post completely, believe it or not, what i can't do proper is the coding because i don't know how to code, but i did a fight.

My modified code:
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
   local n = MTG():GetActionRepCount()      
   local num_Players = MTG():GetNumberOfPlayers()
   local index = n/3
      
      for i = 0, (num_Players-1) do
         if (n &lt; num_players) then
            local index = math.floor(n/3)
            local player = MTG():GetNthPlayer(index)
            if player:GetTeam() ~= EffectController():GetTeam() then
               player:BeginNewMultipleChoice()
               player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1")
               player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
               player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
            end
         
            if player:GetTeam() ~= EffectController():GetTeam() then
               if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
                     player:PayResourceCost(1)
               else
                  local filter = ClearFilter()
                  filter:Add( FE_IS_PERMANENT, true )
                  player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(index) )
                  local ChoosenCard = EffectDC():Get_Targets(index):Get_CardPtr(0)
               end
            end
            
            if player:GetTeam() ~= EffectController():GetTeam() then
               if ChoosenCard ~= nil and player:GetMultipleChoiceResult() == 0 then
                     MTG():GetNthPlayer(index):Sacrifice( ChoosenCard )
               end
            end
            
         else
            return false
         end
      end

    </RESOLUTION_TIME_ACTION>
And a couple of questions.

- Why using index and using it that way (n/3)? i tought the idea was to give a number to each player and then get the values for each depending on that number.
- Why using parity? there are just two options possible: To pay and avoid the perma-sacrifice or to just sacrifice (being able to pay or not)
- Now that i'm seeing it, please don't tell me the "repeating="1"" value on the Resolution time action tag means its going to repeat by itself? because i don't want to feel like an idiot.

As it is the card doesn't work, of course, i'm sure i'm missing several things so please let me know what you think.

Will expect this answer.

Edit: This is the error it throws: "[lua] [string "RISHADAN_CUTPURSE_512019566_TITLE (RESOLUTION_TIME_ACTION)~0x00000559"]:7: attempt to compare number with nil"

Re: Community Wad

PostPosted: 21 Jun 2015, 13:07
by Xander9009
To fix that error, change num_players to num_Players. The variable names and function names are case sensitive. It's one of the biggest problems I have.

The reason you need to use Index and Parity is because you can't use a for loop. If you use a for loop to ask the question, then it asks each player the question, but only the most recent answer will be available with GetMultipleChoiceResult() (that I know of; it's entirely possible that's not true, but I'm explaining how to code it the way I know will work). That means the RTA needs to end before you can access the last answer and respond to it accordingly.

Re: Community Wad

PostPosted: 21 Jun 2015, 13:38
by cenarius
Xander9009 wrote:To fix that error, change num_players to num_Players. The variable names and function names are case sensitive. It's one of the biggest problems I have.

The reason you need to use Index and Parity is because you can't use a for loop. If you use a for loop to ask the question, then it asks each player the question, but only the most recent answer will be available with GetMultipleChoiceResult() (that I know of; it's entirely possible that's not true, but I'm explaining how to code it the way I know will work). That means the RTA needs to end before you can access the last answer and respond to it accordingly.
So the "for" cycle isn't necessary? its going to repeat until "(n > num_Players)", right?

Re: Community Wad

PostPosted: 21 Jun 2015, 16:45
by Kithkin
Bug report

When Vampire Nocturnus attacks, the player is asked to "choose which Planeswalker you want to attack". If there is no Planeswalker, you have to choose a creature. The creature will be damaged instead of the opponent.

Re: Community Wad

PostPosted: 21 Jun 2015, 17:30
by CalT2410
Kolaghan's Command - Target player discards a card mode doesn't target; the only option is the opponent.

Re: Community Wad

PostPosted: 21 Jun 2015, 22:26
by RiiakShiNal
For Dominate:

Well, you could remove the {X} from the casting cost and put it as a generic cost that bases the cost off of the CMC of the selected target. It won't look as nice that way and you will need to adjust the text of the card so that the player knows the {X} cost is still actually there. This way there should be no issues other than it won't quite look like the official card (due to {X} missing from the casting cost).

Another option would be putting the target into a PLAY_TIME_ACTION as you suggested. Then if you don't like your choices in the target cancel the cast (you should still be able to cancel from a PLAY_TIME_ACTION. This way the card gets to look like the original (even keeping the {X} in the casting cost), but now the order is a little out of sync (since you are supposed to target before casting for other effects that can increase casting costs if they target that card). So this method could break other effects, but looks better.

Xander9009 wrote:The reason you need to use Index and Parity is because you can't use a for loop. If you use a for loop to ask the question, then it asks each player the question, but only the most recent answer will be available with GetMultipleChoiceResult() (that I know of; it's entirely possible that's not true, but I'm explaining how to code it the way I know will work). That means the RTA needs to end before you can access the last answer and respond to it accordingly.
Actually, you have to use repeating actions because as soon as you ask a question of the player the function will basically end (not processing things afterwards as you might expect) which causes lots of logic errors. This is why asking a question of the player is always the last thing an action does before returning.

The reason for using parity is because we need to interleave our actions:
  • Ask Question (0)
  • Get Response (1)
  • Ask Question (0)
  • Get Response (1)
  • ...

Each action can only ask one question, the response to that question is only available until another question is asked, and you can only count on getting the response once (meaning once you first get the response if you want to keep it around you need to store it in a data chest).

Also since we don't necessarily know how many players we have (could be a duel, 2HG, 3 or 4 player FFA) we can't really code it up in separate actions so using a single action that repeats is usually a better solution since we can have it repeat more for more players easily.

Re: Community Wad

PostPosted: 22 Jun 2015, 09:30
by cenarius
RiiakShiNal wrote:Actually, you have to use repeating actions because as soon as you ask a question of the player the function will basically end (not processing things afterwards as you might expect) which causes lots of logic errors. This is why asking a question of the player is always the last thing an action does before returning.

The reason for using parity is because we need to interleave our actions:
  • Ask Question (0)
  • Get Response (1)
  • Ask Question (0)
  • Get Response (1)
  • ...

Each action can only ask one question, the response to that question is only available until another question is asked, and you can only count on getting the response once (meaning once you first get the response if you want to keep it around you need to store it in a data chest).

Also since we don't necessarily know how many players we have (could be a duel, 2HG, 3 or 4 player FFA) we can't really code it up in separate actions so using a single action that repeats is usually a better solution since we can have it repeat more for more players easily.
Is there a card that uses "parity" and "index" this way? i can't find any and i understand their theorical use but not practical. I would really appreciate some examples for this please, most cards just uses cycles in a basic way.

My updated code:
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
   local n = MTG():GetActionRepCount()      
   local num_players = MTG():GetNumberOfPlayers()
   local index = n/3
      
   for i = 0, (num_players-1) do
         if (n &lt; num_players) then
            local index = math.floor(n/3)
            local player = MTG():GetNthPlayer(index)
            if player:GetTeam() ~= EffectController():GetTeam() then
               player:BeginNewMultipleChoice()
               player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1")
               player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
               player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
   
               if player:GetTeam() ~= EffectController():GetTeam() then
                  if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
                        player:PayResourceCost(1)
                  else
                     local filter = ClearFilter()
                     filter:Add( FE_IS_PERMANENT, true )
                     player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(index) )
                     local ChoosenCard = EffectDC():Get_Targets(index):Get_CardPtr(0)

                     if player:GetTeam() ~= EffectController():GetTeam() then
                        if ChoosenCard ~= nil and player:GetMultipleChoiceResult() == 0 then
                              MTG():GetNthPlayer(index):Sacrifice( ChoosenCard )
                        end
               
                     end
                  end
               end
            end
         else
            return false
         end
      return true
   end
    </RESOLUTION_TIME_ACTION>

Re: Community Wad

PostPosted: 22 Jun 2015, 10:47
by RiiakShiNal
cenarius wrote:Is there a card that uses "parity" and "index" this way? i can't find any and i understand their theorical use but not practical. I would really appreciate some examples for this please, most cards just uses cycles in a basic way.
Axebane Guardian, Breaking Point, Browbeat, Curse of Echoes, Desecration Demon, Hypergenesis, Killing Wave, Mossbridge Troll, etc.... That is just to name a few that use parity and index in this fashion.

Re: Community Wad

PostPosted: 22 Jun 2015, 13:55
by Xander9009
You're getting closer. The main problem now is that you aren't checking parity before performing actions. You're asking the multiple choice question to each player and immediately responding to it. When parity is 0, you should ask the question, when it's one, you should get the result of that question and either pay the mana or choose a target. When parity it 2, you should sacrifice the target if it's valid. Immediately after performing each of those, return true to move on to the next parity. A bug I see, however, is that you only sacrifice the permanent if they chose 0 and the target is valid. The problem is that they should be sacrificing when the the result is 1. You actually don't need to check the result at that point. If the target is valid, then they can't have chosen 0.

Here's the code with that corrected. If you're already working on it, see how close yours is to this. If it's different, there's a definite chance yours is working and mine's not, because this is untested, and I'm notoriously bad at writing good code without testing it :)

| Open
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
   local n = MTG():GetActionRepCount()      
   local num_players = MTG():GetNumberOfPlayers()
   local index = math.floor(n/3)
   local parity = n%3
   if (index &lt; num_players) then
      local player = MTG():GetNthPlayer(index)
      if player:GetTeam() ~= EffectController():GetTeam() then
         if parity == 0 and player:CanPayResourceCost(1) then
            player:BeginNewMultipleChoice()
            player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1", player:CanPayResourceCost(1))
            player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
            player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
         elseif parity == 1 then
            if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
                  player:PayResourceCost(1)
            else
               local filter = ClearFilter()
               filter:Add( FE_IS_PERMANENT, true )
               player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(index) )
            end
         else
            local ChoosenCard = EffectDC():Get_Targets(index) and EffectDC():Get_Targets(index):Get_CardPtr(0)
            if ChoosenCard ~= nil then
               MTG():GetNthPlayer(index):Sacrifice( ChoosenCard )
            end
         end
      end
      return true
   end
   return false
</RESOLUTION_TIME_ACTION>

Re: Community Wad

PostPosted: 22 Jun 2015, 14:14
by cenarius
Xander9009 wrote:You're getting closer. The main problem now is that you aren't checking parity before performing actions. You're asking the multiple choice question to each player and immediately responding to it. When parity is 0, you should ask the question, when it's one, you should get the result of that question and either pay the mana or choose a target. When parity it 2, you should sacrifice the target if it's valid. Immediately after performing each of those, return true to move on to the next parity. A bug I see, however, is that you only sacrifice the permanent if they chose 0 and the target is valid. The problem is that they should be sacrificing when the the result is 1. You actually don't need to check the result at that point. If the target is valid, then they can't have chosen 0.

Here's the code with that corrected. If you're already working on it, see how close yours is to this. If it's different, there's a definite chance yours is working and mine's not, because this is untested, and I'm notoriously bad at writing good code without testing it :)

| Open
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
   local n = MTG():GetActionRepCount()      
   local num_players = MTG():GetNumberOfPlayers()
   local index = math.floor(n/3)
   local parity = n%3
   if (index &lt; num_players) then
      local player = MTG():GetNthPlayer(index)
      if player:GetTeam() ~= EffectController():GetTeam() then
         if parity == 0 and player:CanPayResourceCost(1) then
            player:BeginNewMultipleChoice()
            player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1", player:CanPayResourceCost(1))
            player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
            player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
         elseif parity == 1 then
            if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
                  player:PayResourceCost(1)
            else
               local filter = ClearFilter()
               filter:Add( FE_IS_PERMANENT, true )
               player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(index) )
            end
         else
            local ChoosenCard = EffectDC():Get_Targets(index) and EffectDC():Get_Targets(index):Get_CardPtr(0)
            if ChoosenCard ~= nil then
               MTG():GetNthPlayer(index):Sacrifice( ChoosenCard )
            end
         end
      end
      return true
   end
   return false
</RESOLUTION_TIME_ACTION>
Já!

This is my modified code after riiak's advice:

Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
         local n = MTG():GetActionRepCount()
         local num_players = MTG():GetNumberOfPlayers()
         local index = n/2
         local parity = n % 2
         local player = MTG():GetNthPlayer(index)
         
         if player ~= nil and n &lt; num_players*2 then
            if player:GetTeam() ~= EffectController():GetTeam() then
               if parity == 0 then
                  player:BeginNewMultipleChoice()
                     player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1")
                     player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
                     player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
               else
                  if player:GetMultipleChoiceResult() == 0 then
                     player:PayResourceCost(1)
                     return false
                  else
                     local filter = ClearFilter()
                     filter:Add( FE_IS_PERMANENT, true )
                     player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(0) )
                  
                  end
               end
            end
            return true
         else
            return false
         end
   </RESOLUTION_TIME_ACTION>
But... it still doesn't work. Tought i just copied it from "Vexing Devil".

I'm still there, but now i remember that "local index = math.floor(n/3)" and "local parity = n%3". But it's weird, if "Vexing Devil" works when considering only opponents for the query, why the (n/3)? it seems that with that n/3 value i'll need to also ask if the player is an opponent or the one who played "Rishadan Cutpurse". If "Vexing Devil" works, why not to just use the same values in that card, which are index=n/2 and parity=n%2?

It seems that i'm still missing something here.

I'll test your code now, then i'll get back to mine, i just want to compare them both for now.

Thanks for the help ;)

Re: Community Wad

PostPosted: 22 Jun 2015, 15:08
by Xander9009
You need to use n%3 and n/3 for Rishadan Cutpurse because it has three actions. Vexing devils has two actions.

Vexing Devils:
  1. Ask to deal damage or not
  2. Deal damage and sacrifice or do nothing

Rishadan Cutpurse:
  1. Ask to pay one or not
  2. Pay one or choose target to sacrifice
  3. Sacrifice

Also, keep in mind that the first time you return false, it will stop repeating. You have it set to return false as soon as someone pays one. This is incorrect. It should allow each player to sacrifice or pay, so it needs to return true until it has asked and responded to each opponent.

Re: Community Wad

PostPosted: 22 Jun 2015, 15:10
by cenarius
Xander9009 wrote:
| Open
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
   local n = MTG():GetActionRepCount()      
   local num_players = MTG():GetNumberOfPlayers()
   local index = math.floor(n/3)
   local parity = n%3
   if (index &lt; num_players) then
      local player = MTG():GetNthPlayer(index)
      if player:GetTeam() ~= EffectController():GetTeam() then
         if parity == 0 and player:CanPayResourceCost(1) then
            player:BeginNewMultipleChoice()
            player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_1", player:CanPayResourceCost(1))
            player:AddMultipleChoiceAnswer("CARD_QUERY_SACRIFICE_A_PERMANENT")
            player:AskMultipleChoiceQuestion("CARD_QUERY_RISHADAN_CUTPURSE")
         elseif parity == 1 then
            if player:CanPayResourceCost(1) and player:GetMultipleChoiceResult() == 0 then
                  player:PayResourceCost(1)
            else
               local filter = ClearFilter()
               filter:Add( FE_IS_PERMANENT, true )
               player:ChooseItem( "CARD_QUERY_CHOOSE_PERMANENT_TO_SACRIFICE", EffectDC():Make_Targets(index) )
            end
         else
            local ChoosenCard = EffectDC():Get_Targets(index) and EffectDC():Get_Targets(index):Get_CardPtr(0)
            if ChoosenCard ~= nil then
               MTG():GetNthPlayer(index):Sacrifice( ChoosenCard )
            end
         end
      end
      return true
   end
   return false
</RESOLUTION_TIME_ACTION>
Nope.

It doesn't work, and i'm starting to get nervous because there is not a single card with this kind of query and resolution to compare. The algorithm works for some things but not for others it seems... that or i'm really missing something here (which might be the case).

Is this possible? i see my code, i see yours, both are right (again, from my low expertise point of view) but both doesn't work and there is no output log file so i can get a clue of what is going on :(