--自然始兽 古鼎鹿
local s,id,o=GetID()
function s.initial_effect(c)
    c:SetUniqueOnField(1,0,id)
    --[[地属性同调怪兽+「自然」怪兽]]
    c:EnableReviveLimit()
    aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0x2a),s.matfilter,true)
    --[[这张卡不用融合召唤不能从额外卡组特殊召唤]]
    local e0=Effect.CreateEffect(c)
    e0:SetType(EFFECT_TYPE_SINGLE)
    e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
    e0:SetCode(EFFECT_SPSUMMON_CONDITION)
    e0:SetCondition(s.con0)
    e0:SetValue(aux.fuslimit)
    c:RegisterEffect(e0)
    --[[同一连锁上，最后1个发动的效果以外的效果无效]]
    local e1=Effect.CreateEffect(c)
    e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
    e1:SetCode(EVENT_CHAIN_SOLVING)
    e1:SetRange(LOCATION_MZONE)
    e1:SetCondition(s.con1)
    e1:SetOperation(s.op1)
    c:RegisterEffect(e1)
    local e2=Effect.CreateEffect(c)
    e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
    e2:SetCode(EVENT_CHAINING)
    e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
    e2:SetRange(LOCATION_MZONE)
    e2:SetOperation(s.op2)
    c:RegisterEffect(e2)
    --[[这张卡不受除以这张卡为对象的效果以外的对方的所发动的效果影响]]
    local e3=Effect.CreateEffect(c)
    e3:SetType(EFFECT_TYPE_SINGLE)
    e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
    e3:SetRange(LOCATION_MZONE)
    e3:SetCode(EFFECT_IMMUNE_EFFECT)
    e3:SetValue(s.efilter)
    c:RegisterEffect(e3)
end
function s.matfilter(c)
    return c:IsFusionType(TYPE_SYNCHRO) and c:IsFusionAttribute(ATTRIBUTE_EARTH)
end
function s.con0(e)
    return e:GetHandler():IsLocation(LOCATION_EXTRA)
end
function s.con1(e,tp,eg,ep,ev,re,r,rp)
    local tv=Duel.GetChainInfo(ev,CHAININFO_CHAIN_COUNT)
    local a=e:GetHandler():GetFlagEffect(id)
    return Duel.IsChainDisablable(ev) and e:GetHandler():GetFlagEffect(id)>tv
end
function s.op1(e,tp,eg,ep,ev,re,r,rp)
    Duel.Hint(HINT_CARD,0,id)
    Duel.NegateEffect(ev)
end
function s.op2(e,tp,eg,ep,ev,re,r,rp)
    e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESET_CHAIN,0,1)
end
function s.efilter(e,te)
    if te:GetOwnerPlayer()==e:GetHandlerPlayer() or not te:IsActivated() then return false end
    if not te:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return true end
    local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
    return not g or not g:IsContains(e:GetHandler())
end