name: Vaalmonica
card_text: While you have 6 or more Resonance Counters on your field, "Vaalmonica" Link Monsters you control gain 1200 ATK. You can only use each of the following effects of "Vaalmonica Creation" once per turn. If your opponent Special Summons a monster(s), you can (except during the Damage Step): Immediately after this effect resolves, Link Summon 1 "Vaalmonica" Link Monster. If this card is sent from the hand or field to the GY: You can place Resonance Counters on 1 card in your Pendulum Zone that you can place a Resonance Counter on, so it has 3 Resonance Counters.
external_ids: local CARD_ID_0 = 39210885 --Vaalmonica, the Agathokakological Voice
  local SETCARD_ID_0 = 0x1a3 --Vaalmonica
  local COUNTER_ID_0 = 0x6a --Resonance
  
lua: local CARD_ID_0 = 39210885 --Vaalmonica, the Agathokakological Voice
  local SETCARD_ID_0 = 0x1a3 --Vaalmonica
  local COUNTER_ID_0 = 0x6a --Resonance
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCondition(aux.dscon)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(1200)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_COUNTER)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id + o)
  	e4:SetCondition(s.coucon)
  	e4:SetTarget(s.coutg)
  	e4:SetOperation(s.couop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:GetCounter(COUNTER_ID_0) > 0
  end
  function s.iee(c)
  	return c:GetCounter(COUNTER_ID_0)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(s.cfilter, e:GetHandler():GetControler(), LOCATION_ONFIELD, 0, nil)
  	local ct = sg:GetSum(s.iee)
  	return ct > 5
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(Card.IsSummonPlayer, 1, e:GetHandler(), 1 - tp)
  end
  function s.spfilter(c)
  	return c:IsLinkSummonable(nil) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.LinkSummon(tp, tc, nil)
  	end
  end
  function s.coucon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND + LOCATION_ONFIELD)
  end
  function s.ctfilter(c)
  	return c:IsFaceup() and c:IsCanAddCounter(COUNTER_ID_0, 1) and c:GetCounter(COUNTER_ID_0) < 3
  end
  function s.coutg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.ctfilter, tp, LOCATION_PZONE, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.ctfilter, tp, LOCATION_PZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, g, 1, 0, 0x6a)
  end
  function s.couop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectMatchingCard(tp, s.ctfilter, tp, LOCATION_PZONE, 0, 1, 1, nil):GetFirst()
  	if tc then
  		local ct = 3 - tc:GetCounter(COUNTER_ID_0)
  		if ct > 0 then
  			tc:AddCounter(COUNTER_ID_0, ct)
  			if tc:GetCounter(COUNTER_ID_0) == 3 then
  				Duel.RaiseEvent(tc, EVENT_CUSTOM + CARD_ID_0, e, 0, tp, tp, 0)
  			end
  		end
  	end
  end
  
  
source_text: Vaalmonica
  While you have 6 or more Resonance Counters on your field, "Vaalmonica" Link Monsters you control gain 1200 ATK. You can only use each of the following effects of "Vaalmonica Creation" once per turn. If your opponent Special Summons a monster(s), you can (except during the Damage Step): Immediately after this effect resolves, Link Summon 1 "Vaalmonica" Link Monster. If this card is sent from the hand or field to the GY: You can place Resonance Counters on 1 card in your Pendulum Zone that you can place a Resonance Counter on, so it has 3 Resonance Counters.
target_text: -- Vaalmonica
  local CARD_ID_0 = 39210885 --Vaalmonica, the Agathokakological Voice
  local SETCARD_ID_0 = 0x1a3 --Vaalmonica
  local COUNTER_ID_0 = 0x6a --Resonance
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCondition(aux.dscon)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(1200)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_COUNTER)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id + o)
  	e4:SetCondition(s.coucon)
  	e4:SetTarget(s.coutg)
  	e4:SetOperation(s.couop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:GetCounter(COUNTER_ID_0) > 0
  end
  function s.iee(c)
  	return c:GetCounter(COUNTER_ID_0)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(s.cfilter, e:GetHandler():GetControler(), LOCATION_ONFIELD, 0, nil)
  	local ct = sg:GetSum(s.iee)
  	return ct > 5
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(Card.IsSummonPlayer, 1, e:GetHandler(), 1 - tp)
  end
  function s.spfilter(c)
  	return c:IsLinkSummonable(nil) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.LinkSummon(tp, tc, nil)
  	end
  end
  function s.coucon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND + LOCATION_ONFIELD)
  end
  function s.ctfilter(c)
  	return c:IsFaceup() and c:IsCanAddCounter(COUNTER_ID_0, 1) and c:GetCounter(COUNTER_ID_0) < 3
  end
  function s.coutg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.ctfilter, tp, LOCATION_PZONE, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.ctfilter, tp, LOCATION_PZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, g, 1, 0, 0x6a)
  end
  function s.couop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectMatchingCard(tp, s.ctfilter, tp, LOCATION_PZONE, 0, 1, 1, nil):GetFirst()
  	if tc then
  		local ct = 3 - tc:GetCounter(COUNTER_ID_0)
  		if ct > 0 then
  			tc:AddCounter(COUNTER_ID_0, ct)
  			if tc:GetCounter(COUNTER_ID_0) == 3 then
  				Duel.RaiseEvent(tc, EVENT_CUSTOM + CARD_ID_0, e, 0, tp, tp, 0)
  			end
  		end
  	end
  end
  
  