It is currently 16 Apr 2024, 14:48
   
Text Size

Add player badge and custom message

Moderator: CCGHQ Admins

Add player badge and custom message

Postby kevlahnota » 24 Jul 2012, 00:19

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
User avatar
kevlahnota
Programmer
 
Posts: 825
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 14 times
Been thanked: 264 times

Re: Add player badge and custom message

Postby thefiremind » 24 Jul 2012, 08:34

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?
< 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: Add player badge and custom message

Postby kevlahnota » 24 Jul 2012, 09:47

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>
User avatar
kevlahnota
Programmer
 
Posts: 825
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 14 times
Been thanked: 264 times

Re: Add player badge and custom message

Postby kevlahnota » 24 Jul 2012, 10:12

anyway, the custom status display is stackable by its icon, anyway its better to have a hint than nothing... :lol:

Image
User avatar
kevlahnota
Programmer
 
Posts: 825
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 14 times
Been thanked: 264 times

Re: Add player badge and custom message

Postby thefiremind » 24 Jul 2012, 11:07

OK, I understood... I had just forgot active_zone="ZONE_TRANSITION", that's why it didn't work. #-o
< 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


Return to Documentation

Who is online

Users browsing this forum: No registered users and 17 guests


Who is online

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

Login Form