Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Documentation
Add player badge and custom message
Moderator: CCGHQ Admins
Add player badge and custom message
by 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:
how to make the message is first I made a UI_TEXT0080.XML that contains
then I add static ability for Iona something like this:
Hope this is helpful.
here's a sample screen:
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>
Hope this is helpful.
-
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
by 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:
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?
- 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
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...
Currently busy with life...
-
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
by kevlahnota » 24 Jul 2012, 09:47
Thanks for the tip.thefiremind wrote:Just a tip: if you want to make your code shorter, instead of making an "if" chain, you can use string concatenation:LUA will take care of the conversion from integer to string.
- 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
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) :
- 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>
-
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
by 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...
-
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
by thefiremind » 24 Jul 2012, 11:07
OK, I understood... I had just forgot active_zone="ZONE_TRANSITION", that's why it didn't work.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests