Skip to content

Duel.GetTargetsRelateToChain ​

Signature ​

lua
Duel.GetTargetsRelateToChain() -> Group

Description ​

Returns all target cards currently related to the resolving Chain. This is the relation-aware helper for multi-target operations; targets that left their expected place are omitted from the returned Group. The returned Group can be empty, so check its count before applying a follow-up action.

How To Use It ​

Use this during resolution when a targeting effect selected more than one card and only the targets still related to the Chain should be affected.

lua
local g=Duel.GetTargetsRelateToChain()
if #g>0 then
    Duel.Destroy(g,REASON_EFFECT)
end

The returned Group can be empty. It is built from the current Chain's target cards and relation state, so it is usually clearer than manually filtering CHAININFO_TARGET_CARDS.

Returns ​

  • Group - New Group containing the current Chain targets whose Chain relation is still valid; empty when none qualify.

Source ​

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

Guided Examples ​

Learn how to use this function in context:

Used By ​

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

  • Detected in 177 indexed script(s).
  • Search this function in the Script Explorer with Duel.GetTargetsRelateToChain.
CardIDScriptDetected Calls
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua1
Ashtraja Susanoo17020474Scripts/c17020474.lua1
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua1
Artmage Masterwork -Succession-37517035Scripts/c37517035.lua1
GMX Associate Noma83528184Scripts/c83528184.lua1
Dracotail Shaulas42125140Scripts/c42125140.lua1
Ecclesia and the Dark Dragon78397661Scripts/c78397661.lua1
S:P Little Knight29301450Scripts/c29301450.lua1
Divine Serpent Apophis97800311Scripts/c97800311.lua1
Arms of Genex Return Zero61775475Scripts/c61775475.lua1
Ghoti Fury65898344Scripts/c65898344.lua1
Astrazma Urania18738846Scripts/c18738846.lua1
Purrelyeap!?82983267Scripts/c82983267.lua1
Yummy☆Surprise29369059Scripts/c29369059.lua1
Traptrix Atypus48183890Scripts/c48183890.lua1
R.B. Shepherd's Crook80071619Scripts/c80071619.lua1
Radiant Typhoon Mandate53813120Scripts/c53813120.lua1
Ryu-Ge Rivalry81549048Scripts/c81549048.lua1
Lunalight Perfume Dancer81196066Scripts/c81196066.lua1
Heraldic Beast Stad Whale97662494Scripts/c97662494.lua1
Possessed Destiny - Wynn60516416Scripts/c60516416.lua1
White Circle Reef21579049Scripts/c21579049.lua1
Unchained Firelord of Yama94014327Scripts/c94014327.lua1
Zefra Metaltron85216896Scripts/c85216896.lua1
...and 153 more

Script Examples ​

Astrograph Sorcerer, the Starfrost Magician (48171151) ​

Source: Scripts/c48171151.lua

lua
	if not c:IsRelateToChain() then return end
	if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then return end
	local desg=Duel.GetTargetsRelateToChain():Filter(s.spfilter1,nil,e,tp)
	if #desg>0 and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then
		Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)

Ashtraja Susanoo (17020474) ​

Source: Scripts/c17020474.lua

lua
function s.setop(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local g=Duel.GetTargetsRelateToChain()
	if aux.NecroValleyNegateCheck(g) then return end
	local sg=g:Filter(aux.NecroValleyFilter(),nil)

D/D/D Alfred the Divine Sage King (11852093) ​

Source: Scripts/c11852093.lua

lua
end
function s.tfop(e,tp,eg,ep,ev,re,r,rp)
	local g=Duel.GetTargetsRelateToChain()
	local sct=Duel.GetLocationCount(tp,LOCATION_SZONE)
	local ct=math.min(g:GetCount(),sct)