Heavymetalfoes
2 "Metalfoes" monsters
If this card is sent from the Monster Zone to the GY by a card effect: You can activate 1 of these effects;
● Target 1 "Metalfoes" monster you control; equip this card to it. It gains 1000 ATK.
● Target 1 "Metalfoes" card you control; destroy it, and if you do, Special Summon this card.
You can only use this effect of "Heavymetalfoes Amalgam" once per turn.
local SETCARD_ID_0 = 0xe1 --Metalfoes

local SETCARD_ID_0 = 0xe1 --Metalfoes
local s, id, o = GetID()
function s.initial_effect(c)
	--(0) Link Summon
	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
	c:EnableReviveLimit()
	--(1) Equip
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_TO_GRAVE)
	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.condition)
	e1:SetTarget(s.eqtg)
	e1:SetOperation(s.eqop)
	c:RegisterEffect(e1)
	--(2) Destroy and Special Summon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.condition)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_EFFECT) and c:CheckUniqueOnField(tp) and not c:IsForbidden()
end
function s.eqfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
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)
	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, e:GetHandler(), 1, 0, 0)
end
function s.eqop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if not c:IsRelateToEffect(e) then
		return
	end
	local tc = Duel.GetFirstTarget()
	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or not tc:IsControler(tp) or tc:IsFacedown() or not tc:IsRelateToEffect(e) then
		return
	end
	if not c:CheckUniqueOnField(tp) or c:IsForbidden() then
		return
	end
	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)
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_EQUIP)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetValue(1000)
	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
	c:RegisterEffect(e2)
end
function s.eqlimit(e, c)
	return c == e:GetLabelObject()
end
function s.desfilter(c, tp)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and Duel.GetMZoneCount(tp, c) > 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	local c = e:GetHandler()
	if chkc then
		return chkc:IsOnField() and chkc:IsControler(tp) and s.desfilter(chkc, tp)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 1, nil, tp) and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 1, 1, nil, tp)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
		local c = e:GetHandler()
		if c:IsRelateToEffect(e) then
			Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
		end
	end
end


Heavymetalfoes
2 "Metalfoes" monsters
If this card is sent from the Monster Zone to the GY by a card effect: You can activate 1 of these effects;
● Target 1 "Metalfoes" monster you control; equip this card to it. It gains 1000 ATK.
● Target 1 "Metalfoes" card you control; destroy it, and if you do, Special Summon this card.
You can only use this effect of "Heavymetalfoes Amalgam" once per turn.
-- Heavymetalfoes
local SETCARD_ID_0 = 0xe1 --Metalfoes
local s, id, o = GetID()
function s.initial_effect(c)
	--(0) Link Summon
	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
	c:EnableReviveLimit()
	--(1) Equip
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_TO_GRAVE)
	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.condition)
	e1:SetTarget(s.eqtg)
	e1:SetOperation(s.eqop)
	c:RegisterEffect(e1)
	--(2) Destroy and Special Summon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.condition)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_EFFECT) and c:CheckUniqueOnField(tp) and not c:IsForbidden()
end
function s.eqfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
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)
	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, e:GetHandler(), 1, 0, 0)
end
function s.eqop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if not c:IsRelateToEffect(e) then
		return
	end
	local tc = Duel.GetFirstTarget()
	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or not tc:IsControler(tp) or tc:IsFacedown() or not tc:IsRelateToEffect(e) then
		return
	end
	if not c:CheckUniqueOnField(tp) or c:IsForbidden() then
		return
	end
	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)
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_EQUIP)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetValue(1000)
	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
	c:RegisterEffect(e2)
end
function s.eqlimit(e, c)
	return c == e:GetLabelObject()
end
function s.desfilter(c, tp)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and Duel.GetMZoneCount(tp, c) > 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	local c = e:GetHandler()
	if chkc then
		return chkc:IsOnField() and chkc:IsControler(tp) and s.desfilter(chkc, tp)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 1, nil, tp) and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 1, 1, nil, tp)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
		local c = e:GetHandler()
		if c:IsRelateToEffect(e) then
			Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
		end
	end
end

