name: D/D/D
card_text: Pendulum Scale = 3
  [ Pendulum Effect ]
  When you take effect damage (except during the Damage Step): You can destroy this card, and if you do, any effect that would inflict damage to a player this turn increases their LP by the same amount, instead.
  ----------------------------------------
  [ Monster Effect ]
  When you take effect damage (except during the Damage Step): You can Special Summon this card from your hand, and if you do, gain LP equal to the damage you took. You take no effect damage.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--reverse damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EVENT_DAMAGE)
  	e2:SetCondition(s.effcon)
  	e2:SetTarget(s.revtg)
  	e2:SetOperation(s.revop)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_RECOVER)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_HAND)
  	e3:SetCode(EVENT_DAMAGE)
  	e3:SetCondition(s.effcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--avoid damage
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EFFECT_CHANGE_DAMAGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(1, 0)
  	e4:SetValue(s.damval)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	c:RegisterEffect(e5)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep == tp and bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.revtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.revop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.Destroy(c, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_REVERSE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 1)
  		e1:SetValue(s.revval)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.revval(e, re, r, rp, rc)
  	return bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ev)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		Duel.Recover(tp, ev, REASON_EFFECT)
  	end
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		return 0
  	end
  	return val
  end
  
  
source_text: D/D/D
  Pendulum Scale = 3
  [ Pendulum Effect ]
  When you take effect damage (except during the Damage Step): You can destroy this card, and if you do, any effect that would inflict damage to a player this turn increases their LP by the same amount, instead.
  ----------------------------------------
  [ Monster Effect ]
  When you take effect damage (except during the Damage Step): You can Special Summon this card from your hand, and if you do, gain LP equal to the damage you took. You take no effect damage.
target_text: -- D/D/D
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--reverse damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EVENT_DAMAGE)
  	e2:SetCondition(s.effcon)
  	e2:SetTarget(s.revtg)
  	e2:SetOperation(s.revop)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_RECOVER)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_HAND)
  	e3:SetCode(EVENT_DAMAGE)
  	e3:SetCondition(s.effcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--avoid damage
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EFFECT_CHANGE_DAMAGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(1, 0)
  	e4:SetValue(s.damval)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	c:RegisterEffect(e5)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep == tp and bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.revtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.revop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.Destroy(c, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_REVERSE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 1)
  		e1:SetValue(s.revval)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.revval(e, re, r, rp, rc)
  	return bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ev)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		Duel.Recover(tp, ev, REASON_EFFECT)
  	end
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		return 0
  	end
  	return val
  end
  
  