name: Cocatorium
card_text: If this card is in your hand or GY: You can Tribute 1 Beast, Beast-Warrior, or Winged Beast monster; Special Summon this card, but banish it when it leaves the field. You can banish 1 Level 4 or lower Beast, Beast-Warrior, or Winged Beast monster from your Deck; this card's name becomes that banished monster's name, also it becomes the same Type, Attribute and Level as that monster's, until the End Phase. You can only use each effect of "Cocatorium the Heavy Metal Avian" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--copy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsRace(RACE_BEAST + RACE_BEASTWARRIOR + RACE_WINDBEAST) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsFaceup() or c:IsControler(tp))
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter, 1, nil, tp)
  	end
  	local g = Duel.SelectReleaseGroup(tp, s.cfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e1, true)
  	end
  end
  function s.filter(c)
  	return c:IsLevelBelow(4) and c:IsRace(RACE_BEAST + RACE_BEASTWARRIOR + RACE_WINDBEAST) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = e:GetLabelObject()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetCode(EFFECT_CHANGE_CODE)
  		e1:SetValue(tc:GetOriginalCode())
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CHANGE_RACE)
  		e2:SetValue(tc:GetOriginalRace())
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e3:SetValue(tc:GetOriginalAttribute())
  		c:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_CHANGE_LEVEL)
  		e4:SetValue(tc:GetOriginalLevel())
  		c:RegisterEffect(e4)
  	end
  end
  
  
source_text: Cocatorium
  If this card is in your hand or GY: You can Tribute 1 Beast, Beast-Warrior, or Winged Beast monster; Special Summon this card, but banish it when it leaves the field. You can banish 1 Level 4 or lower Beast, Beast-Warrior, or Winged Beast monster from your Deck; this card's name becomes that banished monster's name, also it becomes the same Type, Attribute and Level as that monster's, until the End Phase. You can only use each effect of "Cocatorium the Heavy Metal Avian" once per turn.
target_text: -- Cocatorium
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--copy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsRace(RACE_BEAST + RACE_BEASTWARRIOR + RACE_WINDBEAST) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsFaceup() or c:IsControler(tp))
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter, 1, nil, tp)
  	end
  	local g = Duel.SelectReleaseGroup(tp, s.cfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e1, true)
  	end
  end
  function s.filter(c)
  	return c:IsLevelBelow(4) and c:IsRace(RACE_BEAST + RACE_BEASTWARRIOR + RACE_WINDBEAST) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = e:GetLabelObject()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetCode(EFFECT_CHANGE_CODE)
  		e1:SetValue(tc:GetOriginalCode())
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CHANGE_RACE)
  		e2:SetValue(tc:GetOriginalRace())
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e3:SetValue(tc:GetOriginalAttribute())
  		c:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_CHANGE_LEVEL)
  		e4:SetValue(tc:GetOriginalLevel())
  		c:RegisterEffect(e4)
  	end
  end
  
  