Page 1 of 1

god devotion problem

PostPosted: 05 Nov 2016, 14:35
by nivmizzet1
Any ideas as to why this card wouldn't be a creature when you have devotion greater than 7?

Code: Select all
<?xml version="1.0"?>
<CARD_V2 ExportVersion="1">
   <FILENAME text="CREATURE_NM1_131469" />
   <CARDNAME text="CREATURE" />
   <TITLE>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Creature]]></LOCALISED_TEXT>
   </TITLE>
   <MULTIVERSEID value="131469" />
   <ARTID value="CREATURE" />
   <ARTIST name="default" />
   <CASTING_COST cost="{1}{G}{R}{W}" />
   <SUPERTYPE metaname="Legendary" />
   <TYPE metaname="Enchantment" />
   <TYPE metaname="Creature" />
   <SUB_TYPE metaname="God" />
   <EXPANSION value="DPI" />
   <RARITY metaname="M" />
   <POWER value="6" />
   <TOUGHNESS value="5" />
   <STATIC_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Indestructible]]></LOCALISED_TEXT>
      <INTRINSIC characteristic="CHARACTERISTIC_INDESTRUCTIBLE" />
   </STATIC_ABILITY>
   <STATIC_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As long as your devotion to green, red, and white is less than eight, Creature isn’t a creature.]]></LOCALISED_TEXT>
      <CONTINUOUS_ACTION layer="4">
         if S_GetNumOfDevotion(EffectController(), COLOUR_GREEN, COLOUR_RED, COLOUR_WHITE) &lt; 8 then
            local characteristics = EffectSource():GetCurrentCharacteristics()
            local card_type = characteristics:CardType_GetWritable()
            local sub_type = characteristics:SubType_GetWritable()
            local current_type = {}
            for i = 0,7 do
               current_type[i] = EffectSource():GetCardType():Test(i)
            end
            sub_type:ClearAllOfType( CARD_TYPE_CREATURE )
            card_type:Clear()
            for i = 0,7 do
               if i ~= 1 and current_type[i] then
                  card_type:Add(i)
               end
            end
         end
      </CONTINUOUS_ACTION>
   </STATIC_ABILITY>
   <ACTIVATED_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{G}: Put a +1/+1 counter on target creature you control. That creature gains trample until end of turn. Activate this ability only any time you could cast a sorcery.]]></LOCALISED_TEXT>
      <COST mana_cost="{2}{G}" type="Mana" />
   <AVAILABILITY sorcery_time="1" />
      <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_PLUS1_PLUS1_COUNTERS" definition="0" compartment="0" count="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add(FE_CONTROLLER, OP_IS, EffectController() )
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            target:AddCounters( MTG():PlusOnePlusOneCounters(), 1)
         end
      </RESOLUTION_TIME_ACTION>
      <CONTINUOUS_ACTION layer="6">
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            local characteristics = target:GetCurrentCharacteristics()
            characteristics:Bool_Set( CHARACTERISTIC_TRAMPLE, 1 )
         end
      </CONTINUOUS_ACTION>
      <DURATION simple_duration="UntilEOT" />
      <SFX text="CASTER_BUFF_PLAY" />
      <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
   </ACTIVATED_ABILITY>   
   <ACTIVATED_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{R}: Put a +1/+1 counter on target creature you control. That creature gains haste until end of turn. Activate this ability only any time you could cast a sorcery.]]></LOCALISED_TEXT>
    <COST mana_cost="{2}{R}" type="Mana" />
   <AVAILABILITY sorcery_time="1" />
      <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_PLUS1_PLUS1_COUNTERS" definition="0" compartment="0" count="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add(FE_CONTROLLER, OP_IS, EffectController() )
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            target:AddCounters( MTG():PlusOnePlusOneCounters(), 1)
         end
      </RESOLUTION_TIME_ACTION>
      <CONTINUOUS_ACTION layer="6">
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            local characteristics = target:GetCurrentCharacteristics()
            characteristics:Bool_Set( CHARACTERISTIC_HASTE, 1 )
         end
      </CONTINUOUS_ACTION>
      <DURATION simple_duration="UntilEOT" />
      <SFX text="CASTER_BUFF_PLAY" />
      <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
   </ACTIVATED_ABILITY>
   <ACTIVATED_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{W}: Put a +1/+1 counter on target creature you control. That creature gains vigilance until end of turn. Activate this ability only any time you could cast a sorcery.]]></LOCALISED_TEXT>
    <COST mana_cost="{2}{W}" type="Mana" />
   <AVAILABILITY sorcery_time="1" />
      <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_PLUS1_PLUS1_COUNTERS" definition="0" compartment="0" count="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add(FE_CONTROLLER, OP_IS, EffectController() )
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            target:AddCounters( MTG():PlusOnePlusOneCounters(), 1)
         end
      </RESOLUTION_TIME_ACTION>
      <CONTINUOUS_ACTION layer="6">
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            local characteristics = target:GetCurrentCharacteristics()
            characteristics:Bool_Set( CHARACTERISTIC_VIGILANCE, 1 )
         end
      </CONTINUOUS_ACTION>
      <DURATION simple_duration="UntilEOT" />
      <SFX text="CASTER_BUFF_PLAY" />
      <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
   </ACTIVATED_ABILITY>
   <HELP title="MORE_INFO_BADGE_TITLE_8" body="MORE_INFO_BADGE_BODY_8" zone="ZONE_ANY" />
   <HELP title="MORE_INFO_TITLE_DEVOTION" body="MORE_INFO_BODY_DEVOTION" zone="ZONE_ANY" />
   <SFX text="COMBAT_FLAME_LARGE_ATTACK | COMBAT_WHITE_MAGIC_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
   <SFX text="COMBAT_FLAME_SMALL_ATTACK | COMBAT_WHITE_MAGIC_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
   <AI_BASE_SCORE score="750" zone="ZONE_BATTLEFIELD" />
   <AUTHOR><![CDATA[NivMizzet1]]></AUTHOR>
   <EDITORS><![CDATA[NivMizzet1]]></EDITORS>
   <DATE><![CDATA[06-11-16]]></DATE>
