Duel.Destroy
Signature
Duel.Destroy(Card|Group targets, int reason, [int dest], [int reason_player]) -> intDescription
Destroys targets for reason and returns the number of cards actually destroyed. dest defaults to LOCATION_GRAVE. reason_player defaults to the current Chain's reason player. Use REASON_EFFECT for normal card effects and reserve REASON_RULE for rule/procedure cleanup. Use Duel.SetOperationInfo with CATEGORY_DESTROY in the target callback when the cards or source location are known before resolution.
How To Use It
Use this during resolution after checking that the target is still related to the effect.
The return value is important. It is 0 when no card was actually destroyed, for example because the card left the expected place or could not be destroyed.
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)>0 then
-- follow-up that requires successful destruction
endUse Duel.SetOperationInfo(0,CATEGORY_DESTROY,...) in the Target callback when the destruction is known before resolution.
Related Functions
Parameters
targetsCard|Groupreasonintdestintoptionalreason_playerintoptional
Returns
int
Source
D:\Programs\GitHub\ygopro-core\libduel.cpp:4858
Guided Examples
Learn how to use this function in context:
- Methods for Affecting Cards
- Categories, Properties, And Hint Timing
- First Scripts To Study
- Functions That Move Cards Across Locations
- Quick-Play Spells
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 2744 indexed script(s).
- Search this function in the Script Explorer with
Duel.Destroy.
Script Examples
Astrograph Sorcerer, the Starfrost Magician (48171151)
Source: Scripts/c48171151.lua
local c=e:GetHandler()
if not c:IsRelateToChain() then return end
if Duel.Destroy(c,REASON_EFFECT)==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g=Duel.SelectMatchingCard(tp,s.pfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,tp)Astrograph Sorcerer (76794549)
Source: Scripts/c76794549.lua
function c76794549.rpop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)>0 then
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(76794549,6))
local g=Duel.SelectMatchingCard(tp,c76794549.rpfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,e,tp)Mementotlan Fusion (66518509)
Source: Scripts/c66518509.lua
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_MZONE,0,1,1,nil)
if Duel.Destroy(g,REASON_EFFECT)<1 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil)