No need to feel like a failure. Plenty of successes, and the rest can be learned.
For
Quillmane Baku, the ability never lights up because there's no valid target. It's trying to find a target with CMC
X, but until you pay
X, it's nil (or maybe 0). You can't pay the cost until you can cast the card, and you can't cast the card until there are valid targets, and you can't have valid targets until you pay the cost. It's a triangle of "can't"s, each preventing the next.
To fix this, you need to make the target definition return as if it found a valid target so long as there are creatures that would be valid. You just can't actually check their CMC agains the number of counters removed yet. Replace the target definition with this.
- Code: Select all
<TARGET_DEFINITION id="0">
local cost_max
if EffectDC():Get_Int(3) == 0 then
cost_max = EffectSource():CountCounters(MTG():GetCountersType("Ki"))
else
cost_max = EffectDC():Get_Int(4)
end
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
filter:Add( FE_CMC, OP_LESS_THAN_OR_EQUAL_TO, cost_max )
</TARGET_DEFINITION>
In the above code, you'll see EffectDC():Get_Int(3) and Get_Int(4) are used. On lines 84-85, add in the following.
- Code: Select all
EffectDC():Set_Int(3, 1)
EffectDC():Set_Int(4, decision)
Now, once the cost is paid, no matter what number is chosen, int 3 is 1 and int 4 contains the number chosen. The targeting definition will now know it's really choosing targets (thanks to int 3) and it will know the real max CMC to target (thanks to int 4). Until that's done, it'll allow targets with CMC up to the current number of ki counters.
For
Waxmane Baku, the issue is probably related to what I fixed above with int 4. I think it's likely having trouble reading the result that was made inside the COST outside of that. In other words, "local decision = EffectController():GetNumericalChoiceResult()" on line 84 can't access the result of line 79. So, instead, store the result right after it's made (in the RTA where the counters are removed, just like in Quillman Baku) in EffectDC. Then, get the number from the EffectDC in the target block.
Whether this is the problem or not, you also need to limit the number of counters they're allowed to remove. They shouldn't be able to remove more counters than the number of creatures they can target. This will actually be somewhat in-depth. It will need to ensure they don't have protection from
Waxmane Baku (the functions I recently made). They'll also need to make sure they don't have shroud, and they either don't have hexproof or you (or an ally) controls them. If you can get it working otherwise, I'll do the code for that bit.
Line 72: 'token_count' isn't a defined variable, and it should just be 1. Also, for tokens, you don't have to, but you
can use CW_Tokens(). You shorten the token name by removing "TOKEN_" from the beginning and "_CW_#" from the end. You don't need to provide a player if it's EffectController() (as it usually is...) and you don't have to provide a number if it's 1 (as it usually is...).
CW_Tokens("LIZARD_C_8_8_R") would make the token. The only catch here is that if you use this, you need to register each
version of the token. Just open CW_TOKENS.LOL. Find the token in the list and see how many there are. The number at the end of each token's FILENAME is what changes. For instance, there's only one 8/8 red lizard. But there are, for example (not really) 3 2/2 green wolves. You'd need to register
- Code: Select all
<TOKEN_REGISTRATION reservation="1" type="TOKEN_WOLF_C_2_2_G_CW_1" />
<TOKEN_REGISTRATION reservation="1" type="TOKEN_WOLF_C_2_2_G_CW_2" />
<TOKEN_REGISTRATION reservation="1" type="TOKEN_WOLF_C_2_2_G_CW_3" />
This function produces the same results, except the created token can be any version of the token you're making. They all work the same but they have different art. And if you don't want to mess with the registrations, you don't even have to. Just let me know, and I can run a quick script I have that does all of the token registrations (for all cards) automatically.
Just an option.
The problem here is that the target changes zones.
Warren Pilferers is probably granted haste for one frame, then the target is put into your hand and the continuous action can no longer check if it's a goblin, because the pointer to it is nil now that it's changed zones. The solution here is to store either 1 or 0 in the effectdc before the card moves zones based on whether or not it's a goblin. If it is, store a 1 (0 is default, don't need to code that). In the continuous action, just check if EffectDC():Get_Int(1) == 1 before granting haste. (Note that it's in register 1 since register 0 is taken up by the target).
Line 58 makes a delayed trigger for resource id 3, but the delayed trigger on line 80 has id 2.
In the availability block, you've got the first if that checks "if n < NumPlayers then". Inside this, there's another if block, but no matter what happens in that inner block, the code will finish and reach the next line after that inner if, which is "return true". So, in essence, that block says "if n < NumPlayers, then return true".
This is exaccerbated by the fact that you're calling "MTG():GetActionRepCount()", which has no meaning. It's only used is RTAs and PTA with the attribute 'repeating_action="1"'. So, having no meaning, it always returns 0, which is always less than the number of players.
The way to handle this ability would be to start off by counting the player's lands, stored in a variable like PlayersLandCount. Then, go through each player with a 'for i=0,NumPlayers do' loop. Get the 'i'th player, and make sure it's an opponent. If it is, then use the filter to count that opponent's lands. If they have more, immediately return true. At the very end of this block, right before ending the availability, return false (liek it's always doing).
This way, it will only return true when it successfully finds an opponent with more lands.
The availability blocks
might need combined, I don't know off-hand. However, the issue is in fact the length of the draw step. To fix it, what you do is make an empty triggered ability that triggers at the beginning of each player's draw step. It has to have a valid trigger, but it doesn't need anything else. This way, the timer will give the players a chance to activate it.
Note that the code here may not be enough to ensure that only the player whose turn it is can activate it. Sadly, I'd have to fiddle with it a bunch if it's not.
Like with
Wellspring, the enchant ability should be a SPELL_ABILITY.
We can't really effectively do abilities that require payment to attack or block. Basically any way we go with these will result in them interacting incorrectly with various other cards.
The issue with this code in particular is probably related to the fact that the code is trying to tell the player to pay the cost about once per frame. Continuous actions are constantly running again and again. Anything in them such as PayManaCost would cause huge issues, and the game probably simply ignores the function because of that.
You can see this happening if you add a line in a CA that simply reads "EffectController():GainLife(1)". You'll hit the maximum amount of life if just a few seconds.
In order to even come close to being right, this would have to grant a delayed ability to the creature that allows its controller to pay the cost in an RTA once per turn right before combat. Store their decision in a LinkedDC, and use that in the CA to determine if the attacking and blocking restrictions should be applied.
But honestly, this card will likely never work exactly the way it's supposed to. As far as an approximation goes, the above is probably the best way to manage it. I'm not certain, though. It'd require more thought.
First and foremost, never handle costs in the resolution. "EffectSource():Destroy()" in an RTA down there will simply make it so that the controller can activate the ability multiple times in a row. It'll also mean that if they can make it indestructible, then the sacrifice component of the cost is negated. Costs always need to go in a cost tag. In this case: <COST type="SacrificeSelf" />.
Secondly, a minor issue, but it should be addressed anyway, you
are checking if the 'player' variable is nil, which is correct. But you're
using the variable (to get the hand count) before checking if it's nil. move the nil check above the hand count.
Finally, this might be related to the game trying to handle various functions in the same RTA. It doesn't normally matter in situations like this, but it might be the case. If that is the problem, you'll need recode it such that the hand movement, the shuffling, and the drawing are handled in different RTA. You don't need to figure it out from scratch, though, because there's already a card that does exactly this:
Winds of Change.
The first problem I see is also very easy to fix. In the TRIGGER tag, the trigger value has the "TRIGGER_" prefix. Trigger tags' value attributes have "TRIGGER_" removed from their beginning.
The second issue is that the trigger has simple_qualifier="controller", which means this trigger will only every fire if the player who is triggering it is EffectController(). It needs removed and checked in the trigger block.
- Code: Select all
<TRIGGER value="TRIGGER_SPELL_OR_ABILITY_CAUSED_SHUFFLE" simple_qualifier="controller" />
becomes
<TRIGGER value="SPELL_OR_ABILITY_CAUSED_SHUFFLE">
return TriggerObject() ~= nil and SecondaryPlayer() ~= nil and TriggerObject():GetController() == SecondaryPlayer()
</TRIGGER>
Note that I do not know if TriggerObject and SecondaryPlayer are correct. They might need swapped to TriggerPlayer and SecondaryObject.
Not sure if that will make the card work, but it should hopefully be a decent next step.
This is a lot more verbose than it needs to be, and I'm not certain where exactly the problem lies. So, instead of figuring out the exact issue here (sorry), I'm just going to suggest a much simpler way of doing it.
You can use a for loop and two variables. One variable tracks the most creatures a player has been found to control so far: iMaxFound, which starts at 0. The other variable tracks who that player was: oFoundPlayer which starts nil. Iterate through the players with the for loop. When you find a number of creatures that
beats the current count, set both variables. iMaxFound becomes the new count, and oFoundPlayer becomes the player who controlled them. If you find a number that
matches the current max, then leave the current max alone, but set the oPlayerFound to nil.
The result of this is that each time a new max is found, oPlayerFound becomes valid. Whenever they're discovered to have the same number as someone else, they become invalid. So at the end, if oPlayerFound is valid (not nil), then you've got the player with the most creatures. If two players both controlled 5, and 5 was the most anyone controlled, then oPlayerFound will be nil.
- Code: Select all
local oSource = EffectSource()
if oSource ~= nil then
local iPlayerCount = MTG():GetNumberOfPlayers()
local oPlayerFound = nil
local iMaxFound = 0
for i=0,iPlayerCount-1 do
local oPlayer = MTG():GetNthPlayer(i)
if oPlayer ~= nil then
local oFilter = ClearFilter()
oFilter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
oFilter:Add(FE_CONTROLLER, OP_IS, oPlayer)
local iCount = oFilter:Count()
if iCount > iMaxFound then
iMaxFound = iCount
oPlayerFound = oPlayer
elseif iCount == iMaxFound
oPlayerFound = nil
end
end
end
if oPlayerFound ~= nil then
oSource:SetBaseController(oPlayerFound)
end
end
I can't guarantee this code will work as-is, but it should be at least very close.
----
I'm extremely tired, so I'm sorry if there are any mistakes in here.