It is currently 26 Apr 2024, 22:24
   
Text Size

New card - Overwhelming Instinct

Moderator: CCGHQ Admins

New card - Overwhelming Instinct

Postby PhilistineAu » 29 May 2014, 12:55

Hi,

I read through the tutorial and had a go at coding a card. It seems to work in game but I'd appreciate someone taking a look and letting me know if they see anything I should have done differently. The triggered ability is: Whenever you attack with three or more creatures, draw a card.

Code: Select all
<TRIGGER value="ATTACKERS_DECLARED">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
    filter:Add( FE_IS_ATTACKING, true )
    if filter:CountStopAt(3) == 3 then
       return true
    end
    return false
    </TRIGGER> 
  <RESOLUTION_TIME_ACTION>
   EffectController():DrawCards(1)
  </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
<AI_BASE_SCORE score="600" zone="ZONE_BATTLEFIELD" />
It took me a while to get it work but I finally worked out I needed to trigger on attackers declared instead of attacking (it would draw more than 1 card - I'm presuming it drew a card for each attacking creature? i.e. it was working and drawing only 1 card each time, but it was doing it for each creature that was attacking - so 4 creatures = 4 cards.

On the wording of the end of the trigger, could I instead have said:
"return true
else
return false
end
</TIGGER>


Lastly, I never saw it draw cards for an opponent - could that happen with this card or does the effectcontroller portion of the draw card stop that?

Thanks!!!

Phil
PhilistineAu
 
Posts: 22
Joined: 29 Sep 2012, 19:37
Has thanked: 0 time
Been thanked: 1 time

Re: New card - Overwhelming Instinct

Postby thefiremind » 29 May 2014, 14:08

Your code means "Whenever three or more creatures attack, draw a card.": you would draw a card when someone else attacks with three or more creatures, too. Add a controller check to the filter:
Code: Select all
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PhilistineAu wrote:I needed to trigger on attackers declared instead of attacking
That's perfectly fine when you need to do something that involves all the attacking creatures. There's probably a way to do it with an ATTACKING trigger, but it would get really complicated for no reason.

PhilistineAu wrote:On the wording of the end of the trigger, could I instead have said:
"return true
else
return false
end
It's totally equivalent: "return" exits the code block, so you don't reach "return false" when you already reached "return true" anyway.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: New card - Overwhelming Instinct

Postby PhilistineAu » 29 May 2014, 21:41

Thanks! I've added the filter and will give it a go today. Thanks for the explanations as well.

Cheers,

Phil
PhilistineAu
 
Posts: 22
Joined: 29 Sep 2012, 19:37
Has thanked: 0 time
Been thanked: 1 time


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 30 guests


Who is online

In total there are 30 users online :: 0 registered, 0 hidden and 30 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 30 guests

Login Form