Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Anime Card Fixes #462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 110 additions & 74 deletions script/c511000952.lua
Original file line number Diff line number Diff line change
@@ -1,74 +1,110 @@
--Dimension Trap
function c511000952.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c511000952.cost)
e1:SetTarget(c511000952.target)
e1:SetOperation(c511000952.activate)
c:RegisterEffect(e1)
end
function c511000952.filter(c,tp,eg,ep,ev,re,r,rp)
local te=c:GetActivateEffect()
if not te then return false end
local cost=te:GetCost()
local target=te:GetTarget()
return c:IsType(TYPE_TRAP) and c:IsAbleToRemoveAsCost() and (not cost or cost(te,tp,eg,ep,ev,re,r,rp,0) or not cost(te,tp,eg,ep,ev,re,r,rp,0))
and (not target or target(te,tp,eg,ep,ev,re,r,rp,0))
end
function c511000952.cost(e,tp,eg,ep,ev,re,r,rp,chk)
e:SetLabel(1)
if chk==0 then return true end
end
function c511000952.target(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
if e:GetLabel()~=1 then return false end
e:SetLabel(0)
return Duel.IsExistingMatchingCard(Card.IsAbleToRemoveAsCost,tp,LOCATION_MZONE,0,1,nil)
and Duel.IsExistingMatchingCard(c511000952.filter,tp,LOCATION_GRAVE,0,1,nil,tp,eg,ep,ev,re,r,rp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g1=Duel.SelectMatchingCard(tp,Card.IsAbleToRemoveAsCost,tp,LOCATION_MZONE,0,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g2=Duel.SelectMatchingCard(tp,c511000952.filter,tp,LOCATION_GRAVE,0,1,1,nil)
g1:Merge(g2)
Duel.Remove(g1,POS_FACEUP,REASON_COST)
local tc=g2:GetFirst()
local tpe=tc:GetType()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_TYPE)
e1:SetValue(tpe)
e1:SetReset(RESET_EVENT+0x1fc0000)
c:RegisterEffect(e1)
if bit.band(tpe,TYPE_FIELD)~=0 then
local of=Duel.GetFieldCard(1-tp,LOCATION_SZONE,5)
if of then Duel.Destroy(of,REASON_RULE) end
of=Duel.GetFieldCard(tp,LOCATION_SZONE,5)
if of and Duel.Destroy(of,REASON_RULE)==0 then Duel.SendtoGrave(tc,REASON_RULE) end
Duel.MoveSequence(c,5)
end
local te=tc:GetActivateEffect()
c511000952[Duel.GetCurrentChain()]=te
Duel.ClearTargetCard()
local tg=te:GetTarget()
e:SetCategory(te:GetCategory())
e:SetProperty(te:GetProperty())
if tg then tg(e,tp,eg,ep,ev,re,r,rp,1) end
end
function c511000952.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local te=c511000952[Duel.GetCurrentChain()]
if not te then return end
local tpe=te:GetHandler():GetType()
if bit.band(tpe,TYPE_EQUIP+TYPE_CONTINUOUS+TYPE_FIELD)==0 then
c:CancelToGrave(false)
else
c:CancelToGrave(true)
local code=te:GetHandler():GetOriginalCode()
c:CopyEffect(code,RESET_EVENT+0x1fc0000,1)
end
local op=te:GetOperation()
if op then op(e,tp,eg,ep,ev,re,r,rp) end
end
--Dimension Trap
function c511000952.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c511000952.cost)
e1:SetTarget(c511000952.target)
e1:SetOperation(c511000952.activate)
c:RegisterEffect(e1)
end
function c511000952.filter(c,tp)
local te,eg,ep,ev,re,r,rp=c:CheckActivateEffect(true,true,true)
if te==nil then return false end
local cost=te:GetCost()
local target=te:GetTarget()
return c:IsType(TYPE_TRAP) and c:IsAbleToRemoveAsCost() and (not target or target(te,tp,eg,ep,ev,re,r,rp,0))
end
function c511000952.cost(e,tp,eg,ep,ev,re,r,rp,chk)
e:SetLabel(1)
if chk==0 then return true end
end
function c511000952.target(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
if e:GetLabel()~=1 then return false end
e:SetLabel(0)
return Duel.IsExistingMatchingCard(Card.IsAbleToRemoveAsCost,tp,LOCATION_MZONE,0,1,nil)
and Duel.IsExistingMatchingCard(c511000952.filter,tp,LOCATION_GRAVE,0,1,nil,tp,eg,ep,ev,re,r,rp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g1=Duel.SelectMatchingCard(tp,Card.IsAbleToRemoveAsCost,tp,LOCATION_MZONE,0,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g2=Duel.SelectMatchingCard(tp,c511000952.filter,tp,LOCATION_GRAVE,0,1,1,nil)
g1:Merge(g2)
Duel.Remove(g1,POS_FACEUP,REASON_COST)
local tc=g2:GetFirst()
local tpe=tc:GetType()
if bit.band(tpe,TYPE_FIELD)~=0 then
local fc=Duel.GetFieldCard(1-tp,LOCATION_SZONE,5)
--[[if Duel.IsDuelType(DUEL_OBSOLETE_RULING) then
if fc then Duel.Destroy(fc,REASON_RULE) end
fc=Duel.GetFieldCard(tp,LOCATION_SZONE,5)
if fc and Duel.Destroy(fc,REASON_RULE)==0 then Duel.SendtoGrave(tc,REASON_RULE) end
else]]
fc=Duel.GetFieldCard(tp,LOCATION_SZONE,5)
if fc and Duel.SendtoGrave(fc,REASON_RULE)==0 then Duel.SendtoGrave(tc,REASON_RULE) end
--end
end
local te,teg,tep,tev,tre,tr,trp=tc:CheckActivateEffect(true,true,true)
c511000952[Duel.GetCurrentChain()]=te
Duel.ClearTargetCard()
local tg=te:GetTarget()
e:SetCategory(te:GetCategory())
e:SetProperty(te:GetProperty())
if tg then tg(e,tp,teg,tep,tev,tre,tr,trp,1) end
e:SetOperation(c511000952.activateop(teg,tep,tev,tre,tr,trp))
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_CHAIN_SOLVED)
e1:SetReset(RESET_CHAIN)
e1:SetLabelObject(e)
e1:SetOperation(c511000952.resetop)
Duel.RegisterEffect(e1,tp)
end
function c511000952.activateop(teg,tep,tev,tre,tr,trp)
return function(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local c=e:GetHandler()
local te=c511000952[Duel.GetCurrentChain()]
if not te then return end
local tpe=te:GetHandler():GetType()
if bit.band(tpe,TYPE_EQUIP+TYPE_CONTINUOUS+TYPE_FIELD)==0 then
c:CancelToGrave(false)
else
c:CancelToGrave(true)
local code=te:GetHandler():GetOriginalCode()
c:CopyEffect(code,RESET_EVENT+0x1fc0000,1)
end
local op=te:GetOperation()
if op then op(e,tp,teg,tep,tev,tre,tr,trp) end
if g and bit.band(tpe,TYPE_EQUIP)>0 and not e:GetHandler():GetEquipTarget() then
Duel.Equip(tp,e:GetHandler(),g:GetFirst())
end
end
end
function c511000952.resetop(e,tp,eg,ep,ev,re,r,rp)
local te=e:GetLabelObject()
if te then
te:SetOperation(c511000952.activate)
end
end
function c511000952.activate(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local c=e:GetHandler()
local te=c511000952[Duel.GetCurrentChain()]
if not te then return end
local tpe=te:GetHandler():GetType()
if bit.band(tpe,TYPE_EQUIP+TYPE_CONTINUOUS+TYPE_FIELD)==0 then
c:CancelToGrave(false)
else
c:CancelToGrave(true)
local code=te:GetHandler():GetOriginalCode()
c:CopyEffect(code,RESET_EVENT+0x1fc0000,1)
end
local op=te:GetOperation()
if op then op(e,tp,eg,ep,ev,re,r,rp) end
if g and bit.band(tpe,TYPE_EQUIP)>0 and not e:GetHandler():GetEquipTarget() then
Duel.Equip(tp,e:GetHandler(),g:GetFirst())
end
end
84 changes: 36 additions & 48 deletions script/c511002990.lua
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
--Victim's Darkness
function c511002990.initial_effect(c)
--
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCondition(c511002990.condition)
e1:SetTarget(c511002990.target)
e1:SetOperation(c511002990.operation)
c:RegisterEffect(e1)
end
function c511002990.cfilter(c,e,tp)
return c:IsOnField() and c:IsType(TYPE_MONSTER) and c:IsControler(tp) and (not e or c:IsRelateToEffect(e))
end
function c511002990.condition(e,tp,eg,ep,ev,re,r,rp)
local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_DESTROY)
if tg==nil then return false end
local g=tg:Filter(c511002990.cfilter,nil,nil,tp)
g:KeepAlive()
e:SetLabelObject(g)
return re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and ex and tc+g:GetCount()-tg:GetCount()==1
end
function c511002990.tgfilter(c)
return c:IsLevelBelow(3) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsAbleToGrave()
end
function c511002990.target(e,tp,eg,ep,ev,re,r,rp,chk)
local g=e:GetLabelObject()
if chk==0 then return g and Duel.IsExistingMatchingCard(c511002990.tgfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetTargetCard(g)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c511002990.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c511002990.tgfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoGrave(g,REASON_EFFECT)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e1:SetValue(1)
e1:SetReset(RESET_CHAIN)
tc:RegisterEffect(e1)
end
end
end
--Victim's Darkness
function c511002990.initial_effect(c)
--
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOGRAVE+CATEGORY_NEGATE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCondition(c511002990.condition)
e1:SetTarget(c511002990.target)
e1:SetOperation(c511002990.operation)
c:RegisterEffect(e1)
end
function c511002990.cfilter(c)
return c:IsOnField() and c:IsType(TYPE_MONSTER)
end
function c511002990.condition(e,tp,eg,ep,ev,re,r,rp)
if tp==ep or not Duel.IsChainNegatable(ev) then return false end
if not re:IsHasType(EFFECT_TYPE_ACTIVATE) then return false end
local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_DESTROY)
return ex and tg~=nil and tc+tg:FilterCount(c511002990.cfilter,nil)-tg:GetCount()>0
end
function c511002990.tgfilter(c)
return c:IsLevelBelow(3) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsAbleToGrave()
end
function c511002990.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c511002990.tgfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
end
function c511002990.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c511002990.tgfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 and Duel.SendtoGrave(g,REASON_EFFECT)>0 then
Duel.NegateActivation(ev)
end
end
Loading