name: Mini-Guts
card_text: Tribute 1 monster, then target 1 face-up monster your opponent controls; its ATK becomes 0 until the End Phase. This turn, when it is destroyed by battle and sent to their Graveyard: Inflict damage to your opponent equal to its original ATK in the Graveyard.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.tgfilter(c, tc, ec)
  	return c:IsFaceup() and c:GetEquipTarget() ~= tc and c ~= ec
  end
  function s.costfilter(c, ec, tp)
  	return Duel.IsExistingTarget(s.tgfilter, tp, 0, LOCATION_MZONE, 1, c, c, ec)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		if e:GetLabel() == 1 then
  			e:SetLabel(0)
  			return Duel.CheckReleaseGroup(tp, s.costfilter, 1, c, c, tp)
  		else
  			return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  		end
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local sg = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, c, c, tp)
  		Duel.Release(sg, REASON_COST)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) 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 + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetDescription(aux.Stringid(id, 0))
  		e2:SetCategory(CATEGORY_DAMAGE)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  		e2:SetCode(EVENT_BATTLE_DESTROYED)
  		e2:SetCondition(s.damcon)
  		e2:SetTarget(s.damtg)
  		e2:SetOperation(s.damop)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetLabelObject(tc)
  		Duel.RegisterEffect(e2, tp)
  		tc:RegisterFlagEffect(id, RESET_EVENT + 0x17a0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	return eg:IsContains(tc) and tc:GetFlagEffect(id) ~= 0 and tc:GetOwner() == 1 - tp and tc:IsLocation(LOCATION_GRAVE) and tc:IsReason(REASON_BATTLE)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local atk = e:GetLabelObject():GetBaseAttack()
  	if atk < 0 then
  		atk = 0
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(atk)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, atk)
  end
  function s.damop(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
  
  
source_text: Mini-Guts
  Tribute 1 monster, then target 1 face-up monster your opponent controls; its ATK becomes 0 until the End Phase. This turn, when it is destroyed by battle and sent to their Graveyard: Inflict damage to your opponent equal to its original ATK in the Graveyard.
target_text: -- Mini-Guts
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.tgfilter(c, tc, ec)
  	return c:IsFaceup() and c:GetEquipTarget() ~= tc and c ~= ec
  end
  function s.costfilter(c, ec, tp)
  	return Duel.IsExistingTarget(s.tgfilter, tp, 0, LOCATION_MZONE, 1, c, c, ec)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		if e:GetLabel() == 1 then
  			e:SetLabel(0)
  			return Duel.CheckReleaseGroup(tp, s.costfilter, 1, c, c, tp)
  		else
  			return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  		end
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local sg = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, c, c, tp)
  		Duel.Release(sg, REASON_COST)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) 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 + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetDescription(aux.Stringid(id, 0))
  		e2:SetCategory(CATEGORY_DAMAGE)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  		e2:SetCode(EVENT_BATTLE_DESTROYED)
  		e2:SetCondition(s.damcon)
  		e2:SetTarget(s.damtg)
  		e2:SetOperation(s.damop)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetLabelObject(tc)
  		Duel.RegisterEffect(e2, tp)
  		tc:RegisterFlagEffect(id, RESET_EVENT + 0x17a0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	return eg:IsContains(tc) and tc:GetFlagEffect(id) ~= 0 and tc:GetOwner() == 1 - tp and tc:IsLocation(LOCATION_GRAVE) and tc:IsReason(REASON_BATTLE)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local atk = e:GetLabelObject():GetBaseAttack()
  	if atk < 0 then
  		atk = 0
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(atk)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, atk)
  end
  function s.damop(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
  
  