--ESPErgear Knight:Valkyrie local cid,id=GetID() function cid.initial_effect(c) aux.AddOrigEvoluteType(c) aux.AddEvoluteProc(c,nil,9,aux.FilterBoolFunction(Card.IsCode,16000020),1,1,cid.matfilter,2,2) c:EnableReviveLimit() --negate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,0)) e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e2:SetCode(EVENT_CHAINING) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCondition(cid.negcon) e2:SetCost(cid.negcost) e2:SetTarget(cid.negtg) e2:SetOperation(cid.negop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,1)) e3:SetCategory(CATEGORY_REMOVE) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) --e3:SetCountLimit(1,52068433) e3:SetCondition(cid.remcon) e3:SetTarget(cid.remtg) e3:SetOperation(cid.remop) c:RegisterEffect(e3) --Special SUmmon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,1)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_TO_GRAVE) e4:SetCondition(cid.spcon) e4:SetTarget(cid.sumtg) e4:SetOperation(cid.spop) c:RegisterEffect(e4) local e5=e4:Clone() e5:SetCode(EVENT_REMOVE) c:RegisterEffect(e5) local e6=e4:Clone() e6:SetCode(EVENT_TO_DECK) c:RegisterEffect(e6) end function cid.matfilter(c,ec,tp) return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsType(TYPE_UNION) and c:IsRace(RACE_MACHINE) end function cid.negcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if ep==tp or c:IsStatus(STATUS_BATTLE_DESTROYED) then return false end return (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev) end function cid.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsCanRemoveEC(tp,3,REASON_COST) end e:GetHandler():RemoveEC(tp,3,REASON_COST) end function cid.negtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function cid.negop(e,tp,eg,ep,ev,re,r,rp) local rc=re:GetHandler() if not Duel.NegateActivation(ev) then return end if rc:IsRelateToEffect(re) and Duel.Destroy(eg,REASON_EFFECT)~=0 and not rc:IsLocation(LOCATION_HAND+LOCATION_DECK) then if rc:IsAbleToHand() and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then Duel.BreakEffect() Duel.SendtoHand(rc,tp,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,rc) end end end function cid.filter(c) return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() end function cid.remcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+388 end function cid.remtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.filter,tp,0,LOCATION_ONFIELD,1,nil) and Duel.IsExistingMatchingCard(cid.filter,tp,0,LOCATION_GRAVE,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,0,LOCATION_ONFIELD+LOCATION_GRAVE+LOCATION_HAND) end function cid.remop(e,tp,eg,ep,ev,re,r,rp) local g1=Duel.GetMatchingGroup(cid.filter,tp,0,LOCATION_ONFIELD,nil) local g2=Duel.GetMatchingGroup(cid.filter,tp,0,LOCATION_GRAVE,nil) if g1:GetCount()>0 and g2:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg1=g1:Select(tp,1,1,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg2=g2:Select(tp,1,1,nil) sg1:Merge(sg2) Duel.HintSelection(sg1) Duel.Remove(sg1,POS_FACEUP,REASON_EFFECT) end end function cid.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousPosition(POS_FACEUP) and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) end function cid.mgfilter(c,e,tp,sync) return not c:IsControler(tp) or not c:IsLocation(LOCATION_GRAVE+LOCATION_REMOVED) or not r==REASON_MATERIAL+0x10000000 or not c:IsCanBeSpecialSummoned(e,0,tp,false,false) or c:IsHasEffect(EFFECT_NECRO_VALLEY) end function cid.sumtg(e,tp,eg,ep,ev,re,r,rp,chk) local mg=e:GetHandler():GetMaterial() local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft>1 and Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end if chk==0 then return mg:GetCount()>0 and ft>=mg:GetCount() and not mg:IsExists(cid.mgfilter,1,nil,e,tp,e:GetHandler()) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,mg,mg:GetCount(),tp,0) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) local mg=e:GetHandler():GetMaterial() local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft>1 and Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end if mg:GetCount()>ft or mg:IsExists(cid.mgfilter,1,nil,e,tp,e:GetHandler()) then return end Duel.SpecialSummon(mg,0,tp,tp,false,false,POS_FACEUP) end