name: Earthbound
card_text: There can only be 1 "Earthbound Immortal" monster on the field. If there is no face-up Field Spell on the field, destroy this card. Your opponent's monsters cannot target this card for attacks. This card can attack your opponent directly. Once per turn: You can inflict damage to your opponent equal to half this card's DEF on the field. This card cannot attack the turn this effect is activated. While this card is in Defense Position, your opponent cannot conduct their Battle Phase.
external_ids: local SETCARD_ID_0 = 0x1021 --Earthbound
  
lua: local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), LOCATION_MZONE)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.sdcon)
  	c:RegisterEffect(e4)
  	--battle target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(aux.imval1)
  	c:RegisterEffect(e5)
  	--direct atk
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e6)
  	--damage
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_DAMAGE)
  	e7:SetType(EFFECT_TYPE_IGNITION)
  	e7:SetRange(LOCATION_MZONE)
  	e7:SetCountLimit(1)
  	e7:SetCost(s.damcost)
  	e7:SetTarget(s.damtg)
  	e7:SetOperation(s.damop)
  	c:RegisterEffect(e7)
  	--bp
  	local e8 = Effect.CreateEffect(c)
  	e8:SetType(EFFECT_TYPE_FIELD)
  	e8:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e8:SetCode(EFFECT_CANNOT_BP)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetTargetRange(0, 1)
  	e8:SetCondition(s.bpcon)
  	c:RegisterEffect(e8)
  end
  function s.sdcon(e)
  	return not Duel.IsExistingMatchingCard(Card.IsFaceup, 0, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.damcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local dam = math.floor(e:GetHandler():GetDefense() / 2)
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  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
  function s.bpcon(e)
  	return e:GetHandler():IsPosition(POS_FACEUP_DEFENSE)
  end
  
  
source_text: Earthbound
  There can only be 1 "Earthbound Immortal" monster on the field. If there is no face-up Field Spell on the field, destroy this card. Your opponent's monsters cannot target this card for attacks. This card can attack your opponent directly. Once per turn: You can inflict damage to your opponent equal to half this card's DEF on the field. This card cannot attack the turn this effect is activated. While this card is in Defense Position, your opponent cannot conduct their Battle Phase.
target_text: -- Earthbound
  local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), LOCATION_MZONE)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.sdcon)
  	c:RegisterEffect(e4)
  	--battle target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(aux.imval1)
  	c:RegisterEffect(e5)
  	--direct atk
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e6)
  	--damage
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_DAMAGE)
  	e7:SetType(EFFECT_TYPE_IGNITION)
  	e7:SetRange(LOCATION_MZONE)
  	e7:SetCountLimit(1)
  	e7:SetCost(s.damcost)
  	e7:SetTarget(s.damtg)
  	e7:SetOperation(s.damop)
  	c:RegisterEffect(e7)
  	--bp
  	local e8 = Effect.CreateEffect(c)
  	e8:SetType(EFFECT_TYPE_FIELD)
  	e8:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e8:SetCode(EFFECT_CANNOT_BP)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetTargetRange(0, 1)
  	e8:SetCondition(s.bpcon)
  	c:RegisterEffect(e8)
  end
  function s.sdcon(e)
  	return not Duel.IsExistingMatchingCard(Card.IsFaceup, 0, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.damcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local dam = math.floor(e:GetHandler():GetDefense() / 2)
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  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
  function s.bpcon(e)
  	return e:GetHandler():IsPosition(POS_FACEUP_DEFENSE)
  end
  
  