Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



Question how to set a value free from zone changes
Moderator: CCGHQ Admins
9 posts
• Page 1 of 1
Question how to set a value free from zone changes
by NeoAnderson » 08 Sep 2014, 17:23
Just a simple question, i need to set a integer value into a register and i would avoid to build a DuelDataChest.
I need that this flag is stored when i play an ability from hand, and it must be keeped also throught the zone changes of the card.
I tried with LinkedDC but it is resetted when the card is cast.
I tried with RSN_ObjectDC but it is resetted when the card is cast.
I tried RSN_Characteristics the same as above.
I need to set an Int value = to 1 when i use an activated ability from hand, i need it to keep the duration of an effect until i set it to 0 again.
Any idea will be appreciated
I need that this flag is stored when i play an ability from hand, and it must be keeped also throught the zone changes of the card.
I tried with LinkedDC but it is resetted when the card is cast.
I tried with RSN_ObjectDC but it is resetted when the card is cast.
I tried RSN_Characteristics the same as above.
I need to set an Int value = to 1 when i use an activated ability from hand, i need it to keep the duration of an effect until i set it to 0 again.
Any idea will be appreciated

- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
Re: Question how to set a value free from zone changes
by sweetLu » 08 Sep 2014, 19:49
I don't know how you could do it without duel or player data chests. LinkedDC and RSN_ObjectDC are set up to clear for zone changes (I'm not too familiar with Riiak's custom characteristics). You might be able to add a triggered ability to protect the pointer to the RSN_ObjectDC whenever a zone change is considered. I did this when I worked on the EDH mod but with that there can only be one commander per player so I think I just used a player data chest and a single register. I think RSN_ObjectDC uses duel data chests and manages what registers are used behind the scenes. So if you can figure out how to protect the card pointer for a zone change you should be fine since a lot of the hard work is already done for you.
Re: Question how to set a value free from zone changes
by thefiremind » 08 Sep 2014, 21:23
I have 2 ideas, but I think I tried at least one of them and I had problems implementing it.
EDIT: Example added, and fixed (I was too hasty the first time I wrote it).
- Make a ZONECHANGE_BEGIN trigger that triggers for any zone change. Save the value into EffectDC inside the TRIGGER block, then write it back to LinkedDC inside the resolution (remember that the resolution of a ZONECHANGE_BEGIN trigger happens after the zone change, only the TRIGGER code is executed before).
- Code: Select all
<TRIGGERED_ABILITY replacement_effect="1" linked_ability_group="1" active_zone="ZONE_ANY">
<TRIGGER value="ZONECHANGE_BEGIN" simple_qualifier="self" to_zone="ZONE_ANY" from_zone="ZONE_ANY">
EffectDC():Set_Int( 0, LinkedDC():Get_Int(YOUR_VALUE_REGISTER) )
return true
</TRIGGER>
<RESOLUTION_TIME_ACTION>
LinkedDC():Set_Int( YOUR_VALUE_REGISTER, EffectDC():Get_Int(0) )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
- Same as above, but use a delayed ZONECHANGE_END trigger for writing back the value to LinkedDC.
EDIT: Example added, and fixed (I was too hasty the first time I wrote it).
Last edited by thefiremind on 08 Sep 2014, 21:51, edited 1 time in total.
< 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: 722 times
Re: Question how to set a value free from zone changes
by NeoAnderson » 08 Sep 2014, 21:38
I was thinking something similar, i am not at pc right now i will make some tests later, but i have 2 questions,thefiremind wrote:I have 2 ideas, but I think I tried at least one of them and I had problems implementing it.
- Make a ZONECHANGE_BEGIN trigger that triggers for any zone change. Save the value into EffectDC inside the TRIGGER block, then write it back to LinkedDC inside the resolution (remember that the resolution of a ZONECHANGE_BEGIN trigger happens after the zone change, only the TRIGGER code is executed before).
- Code: Select all
<TRIGGERED_ABILITY replacement_query="1" linked_ability_group="1" active_zone="ZONE_ANY">
<TRIGGER value="ZONECHANGE_BEGIN" simple_qualifier="self" to_zone="ZONE_ANY" from_zone="ZONE_ANY">
EffectDC():Set_Int( 0, LinkedDC():Get_Int(YOUR_VALUE_REGISTER) )
return true
</TRIGGER>
<RESOLUTION_TIME_ACTION>
LinkedDC():Set_Int( YOUR_VALUE_REGISTER, EffectDC():Get_Int(0) )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>- Same as above, but use a delayed ZONECHANGE_END trigger for writing back the value to LinkedDC.
EDIT: Example added, and fixed (I was too hasty the first time I wrote it).
First why are you using replacement_query instead of replacement_effect ?
Second could be later to store the register value when the change zone begin, could be better to use zone_change_considered?
Probably make a delayed trigger could be the best solution because we store the value into delayDC then we pass it as parameter.
Hope that continuos effect will not retrieve any changes while we do these actions.
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
Re: Question how to set a value free from zone changes
by thefiremind » 08 Sep 2014, 21:52
Because I copied the code from a card that was using replacement_query and forgot to change it.NeoAnderson wrote:First why are you using replacement_query instead of replacement_effect ?

