@@ -253,6 +253,13 @@ function Card.IsTrapMonster(c)
253253 return c :IsTrapCard () and (c :GetOriginalLevel ()> 0 or c :GetOriginalAttribute ()> 0 or c :GetOriginalRace ()> 0 )
254254end
255255
256+ function Card .IsEquipTrap (c )
257+ if not c :IsTrap () then return false end
258+ if c .self_equip_trap then return true end
259+ local activate_eff = c :GetActivateEffect ()
260+ return activate_eff and activate_eff :HasRemainFieldCost ()
261+ end
262+
256263function Card .GetMainCardType (c )
257264 return c :GetType ()&(TYPE_MONSTER |TYPE_SPELL |TYPE_TRAP )
258265end
@@ -1650,6 +1657,36 @@ function Cost.DetachFromSelf(min,max,op)
16501657 return cost_func
16511658end
16521659
1660+
1661+ -- check for cards that can stay on the field, but not always
1662+ function Auxiliary .RemainFieldCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1663+ if chk == 0 then return true end
1664+ local c = e :GetHandler ()
1665+ local cid = Duel .GetChainInfo (0 ,CHAININFO_CHAIN_ID )
1666+ local e1 = Effect .CreateEffect (c )
1667+ e1 :SetType (EFFECT_TYPE_SINGLE )
1668+ e1 :SetCode (EFFECT_REMAIN_FIELD )
1669+ e1 :SetProperty (EFFECT_FLAG_OATH )
1670+ e1 :SetReset (RESET_CHAIN )
1671+ c :RegisterEffect (e1 )
1672+ local e2 = Effect .CreateEffect (c )
1673+ e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
1674+ e2 :SetCode (EVENT_CHAIN_DISABLED )
1675+ e2 :SetOperation (Auxiliary .RemainFieldDisabled )
1676+ e2 :SetLabel (cid )
1677+ e2 :SetReset (RESET_CHAIN )
1678+ Duel .RegisterEffect (e2 ,tp )
1679+ end
1680+ function Auxiliary .RemainFieldDisabled (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
1681+ local cid = Duel .GetChainInfo (ev ,CHAININFO_CHAIN_ID )
1682+ if cid ~= e :GetLabel () then return end
1683+ if e :GetOwner ():IsLocation (LOCATION_ONFIELD ) then
1684+ e :GetOwner ():CancelToGrave (false )
1685+ end
1686+ end
1687+ local remain_field_costs = {}
1688+ remain_field_costs [aux .RemainFieldCost ]= true
1689+
16531690local function cost_table_check (t )
16541691 return function (eff ) return t [eff :GetCost ()] end
16551692end
@@ -1658,6 +1695,7 @@ Effect.HasSelfToGraveCost=cost_table_check(self_tograve_costs)
16581695Effect .HasSelfDiscardCost = cost_table_check (self_discard_costs )
16591696Effect .HasDetachCost = cost_table_check (detach_costs )
16601697Effect .HasSelfChangePositionCost = cost_table_check (self_changepos_costs )
1698+ Effect .HasRemainFieldCost = cost_table_check (remain_field_costs )
16611699
16621700-- Default cost for "You can pay X LP;"
16631701function Cost .PayLP (lp_value ,pay_until )
@@ -1733,6 +1771,7 @@ function Cost.AND(...)
17331771 if detach_costs [fn ] then detach_costs [full_cost ]= true end
17341772 if self_discard_costs [fn ] then self_discard_costs [full_cost ]= true end
17351773 if self_tograve_costs [fn ] then self_tograve_costs [full_cost ]= true end
1774+ if remain_field_costs [fn ] then remain_field_costs [full_cost ]= true end
17361775 end
17371776 return full_cost
17381777end
@@ -1941,32 +1980,7 @@ function Auxiliary.ChkfMMZ(sumcount)
19411980 return Duel .GetMZoneCount (tp ,sg )>= sumcount
19421981 end
19431982end
1944- -- check for cards that can stay on the field, but not always
1945- function Auxiliary .RemainFieldCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1946- if chk == 0 then return true end
1947- local c = e :GetHandler ()
1948- local cid = Duel .GetChainInfo (0 ,CHAININFO_CHAIN_ID )
1949- local e1 = Effect .CreateEffect (c )
1950- e1 :SetType (EFFECT_TYPE_SINGLE )
1951- e1 :SetCode (EFFECT_REMAIN_FIELD )
1952- e1 :SetProperty (EFFECT_FLAG_OATH )
1953- e1 :SetReset (RESET_CHAIN )
1954- c :RegisterEffect (e1 )
1955- local e2 = Effect .CreateEffect (c )
1956- e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
1957- e2 :SetCode (EVENT_CHAIN_DISABLED )
1958- e2 :SetOperation (Auxiliary .RemainFieldDisabled )
1959- e2 :SetLabel (cid )
1960- e2 :SetReset (RESET_CHAIN )
1961- Duel .RegisterEffect (e2 ,tp )
1962- end
1963- function Auxiliary .RemainFieldDisabled (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
1964- local cid = Duel .GetChainInfo (ev ,CHAININFO_CHAIN_ID )
1965- if cid ~= e :GetLabel () then return end
1966- if e :GetOwner ():IsLocation (LOCATION_ONFIELD ) then
1967- e :GetOwner ():CancelToGrave (false )
1968- end
1969- end
1983+
19701984-- autocheck for Summoning a Group containing Extra Deck/non-Extra Deck monsters to avoid zone issues
19711985function Auxiliary .MainAndExtraSpSummonLoop (func ,sumtype ,sump ,targetp ,nocheck ,nolimit ,pos ,mmz ,emz )
19721986 return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,sg )
0 commit comments