Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bait Doll overrides the "Reason Effect" of the card it activates #246

Open
NaimSantos opened this issue Dec 2, 2019 · 3 comments
Open

Comments

@NaimSantos
Copy link

NaimSantos commented Dec 2, 2019

When Bait Doll targets Treacherous Trap Hole, cards immune to Spell effects are not destroyed, and cards immune to Trap effects are, which is the reverse of the correct interaction. This is because the "Reason Effect" applying Duel.Destroy is that of Bait Doll, a Spell Card.
Would be be possible to have a function that makes clear that the effect applying the operation is that of Bait Doll's target, not Bait Doll itself?

@Lyris12
Copy link
Contributor

Lyris12 commented Apr 23, 2020

I made a workaround fix for Bait Doll, with which you can compare the current code with for what I changed:

--おとり人形
function c7165085.initial_effect(c)
    --Activate
    local e1=Effect.CreateEffect(c)
    e1:SetCategory(CATEGORY_DESTROY)
    e1:SetType(EFFECT_TYPE_ACTIVATE)
    e1:SetCode(EVENT_FREE_CHAIN)
    e1:SetTarget(c7165085.target)
    e1:SetOperation(c7165085.activate)
    c:RegisterEffect(e1)
end
function c7165085.filter(c)
    return c:IsFacedown() and c:GetSequence()~=5
end
function c7165085.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    if chkc then return chkc:IsLocation(LOCATION_SZONE) and c7165085.filter(chkc) end
    if chk==0 then return Duel.IsExistingTarget(c7165085.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,e:GetHandler()) end
    e:SetProperty(EFFECT_FLAG_CARD_TARGET)
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEDOWN)
    Duel.SelectTarget(tp,c7165085.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,1,e:GetHandler())
end
function c7165085.activate(e,tp,eg,ep,ev,re,r,rp)
    local c=e:GetHandler()
    local tc=Duel.GetFirstTarget()
    if not tc:IsRelateToEffect(e) or tc:IsFaceup() then
        if c:IsRelateToEffect(e) and e:IsHasType(EFFECT_TYPE_ACTIVATE) then
            c:CancelToGrave()
            Duel.SendtoDeck(c,nil,2,REASON_EFFECT)
        end
        return
    end
    Duel.ConfirmCards(tp,tc)
    if tc:IsType(TYPE_TRAP) then
        local e1=Effect.CreateEffect(c)
        e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
        e1:SetCode(EVENT_CHAIN_END)
        e1:SetLabel(Duel.GetChainInfo(0,CHAININFO_CHAIN_ID))
        e1:SetLabelObject(tc)
        e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
        e1:SetOperation(c7165085.actop)
        Duel.RegisterEffect(e1,tp)
    end
    if c:IsRelateToEffect(e) and e:IsHasType(EFFECT_TYPE_ACTIVATE) then
        c:CancelToGrave()
        Duel.SendtoDeck(c,nil,2,REASON_EFFECT)
    end
end
function c7165085.actop(e,tp,eg,ep,ev,re,r,rp)
    local tc=e:GetLabelObject()
    local te=tc:GetActivateEffect()
    local tep=tc:GetControler()
    e:Reset()
    if not te then Duel.Destroy(tc,REASON_EFFECT)
    else
        local e1=Effect.CreateEffect(e:GetHandler())
        e1:SetType(EFFECT_TYPE_FIELD)
        e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
        e1:SetCode(EFFECT_CANNOT_ACTIVATE)
        e1:SetTargetRange(1,1)
        e1:SetValue(function(ef,ref) return te~=ref end)
        e1:SetReset(RESET_CHAIN)
        Duel.RegisterEffect(e1,tp)
        local condition=te:GetCondition()
        local cost=te:GetCost()
        local target=te:GetTarget()
        if te:GetCode()==EVENT_FREE_CHAIN and te:IsActivatable(tep)
            and (not condition or condition(te,tep,eg,ep,ev,re,r,rp))
            and (not cost or cost(te,tep,eg,ep,ev,re,r,rp,0))
            and (not target or target(te,tep,eg,ep,ev,re,r,rp,0)) then
            Duel.Activate(te)
        end
        e1:Reset()
        if tc:IsFacedown() then Duel.Destroy(tc,REASON_EFFECT) end
    end
end

@edo9300
Copy link
Contributor

edo9300 commented Apr 23, 2020

This approach is wrong, by rulings, the trap has to be activated and resolved during the same chain, it cannot be left resolving after the chain end, also this will cause issues, sample scenario, opponent has 2 traps that can be activated, you use bait doll and chain serial spell. The chain will resolve, then after it ended, the last targeted card will be activated, then after that, the opponent will be able to activate the other target as well, and after the opponent had the possibility top activate and resolve the effect, the second forced activation will take place twice.

sample puzzle to show this behaviour, after all the effects resolved, you'll end up gaining 12k lifepoints from 2 gift cards

Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN,5)
Debug.SetPlayerInfo(0,3000,0,0)
Debug.SetPlayerInfo(1,8000,0,0)

Debug.AddCard(7165085,0,0,LOCATION_HAND,5,POS_FACEUP_ATTACK)
Debug.AddCard(49398568,0,0,LOCATION_HAND,5,POS_FACEUP_ATTACK)
Debug.AddCard(49398568,0,0,LOCATION_HAND,5,POS_FACEUP_ATTACK)
Debug.AddCard(39526584,1,1,LOCATION_SZONE,1,POS_FACEDOWN)
Debug.AddCard(39526584,1,1,LOCATION_SZONE,2,POS_FACEDOWN)

Debug.ReloadFieldEnd()

@Lyris12
Copy link
Contributor

Lyris12 commented Apr 24, 2020

Oh. No problem, then, but I guess "Bait Doll" will just copy the effect of the targeted Trap, if able. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants