Ghostrick
Monsters cannot attack face-down Defense Position monsters, but can attack directly if all monsters their opponent controls are face-down Defense Position. All effect damage, and battle damage inflicted by monsters other than "Ghostrick" monsters, is halved.
local SETCARD_ID_0 = 0x8d --Ghostrick

local SETCARD_ID_0 = 0x8d --Ghostrick
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--atklimit
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
	e2:SetRange(LOCATION_FZONE)
	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e2:SetValue(aux.TargetBoolFunction(Card.IsFacedown))
	c:RegisterEffect(e2)
	--direct attack
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_DIRECT_ATTACK)
	e3:SetRange(LOCATION_FZONE)
	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e3:SetTarget(s.dirtg)
	c:RegisterEffect(e3)
	--
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD)
	e4:SetRange(LOCATION_FZONE)
	e4:SetCode(EFFECT_CHANGE_DAMAGE)
	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e4:SetTargetRange(1, 1)
	e4:SetValue(s.val)
	c:RegisterEffect(e4)
	local e5 = Effect.CreateEffect(c)
	e5:SetType(EFFECT_TYPE_FIELD)
	e5:SetRange(LOCATION_FZONE)
	e5:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
	e5:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e5:SetTarget(s.rdtg)
	e5:SetValue(HALF_DAMAGE)
	c:RegisterEffect(e5)
end
function s.dirtg(e, c)
	return not Duel.IsExistingMatchingCard(Card.IsFaceup, c:GetControler(), 0, LOCATION_MZONE, 1, nil)
end
function s.val(e, re, dam, r, rp, rc)
	if bit.band(r, REASON_EFFECT) ~= 0 then
		return math.floor(dam / 2)
	else
		return dam
	end
end
function s.rdtg(e, c)
	return not c:IsSetCard(SETCARD_ID_0)
end


Ghostrick
Monsters cannot attack face-down Defense Position monsters, but can attack directly if all monsters their opponent controls are face-down Defense Position. All effect damage, and battle damage inflicted by monsters other than "Ghostrick" monsters, is halved.
-- Ghostrick
local SETCARD_ID_0 = 0x8d --Ghostrick
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--atklimit
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
	e2:SetRange(LOCATION_FZONE)
	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e2:SetValue(aux.TargetBoolFunction(Card.IsFacedown))
	c:RegisterEffect(e2)
	--direct attack
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_DIRECT_ATTACK)
	e3:SetRange(LOCATION_FZONE)
	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e3:SetTarget(s.dirtg)
	c:RegisterEffect(e3)
	--
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD)
	e4:SetRange(LOCATION_FZONE)
	e4:SetCode(EFFECT_CHANGE_DAMAGE)
	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e4:SetTargetRange(1, 1)
	e4:SetValue(s.val)
	c:RegisterEffect(e4)
	local e5 = Effect.CreateEffect(c)
	e5:SetType(EFFECT_TYPE_FIELD)
	e5:SetRange(LOCATION_FZONE)
	e5:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
	e5:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
	e5:SetTarget(s.rdtg)
	e5:SetValue(HALF_DAMAGE)
	c:RegisterEffect(e5)
end
function s.dirtg(e, c)
	return not Duel.IsExistingMatchingCard(Card.IsFaceup, c:GetControler(), 0, LOCATION_MZONE, 1, nil)
end
function s.val(e, re, dam, r, rp, rc)
	if bit.band(r, REASON_EFFECT) ~= 0 then
		return math.floor(dam / 2)
	else
		return dam
	end
end
function s.rdtg(e, c)
	return not c:IsSetCard(SETCARD_ID_0)
end

