Page 1 of 1

Add player badge and custom message

PostPosted: 24 Jul 2012, 00:19
by kevlahnota
Hi, I managed to make Iona, Shield of Emeria display a custom message status for player using badges. If there's a way to add custom player badge then it's much better. Since I cannot find the definition for the player badges except for CONSTANTS.LOL I used prevention icon.

here's a sample screen:

Image

how to make the message is first I made a UI_TEXT0080.XML that contains

    Ident Comment Master Text French Spanish German Italian Japanese Korean Russian Portuguese (Brazil)
    PLAYER_SET_IONA_COLOR_1 Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells. Can’t cast white spells.
    PLAYER_SET_IONA_COLOR_2 Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells. Can’t cast blue spells.
    PLAYER_SET_IONA_COLOR_3 Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells. Can’t cast black spells.
    PLAYER_SET_IONA_COLOR_4 Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells. Can’t cast red spells.
    PLAYER_SET_IONA_COLOR_5 Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells. Can’t cast green spells.



then I add static ability for Iona something like this:
Code: Select all
<STATIC_ABILITY filter_zone="ZONE_IN_PLAY">
  <CONTINUOUS_ACTION>
    local chosencolor = ObjectDC():Get_Int( 0 )
    local num_players = MTG():GetNumberOfPlayers()
    for i=0,num_players-1 do
       local player = MTG():GetNthPlayer(i)
       if player ~= nil and player:GetTeam() ~= Object():GetPlayer():GetTeam() then 
         if chosencolor == 1 then
            player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_1")
         end
         if chosencolor == 2 then
            player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_2")
         end
         if chosencolor == 3 then
            player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_3")
         end
         if chosencolor == 4 then
            player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_4")
         end
         if chosencolor == 5 then
            player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_5")
         end
       end 
    end
    </CONTINUOUS_ACTION>
</STATIC_ABILITY>
Now I don't know if the status display is stackable with other cards that uses Prevention Icon.

Hope this is helpful. :D

Re: Add player badge and custom message

PostPosted: 24 Jul 2012, 08:34
by thefiremind
Just a tip: if you want to make your code shorter, instead of making an "if" chain, you can use string concatenation:
Code: Select all
       if player ~= nil and player:GetTeam() ~= Object():GetPlayer():GetTeam() then
          player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_"..chosencolor)
       end
LUA will take care of the conversion from integer to string. :wink:

Oh, since we're talking about Iona which is similar: I recently (re)coded Voice of All, the problem is that I can't make the player choose the color during ZONECHANGE_TRANSITION, which would be more correct because Gatherer clearly states that the color is chosen when Voice of All isn't in play yet. Only on ZONECHANGE_END the color query appears, but if there's that red enchantment that deals 2 damage to each creature that enters the battlefield, and I choose red for Voice of All, she should be protected before getting damaged. I made the color choice forced_skip and with high priority, so that it should always resolve first, but I'd like to find a cleaner way if there's one. How did you code the color choice ability for Iona?

Re: Add player badge and custom message

PostPosted: 24 Jul 2012, 09:47
by kevlahnota
thefiremind wrote:Just a tip: if you want to make your code shorter, instead of making an "if" chain, you can use string concatenation:
Code: Select all
       if player ~= nil and player:GetTeam() ~= Object():GetPlayer():GetTeam() then
          player:AddBadge(PLAYER_BADGE_ICON_PREVENTION, "PLAYER_SET_IONA_COLOR_"..chosencolor)
       end
LUA will take care of the conversion from integer to string. :wink:
Thanks for the tip. =D>

anyway I code Iona's trigger for choosing a color in ZONECHANGE_TRANSITION like this( I removed the localized text so its easier to see) :D :

Code: Select all
<TRIGGERED_ABILITY auto_skip="1" pre_trigger="1" filter_zone="ZONE_IN_PLAY" active_zone="ZONE_TRANSITION">
    <TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
    <RESOLUTION_TIME_ACTION>
    EffectController():ChooseColour("CARD_QUERY_CHOOSE_COLOUR", 1) 
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    ObjectDC():Set_Int( 0, GetChosenColour() )
    </RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

Re: Add player badge and custom message

PostPosted: 24 Jul 2012, 10:12
by kevlahnota
anyway, the custom status display is stackable by its icon, anyway its better to have a hint than nothing... :lol:

Image

Re: Add player badge and custom message

PostPosted: 24 Jul 2012, 11:07
by thefiremind
OK, I understood... I had just forgot active_zone="ZONE_TRANSITION", that's why it didn't work. #-o