name: Roar
card_text: Once per turn, if an opponent's monster declares an attack: Target the attacking monster; destroy that target, and if you do, inflict damage to your opponent equal to half the destroyed monster's ATK. You must control an "Earthbound Immortal" monster with ATK higher than the ATK of the attacking monster to activate and to resolve this effect.
external_ids: local SETCARD_ID_0 = 0x1021 --Earthbound
  
lua: local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, atk)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetAttack() > atk
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	return Duel.GetTurnPlayer() ~= tp and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, tc:GetAttack())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tc = Duel.GetAttacker()
  	if chkc then
  		return chkc == tc
  	end
  	if chk == 0 then
  		return tc:IsOnField() and tc:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tc)
  	local dam = math.floor(tc:GetAttack() / 2)
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackable() then
  		local atk = math.floor(tc:GetAttack() / 2)
  		if Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Roar
  Once per turn, if an opponent's monster declares an attack: Target the attacking monster; destroy that target, and if you do, inflict damage to your opponent equal to half the destroyed monster's ATK. You must control an "Earthbound Immortal" monster with ATK higher than the ATK of the attacking monster to activate and to resolve this effect.
target_text: -- Roar
  local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, atk)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetAttack() > atk
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	return Duel.GetTurnPlayer() ~= tp and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, tc:GetAttack())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tc = Duel.GetAttacker()
  	if chkc then
  		return chkc == tc
  	end
  	if chk == 0 then
  		return tc:IsOnField() and tc:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tc)
  	local dam = math.floor(tc:GetAttack() / 2)
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackable() then
  		local atk = math.floor(tc:GetAttack() / 2)
  		if Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		end
  	end
  end
  
  