D/D/D
Pendulum Scale = 4
[ Pendulum Effect ]
Once per turn: You can target 1 "D/D" monster you control; it gains 800 ATK until the end of this turn (even if this card leaves the field).
----------------------------------------
[ Monster Effect ]
Once per turn, if a monster(s) you control is destroyed by battle or card effect: You can target 1 of those monsters; this card gains ATK equal to that monster's original ATK until the end of this turn. This card cannot attack your opponent directly during the turn this effect is activated. Cannot be destroyed by Spell/Trap effects that do not target this card.
local SETCARD_ID_0 = 0xaf --D/D

local SETCARD_ID_0 = 0xaf --D/D
local s, id, o = GetID()
function s.initial_effect(c)
	--pendulum summon
	aux.EnablePendulumAttribute(c)
	--atk up
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_PZONE)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetCountLimit(1)
	e2:SetTarget(s.atktg1)
	e2:SetOperation(s.atkop1)
	c:RegisterEffect(e2)
	--atk up
	local e3 = Effect.CreateEffect(c)
	e3:SetCategory(CATEGORY_ATKCHANGE)
	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_DESTROYED)
	e3:SetRange(LOCATION_MZONE)
	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
	e3:SetCountLimit(1)
	e3:SetCost(s.atkcost)
	e3:SetTarget(s.atktg2)
	e3:SetOperation(s.atkop2)
	c:RegisterEffect(e3)
	--indes
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_SINGLE)
	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e4:SetRange(LOCATION_MZONE)
	e4:SetValue(s.efilter)
	c:RegisterEffect(e4)
end
function s.filter1(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.atktg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter1(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
end
function s.atkop1(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
		local e1 = Effect.CreateEffect(e:GetHandler())
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetValue(800)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		tc:RegisterEffect(e1)
	end
end
function s.filter2(c, e, tp)
	return c:IsReason(REASON_BATTLE + REASON_EFFECT)
		and c:IsType(TYPE_MONSTER)
		and c:IsPreviousLocation(LOCATION_MZONE)
		and c:IsPreviousControler(tp)
		and c:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED)
		and c:IsCanBeEffectTarget(e)
end
function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return not e:GetHandler():IsDirectAttacked()
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.atktg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return eg:IsContains(chkc) and s.filter2(chkc, e, tp)
	end
	if chk == 0 then
		return eg:IsExists(s.filter2, 1, nil, e, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
	local g = eg:FilterSelect(tp, s.filter2, 1, 1, nil, e, tp)
	Duel.SetTargetCard(g)
end
function s.atkop2(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local tc = Duel.GetFirstTarget()
	if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetValue(tc:GetBaseAttack())
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
		c:RegisterEffect(e1)
	end
end
function s.efilter(e, re, rp)
	if not re:IsActiveType(TYPE_SPELL + TYPE_TRAP) then
		return false
	end
	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
		return true
	end
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
	return not g:IsContains(e:GetHandler())
end


D/D/D
Pendulum Scale = 4
[ Pendulum Effect ]
Once per turn: You can target 1 "D/D" monster you control; it gains 800 ATK until the end of this turn (even if this card leaves the field).
----------------------------------------
[ Monster Effect ]
Once per turn, if a monster(s) you control is destroyed by battle or card effect: You can target 1 of those monsters; this card gains ATK equal to that monster's original ATK until the end of this turn. This card cannot attack your opponent directly during the turn this effect is activated. Cannot be destroyed by Spell/Trap effects that do not target this card.
-- D/D/D
local SETCARD_ID_0 = 0xaf --D/D
local s, id, o = GetID()
function s.initial_effect(c)
	--pendulum summon
	aux.EnablePendulumAttribute(c)
	--atk up
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_PZONE)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetCountLimit(1)
	e2:SetTarget(s.atktg1)
	e2:SetOperation(s.atkop1)
	c:RegisterEffect(e2)
	--atk up
	local e3 = Effect.CreateEffect(c)
	e3:SetCategory(CATEGORY_ATKCHANGE)
	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_DESTROYED)
	e3:SetRange(LOCATION_MZONE)
	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
	e3:SetCountLimit(1)
	e3:SetCost(s.atkcost)
	e3:SetTarget(s.atktg2)
	e3:SetOperation(s.atkop2)
	c:RegisterEffect(e3)
	--indes
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_SINGLE)
	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e4:SetRange(LOCATION_MZONE)
	e4:SetValue(s.efilter)
	c:RegisterEffect(e4)
end
function s.filter1(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.atktg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter1(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
end
function s.atkop1(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
		local e1 = Effect.CreateEffect(e:GetHandler())
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetValue(800)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		tc:RegisterEffect(e1)
	end
end
function s.filter2(c, e, tp)
	return c:IsReason(REASON_BATTLE + REASON_EFFECT)
		and c:IsType(TYPE_MONSTER)
		and c:IsPreviousLocation(LOCATION_MZONE)
		and c:IsPreviousControler(tp)
		and c:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED)
		and c:IsCanBeEffectTarget(e)
end
function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return not e:GetHandler():IsDirectAttacked()
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.atktg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return eg:IsContains(chkc) and s.filter2(chkc, e, tp)
	end
	if chk == 0 then
		return eg:IsExists(s.filter2, 1, nil, e, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
	local g = eg:FilterSelect(tp, s.filter2, 1, 1, nil, e, tp)
	Duel.SetTargetCard(g)
end
function s.atkop2(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local tc = Duel.GetFirstTarget()
	if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetValue(tc:GetBaseAttack())
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
		c:RegisterEffect(e1)
	end
end
function s.efilter(e, re, rp)
	if not re:IsActiveType(TYPE_SPELL + TYPE_TRAP) then
		return false
	end
	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
		return true
	end
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
	return not g:IsContains(e:GetHandler())
end

