Log in

Object() functions (DotP 2012)

Contents

Summary

Below is a list of functions that can be applied to Object(). Note that I'll call "current object" the object that calls the function. Maybe "parent object" could have been more appropriate, but since the word "parent" is used for objects that got other objects attached, I opted for another word, in order to avoid confusion.

AddCounters

Syntax: AddCounters( <counter type identifier>, <number of counters> )

Effect: Adds the specified type of counters in the specified quantity to the current object.

Notes: The identifiers for the counter types must be taken from MTG(). See DotP 2012 MTG() functions for more information.

Example: Blood Tyrant's triggered ability resolution code:

   <RESOLUTION_TIME_ACTION>
   if Object():GetZone() == ZONE_IN_PLAY then
     Object():AddCounters( MTG():PlusOnePlusOneCounters(), 5 )
   end
   </RESOLUTION_TIME_ACTION>

Attach

Syntax: Attach( <object to be attached to> )

Effect: Assigns the current object to the specified object as an Equipment.

Notes: There's a specific sequence of functions that make an equipment work, this alone isn't enough. See the example for more details.

Example: Any equipment assignment resolution code:

   <RESOLUTION_TIME_ACTION>
   local target = Object():GetTargetCard()
   if target ~= nil then
     Object():AttachmentFilter_Get():Clear()
     Object():AttachmentFilter_Get():AddCardType( CARD_TYPE_CREATURE )
     Object():Attach( target )
   end
   </RESOLUTION_TIME_ACTION>

AttachmentFilter_Get

Syntax: AttachmentFilter_Get()

Effect: Returns a filter that specifies the kinds of objects that the current object can be assigned to.

Notes: Despite the name, it's used not only for Equipments, but also for Auras. See the example for more details, and see DotP 2012 Filter() functions for the list of sub-functions you can use with it.

Example: Any aura assignment resolution code:

   <RESOLUTION_TIME_ACTION>
   Object():AttachmentFilter_Get():Clear()
   Object():AttachmentFilter_Get():AddCardType( CARD_TYPE_CREATURE )
   Object():Enchant( Object():GetTargetCard())
   </RESOLUTION_TIME_ACTION>

CalcPotentialScore

Syntax: ?

Effect: ?

Notes: There's no proof of it, but judging from the name, this function should be used by the AI in order to calculate the score of cards. Not clear what it means for "potential".

Example: No example given.

CalcScore

Syntax: ?

Effect: ?

Notes: There's no proof of it, but judging from the name, this function should be used by the AI in order to calculate the score of cards.

Example: No example given.

ClearDamage

Syntax: ?

Effect: ?

Notes: There's no proof of it, but judging from the name, this function should clear all the damage on a creature, just as the regeneration does.

Example: No example given.

ClearTarget

Syntax: ?

Effect: ?

Notes: There's no proof of it, but judging from the name, this function should delete the target(s) chosen for the current object.

Example: No example given.

ComesIntoPlayTapped

Syntax: ComesIntoPlayTapped()

Effect: Forces the current object to come into play tapped.

Notes: The only official example (Loxodon Gatekeeper) uses this function in a COMES_INTO_PLAY triggered ability with pre_trigger="1". It could be the only working way of using it.

Example: Loxodon Gatekeeper's triggered ability resolution code:

   <RESOLUTION_TIME_ACTION>
   if TriggerObject() ~= nil then
     TriggerObject():ComesIntoPlayTapped()
   end
   </RESOLUTION_TIME_ACTION>

CountCounters

Syntax: CountCounters( <counter type identifier> )

Effect: Counts the quantity of the specified type of counters on the current object.

Notes: The identifiers for the counter types must be taken from MTG(). See DotP 2012 MTG() functions for more information.

Example: Blastoderm's fading ability resolution code:

   <RESOLUTION_TIME_ACTION>
   if Object():CountCounters(MTG():GetCountersType("Fade")) > 0 then
     Object():RemoveCounters(MTG():GetCountersType("Fade"), 1)
   else
     Object():Sacrifice()
   end
   </RESOLUTION_TIME_ACTION>

CounterSpell

Syntax: CounterSpell()

Effect: Counters the current object.

Notes: The object that calls this function should be on the stack, otherwise it wouldn't be considered as a spell.

Example: Cancel spell resolution code:

   <RESOLUTION_TIME_ACTION>
   if Object():GetTargetCard() ~= nil then
     Object():GetTargetCard():CounterSpell()
   end
   </RESOLUTION_TIME_ACTION>

DealCDamage

Syntax: DealCDamage( <damage amount>, <damage source> )

Effect: Deals the specified amount of combat damage to the current object, considering the specified source as the damage source.

Notes: There's no proof of the use of this function, but it should almost surely work the same way as DealDamage, the only difference is that this function deals combat damage.

Example: No example given.

DealDamage

Syntax: DealDamage( <damage amount>, <damage source> )

Effect: Deals the specified amount of (non-combat) damage to the current object, considering the specified source as the damage source.

Notes: Nothing to add.

Example: Shock spell resolution code:

   <RESOLUTION_TIME_ACTION>
   if ( Object():GetTargetCard() ~= nil ) then
     Object():GetTargetCard():DealDamage(2, Object())
   elseif ( Object():GetTargetPlayer() ~= nil ) then
     Object():GetTargetPlayer():DealDamage(2, Object())
   end
   </RESOLUTION_TIME_ACTION>

DealDamageFullParams

Syntax: DealDamage( <damage amount>, <damage source>, <?>, <unpreventable> )

Effect: Deals the specified amount of damage to the current object, considering the specified source as the damage source. The damage can be unpreventable by setting the last parameter to 1.

Notes: The third parameter is unknown. It could be a flag that specifies whether the damage is non-combat (0) or combat (1).

Example: Banefire spell resolution code:

   <RESOLUTION_TIME_ACTION>
   if Object():GetManaX() > 4 then
     if (Object():GetTargetCard() ~= nil) then
       Object():GetTargetCard():DealDamageFullParams( Object():GetManaX(), Object(), 0, 1 )
     elseif (Object():GetTargetPlayer() ~= nil) then
       Object():GetTargetPlayer():DealDamageFullParams( Object():GetManaX(), Object(), 0, 1 )
     end
   else
     if (Object():GetTargetCard() ~= nil) then
       Object():GetTargetCard():DealDamage(Object():GetManaX(), Object())
     elseif (Object():GetTargetPlayer() ~= nil) then
       Object():GetTargetPlayer():DealDamage(Object():GetManaX(), Object())
     end
   end
   </RESOLUTION_TIME_ACTION>

DecreaseColouredCost

Syntax: DecreaseColouredCost( <mana colour>, <decrease amount> )

Effect: Decreases the cost of the current object by the specified amount, influencing only the part of cost with the specified mana colour.

Notes: This function is not used in the core of the game, but we have working examples from the modders' community. A decrease bigger than the full coloured cost probably doesn't fall in a decrease of the colourless remaining cost, so this should be taken into account when coding dynamic cost reductions (such as Khalni Hydra).

Example: The following statement reduces the green mana cost of the current object by 2:

   Object():DecreaseColouredCost( COLOUR_GREEN, 2 )

DecreaseColouredCost

Syntax: DecreaseCost( <decrease amount> )

Effect: Decreases the cost of the current object by the specified amount, influencing only the colourless part of cost.

Notes: Nothing to add.

Example: Ruby Medallion's static ability continous code:

   <FILTER>
   return (FilteredCard():GetColour():Test( COLOUR_RED ) ~= 0 and OwnedByYou() and InHand())
   </FILTER>
   <CONTINUOUS_ACTION>
   FilteredCard():DecreaseCost( 1 )
   </CONTINUOUS_ACTION>

DecreaseColouredCost

Syntax: Destroy()

Effect: Destroys the current object.

Notes: Nothing to add.

Example: Argentum Armor's triggered ability resolution code:

   <RESOLUTION_TIME_ACTION>
   if Object():GetTargetCard() ~= nil then
     Object():GetTargetCard():Destroy()
   end
   </RESOLUTION_TIME_ACTION>

work in progress...