</CARD_V2>

Re: god devotion problem

PostPosted: 05 Nov 2016, 17:11
by thefiremind
I don't know how S_GetNumOfDevotion is coded. Have you checked that it can accept 3 colors? You could try testing the code with just 1 or 2 and see if it works: if it does, then the problem is there.

I would check myself but I can't find S_GetNumOfDevotion in the copy of the CW I have.

Re: god devotion problem

PostPosted: 05 Nov 2016, 22:49
by nivmizzet1
thefiremind wrote:I don't know how S_GetNumOfDevotion is coded. Have you checked that it can accept 3 colors? You could try testing the code with just 1 or 2 and see if it works: if it does, then the problem is there.

I would check myself but I can't find S_GetNumOfDevotion in the copy of the CW I have.
I have a sneaking suspicion you're right about it not accepting 3 colours. I can't find it in the WAD either, but it's working with 2 colours.

EDIT: I'm not sure if this is the correct function but it's the most likely thing I could find. I found it in this thread; the dual-colour gods that use the function were coded by sumomole, so there is a good chance this is the function, but it could be an older version.

Having a quick look I think I can see why it only works with 2 colours -- I think this line here shows it only considers two colours
Code: Select all
GetNumOfRedundantDevotion = function(object, colour_A, colour_B)
Here is the whole function
Code: Select all
GetNumOfColourSymbol = function(object, colour)
  local filter = ClearFilter()
  filter:Add( FE_CARD_INSTANCE, OP_IS, object )
   return filter:ChromaCount(colour)
end

