name: Xyz
card_text: 2 Level 3 monsters
  Cannot attack unless it has material. You can detach 2 materials from this card; draw 1 card. You can only use this effect of "Xyz Armor Torpedo" once per turn. Apply these effects while this card is equipped to a monster.
  ● If the equipped monster battles, until the end of the Damage Step, your opponent cannot activate cards or effects, also negate the effects of all face-up monsters they control.
  ● If the equipped monster is an Xyz Monster, your opponent cannot target it with card effects.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	c:EnableReviveLimit()
  	--cannot direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetCondition(s.attcon)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.drawcost)
  	e2:SetTarget(s.drawtarget)
  	e2:SetOperation(s.drawoperation)
  	c:RegisterEffect(e2)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetTargetRange(0, 1)
  	e3:SetCondition(s.actcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--disable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetCondition(s.actcon)
  	e4:SetOperation(s.disop)
  	c:RegisterEffect(e4)
  	--cannot be target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_EQUIP)
  	e5:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e5:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e5:SetValue(aux.tgoval)
  	e5:SetCondition(s.targetcon)
  	c:RegisterEffect(e5)
  end
  function s.targetcon(e)
  	return e:GetHandler():GetEquipTarget():IsType(TYPE_XYZ)
  end
  function s.attcon(e)
  	return e:GetHandler():GetOverlayCount() == 0
  end
  function s.drawcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.drawtarget(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drawoperation(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.actcon(e)
  	local tc = e:GetHandler():GetEquipTarget()
  	return tc ~= nil and (Duel.GetAttacker() == tc or Duel.GetAttackTarget() == tc)
  end
  function s.disfilter(c)
  	return aux.NegateAnyFilter(c) and c:IsType(TYPE_MONSTER) and c:IsFaceup()
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.disfilter, tp, 0, LOCATION_MZONE, c)
  	local tc = g:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e2)
  		if tc:IsType(TYPE_TRAPMONSTER) then
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  			tc:RegisterEffect(e3)
  		end
  		tc = g:GetNext()
  	end
  end
  
  
source_text: Xyz
  2 Level 3 monsters
  Cannot attack unless it has material. You can detach 2 materials from this card; draw 1 card. You can only use this effect of "Xyz Armor Torpedo" once per turn. Apply these effects while this card is equipped to a monster.
  ● If the equipped monster battles, until the end of the Damage Step, your opponent cannot activate cards or effects, also negate the effects of all face-up monsters they control.
  ● If the equipped monster is an Xyz Monster, your opponent cannot target it with card effects.
target_text: -- Xyz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	c:EnableReviveLimit()
  	--cannot direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetCondition(s.attcon)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.drawcost)
  	e2:SetTarget(s.drawtarget)
  	e2:SetOperation(s.drawoperation)
  	c:RegisterEffect(e2)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetTargetRange(0, 1)
  	e3:SetCondition(s.actcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--disable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetCondition(s.actcon)
  	e4:SetOperation(s.disop)
  	c:RegisterEffect(e4)
  	--cannot be target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_EQUIP)
  	e5:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e5:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e5:SetValue(aux.tgoval)
  	e5:SetCondition(s.targetcon)
  	c:RegisterEffect(e5)
  end
  function s.targetcon(e)
  	return e:GetHandler():GetEquipTarget():IsType(TYPE_XYZ)
  end
  function s.attcon(e)
  	return e:GetHandler():GetOverlayCount() == 0
  end
  function s.drawcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.drawtarget(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drawoperation(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.actcon(e)
  	local tc = e:GetHandler():GetEquipTarget()
  	return tc ~= nil and (Duel.GetAttacker() == tc or Duel.GetAttackTarget() == tc)
  end
  function s.disfilter(c)
  	return aux.NegateAnyFilter(c) and c:IsType(TYPE_MONSTER) and c:IsFaceup()
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.disfilter, tp, 0, LOCATION_MZONE, c)
  	local tc = g:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e2)
  		if tc:IsType(TYPE_TRAPMONSTER) then
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  			tc:RegisterEffect(e3)
  		end
  		tc = g:GetNext()
  	end
  end
  
  