name: Alien
card_text: You can remove 2 A-Counters from anywhere on the field to Special Summon this card from your hand. Once per turn, you can place 1 A-Counter on each face-up monster your opponent controls. (If a monster with an A-Counter battles an "Alien" monster, it loses 300 ATK and DEF for each A-Counter during damage calculation only.) You can only control 1 "Alien Overlord".
external_ids: local SETCARD_ID_0 = 0xc --Alien
  local COUNTER_ID_0 = 0x100e --A-Counter
  
lua: local SETCARD_ID_0 = 0xc --Alien
  local COUNTER_ID_0 = 0x100e --A-Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_COUNTER)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.cttg)
  	e2:SetOperation(s.ctop)
  	c:RegisterEffect(e2)
  	--atk def
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetCondition(s.adcon)
  	e3:SetTarget(s.adtg)
  	e3:SetValue(s.adval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e4)
  end
  s.counter_add_list = { 0x100e }
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.IsCanRemoveCounter(c:GetControler(), 1, 1, COUNTER_ID_0, 2, REASON_COST)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.RemoveCounter(tp, 1, 1, COUNTER_ID_0, 2, REASON_COST)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsCanAddCounter, tp, 0, LOCATION_MZONE, 1, nil, 0x100e, 1)
  	end
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsCanAddCounter, tp, 0, LOCATION_MZONE, nil, 0x100e, 1)
  	local tc = g:GetFirst()
  	while tc do
  		tc:AddCounter(COUNTER_ID_0, 1)
  		tc = g:GetNext()
  	end
  end
  function s.adcon(e)
  	return Duel.GetCurrentPhase() == PHASE_DAMAGE_CAL and Duel.GetAttackTarget()
  end
  function s.adtg(e, c)
  	local bc = c:GetBattleTarget()
  	return bc and c:GetCounter(COUNTER_ID_0) ~= 0 and bc:IsSetCard(SETCARD_ID_0)
  end
  function s.adval(e, c)
  	return c:GetCounter(COUNTER_ID_0) * -300
  end
  
  
source_text: Alien
  You can remove 2 A-Counters from anywhere on the field to Special Summon this card from your hand. Once per turn, you can place 1 A-Counter on each face-up monster your opponent controls. (If a monster with an A-Counter battles an "Alien" monster, it loses 300 ATK and DEF for each A-Counter during damage calculation only.) You can only control 1 "Alien Overlord".
target_text: -- Alien
  local SETCARD_ID_0 = 0xc --Alien
  local COUNTER_ID_0 = 0x100e --A-Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_COUNTER)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.cttg)
  	e2:SetOperation(s.ctop)
  	c:RegisterEffect(e2)
  	--atk def
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetCondition(s.adcon)
  	e3:SetTarget(s.adtg)
  	e3:SetValue(s.adval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e4)
  end
  s.counter_add_list = { 0x100e }
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.IsCanRemoveCounter(c:GetControler(), 1, 1, COUNTER_ID_0, 2, REASON_COST)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.RemoveCounter(tp, 1, 1, COUNTER_ID_0, 2, REASON_COST)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsCanAddCounter, tp, 0, LOCATION_MZONE, 1, nil, 0x100e, 1)
  	end
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsCanAddCounter, tp, 0, LOCATION_MZONE, nil, 0x100e, 1)
  	local tc = g:GetFirst()
  	while tc do
  		tc:AddCounter(COUNTER_ID_0, 1)
  		tc = g:GetNext()
  	end
  end
  function s.adcon(e)
  	return Duel.GetCurrentPhase() == PHASE_DAMAGE_CAL and Duel.GetAttackTarget()
  end
  function s.adtg(e, c)
  	local bc = c:GetBattleTarget()
  	return bc and c:GetCounter(COUNTER_ID_0) ~= 0 and bc:IsSetCard(SETCARD_ID_0)
  end
  function s.adval(e, c)
  	return c:GetCounter(COUNTER_ID_0) * -300
  end
  
  