Duel.IsExistingTarget
Signature
lua
Duel.IsExistingTarget([function|nil f], int player, int s, int o, int count, [Card|Group|nil ex], ... any) -> boolDescription
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)
endParameters
ffunction|niloptional - Filter called with each candidate card first, then any extra arguments after ex.playerint- Viewpoint player for s and o.sint- Locations on player's side to search.oint- Locations on the opponent's side to search.countint- Minimum number of legal targets required.exCard|Group|niloptional - 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:
- Common Script Errors And Debugging
- Filters, Card Objects, and Group Objects
- Write Your First Custom Card
- First Scripts To Study
- Normal And Continuous Traps
- Quick-Play Spells
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.
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()