name: Giant
card_text: 2 Level 3 Rock-Type monsters
  This card is unaffected by other monsters' effects. Once per turn, during either player's turn: You can detach 1 Xyz Material from this card; it gains 1000 DEF until the end of this turn, and if it does, you take no effect damage from your opponent's card effects this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_ROCK), 3, 2)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DEFCHANGE)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1)
  	e2:SetHintTiming(TIMING_DAMAGE_STEP)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwner() ~= e:GetOwner()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_DEFENSE)
  		e1:SetValue(1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CHANGE_DAMAGE)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetTargetRange(1, 0)
  		e2:SetValue(s.damval)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e2, tp)
  		local e3 = e2:Clone()
  		e3:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  		e3:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e3, tp)
  	end
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - e:GetOwnerPlayer() then
  		return 0
  	else
  		return val
  	end
  end
  
  
source_text: Giant
  2 Level 3 Rock-Type monsters
  This card is unaffected by other monsters' effects. Once per turn, during either player's turn: You can detach 1 Xyz Material from this card; it gains 1000 DEF until the end of this turn, and if it does, you take no effect damage from your opponent's card effects this turn.
target_text: -- Giant
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_ROCK), 3, 2)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DEFCHANGE)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1)
  	e2:SetHintTiming(TIMING_DAMAGE_STEP)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwner() ~= e:GetOwner()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_DEFENSE)
  		e1:SetValue(1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CHANGE_DAMAGE)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetTargetRange(1, 0)
  		e2:SetValue(s.damval)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e2, tp)
  		local e3 = e2:Clone()
  		e3:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  		e3:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e3, tp)
  	end
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - e:GetOwnerPlayer() then
  		return 0
  	else
  		return val
  	end
  end
  
  