name: Herald
card_text: Pay 1500 LP and declare 1 Monster Type and 1 Attribute; your opponent must send 1 face-up monster with the declared Type and Attribute from their field to the GY, if possible. For the rest of this turn, your opponent cannot activate the effects of monsters with that sent monster's name. You can only activate 1 "Herald of the Abyss" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	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)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1500)
  	end
  	Duel.PayLPCost(tp, 1500)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, 1 - tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local att = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RACE)
  	local rc = Duel.AnnounceRace(tp, 1, RACE_ALL)
  	e:SetLabel(att)
  	Duel.SetTargetParam(rc)
  end
  function s.tgfilter(c, rc, att)
  	return c:IsFaceup() and c:IsRace(rc) and c:IsAttribute(att) and c:IsAbleToGrave()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local att = e:GetLabel()
  	local rc = Duel.GetChainInfo(0, CHAININFO_TARGET_PARAM)
  	local g = Duel.GetMatchingGroup(s.tgfilter, 1 - tp, LOCATION_MZONE, 0, nil, rc, att)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(1 - tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		local code = sg:GetFirst():GetCode()
  		if Duel.SendtoGrave(sg, REASON_RULE, 1 - tp) ~= 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  			e1:SetTargetRange(0, 1)
  			e1:SetValue(s.aclimit)
  			e1:SetLabel(code)
  			e1:SetReset(RESET_PHASE + PHASE_END)
  			Duel.RegisterEffect(e1, tp)
  		end
  	end
  end
  function s.aclimit(e, re, tp)
  	return re:GetHandler():IsCode(e:GetLabel()) and re:IsActiveType(TYPE_MONSTER)
  end
  
  
source_text: Herald
  Pay 1500 LP and declare 1 Monster Type and 1 Attribute; your opponent must send 1 face-up monster with the declared Type and Attribute from their field to the GY, if possible. For the rest of this turn, your opponent cannot activate the effects of monsters with that sent monster's name. You can only activate 1 "Herald of the Abyss" per turn.
target_text: -- Herald
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	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)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1500)
  	end
  	Duel.PayLPCost(tp, 1500)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, 1 - tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local att = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RACE)
  	local rc = Duel.AnnounceRace(tp, 1, RACE_ALL)
  	e:SetLabel(att)
  	Duel.SetTargetParam(rc)
  end
  function s.tgfilter(c, rc, att)
  	return c:IsFaceup() and c:IsRace(rc) and c:IsAttribute(att) and c:IsAbleToGrave()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local att = e:GetLabel()
  	local rc = Duel.GetChainInfo(0, CHAININFO_TARGET_PARAM)
  	local g = Duel.GetMatchingGroup(s.tgfilter, 1 - tp, LOCATION_MZONE, 0, nil, rc, att)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(1 - tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		local code = sg:GetFirst():GetCode()
  		if Duel.SendtoGrave(sg, REASON_RULE, 1 - tp) ~= 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  			e1:SetTargetRange(0, 1)
  			e1:SetValue(s.aclimit)
  			e1:SetLabel(code)
  			e1:SetReset(RESET_PHASE + PHASE_END)
  			Duel.RegisterEffect(e1, tp)
  		end
  	end
  end
  function s.aclimit(e, re, tp)
  	return re:GetHandler():IsCode(e:GetLabel()) and re:IsActiveType(TYPE_MONSTER)
  end
  
  