name: Alien
card_text: This card is treated as a Normal Monster while face-up on the field or in the Graveyard. While this card is face-up on the field, you can Normal Summon it to have it be treated as an Effect Monster with this effect:
  ● During your Main Phase, you can select 1 monster your opponent controls with an A-Counter(s), and take control of it while this card is on the field. During each of your End Phases, remove 1 A-Counter from each controlled monster. If all A-Counters are removed from one of these monsters, destroy it.
external_ids: local COUNTER_ID_0 = 0x100e --A-Counter
  
lua: local COUNTER_ID_0 = 0x100e --A-Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnableDualAttribute(c)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(aux.IsDualState)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:GetCounter(COUNTER_ID_0) > 0 and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if tc:GetCounter(COUNTER_ID_0) > 0 and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_CONTROL)
  		e1:SetValue(tp)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetCondition(s.ctcon)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetCountLimit(1)
  		e2:SetLabel(tp)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetCondition(s.rmctcon)
  		e2:SetOperation(s.rmctop)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_SELF_DESTROY)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e3:SetCondition(s.descon)
  		tc:RegisterEffect(e3)
  	end
  end
  function s.ctcon(e)
  	local c = e:GetOwner()
  	return c:IsHasCardTarget(e:GetHandler())
  end
  function s.rmctcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == e:GetLabel()
  end
  function s.rmctop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, 1, REASON_EFFECT)
  	Duel.RaiseEvent(e:GetHandler(), EVENT_REMOVE_COUNTER + 0x100e, e, REASON_EFFECT, tp, tp, 1)
  end
  function s.descon(e)
  	return e:GetHandler():GetCounter(COUNTER_ID_0) == 0
  end
  
  
source_text: Alien
  This card is treated as a Normal Monster while face-up on the field or in the Graveyard. While this card is face-up on the field, you can Normal Summon it to have it be treated as an Effect Monster with this effect:
  ● During your Main Phase, you can select 1 monster your opponent controls with an A-Counter(s), and take control of it while this card is on the field. During each of your End Phases, remove 1 A-Counter from each controlled monster. If all A-Counters are removed from one of these monsters, destroy it.
target_text: -- Alien
  local COUNTER_ID_0 = 0x100e --A-Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnableDualAttribute(c)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(aux.IsDualState)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:GetCounter(COUNTER_ID_0) > 0 and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if tc:GetCounter(COUNTER_ID_0) > 0 and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_CONTROL)
  		e1:SetValue(tp)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetCondition(s.ctcon)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetCountLimit(1)
  		e2:SetLabel(tp)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetCondition(s.rmctcon)
  		e2:SetOperation(s.rmctop)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_SELF_DESTROY)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e3:SetCondition(s.descon)
  		tc:RegisterEffect(e3)
  	end
  end
  function s.ctcon(e)
  	local c = e:GetOwner()
  	return c:IsHasCardTarget(e:GetHandler())
  end
  function s.rmctcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == e:GetLabel()
  end
  function s.rmctop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, 1, REASON_EFFECT)
  	Duel.RaiseEvent(e:GetHandler(), EVENT_REMOVE_COUNTER + 0x100e, e, REASON_EFFECT, tp, tp, 1)
  end
  function s.descon(e)
  	return e:GetHandler():GetCounter(COUNTER_ID_0) == 0
  end
  
  