--Dorein Casalinga --Scripted by: XGlitchy30 local s,id=GetID() s.original_category={} s.original_property={} function s.initial_effect(c) aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkSetCard,0xd04),1,1) c:EnableReviveLimit() --Effects upon Link Summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_DELAY) e1:SetCountLimit(1,id) e1:SetCondition(aux.LinkSummonedCond) e1:SetCost(s.damcost) e1:SetTarget(s.damtg) e1:SetOperation(s.damop) c:RegisterEffect(e1) local c1=e1:GetCategory() local p1,p2=e1:GetProperty() s.original_property[e1]=c1 s.original_property[e1]={p1,p2} --Search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,3)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id+100) e2:SetCondition(s.damchk(1000)) e2:SetCost(s.damcost) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) --Add local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,4)) e3:SetCategory(CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_DELAY) e3:SetCode(EVENT_TO_GRAVE) e3:SetCountLimit(1,id+200) e3:SetCondition(s.gycon) e3:SetCost(s.damcost) e3:SetTarget(s.gytg) e3:SetOperation(s.gyop) c:RegisterEffect(e3) --Protection local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,5)) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetCode(EVENT_FREE_CHAIN) e4:SetRange(LOCATION_GRAVE) e4:SetCountLimit(1,id+300) e4:SetCondition(s.damchk(3000)) e4:SetCost(s.immcost) e4:SetTarget(s.immtg) e4:SetOperation(s.immop) c:RegisterEffect(e4) --count damage if not s.global_check then s.global_check=true s[0]=0 s[1]=0 local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_DAMAGE) ge1:SetOperation(s.checkop) Duel.RegisterEffect(ge1,0) end Duel.AddCustomActivityCounter(id,ACTIVITY_CHAIN,s.chainfilter) end function s.chainfilter(re,tp,cid) return re:GetHandler():IsSetCard(0xd04) or not re:IsHasCategory(CATEGORY_DAMAGE) end function s.checkop(e,tp,eg,ep,ev,re,r,rp) if bit.band(r,REASON_EFFECT)~=0 and rp==1-ep and re and re:GetHandler():IsSetCard(0xd04) then s[rp]=s[rp]+ev end end function s.damchk(val) return function(e,tp,eg,ep,ev,re,r,rp) if not tp then tp=e:GetHandlerPlayer() end return s[tp]>=val end end function s.damcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(id,tp,ACTIVITY_CHAIN)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(1,0) e1:SetValue(s.aclimit) e1:SetReset(RESET_PHASE+PHASE_END+RESET_TURN_OPPO) Duel.RegisterEffect(e1,tp) end function s.aclimit(e,re,tp) return not s.chainfilter(re,tp) end function s.damtg(e,tp,eg,ep,ev,re,r,rp,chk) local b1=Duel.GetLP(1-tp)>=3000 local b2=Duel.GetLP(1-tp)<6000 e:SetCategory(s.original_category[e]) e:SetProperty(s.original_property[e][1],s.original_property[e][2]) if chk==0 then return b1 or b2 end local sel=aux.Option(id,tp,1,b1,b2) e:SetLabel(sel) if sel==0 then e:SetCategory(CATEGORY_DAMAGE) e:SetProperty(EFFECT_FLAG_PLAYER_TARGET) Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(500) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,0,0,1-tp,500) end end function s.damop(e,tp,eg,ep,ev,re,r,rp) local sel=e:GetLabel() local c=e:GetHandler() if sel==0 and Duel.GetLP(1-tp)>=3000 then local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) else Duel.SetLP(1-tp,6000) end end function s.thfilter(c) return c:GetType()&(TYPE_SPELL+TYPE_FIELD)==TYPE_SPELL+TYPE_FIELD and c:IsSetCard(0xd04) and c:IsAbleToHand() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function s.gycon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) and s.damchk(2000)(e,tp) end function s.gyfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0xd04) and c:IsFaceup() and c:IsAbleToHand() end function s.gytg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.gyfilter,tp,LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_REMOVED) end function s.gyop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.gyfilter,tp,LOCATION_REMOVED,0,1,1,nil) if #g>0 then Duel.HintSelection(g) Duel.SendtoHand(g,nil,REASON_EFFECT) end end function s.immcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,0) and s.damcost(e,tp,eg,ep,ev,re,r,rp,0) end aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,1) s.damcost(e,tp,eg,ep,ev,re,r,rp,1) end function s.immfilter(c) return c:IsFaceup() and c:IsMonster() and c:IsSetCard(0xd04) end function s.immtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.immfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.immfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,s.immfilter,tp,LOCATION_MZONE,0,1,1,nil) end function s.immop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) and s.immfilter(tc) then local rct=Duel.GetTurnPlayer()==tp and 2 or 1 local e1=Effect.CreateEffect(e:GetHandler()) e1:Desc(5) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetProperty(EFFECT_FLAG_CLIENT_HINT) e1:SetValue(s.efilter) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END+RESET_SELF_TURN,rct) e1:SetOwnerPlayer(tp) tc:RegisterEffect(e1) end end function s.efilter(e,te) return not te:GetOwner():IsSetCard(0xd04) end