--Play by my Risk! --scripted by Rawstone local s,id=GetID() function s.initial_effect(c) --negate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DRAW+CATEGORY_NEGATE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_PLAYER_TARGET) e1:SetCondition(s.discon) e1:SetTarget(s.distg) e1:SetOperation(s.disop) c:RegisterEffect(e1) --SP local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_GRAVE) e2:SetCondition(s.setcon) e2:SetHintTiming(TIMING_END_PHASE) e2:SetCost(aux.bfgcost) e2:SetTarget(s.settg) e2:SetOperation(s.setop) c:RegisterEffect(e2) Duel.AddCustomActivityCounter(40010,ACTIVITY_CHAIN,s.counterfilter) end c40010.toss_coin=true function s.discon(e,tp,eg,ep,ev,re,r,rp) return rp==1-tp and Duel.IsChainNegatable(ev) end function s.filter(c,e,tp) return c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(1-tp,1) and Duel.GetFieldGroupCount(1-tp,LOCATION_DECK,0)>=1 end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,1-tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,1,1-tp,1) Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,1-tp,0) end function s.disop(e,tp,eg,ep,ev,re,r,rp) local c1,c2,c3=Duel.TossCoin(1-tp,3) if c1+c2+c3==0 then local WIN_REASON_YOU=0x15 Duel.Win(tp,WIN_REASON_YOU) elseif c1+c2+c3==1 then Duel.NegateActivation(ev) elseif c1+c2+c3==2 then local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) else local g=Duel.GetMatchingGroup(s.filter,1-tp,LOCATION_DECK,0,nil,e,1-tp) if g:GetCount()>0 and Duel.GetLocationCount(1-tp,LOCATION_MZONE)>0 then Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_SPSUMMON) local sg=g:Select(1-tp,1,1,nil) Duel.SpecialSummon(sg,0,1-tp,1-tp,false,false,POS_FACEUP) end end end function s.filta(c,e,tp) return c.toss_coin and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE) end function s.counterfilter(c) return c.toss_coin end function s.setcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()==PHASE_END and Duel.GetCustomActivityCount(40010,tp,ACTIVITY_CHAIN)>=1 end function s.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.filta,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.setop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.filta,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE) end end