name: Bujingi
card_text: When a Beast-Warrior-Type "Bujin" monster you control is targeted for an attack by an opponent's monster: You can send this card from your hand to the Graveyard; negate the attack, and if you do, inflict damage to your opponent equal to half the attacker's ATK. You can only use the effect of "Bujingi Crow" once per turn.
external_ids: local SETCARD_ID_0 = 0x88 --Bujin
  
lua: local SETCARD_ID_0 = 0x88 --Bujin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--negate attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.nacon)
  	e1:SetCost(s.nacost)
  	e1:SetTarget(s.natg)
  	e1:SetOperation(s.naop)
  	c:RegisterEffect(e1)
  end
  function s.nacon(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttackTarget()
  	return at:IsControler(tp) and at:IsFaceup() and at:IsSetCard(SETCARD_ID_0) and at:IsRace(RACE_BEASTWARRIOR)
  end
  function s.nacost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.natg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetAttacker():IsOnField()
  	end
  	local dam = math.floor(Duel.GetAttacker():GetAttack() / 2)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.naop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	if Duel.NegateAttack() then
  		Duel.Damage(1 - tp, math.floor(a:GetAttack() / 2), REASON_EFFECT)
  	end
  end
  
  
source_text: Bujingi
  When a Beast-Warrior-Type "Bujin" monster you control is targeted for an attack by an opponent's monster: You can send this card from your hand to the Graveyard; negate the attack, and if you do, inflict damage to your opponent equal to half the attacker's ATK. You can only use the effect of "Bujingi Crow" once per turn.
target_text: -- Bujingi
  local SETCARD_ID_0 = 0x88 --Bujin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--negate attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.nacon)
  	e1:SetCost(s.nacost)
  	e1:SetTarget(s.natg)
  	e1:SetOperation(s.naop)
  	c:RegisterEffect(e1)
  end
  function s.nacon(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttackTarget()
  	return at:IsControler(tp) and at:IsFaceup() and at:IsSetCard(SETCARD_ID_0) and at:IsRace(RACE_BEASTWARRIOR)
  end
  function s.nacost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.natg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetAttacker():IsOnField()
  	end
  	local dam = math.floor(Duel.GetAttacker():GetAttack() / 2)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.naop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	if Duel.NegateAttack() then
  		Duel.Damage(1 - tp, math.floor(a:GetAttack() / 2), REASON_EFFECT)
  	end
  end
  
  