Commit 84a3347e authored by DailyShana's avatar DailyShana

fix battle destroy redirect

generally use EFFECT_BATTLE_DESTROY_REDIRECT,
optional effect use EFFECT_SEND_REPLACE to append redirect effect to the target,
the value should be a function that always return false
to avoid absense of EVENT_DESTROYED, etc
parent 7d6b1811
......@@ -3,14 +3,10 @@ function c11448373.initial_effect(c)
--todeck
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_TO_GRAVE_REDIRECT)
e1:SetCode(EFFECT_BATTLE_DESTROY_REDIRECT)
e1:SetRange(LOCATION_MZONE)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetTarget(c11448373.rmtarget)
e1:SetValue(LOCATION_DECKSHF)
c:RegisterEffect(e1)
end
function c11448373.rmtarget(e,c)
return c:IsReason(REASON_BATTLE)
end
......@@ -4,8 +4,9 @@ function c15935204.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EVENT_BATTLED)
e1:SetOperation(c15935204.operation)
e1:SetCode(EFFECT_SEND_REPLACE)
e1:SetTarget(c15935204.reptg)
e1:SetValue(aux.FALSE)
c:RegisterEffect(e1)
--damage
local e2=Effect.CreateEffect(c)
......@@ -18,39 +19,29 @@ function c15935204.initial_effect(c)
e2:SetOperation(c15935204.dmop)
c:RegisterEffect(e2)
end
function c15935204.operation(e,tp,eg,ep,ev,re,r,rp)
function c15935204.repfilter(c,e,tp)
return c:IsStatus(STATUS_BATTLE_DESTROYED) and not c:IsType(TYPE_TOKEN)
and c:IsControler(1-tp) and c:IsReason(REASON_BATTLE) and c:GetReasonCard():IsRace(RACE_PSYCHO) and c:GetReasonCard()~=e:GetHandler()
and c:GetLeaveFieldDest()==0 and c:GetDestination()~=LOCATION_DECK
end
function c15935204.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
local b1=not a:IsType(TYPE_TOKEN) and a:IsStatus(STATUS_BATTLE_DESTROYED) and a:IsControler(1-tp) and d and d~=c and d:IsRace(RACE_PSYCHO)
local b2=d and not d:IsType(TYPE_TOKEN) and d:IsStatus(STATUS_BATTLE_DESTROYED) and d:IsControler(1-tp) and a~=c and a:IsRace(RACE_PSYCHO)
if (not b1 and not b2) or not Duel.SelectYesNo(tp,aux.Stringid(15935204,1)) then return end
if b1 then
local e1=Effect.CreateEffect(c)
e1:SetCode(EFFECT_SEND_REPLACE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetTarget(c15935204.reptg)
e1:SetOperation(c15935204.repop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE)
a:RegisterEffect(e1)
end
if b2 then
if chk==0 then return r&REASON_BATTLE~=0 and eg:IsExists(c15935204.repfilter,1,nil,e,tp) end
if Duel.SelectYesNo(tp,aux.Stringid(15935204,1)) then
local tc=eg:Filter(c15935204.repfilter,nil,e,tp):GetFirst()
local e1=Effect.CreateEffect(c)
e1:SetCode(EFFECT_SEND_REPLACE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetTarget(c15935204.reptg)
e1:SetOperation(c15935204.repop)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetCondition(c15935204.recon)
e1:SetValue(LOCATION_DECK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE)
d:RegisterEffect(e1)
end
tc:RegisterEffect(e1)
return true
else return false end
end
function c15935204.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
function c15935204.recon(e)
local c=e:GetHandler()
if chk==0 then return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_BATTLE) end
return true
end
function c15935204.repop(e,tp,eg,ep,ev,re,r,rp)
Duel.SendtoDeck(e:GetHandler(),nil,0,REASON_EFFECT)
return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_BATTLE)
end
function c15935204.dmcon(e,tp,eg,ep,ev,re,r,rp)
return not e:GetHandler():IsReason(REASON_BATTLE)
......
......@@ -16,30 +16,11 @@ function c52913738.regcon(e,tp,eg,ep,ev,re,r,rp)
end
function c52913738.regop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_BATTLED)
e1:SetOperation(c52913738.tdop)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_BATTLE_DESTROY_REDIRECT)
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetTarget(aux.TargetBoolFunction(Card.IsType,TYPE_RITUAL))
e1:SetValue(LOCATION_DECK)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c52913738.tdop(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
if d and a:IsType(TYPE_RITUAL) and d:IsStatus(STATUS_BATTLE_DESTROYED) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetCode(EFFECT_SEND_REPLACE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetTarget(c52913738.reptg)
e1:SetOperation(c52913738.repop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE)
d:RegisterEffect(e1)
end
end
function c52913738.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_BATTLE) end
return true
end
function c52913738.repop(e,tp,eg,ep,ev,re,r,rp)
Duel.SendtoDeck(e:GetHandler(),nil,0,REASON_EFFECT)
end
......@@ -17,7 +17,8 @@ function c76372778.condition(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsStatus(STATUS_BATTLE_DESTROYED) then return false end
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and not bc:IsType(TYPE_TOKEN) and bc:GetLeaveFieldDest()==0
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and not bc:IsType(TYPE_TOKEN)
and bc:GetLeaveFieldDest()==0 and bc:GetDestination()~=LOCATION_DECK
end
function c76372778.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
......@@ -28,19 +29,15 @@ function c76372778.operation(e,tp,eg,ep,ev,re,r,rp)
local bc=c:GetBattleTarget()
if bc:IsRelateToBattle() then
local e1=Effect.CreateEffect(c)
e1:SetCode(EFFECT_SEND_REPLACE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetTarget(c76372778.reptg)
e1:SetOperation(c76372778.repop)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetCondition(c76372778.recon)
e1:SetValue(LOCATION_DECKSHF)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE)
bc:RegisterEffect(e1)
end
end
function c76372778.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
function c76372778.recon(e)
local c=e:GetHandler()
if chk==0 then return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_BATTLE) end
return true
end
function c76372778.repop(e,tp,eg,ep,ev,re,r,rp)
Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_EFFECT)
return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_BATTLE)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment