name: King's
card_text: "Horus" monsters you control cannot be destroyed by card effects that do not target them. You can send 1 card from your hand to the GY; send 1 "Horus" monster from your Deck to the GY. You can only use this effect of "King's Sarcophagus" up to four times per turn. Once per turn, at the start of the Damage Step, if your "Horus" monster battles an opponent's monster: You can send that opponent's monster to the GY.
external_ids: local SETCARD_ID_0 = 0x19d --Horus
  
lua: local SETCARD_ID_0 = 0x19d --Horus
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetValue(s.efilter)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.intg)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(4, id)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.activate)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.intg(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.efilter(e, re, rp, c)
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return true
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	return not g or not g:IsContains(c)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetBattleMonster(tp)
  	if not (ac and ac:IsFaceup() and ac:IsSetCard(SETCARD_ID_0)) then
  		return false
  	end
  	local bc = ac:GetBattleTarget()
  	e:SetLabelObject(bc)
  	return bc and bc:IsControler(1 - tp) and bc:IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetLabelObject()
  	if chk == 0 then
  		return bc
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, bc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetLabelObject()
  	if bc and bc:IsControler(1 - tp) and bc:IsRelateToBattle() then
  		Duel.SendtoGrave(bc, REASON_EFFECT)
  	end
  end
  
  
source_text: King's
  "Horus" monsters you control cannot be destroyed by card effects that do not target them. You can send 1 card from your hand to the GY; send 1 "Horus" monster from your Deck to the GY. You can only use this effect of "King's Sarcophagus" up to four times per turn. Once per turn, at the start of the Damage Step, if your "Horus" monster battles an opponent's monster: You can send that opponent's monster to the GY.
target_text: -- King's
  local SETCARD_ID_0 = 0x19d --Horus
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetValue(s.efilter)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.intg)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(4, id)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.activate)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.intg(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.efilter(e, re, rp, c)
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return true
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	return not g or not g:IsContains(c)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetBattleMonster(tp)
  	if not (ac and ac:IsFaceup() and ac:IsSetCard(SETCARD_ID_0)) then
  		return false
  	end
  	local bc = ac:GetBattleTarget()
  	e:SetLabelObject(bc)
  	return bc and bc:IsControler(1 - tp) and bc:IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetLabelObject()
  	if chk == 0 then
  		return bc
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, bc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetLabelObject()
  	if bc and bc:IsControler(1 - tp) and bc:IsRelateToBattle() then
  		Duel.SendtoGrave(bc, REASON_EFFECT)
  	end
  end
  
  