Try and see.NeoAnderson wrote:Second could be later to store the register value when the change zone begin, could be better to use zone_change_considered?
Probably make a delayed trigger could be the best solution because we store the value into delayDC then we pass it as parameter.
< 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: 722 times
Re: Question how to set a value free from zone changes
by RiiakShiNal » 09 Sep 2014, 00:41
My ObjectDC functions does use the DuelDataChest behind the scenes as that is the best place to put chests that are associated with a card that should be universally accessible. If you really don't want to use the DuelDataChest then using a delayed trigger as suggested by thefiremind is probably the best solution.NeoAnderson wrote:Just a simple question, i need to set a integer value into a register and i would avoid to build a DuelDataChest.
I need that this flag is stored when i play an ability from hand, and it must be keeped also throught the zone changes of the card.
I tried with LinkedDC but it is resetted when the card is cast.
I tried with RSN_ObjectDC but it is resetted when the card is cast.
I tried RSN_Characteristics the same as above.
I need to set an Int value = to 1 when i use an activated ability from hand, i need it to keep the duration of an effect until i set it to 0 again.
Any idea will be appreciated
If, however, you don't care that DuelDataChest is used behind the scenes you can still use the ObjectDC functions. Instead of using RSN_ObjectDC() you would use something like this:
- Code: Select all
local oChest = RSN_GetObjectDC( Object(), true )
Custom Characteristics are not suitable for this as they are meant to be constantly set and cleared (every time state-based effects are calculated) and even then they use the ObjectDC functions behind the scenes.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Question how to set a value free from zone changes
by NeoAnderson » 09 Sep 2014, 01:27
As always Riiak I really appreciate your answers, probably i made a mistake using your function RSN_ObjectDC because i simply create the Object chest using RSN_ObjectDC() function, as you said i should use the other one (RSN_GetObjectDC( Object(), true ))RiiakShiNal wrote:My ObjectDC functions does use the DuelDataChest behind the scenes as that is the best place to put chests that are associated with a card that should be universally accessible. If you really don't want to use the DuelDataChest then using a delayed trigger as suggested by thefiremind is probably the best solution.NeoAnderson wrote:Just a simple question, i need to set a integer value into a register and i would avoid to build a DuelDataChest.
I need that this flag is stored when i play an ability from hand, and it must be keeped also throught the zone changes of the card.
I tried with LinkedDC but it is resetted when the card is cast.
I tried with RSN_ObjectDC but it is resetted when the card is cast.
I tried RSN_Characteristics the same as above.
I need to set an Int value = to 1 when i use an activated ability from hand, i need it to keep the duration of an effect until i set it to 0 again.
Any idea will be appreciated
If, however, you don't care that DuelDataChest is used behind the scenes you can still use the ObjectDC functions. Instead of using RSN_ObjectDC() you would use something like this:Since the Object() pointer is not invalidated between zone changes it should be able to retain the data chest. This would probably be the simplest solution since all the behind the scenes code is already written.
- Code: Select all
local oChest = RSN_GetObjectDC( Object(), true )
Custom Characteristics are not suitable for this as they are meant to be constantly set and cleared (every time state-based effects are calculated) and even then they use the ObjectDC functions behind the scenes.
Anyway i have already done with a workaround, i am using a card embedded characteristic.
When i activate the ability from the hand i set the duration :
- Code: Select all
<DURATION>
return Object():GetCurrentCharacteristics():Bool_Get( CHARACTERISTIC_CANT_BE_PLAYED )
</DURATION>
- Code: Select all
<RESOLUTION_TIME_ACTION>
Object():GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_CANT_BE_PLAYED, 1 )
MTG():ReevaluateContinuousEffects()
</RESOLUTION_TIME_ACTION>
Anyway i will make also some test using Firemind solution and also your different object function so i can have more options...
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
Re: Question how to set a value free from zone changes
by RiiakShiNal » 09 Sep 2014, 10:32
I could swear that there are other cards that are using CHARACTERISTIC_CANT_BE_PLAYED for cards on the battlefield, but I can't currently remember which modder did that and for which cards. So there may be a conflict with that card(s) if I can ever remember which one(s).
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Question how to set a value free from zone changes
by NeoAnderson » 09 Sep 2014, 11:53
ahahhah so my idea was already taken?? And what about CHARACTERISTIC_CANT_BE_COUNTERED another one that has no-sense onto battlefield.RiiakShiNal wrote:I could swear that there are other cards that are using CHARACTERISTIC_CANT_BE_PLAYED for cards on the battlefield, but I can't currently remember which modder did that and for which cards. So there may be a conflict with that card(s) if I can ever remember which one(s).
UPDATE: I made a search using your deck builder and XML STRING SEARCH and i found these 2 cards made by sumomole :
Meddling Mage and Nevermore and both uses the follow filter :
- Code: Select all
<FILTER filter_id="0">
local filter = ClearFilter()
filter:SetZone(ZONE_ANYWHERE)
filter:Add( FE_CARD_NAME, OP_IS, S_LoadName() )
</FILTER>
<CONTINUOUS_ACTION layer="8" filter_id="0">
if FilteredCard() ~= nil then
FilteredCard():GetCurrentCharacteristics():Bool_Set(CHARACTERISTIC_CANT_BE_PLAYED, 1)
end
</CONTINUOUS_ACTION>
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests