name: B.E.S.
card_text: If you control no monsters, you can Normal Summon this card without Tributing.When this card is Special Summoned, place 3 counters on it. This card cannot be destroyed by battle. If this card attacks or is attacked, remove 1 counter from this card at the end of the Damage Step. If you cannot, destroy it.
external_ids: local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  
lua: local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x1f)
  	--spsummon success
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.addct)
  	e1:SetOperation(s.addc)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--remove counter
  	aux.EnableBESRemove(c)
  	--summon with no tribute
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 3))
  	e5:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_SUMMON_PROC)
  	e5:SetCondition(s.ntcon)
  	c:RegisterEffect(e5)
  end
  function s.addct(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 3, 0, 0x1f)
  end
  function s.addc(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 3)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) == 0
  end
  
  
source_text: B.E.S.
  If you control no monsters, you can Normal Summon this card without Tributing.When this card is Special Summoned, place 3 counters on it. This card cannot be destroyed by battle. If this card attacks or is attacked, remove 1 counter from this card at the end of the Damage Step. If you cannot, destroy it.
target_text: -- B.E.S.
  local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x1f)
  	--spsummon success
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.addct)
  	e1:SetOperation(s.addc)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--remove counter
  	aux.EnableBESRemove(c)
  	--summon with no tribute
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 3))
  	e5:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_SUMMON_PROC)
  	e5:SetCondition(s.ntcon)
  	c:RegisterEffect(e5)
  end
  function s.addct(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 3, 0, 0x1f)
  end
  function s.addc(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 3)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) == 0
  end
  
  