name: Umbral
card_text: When this card is Normal or Special Summoned: You can target 1 "Umbral Horror" monster you control or in your Graveyard, except this card; this card's Level becomes the current Level of that monster. When this Attack Position card is destroyed by battle and sent to the Graveyard, and was in face-up Attack Position at the start of the Damage Step: Destroy the monster that destroyed this card.
external_ids: local SETCARD_ID_0 = 0x87 --Umbral
  
lua: local SETCARD_ID_0 = 0x87 --Umbral
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c, clv)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(1) and not c:IsLevel(clv) and ((c:IsLocation(LOCATION_MZONE) and c:IsFaceup()) or c:IsLocation(LOCATION_GRAVE))
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE + LOCATION_GRAVE) and s.filter(chkc, e:GetHandler():GetLevel())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, e:GetHandler(), e:GetHandler():GetLevel())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, 1, e:GetHandler(), e:GetHandler():GetLevel())
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and (not tc:IsLocation(LOCATION_MZONE) or tc:IsFaceup()) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetValue(tc:GetLevel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetBattlePosition() == POS_FACEUP_ATTACK and c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local rc = e:GetHandler():GetReasonCard()
  	Duel.SetTargetCard(rc)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, rc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local rc = Duel.GetFirstTarget()
  	if rc:IsRelateToEffect(e) then
  		Duel.Destroy(rc, REASON_EFFECT)
  	end
  end
  
  
source_text: Umbral
  When this card is Normal or Special Summoned: You can target 1 "Umbral Horror" monster you control or in your Graveyard, except this card; this card's Level becomes the current Level of that monster. When this Attack Position card is destroyed by battle and sent to the Graveyard, and was in face-up Attack Position at the start of the Damage Step: Destroy the monster that destroyed this card.
target_text: -- Umbral
  local SETCARD_ID_0 = 0x87 --Umbral
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c, clv)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(1) and not c:IsLevel(clv) and ((c:IsLocation(LOCATION_MZONE) and c:IsFaceup()) or c:IsLocation(LOCATION_GRAVE))
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE + LOCATION_GRAVE) and s.filter(chkc, e:GetHandler():GetLevel())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, e:GetHandler(), e:GetHandler():GetLevel())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, 1, e:GetHandler(), e:GetHandler():GetLevel())
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and (not tc:IsLocation(LOCATION_MZONE) or tc:IsFaceup()) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetValue(tc:GetLevel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetBattlePosition() == POS_FACEUP_ATTACK and c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local rc = e:GetHandler():GetReasonCard()
  	Duel.SetTargetCard(rc)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, rc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local rc = Duel.GetFirstTarget()
  	if rc:IsRelateToEffect(e) then
  		Duel.Destroy(rc, REASON_EFFECT)
  	end
  end
  
  