name: Ambush
card_text: Activate only when a face-up "Venom" monster you control is declared as an attack target. Negate the attack and end the Battle Phase. Then place 1 Venom Counter on the monster that attacked.
external_ids: local CARD_ID_0 = 54306223 --Venom Swamp
  local SETCARD_ID_0 = 0x50 --Venom
  local COUNTER_ID_0 = 0x1009 --Venom
  
lua: local CARD_ID_0 = 54306223 --Venom Swamp
  local SETCARD_ID_0 = 0x50 --Venom
  local COUNTER_ID_0 = 0x1009 --Venom
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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 tc = Duel.GetAttackTarget()
  	return tc and tc:IsControler(tp) and tc:IsFaceup() and tc:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Duel.GetAttacker()
  	if chkc then
  		return chkc == tg
  	end
  	if chk == 0 then
  		return tg:IsOnField() and tg:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tg)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	if tc:IsRelateToEffect(e) and Duel.NegateAttack() then
  		Duel.SkipPhase(1 - tp, PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
  		Duel.BreakEffect()
  		local atk = tc:GetAttack()
  		tc:AddCounter(COUNTER_ID_0, 1)
  		if atk > 0 and tc:IsAttack(0) then
  			Duel.RaiseEvent(tc, EVENT_CUSTOM + CARD_ID_0, e, 0, 0, 0, 0)
  		end
  	end
  end
  
  
source_text: Ambush
  Activate only when a face-up "Venom" monster you control is declared as an attack target. Negate the attack and end the Battle Phase. Then place 1 Venom Counter on the monster that attacked.
target_text: -- Ambush
  local CARD_ID_0 = 54306223 --Venom Swamp
  local SETCARD_ID_0 = 0x50 --Venom
  local COUNTER_ID_0 = 0x1009 --Venom
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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 tc = Duel.GetAttackTarget()
  	return tc and tc:IsControler(tp) and tc:IsFaceup() and tc:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Duel.GetAttacker()
  	if chkc then
  		return chkc == tg
  	end
  	if chk == 0 then
  		return tg:IsOnField() and tg:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tg)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	if tc:IsRelateToEffect(e) and Duel.NegateAttack() then
  		Duel.SkipPhase(1 - tp, PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
  		Duel.BreakEffect()
  		local atk = tc:GetAttack()
  		tc:AddCounter(COUNTER_ID_0, 1)
  		if atk > 0 and tc:IsAttack(0) then
  			Duel.RaiseEvent(tc, EVENT_CUSTOM + CARD_ID_0, e, 0, 0, 0, 0)
  		end
  	end
  end
  
  