name: DZW
card_text: You can target 1 "Number C39" monster you control; equip this monster from your hand or your side of the field to that target. The equipped monster cannot be destroyed by battle. At the end of the Damage Step, when the equipped monster attacks an opponent's monster, but the opponent's monster was not destroyed by the battle: You can make the opponent's monster's ATK 0 (even after this card leaves the field or the monster becomes unaffected by card effects), and if you do, the equipped monster can make a second attack on the same monster in a row.
external_ids: local SETCARD_ID_0 = 0x107f --Utopia
  
lua: local SETCARD_ID_0 = 0x107f --Utopia
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetRange(LOCATION_HAND + LOCATION_MZONE)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--destroy sub
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--chain attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsSetCard(0x1048)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if c:IsLocation(LOCATION_MZONE) and c:IsFacedown() then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or tc:IsControler(1 - tp) or tc:IsFacedown() or not tc:IsRelateToEffect(e) or not c:CheckUniqueOnField(tp) then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  		return
  	end
  	s.zw_equip_monster(c, tp, tc)
  end
  function s.zw_equip_monster(c, tp, tc)
  	if not Duel.Equip(tp, c, tc) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EQUIP_LIMIT)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(s.eqlimit)
  	e1:SetLabelObject(tc)
  	c:RegisterEffect(e1)
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local at = Duel.GetAttackTarget()
  	return at and a == e:GetHandler():GetEquipTarget() and at:IsRelateToBattle() and at:GetAttack() > 0 and a:IsChainAttackable()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttackTarget()
  	local c = e:GetHandler()
  	local ec = c:GetEquipTarget()
  	if at:IsRelateToBattle() and not at:IsImmuneToEffect(e) and at:GetAttack() > 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		at:RegisterEffect(e1)
  		Duel.ChainAttack(at)
  	end
  end
  
  
source_text: DZW
  You can target 1 "Number C39" monster you control; equip this monster from your hand or your side of the field to that target. The equipped monster cannot be destroyed by battle. At the end of the Damage Step, when the equipped monster attacks an opponent's monster, but the opponent's monster was not destroyed by the battle: You can make the opponent's monster's ATK 0 (even after this card leaves the field or the monster becomes unaffected by card effects), and if you do, the equipped monster can make a second attack on the same monster in a row.
target_text: -- DZW
  local SETCARD_ID_0 = 0x107f --Utopia
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetRange(LOCATION_HAND + LOCATION_MZONE)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--destroy sub
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--chain attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsSetCard(0x1048)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if c:IsLocation(LOCATION_MZONE) and c:IsFacedown() then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or tc:IsControler(1 - tp) or tc:IsFacedown() or not tc:IsRelateToEffect(e) or not c:CheckUniqueOnField(tp) then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  		return
  	end
  	s.zw_equip_monster(c, tp, tc)
  end
  function s.zw_equip_monster(c, tp, tc)
  	if not Duel.Equip(tp, c, tc) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EQUIP_LIMIT)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(s.eqlimit)
  	e1:SetLabelObject(tc)
  	c:RegisterEffect(e1)
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local at = Duel.GetAttackTarget()
  	return at and a == e:GetHandler():GetEquipTarget() and at:IsRelateToBattle() and at:GetAttack() > 0 and a:IsChainAttackable()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local at = Duel.GetAttackTarget()
  	local c = e:GetHandler()
  	local ec = c:GetEquipTarget()
  	if at:IsRelateToBattle() and not at:IsImmuneToEffect(e) and at:GetAttack() > 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		at:RegisterEffect(e1)
  		Duel.ChainAttack(at)
  	end
  end
  
  