GetNumOfRedundantDevotion = function(object, colour_A, colour_B)
   local cmc = object:GetConvertedManaCost()
   local amount = {}
   local num_color = 0
   local num_colored_mana = 0
   local num_total_colored_mana = 0
   local num_hybrid_symbol = 0
   if cmc > 0 and colour_A ~= colour_B then
      for i=0,5 do
         amount[i] = GetNumOfColourSymbol(object, i)
         if i == 0 then
          num_colored_mana = cmc - amount[i]
        elseif amount[i] > 0 then
           num_total_colored_mana = num_total_colored_mana + amount[i]
           num_color = num_color  + 1
        end
      end
      if num_total_colored_mana > num_colored_mana and amount[colour_A] > 0 and amount[colour_B] > 0 then
        if (num_color == 2 or (num_color == 3 and (colour_A - colour_B == 2 or colour_B - colour_A == 2 or colour_A - colour_B == 3 or colour_B - colour_A == 3))) then
           num_hybrid_symbol = num_total_colored_mana - num_colored_mana
        end
      end
   end
   return num_hybrid_symbol
end

GetNumOfDevotion = function(colour_A, colour_B)
  local devotion = 0
  local filter = ClearFilter()
   local subfilter = filter:AddSubFilter_Or()
     subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER )
  filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
   if colour_B == nil or colour_A == colour_B then
     devotion = filter:ChromaCount(colour_A)
   else
    devotion = filter:ChromaCount(colour_A)+ filter:ChromaCount(colour_B)
     local creatures = {}
    local numCards = filter:EvaluateObjects()
    for i=0,(numCards-1) do
       local card = filter:GetNthEvaluatedObject(i)
       if card ~= nil then
           creatures[i] = card
       end
    end
    for i=0,(numCards-1) do
      devotion = devotion - GetNumOfRedundantDevotion(creatures[i], colour_A, colour_B)
    end
  end
   return devotion
end
EDIT: that will be fun to try and work out for three colours... 8-[

Re: god devotion problem

PostPosted: 08 Nov 2016, 17:16
by Xander9009
It's in MANA_FUNCTIONS62.LOL, and this is its declaration: "S_GetNumOfDevotion = function(player, color_A, color_B)", so yes, the function only accepts two.

When I have some time, I'll see if I can rework it to accept any number of colors, but here's the code in the wad already:
Code: Select all
S_GetNumOfDevotion = function(player, color_A, color_B)
   local devotion = 0
   local filter = ClearFilter()
   local subfilter = filter:AddSubFilter_Or()
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER )
   filter:Add( FE_CONTROLLER, OP_IS, player )
   if color_B == nil or color_A == color_B then
      devotion = filter:ChromaCount(color_A)
   else
      devotion = filter:ChromaCount(color_A)+ filter:ChromaCount(color_B)
      local creatures = {}
      local numCards = filter:EvaluateObjects()
      for i=0,(numCards-1) do
         local card = filter:GetNthEvaluatedObject(i)
         if card ~= nil then
            creatures[i] = card
         end
      end
      for i=0,(numCards-1) do
      devotion = devotion - S_GetNumOfRedundantDevotion(creatures[i], color_A, color_B)
      end
   end
   return devotion
end
By the way, I don't know if it's packed or not (my repacker might skip the AHK files I include), but if it's included, then there's an AutoHotKey file in the functions folder labeled "_List Functions.ahk". If you run it (you have to have AHK installed), it'll list all functions available, their entire declaration line, and the file in which they're found.

Re: god devotion problem

PostPosted: 10 Nov 2016, 09:29
by nivmizzet1
Xander9009 wrote:It's in MANA_FUNCTIONS62.LOL, and this is its declaration: "S_GetNumOfDevotion = function(player, color_A, color_B)", so yes, the function only accepts two.

When I have some time, I'll see if I can rework it to accept any number of colors, but here's the code in the wad already:
Code: Select all
S_GetNumOfDevotion = function(player, color_A, color_B)
   local devotion = 0
   local filter = ClearFilter()
   local subfilter = filter:AddSubFilter_Or()
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
      subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER )
   filter:Add( FE_CONTROLLER, OP_IS, player )
   if color_B == nil or color_A == color_B then
      devotion = filter:ChromaCount(color_A)
   else
      devotion = filter:ChromaCount(color_A)+ filter:ChromaCount(color_B)
      local creatures = {}
      local numCards = filter:EvaluateObjects()
      for i=0,(numCards-1) do
         local card = filter:GetNthEvaluatedObject(i)
         if card ~= nil then
            creatures[i] = card
         end
      end
      for i=0,(numCards-1) do
      devotion = devotion - S_GetNumOfRedundantDevotion(creatures[i], color_A, color_B)
      end
   end
   return devotion
end
By the way, I don't know if it's packed or not (my repacker might skip the AHK files I include), but if it's included, then there's an AutoHotKey file in the functions folder labeled "_List Functions.ahk". If you run it (you have to have AHK installed), it'll list all functions available, their entire declaration line, and the file in which they're found.
Thanks Xander, I wouldn't want you to try to rework purely on my behalf -- there are no official cards that use tri-colour (or more) devotion; I simply wanted to use it on a custom card I was making. Having said that, if you want to do it to "challenge" yourself or you'd like to use it for your own purposes, I won't object. :)

Re: god devotion problem

PostPosted: 10 Nov 2016, 11:10
by Xander9009
CW_Mana_Devotion(oPlayer, ...)

There you go.
CW_Mana_Devotion(oPlayer, COLOUR_WHITE)
CW_Mana_Devotion(oPlayer, COLOUR_WHITE, COLOUR_BLUE)
CW_Mana_Devotion(oPlayer, COLOUR_WHITE, COLOUR_BLUE, COLOUR_GREEN)

Those three combinations were tested using Ephara, God of the Polis. I haven't tested it with phyrexian mana, but I did test it with many combinations of hybrid mana. However, there were no triple hybrids (I don't even know if the game can display triple hybrid mana). Should theoretically be able to handle all five colors.

Code: Select all
--Returns the devotion count to any number of colors.
--Input: Player, Ints
--Output: Int
CW_Mana_Devotion = function(oPlayer, ...)
   if oPlayer == nil then
      oPlayer = EffectController()
   end
   local iDevotion = 0
   if oPlayer == nil then
      CW_General_Error("CW_Mana_Devotion: oPlayer is nil.")
      return -1
   end
   for _, iColor in ipairs(arg) do
      local oFilter = ClearFilter()
      CW_Filter_AddPermanents(oFilter)
      oFilter:Add(FE_CONTROLLER, OP_IS, oPlayer)
      local iCount = oFilter:EvaluateObjects()
      local aoPermanents = {}
      for i=0,iCount-1 do
         local oCard = oFilter:GetNthEvaluatedObject(i)
         if oCard ~= nil then
            aoPermanents[i] = oCard
         end
      end
      iDevotion = iDevotion + oFilter:ChromaCount(iColor)
      for _, iSecondaryColor in ipairs(arg) do
         if iSecondaryColor > iColor then
            for i=0,iCount-1 do
               local oCard = aoPermanents[i]
               if oCard ~= nil then
                  iDevotion = iDevotion - S_GetNumOfRedundantDevotion(oCard, iColor, iSecondaryColor)
               end
            end
         end
      end
   end
   return iDevotion
end

Re: god devotion problem

PostPosted: 10 Nov 2016, 11:11
by Xander9009
Note that the if you include this in your mod directly (instead of just having the CW be a requirement), then please change the function's name.

Re: god devotion problem

PostPosted: 10 Nov 2016, 12:50
by nivmizzet1
Xander9009 wrote:
Code: Select all
--Returns the devotion count to any number of colors.
--Input: Player, Ints
--Output: Int
CW_Mana_Devotion = function(oPlayer, ...)
   if oPlayer == nil then
      oPlayer = EffectController()
   end
   local iDevotion = 0
   if oPlayer == nil then
      CW_General_Error("CW_Mana_Devotion: oPlayer is nil.")
      return -1
   end
   for _, iColor in ipairs(arg) do
      local oFilter = ClearFilter()
      CW_Filter_AddPermanents(oFilter)
      oFilter:Add(FE_CONTROLLER, OP_IS, oPlayer)
      local iCount = oFilter:EvaluateObjects()
      local aoPermanents = {}
      for i=0,iCount-1 do
         local oCard = oFilter:GetNthEvaluatedObject(i)
         if oCard ~= nil then
            aoPermanents[i] = oCard
         end
      end
      iDevotion = iDevotion + oFilter:ChromaCount(iColor)
      for _, iSecondaryColor in ipairs(arg) do
         if iSecondaryColor > iColor then
            for i=0,iCount-1 do
               local oCard = aoPermanents[i]
               if oCard ~= nil then
                  iDevotion = iDevotion - S_GetNumOfRedundantDevotion(oCard, iColor, iSecondaryColor)
               end
            end
         end
      end
   end
   return iDevotion
end
Wow -- you are awesome! :supz:

Re: god devotion problem

PostPosted: 17 Nov 2016, 06:21
by nivmizzet1
Xander9009 wrote:CW_Mana_Devotion(oPlayer, ...)

There you go.
CW_Mana_Devotion(oPlayer, COLOUR_WHITE)
CW_Mana_Devotion(oPlayer, COLOUR_WHITE, COLOUR_BLUE)
CW_Mana_Devotion(oPlayer, COLOUR_WHITE, COLOUR_BLUE, COLOUR_GREEN)

Those three combinations were tested using Ephara, God of the Polis. I haven't tested it with phyrexian mana, but I did test it with many combinations of hybrid mana. However, there were no triple hybrids (I don't even know if the game can display triple hybrid mana). Should theoretically be able to handle all five colors.

Code: Select all
--Returns the devotion count to any number of colors.
--Input: Player, Ints
--Output: Int
CW_Mana_Devotion = function(oPlayer, ...)
   if oPlayer == nil then
      oPlayer = EffectController()
   end
   local iDevotion = 0
   if oPlayer == nil then
      CW_General_Error("CW_Mana_Devotion: oPlayer is nil.")
      return -1
   end
   for _, iColor in ipairs(arg) do
      local oFilter = ClearFilter()
      CW_Filter_AddPermanents(oFilter)
      oFilter:Add(FE_CONTROLLER, OP_IS, oPlayer)
      local iCount = oFilter:EvaluateObjects()
      local aoPermanents = {}
      for i=0,iCount-1 do
         local oCard = oFilter:GetNthEvaluatedObject(i)
         if oCard ~= nil then
            aoPermanents[i] = oCard
         end
      end
      iDevotion = iDevotion + oFilter:ChromaCount(iColor)
      for _, iSecondaryColor in ipairs(arg) do
         if iSecondaryColor > iColor then
            for i=0,iCount-1 do
               local oCard = aoPermanents[i]
               if oCard ~= nil then
                  iDevotion = iDevotion - S_GetNumOfRedundantDevotion(oCard, iColor, iSecondaryColor)
               end
            end
         end
      end
   end
   return iDevotion
end
Do you want me to replace the the old devotion function with your new CW_Mana_Devotion on all the cards in the CW that use devotion? Currently I think there is at least two different functions being used, so it would be good to make it universal.

Re: god devotion problem

PostPosted: 17 Nov 2016, 08:12
by Xander9009
If you want, go for it. It'd certainly be nice to have fewer functions floating around. Let me know if you do so I can remove the old function from the file so it's not used by accident.

Re: god devotion problem

PostPosted: 23 Nov 2016, 11:23
by nivmizzet1
Xander9009 wrote:If you want, go for it. It'd certainly be nice to have fewer functions floating around. Let me know if you do so I can remove the old function from the file so it's not used by accident.
Okay, I've replaced the function on all multi-colour gods, but I can't remember what the two old functions were; also, I haven't checked if anything else was using those functions