Skip to content

Duel.IsExistingTarget ​

Signature ​

lua
Duel.IsExistingTarget([function|nil f], int player, int s, int o, int count, [Card|Group|nil ex], ... any) -> bool

Description ​

Checks whether the specified locations contain at least count cards that satisfy filter f, are not excluded by ex, and can be targeted by the currently handled effect. Use this in Target callbacks when the card must become an official effect target.

How To Use It ​

Use this in a Target callback when the effect text chooses target cards.

Duel.IsExistingTarget is like Duel.IsExistingMatchingCard, but it also checks whether each candidate can become a target of the current effect. That matters for cards unaffected by targeting, cards protected by effects, and target restrictions.

lua
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    if chkc then return chkc:IsOnField() and s.filter(chkc) end
    if chk==0 then
        return Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil)
    end
    Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end

Parameters ​

  • f function|nil optional - Filter called with each candidate card first, then any extra arguments after ex.
  • player int - Viewpoint player for s and o.
  • s int - Locations on player's side to search.
  • o int - Locations on the opponent's side to search.
  • count int - Minimum number of legal targets required.
  • ex Card|Group|nil optional - Card or Group excluded from the search.
  • ... any - Extra values passed to f after the candidate card.

Returns ​

  • bool - True if at least count matching cards can be targeted by the current effect.

Source ​

  • D:\Programs\GitHub\ygopro-core\libduel.cpp:4985

Guided Examples ​

Learn how to use this function in context:

More guided lessons (2)

Used By ​

Generated from the local Scripts/ folder and cards.cdb.

  • Detected in 4928 indexed script(s).
  • Search this function in the Script Explorer with Duel.IsExistingTarget.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua1
Pendulum Evolution55795155Scripts/c55795155.lua1
Surprise Fusion35167375Scripts/c35167375.lua1
Ultra Polymerization76647978Scripts/c76647978.lua1
Melffy Playtime Surprise58036097Scripts/c58036097.lua1
Ashtraja Susanoo17020474Scripts/c17020474.lua1
Fiendsmith's Sequence49867899Scripts/c49867899.lua1
El Shaddoll Apkallone50907446Scripts/c50907446.lua1
Meteoroa Drytron24166324Scripts/c24166324.lua1
Mixousia the Confounder80843006Scripts/c80843006.lua1
Invoked Sorath43989315Scripts/c43989315.lua1
Performage Cup Tricker6812770Scripts/c6812770.lua2
Spirit Illusion71939275Scripts/c71939275.lua1
Ghostrick Renovation61818176Scripts/c61818176.lua1
Hecahands Tartaros57809669Scripts/c57809669.lua1
Enneacraft - Asta.PIXEA28454232Scripts/c28454232.lua1
Odd-Eyes Revolution Dragon16306932Scripts/c16306932.lua1
Resurgam Xyz49082032Scripts/c49082032.lua1
Tohushaddoll Grysta95072744Scripts/c95072744.lua1
PSY-Framelord Omega74586817Scripts/c74586817.lua2
Teleport Fusion36494597Scripts/c36494597.lua1
Graydle Split75361204Scripts/c75361204.lua1
Enneacraft - Archa.TAIL81237046Scripts/c81237046.lua1
D/D/D/D Dimensional King Arc Crisis71398055Scripts/c71398055.lua1
...and 4904 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

lua
	if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc) end
	if chk==0 then return e:IsCostChecked()
		and Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
	Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)

Pendulum Evolution (55795155) ​

Source: Scripts/c55795155.lua

lua
function c55795155.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsCode(13331639) and chkc:IsFaceup() end
	if chk==0 then return Duel.IsExistingTarget(c55795155.atkfilter,tp,LOCATION_MZONE,0,1,nil) end
	Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)

Surprise Fusion (35167375) ​

Source: Scripts/c35167375.lua

lua
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() and s.rafilter(chkc) end
	if chk==0 then return Duel.IsExistingTarget(s.rafilter,tp,LOCATION_MZONE,0,1,nil) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
	local tc=Duel.SelectTarget(tp,s.rafilter,tp,LOCATION_MZONE,0,1,1,nil):GetFirst()