--Arcarum III - L'IMPERATRICE --Script by XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) c:SetUniqueOnField(1,0,id) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --indes local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetRange(LOCATION_SZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x5477)) e2:SetValue(aux.indoval) c:RegisterEffect(e2) --spsummon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,0)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e3:SetCode(EVENT_DESTROYED) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1) e3:SetCondition(cid.spcon) e3:SetCost(cid.spcost) e3:SetTarget(cid.sptg) e3:SetOperation(cid.spop) c:RegisterEffect(e3) --draw local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,1)) e4:SetCategory(CATEGORY_DRAW) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetCode(EVENT_PHASE+PHASE_STANDBY) e4:SetRange(LOCATION_SZONE) e4:SetLabelObject(e3) e4:SetCountLimit(1) e4:SetCondition(cid.drawcon) e4:SetCost(cid.drawcost) e4:SetTarget(cid.drawtg) e4:SetOperation(cid.drawop) c:RegisterEffect(e4) end --filters function cid.cfilter(c,tp) return c:IsPreviousLocation(LOCATION_MZONE) and c:GetPreviousTypeOnField()&TYPE_MONSTER==TYPE_MONSTER and c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:GetPreviousControler()==tp end function cid.spfilter(c,e,tp,g) local check=false if not g or #g<=0 then return false end for tc in aux.Next(g) do if cid.cfilter(tc,1-tp) then local atk=tc:GetAttack() if atk<0 then atk=0 end if atk>=c:GetAttack() then check=true end end end return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x5477) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and check end --spsummon function cid.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.cfilter,1,nil,1-tp) end function cid.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end if Duel.GetCurrentPhase()==PHASE_STANDBY and Duel.GetTurnPlayer()==tp then e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,2,Duel.GetTurnCount()) else e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,1,0) end end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return eg and #eg>0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp,eg) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) if not eg or #eg<=0 then return end if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(cid.spfilter),tp,LOCATION_GRAVE,0,1,1,nil,e,tp,eg) if #g>0 then Duel.HintSelection(g) if Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)~=0 then local og=Duel.GetOperatedGroup():GetFirst() e:SetLabelObject(og) if Duel.GetCurrentPhase()==PHASE_STANDBY and Duel.GetTurnPlayer()==tp then e:GetHandler():RegisterFlagEffect(id+100,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,2,Duel.GetTurnCount()) else e:GetHandler():RegisterFlagEffect(id+100,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,1,0) end end end end end --draw function cid.drawcon(e,tp,eg,ep,ev,re,r,rp) local tid,tid2=e:GetHandler():GetFlagEffectLabel(id),e:GetHandler():GetFlagEffectLabel(id+100) return tid and tid2 and tid~=Duel.GetTurnCount() and Duel.GetTurnPlayer()==tp end function cid.drawcost(e,tp,eg,ep,ev,re,r,rp,chk) local tc=e:GetLabelObject():GetLabelObject() if chk==0 then return tc and tc:IsLocation(LOCATION_MZONE) and tc:IsAbleToGraveAsCost() end Duel.SendtoGrave(tc,REASON_COST) end function cid.drawtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function cid.drawop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end