--Marmotrite Incisor --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_BEAST),2,2) --attach local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetTarget(s.xyztg) e1:SetOperation(s.xyzop) c:RegisterEffect(e1) --place local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE+CATEGORY_DISABLE) e2:SetCustomCategory(CATEGORY_PLACE_AS_CONTINUOUS_TRAP,CATEGORY_FLAG_SELF) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id) e2:SetTarget(s.target) e2:SetOperation(s.operation) c:RegisterEffect(e2) end --ATTACH function s.xyzfilter(c) return c:IsFaceup() and c:GetType()&0x20004==0x20004 end function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.xyzfilter,tp,LOCATION_SZONE,LOCATION_SZONE,1,nil) end end function s.xyzop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFacedown() or not c:IsRelateToChain(0) then return end local g=Duel.GetMatchingGroup(s.xyzfilter,tp,LOCATION_SZONE,LOCATION_SZONE,nil) if #g>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) local og=g:Select(tp,1,1,nil) Duel.HintSelection(og) Duel.Overlay(c,og) end end --PLACE function s.tgfilter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSetCard(0x549) and c:IsAbleToHand() end function s.filter(c) return c:IsFaceup() and (c:GetAttack()>0 or c:GetDefense()>0) end function s.filter2(c) return c:IsFaceup() and not (c:GetAttack()==0 and c:GetDefense()==0 and not aux.NegateMonsterFilter(c)) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if e:GetHandler():GetOverlayCount()<=0 then return false end local b1=(e:GetHandler():GetOverlayCount()>=1 and Duel.GetLocationCount(tp,LOCATION_MZONE,PLAYER_NONE,LOCATION_REASON_COUNT)+Duel.GetLocationCount(1-tp,LOCATION_MZONE,PLAYER_NONE,LOCATION_REASON_COUNT)>0 and Duel.IsExistingMatchingCard(s.tgfilter,tp,LOCATION_DECK,0,1,nil)) local b2=(e:GetHandler():GetOverlayCount()>=2 and Duel.IsExistingMatchingCard(s.filter,tp,0,LOCATION_MZONE,1,nil)) local b3=(e:GetHandler():GetOverlayCount()>=3 and Duel.IsExistingMatchingCard(s.filter2,tp,0,LOCATION_MZONE,1,nil)) return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and not e:GetHandler():IsForbidden() and (b1 or b2 or b3) end Duel.SetCustomOperationInfo(0,CATEGORY_PLACE_AS_CONTINUOUS_TRAP,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) if e:GetHandler():GetOverlayCount()>1 then local g=Duel.GetMatchingGroup(s.filter,tp,0,LOCATION_MZONE,nil) Duel.SetCustomOperationInfo(0,CATEGORY_ATKCHANGE,g,1,0,0,{-2}) Duel.SetCustomOperationInfo(0,CATEGORY_DEFCHANGE,g,1,0,0,{-2}) end if e:GetHandler():GetOverlayCount()>2 then local g=Duel.GetMatchingGroup(s.filter2,tp,0,LOCATION_MZONE,nil) Duel.SetCustomOperationInfo(0,CATEGORY_ATKCHANGE,g,1,0,0,{0}) Duel.SetCustomOperationInfo(0,CATEGORY_DEFCHANGE,g,1,0,0,{0}) Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) end end function s.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToChain(0) or Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end local ct=e:GetHandler():GetOverlayCount() if not c:IsImmuneToEffect(e) and Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) then local e1=Effect.CreateEffect(c) e1:SetCode(EFFECT_CHANGE_TYPE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TURN_SET) e1:SetValue(TYPE_TRAP+TYPE_CONTINUOUS) c:RegisterEffect(e1) --check respected conditions local b1=(ct>=1 and Duel.GetLocationCount(tp,LOCATION_MZONE,PLAYER_NONE,LOCATION_REASON_COUNT)+Duel.GetLocationCount(1-tp,LOCATION_MZONE,PLAYER_NONE,LOCATION_REASON_COUNT)>0 and Duel.IsExistingMatchingCard(s.tgfilter,tp,LOCATION_DECK,0,1,nil)) local b2=(ct>=2 and Duel.IsExistingMatchingCard(s.filter,tp,0,LOCATION_MZONE,1,nil)) local b3=(ct>=3 and Duel.IsExistingMatchingCard(s.filter2,tp,0,LOCATION_MZONE,1,nil)) local off=1 --choose effect and apply local ops={} local opval={} if b1 then ops[off]=aux.Stringid(id,2) opval[off]=0 off=off+1 end if b2 then ops[off]=aux.Stringid(id,3) opval[off]=1 off=off+1 end if b3 then ops[off]=aux.Stringid(id,4) opval[off]=2 off=off+1 end local op=Duel.SelectOption(tp,table.unpack(ops))+1 local sel=opval[op] Duel.Hint(HINT_OPSELECTED,1-tp,aux.Stringid(id,sel+2)) if sel==0 then local dis=Duel.SelectDisableField(tp,1,LOCATION_MZONE,LOCATION_MZONE,EXTRA_MONSTER_ZONE) Duel.Hint(HINT_ZONE,tp,dis) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_ONFIELD) e1:SetCode(EFFECT_DISABLE_FIELD) e1:SetReset(RESET_EVENT+(RESETS_STANDARD_DISABLE&(~RESET_TOFIELD))) e1:SetLabel(dis) e1:SetOperation(s.disop) e:GetHandler():RegisterEffect(e1) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,s.tgfilter,tp,LOCATION_DECK,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif sel==1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectMatchingCard(tp,s.filter,tp,0,LOCATION_MZONE,1,1,nil) local tc=g:GetFirst() if tc then Duel.HintSelection(g) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_ATTACK_FINAL) e1:SetValue(tc:GetAttack()//2) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) local e1x=Effect.CreateEffect(c) e1x:SetType(EFFECT_TYPE_SINGLE) e1x:SetCode(EFFECT_SET_DEFENSE_FINAL) e1x:SetValue(tc:GetDefense()//2) e1x:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1x) end else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectMatchingCard(tp,s.filter2,tp,0,LOCATION_MZONE,1,2,nil) if #g>0 then Duel.HintSelection(g) for tc in aux.Next(g) do local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_ATTACK_FINAL) e1:SetValue(0) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) local e1x=Effect.CreateEffect(c) e1x:SetType(EFFECT_TYPE_SINGLE) e1x:SetCode(EFFECT_SET_DEFENSE_FINAL) e1x:SetValue(0) e1x:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1x) Duel.Negate(tc,e) end end end end end function s.disop(e,tp) return e:GetLabel() end