name: Trap
card_text: When an opponent's monster that was Normal or Special Summoned this turn declares an attack: Destroy that attacking monster, and if you do, inflict damage to your opponent equal to half the original ATK of that monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttacker()
  	return at:IsControler(1 - tp) and at:IsStatus(STATUS_SUMMON_TURN + STATUS_SPSUMMON_TURN)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local at = Duel.GetAttacker()
  	if chk == 0 then
  		return at:IsRelateToBattle()
  	end
  	local dam = math.max(math.floor(at:GetBaseAttack() / 2), 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, at, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttacker()
  	if at:IsRelateToBattle() and Duel.Destroy(at, REASON_EFFECT) ~= 0 then
  		local atk = math.floor(at:GetBaseAttack() / 2)
  		if atk > 0 then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Trap
  When an opponent's monster that was Normal or Special Summoned this turn declares an attack: Destroy that attacking monster, and if you do, inflict damage to your opponent equal to half the original ATK of that monster.
target_text: -- Trap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttacker()
  	return at:IsControler(1 - tp) and at:IsStatus(STATUS_SUMMON_TURN + STATUS_SPSUMMON_TURN)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local at = Duel.GetAttacker()
  	if chk == 0 then
  		return at:IsRelateToBattle()
  	end
  	local dam = math.max(math.floor(at:GetBaseAttack() / 2), 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, at, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttacker()
  	if at:IsRelateToBattle() and Duel.Destroy(at, REASON_EFFECT) ~= 0 then
  		local atk = math.floor(at:GetBaseAttack() / 2)
  		if atk > 0 then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		end
  	end
  end
  
  