name: Malice,
card_text: (Quick Effect): You can Tribute 2 monsters, then target 1 of your Normal Traps that is banished or in your GY; Set that target, but place it on the bottom of the Deck when it leaves the field. You can only use this effect of "Malice, Lady of Lament" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.stcost)
  	e1:SetTarget(s.sttg)
  	e1:SetOperation(s.stop)
  	c:RegisterEffect(e1)
  end
  function s.stcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, aux.TRUE, 2, nil)
  	end
  	local g = Duel.SelectReleaseGroup(tp, aux.TRUE, 2, 2, nil)
  	Duel.Release(g, REASON_COST)
  end
  function s.stfilter(c)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:GetType() == TYPE_TRAP and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.stfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.stfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectTarget(tp, s.stfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SSet(tp, tc) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_DECKBOT)
  		tc:RegisterEffect(e1)
  	end
  end
  
  
source_text: Malice,
  (Quick Effect): You can Tribute 2 monsters, then target 1 of your Normal Traps that is banished or in your GY; Set that target, but place it on the bottom of the Deck when it leaves the field. You can only use this effect of "Malice, Lady of Lament" once per turn.
target_text: -- Malice,
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.stcost)
  	e1:SetTarget(s.sttg)
  	e1:SetOperation(s.stop)
  	c:RegisterEffect(e1)
  end
  function s.stcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, aux.TRUE, 2, nil)
  	end
  	local g = Duel.SelectReleaseGroup(tp, aux.TRUE, 2, 2, nil)
  	Duel.Release(g, REASON_COST)
  end
  function s.stfilter(c)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:GetType() == TYPE_TRAP and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.stfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.stfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectTarget(tp, s.stfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SSet(tp, tc) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_DECKBOT)
  		tc:RegisterEffect(e1)
  	end
  end
  
  