name: Evil★Twin
card_text: You can Tribute 1 "Ki-sikil" monster or 1 "Lil-la" monster, then activate 1 of the following effects.
  ● You can target 1 "Ki-sikil" monster or 1 "Lil-la" monster you control; it gains ATK equal to the original ATK of the Tributed monster, until the end of this turn.
  ● When a card or effect is activated that would destroy a card(s) on the field: You can negate that effect.
  You can only use this effect of "Evil★Twin GG EZ" once per turn.
external_ids: local SETCARD_ID_0 = 0x152 --Ki-sikil
  
lua: local SETCARD_ID_0 = 0x152 --Ki-sikil
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.cost1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.activate1)
  	c:RegisterEffect(e1)
  	--disable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_DISABLE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.condition2)
  	e3:SetCost(s.cost2)
  	e3:SetTarget(s.target2)
  	e3:SetOperation(s.activate2)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter1(c)
  	return c:IsSetCard(SETCARD_ID_0, 0x153) and c:IsFaceup()
  end
  function s.cfilter1(c, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0x153)
  		and c:GetBaseAttack() > 0
  		and (c:IsControler(tp) or c:IsFaceup())
  		and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  		and Duel.IsExistingTarget(s.tgfilter1, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter1, 1, nil, tp)
  	end
  	local sg = Duel.SelectReleaseGroup(tp, s.cfilter1, 1, 1, nil, tp)
  	e:SetLabel(sg:GetFirst():GetBaseAttack())
  	Duel.Release(sg, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter1(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.tgfilter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(e:GetLabel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsChainDisablable(ev) then
  		return false
  	end
  	if re:IsHasCategory(CATEGORY_NEGATE) and Duel.GetChainInfo(ev - 1, CHAININFO_TRIGGERING_EFFECT):IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	local ex, tg, tc = Duel.GetOperationInfo(ev, CATEGORY_DESTROY)
  	return ex and tg ~= nil and tc + tg:FilterCount(Card.IsOnField, nil) - tg:GetCount() > 0
  end
  function s.cfilter2(c, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0x153) and (c:IsControler(tp) or c:IsFaceup()) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter2, 1, nil, tp)
  	end
  	local sg = Duel.SelectReleaseGroup(tp, s.cfilter2, 1, 1, nil, tp)
  	Duel.Release(sg, REASON_COST)
  end
  function s.target2(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)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateEffect(ev)
  end
  
  
source_text: Evil★Twin
  You can Tribute 1 "Ki-sikil" monster or 1 "Lil-la" monster, then activate 1 of the following effects.
  ● You can target 1 "Ki-sikil" monster or 1 "Lil-la" monster you control; it gains ATK equal to the original ATK of the Tributed monster, until the end of this turn.
  ● When a card or effect is activated that would destroy a card(s) on the field: You can negate that effect.
  You can only use this effect of "Evil★Twin GG EZ" once per turn.
target_text: -- Evil★Twin
  local SETCARD_ID_0 = 0x152 --Ki-sikil
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.cost1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.activate1)
  	c:RegisterEffect(e1)
  	--disable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_DISABLE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.condition2)
  	e3:SetCost(s.cost2)
  	e3:SetTarget(s.target2)
  	e3:SetOperation(s.activate2)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter1(c)
  	return c:IsSetCard(SETCARD_ID_0, 0x153) and c:IsFaceup()
  end
  function s.cfilter1(c, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0x153)
  		and c:GetBaseAttack() > 0
  		and (c:IsControler(tp) or c:IsFaceup())
  		and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  		and Duel.IsExistingTarget(s.tgfilter1, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter1, 1, nil, tp)
  	end
  	local sg = Duel.SelectReleaseGroup(tp, s.cfilter1, 1, 1, nil, tp)
  	e:SetLabel(sg:GetFirst():GetBaseAttack())
  	Duel.Release(sg, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter1(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.tgfilter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(e:GetLabel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsChainDisablable(ev) then
  		return false
  	end
  	if re:IsHasCategory(CATEGORY_NEGATE) and Duel.GetChainInfo(ev - 1, CHAININFO_TRIGGERING_EFFECT):IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	local ex, tg, tc = Duel.GetOperationInfo(ev, CATEGORY_DESTROY)
  	return ex and tg ~= nil and tc + tg:FilterCount(Card.IsOnField, nil) - tg:GetCount() > 0
  end
  function s.cfilter2(c, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0x153) and (c:IsControler(tp) or c:IsFaceup()) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.cfilter2, 1, nil, tp)
  	end
  	local sg = Duel.SelectReleaseGroup(tp, s.cfilter2, 1, 1, nil, tp)
  	Duel.Release(sg, REASON_COST)
  end
  function s.target2(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)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateEffect(ev)
  end
  
  