It is currently 01 Sep 2025, 06:52
   
Text Size

Question how to set a value free from zone changes

Moderator: CCGHQ Admins

Question how to set a value free from zone changes

Postby 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 :D
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

Postby 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.
sweetLu
 
Posts: 181
Joined: 16 Jul 2014, 01:24
Has thanked: 21 times
Been thanked: 22 times

Re: Question how to set a value free from zone changes

Postby 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.
  1. 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>
  2. 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...
User avatar
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

Postby NeoAnderson » 08 Sep 2014, 21:38

thefiremind wrote:I have 2 ideas, but I think I tried at least one of them and I had problems implementing it.
  1. 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>
  2. 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).
I was thinking something similar, i am not at pc right now i will make some tests later, but i have 2 questions,
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

Postby thefiremind » 08 Sep 2014, 21:52

NeoAnderson wrote:First why are you using replacement_query instead of replacement_effect ?
Because I copied the code from a card that was using replacement_query and forgot to change it. :lol:

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.
Try and see.
< 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: 722 times

Re: Question how to set a value free from zone changes

Postby RiiakShiNal » 09 Sep 2014, 00:41

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 :D
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.

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 )
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.

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.
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

Postby NeoAnderson » 09 Sep 2014, 01:27

RiiakShiNal wrote:
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 :D
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.

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 )
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.

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.
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 ))
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>
So when i have to turn off i simply use a RESOLUTION block as the follow :
Code: Select all
      <RESOLUTION_TIME_ACTION>
            Object():GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_CANT_BE_PLAYED, 1 )
                 MTG():ReevaluateContinuousEffects()
      </RESOLUTION_TIME_ACTION>
This has no effect with other cards, because the Object is already on battlefield, so "can't be played" has no meaning, and it is set to 1 just for few seconds.

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

Postby 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).
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

Postby NeoAnderson » 09 Sep 2014, 11:53

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).
ahahhah so my idea was already taken?? And what about CHARACTERISTIC_CANT_BE_COUNTERED another one that has no-sense onto battlefield.

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>
Honestly if we are talking about these 2 cards, i believe that can be implemented simply changing the filter excluding the ZONE_BATTLEFIELD, but most important probably i would code them using the Trigger Considered_For_Cast as many other cards like these.
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 8 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 8 guests

Login Form