NeoAnderson wrote:I was looking to the planeswalkers manager code, to try to understand why the game performance slow down so much when we play with planeswalkers.
I found that the most resources are used from the follow ability- Targetting override | Open
- Code: Select all
<!-- 7. Cards not allowed to target Planeswalkers -->
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="CARD_CONSIDERED_FOR_TARGETTING" pre_trigger="1">
local target = TriggerObject()
local filter = ClearFilter()
filter:Add(FE_CARD_NAME, OP_IS, "ENCHANTED_EVENING") -- With Enchanted Evening on the battlefield, Planeswalkers would be enchantments for real
if filter:CountStopAt(1) == 0 or target:GetZone() ~= ZONE_BATTLEFIELD then
local targetter = SecondaryObject()
if PLW_IsInNameSet(target, "PLANESWALKERS") and
( PLW_IsInNameSet(targetter, "TARGET_ENCHANTMENTS_NOT_CREATURES") or
(target:GetCardType():Test(CARD_TYPE_CREATURE) == false and
PLW_IsInNameSet(targetter, "TARGET_ENCHANTMENTS_AND_CREATURES")) ) then
MTG():OverrideEvent()
return true
end
end
return false
</TRIGGER>
</TRIGGERED_ABILITY>
I tested the game without this override trigger and the game works without any lag.
So i was thinking if we change the trigger into a static protection action, does it could create any issue? I think could be a good performance improvement.
Oh, please, yes!
- Code: Select all
<!-- 7. Cards not allowed to target Planeswalkers -->
<STATIC_ABILITY>
<FILTER filter_id="0">
local filter = ClearFilter()
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
</FILTER>
<CONTINUOUS_ACTION layer="0" filter_id="0">
if FilteredCard() ~= nil then
local filter = ClearFilter()
filter:Add(FE_CARD_NAME, OP_IS, "ENCHANTED_EVENING") -- With Enchanted Evening on the battlefield, Planeswalkers would be enchantments for real
if filter:CountStopAt(1) == 0 or FilteredCard():GetZone() ~= ZONE_BATTLEFIELD and PLW_IsInNameSet(FilteredCard(), "PLANESWALKERS") then
filter = ClearFilter()
PLW_FilterNameSet(filter, "TARGET_ENCHANTMENTS_NOT_CREATURES", true)
if FilteredCard():GetCardType():Test(CARD_TYPE_CREATURE) == false then
PLW_FilterNameSet(filter, "TARGET_ENCHANTMENTS_AND_CREATURES", true)
end
FilteredCard():Protection()
end
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
Starting point, at least?
EDIT: Well, no luck. This ability slows it down all the time instead of just when zoomed into cards and stuff. (Also, I forgot the closing slash in the </STATIC_ABILITY>).
One way we might be able to speed it up is to use either the static or triggered ability, but instead of using the PLANESWALKERS, TARGET_ENCHANTMENTS_NOT_CREATURES, and TARGET_ENCHANTMENTS_AND_CREATURES lists, use those lists to create shorter lists of only the cards which actually exist within the current duel. With shorter lists, it should be able to run a bit faster. You could put the lists in object dc chests within each player's planeswalker manager.