name: Glacial
card_text: 1 Tuner + 1+ non-Tuner WATER monsters
  Each time another monster(s) you control is destroyed by your opponent's attack or card effect: Inflict 600 damage to your opponent. During the Battle Phase, when your opponent activates a card or effect while you control another monster (Quick Effect): You can negate that effect, and if you do, destroy that card. You can only use this effect of "Glacial Beast Iceberg Narwhal" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(Card.IsAttribute, ATTRIBUTE_WATER), 1)
  	c:EnableReviveLimit()
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_DESTROYED)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, tp, rp)
  	return c:IsPreviousControler(tp)
  		and c:IsPreviousLocation(LOCATION_MZONE)
  		and ((c:IsReason(REASON_EFFECT) and rp == 1 - tp) or (c:IsReason(REASON_BATTLE) and Duel.GetAttacker():IsControler(1 - tp)))
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.filter, 1, nil, tp, rp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(600)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, 1 - tp, 600)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ph = Duel.GetCurrentPhase()
  	if not (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE) then
  		return false
  	end
  	return not c:IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainDisablable(ev) and ep == 1 - tp and Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateEffect(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  
source_text: Glacial
  1 Tuner + 1+ non-Tuner WATER monsters
  Each time another monster(s) you control is destroyed by your opponent's attack or card effect: Inflict 600 damage to your opponent. During the Battle Phase, when your opponent activates a card or effect while you control another monster (Quick Effect): You can negate that effect, and if you do, destroy that card. You can only use this effect of "Glacial Beast Iceberg Narwhal" once per turn.
target_text: -- Glacial
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(Card.IsAttribute, ATTRIBUTE_WATER), 1)
  	c:EnableReviveLimit()
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_DESTROYED)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, tp, rp)
  	return c:IsPreviousControler(tp)
  		and c:IsPreviousLocation(LOCATION_MZONE)
  		and ((c:IsReason(REASON_EFFECT) and rp == 1 - tp) or (c:IsReason(REASON_BATTLE) and Duel.GetAttacker():IsControler(1 - tp)))
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.filter, 1, nil, tp, rp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(600)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, 1 - tp, 600)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ph = Duel.GetCurrentPhase()
  	if not (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE) then
  		return false
  	end
  	return not c:IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainDisablable(ev) and ep == 1 - tp and Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateEffect(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  