name: Battlewasp
card_text: 1 Insect Tuner + 1+ non-Tuner monsters
  Once per battle, during damage calculation, if this card attacks an opponent's monster with equal or higher ATK (Quick Effect): You can halve the ATK of that opponent's monster, during that damage calculation only. When this card inflicts battle damage to your opponent: You can inflict 200 damage to your opponent for each "Battlewasp" monster you control. You can only use this effect of "Battlewasp - Halberd the Charge" once per turn.
external_ids: local SETCARD_ID_0 = 0x12f --Battlewasp
  
lua: local SETCARD_ID_0 = 0x12f --Battlewasp
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_INSECT), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--atk change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.atkcon)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	return c == Duel.GetAttacker() and tc and tc:IsFaceup() and tc:IsControler(1 - tp) and tc:IsAttackAbove(c:GetAttack())
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:GetFlagEffect(id) == 0
  	end
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL, 0, 1)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	if c:IsRelateToBattle() and c:IsFaceup() and tc:IsRelateToBattle() and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL)
  		e1:SetValue(math.ceil(tc:GetAttack() / 2))
  		tc:RegisterEffect(e1)
  	end
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.damfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.damfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	local val = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil) * 200
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, val)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local val = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil) * 200
  	Duel.Damage(p, val, REASON_EFFECT)
  end
  
  
source_text: Battlewasp
  1 Insect Tuner + 1+ non-Tuner monsters
  Once per battle, during damage calculation, if this card attacks an opponent's monster with equal or higher ATK (Quick Effect): You can halve the ATK of that opponent's monster, during that damage calculation only. When this card inflicts battle damage to your opponent: You can inflict 200 damage to your opponent for each "Battlewasp" monster you control. You can only use this effect of "Battlewasp - Halberd the Charge" once per turn.
target_text: -- Battlewasp
  local SETCARD_ID_0 = 0x12f --Battlewasp
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_INSECT), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--atk change
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.atkcon)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	return c == Duel.GetAttacker() and tc and tc:IsFaceup() and tc:IsControler(1 - tp) and tc:IsAttackAbove(c:GetAttack())
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:GetFlagEffect(id) == 0
  	end
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL, 0, 1)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	if c:IsRelateToBattle() and c:IsFaceup() and tc:IsRelateToBattle() and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL)
  		e1:SetValue(math.ceil(tc:GetAttack() / 2))
  		tc:RegisterEffect(e1)
  	end
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.damfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.damfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	local val = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil) * 200
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, val)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local val = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil) * 200
  	Duel.Damage(p, val, REASON_EFFECT)
  end
  
  