--Mantra's Hidden Ability --Automate ID local scard,s_id=GetID() function scard.initial_effect(c) --draw Card.IsMantra=Card.IsMantra or (function(tc) return tc:IsSetCard(0x7d0) or (tc:GetCode()>30200 and tc:GetCode()<30230) end) local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,RELEVANT_TIMINGS) e1:SetCountLimit(1,s_id+EFFECT_COUNT_CODE_OATH) e1:SetCost(scard.cost) e1:SetOperation(scard.operation) c:RegisterEffect(e1) end function scard.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetActivityCount(tp,ACTIVITY_BATTLE_PHASE)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_BP) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) Duel.RegisterHint(tp,s_id,PHASE_END,1,s_id,1) end function scard.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(scard.drcon1) e1:SetOperation(scard.drop1) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) --sp_summon effect local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCondition(scard.regcon) e2:SetOperation(scard.regop) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e3:SetCode(EVENT_CHAIN_SOLVED) e3:SetCondition(scard.drcon2) e3:SetOperation(scard.drop2) e3:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e3,tp) end function scard.filter(c,tp) return c:GetSummonPlayer()==tp and c:IsMantra() and c:IsFaceup() end function scard.drcon1(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(scard.filter,1,nil,tp) and (not re:IsHasType(EFFECT_TYPE_ACTIONS) or re:IsHasType(EFFECT_TYPE_CONTINUOUS)) end function scard.drop1(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) if #g>0 then Duel.Hint(HINT_CARD,tp,s_id) local tg=g:Select(tp,1,1,nil) if #tg>0 then Duel.HintSelection(tg) Duel.Destroy(tg,REASON_EFFECT) end end end function scard.regcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(scard.filter,1,nil,tp) and re:IsHasType(EFFECT_TYPE_ACTIONS) and not re:IsHasType(EFFECT_TYPE_CONTINUOUS) end function scard.regop(e,tp,eg,ep,ev,re,r,rp) Duel.RegisterFlagEffect(tp,s_id+1,RESET_CHAIN,0,1) end function scard.drcon2(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFlagEffect(tp,s_id+1)>0 end function scard.drop2(e,tp,eg,ep,ev,re,r,rp) local n=Duel.GetFlagEffect(tp,s_id+1) Duel.ResetFlagEffect(tp,s_id+1) local g=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) if #g>0 then Duel.Hint(HINT_CARD,tp,s_id) local tg=g:Select(tp,1,1,nil) if #tg>0 then Duel.HintSelection(tg) Duel.Destroy(tg,REASON_EFFECT) end end end