Advertisement
arcagamer

velocista

Mar 30th, 2023
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.38 KB | None | 0 0
  1. --Relampagos - Astrid Fischer,Velocista das Relampagos
  2. local s,id,o=GetID()
  3. function s.initial_effect(c)
  4.     local e1=Effect.CreateEffect(c)
  5.     e1:SetType(EFFECT_TYPE_QUICK_O)
  6.     e1:SetCode(EVENT_FREE_CHAIN)
  7.     e1:SetRange(LOCATION_MZONE)
  8.     e1:SetTarget(s.target)
  9.     e1:SetOperation(s.operation)
  10.     c:RegisterEffect(e1)
  11.     -- If this card is destroyed by a card effect: you can destroy 1 face-down card your opponent controls.
  12.     local e2=Effect.CreateEffect(c)
  13.     e2:SetCategory(CATEGORY_DESTROY)
  14.     e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
  15.     e2:SetCode(EVENT_DESTROYED)
  16.     e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
  17.     e2:SetCondition(s.descon)
  18.     e2:SetTarget(s.destg)
  19.     e2:SetOperation(s.desop)
  20.     c:RegisterEffect(e2)
  21.     -- Effect to limit the number of copies on the field to 1
  22.     local e5=Effect.CreateEffect(c)
  23.     e5:SetType(EFFECT_TYPE_SINGLE)
  24.     e5:SetCode(EFFECT_CANNOT_SUMMON)
  25.     e5:SetCondition(s.sumcon)
  26.     c:RegisterEffect(e5)
  27.     local e6=e5:Clone()
  28.     e6:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
  29.     c:RegisterEffect(e6)
  30.     local e7=e5:Clone()
  31.     e7:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  32.     c:RegisterEffect(e7)
  33. end
  34. function s.sumcon(e)
  35.     return Duel.IsExistingMatchingCard(Card.IsCode,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,id)
  36. end
  37.  
  38. function s.filter(c)
  39.     return c:IsFaceup() and c:IsSetCard(0xb13) and not c:IsCode(id)
  40. end
  41. function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
  42.     if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and s.filter(chkc) end
  43.     if chk==0 then return Duel.IsExistingTarget(s.filter,tp,0,LOCATION_MZONE,1,nil) end
  44.     Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
  45.     local g=Duel.SelectTarget(tp,s.filter,tp,0,LOCATION_MZONE,1,1,nil)
  46. end
  47. function s.operation(e,tp,eg,ep,ev,re,r,rp)
  48.     local tc=Duel.GetFirstTarget()
  49.     if tc and tc:IsRelateToEffect(e) then
  50.         Duel.SwapControl(e:GetHandler(),tc)
  51.         Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
  52.         local g=Duel.SelectMatchingCard(tp,nil,tp,0,LOCATION_ONFIELD,1,1,nil)
  53.         if #g>0 then
  54.             Duel.HintSelection(g)
  55.             Duel.Destroy(g,REASON_EFFECT)
  56.             if g:GetFirst():IsSetCard(0xb13) then
  57.                 local e1=Effect.CreateEffect(e:GetHandler())
  58.                 e1:SetType(EFFECT_TYPE_SINGLE)
  59.                 e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  60.                 e1:SetValue(1)
  61.                 e1:SetReset(RESET_PHASE+PHASE_END,2)
  62.                 e:GetHandler():RegisterEffect(e1,true)
  63.                 local e2=e1:Clone()
  64.                 e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  65.                 e:GetHandler():RegisterEffect(e2,true)
  66.             end
  67.         end
  68.     end
  69. end
  70.  
  71. function s.descon(e,tp,eg,ep,ev,re,r,rp)
  72.     return (r&REASON_EFFECT)~=0
  73. end
  74. function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
  75.     if chkc then return chkc:IsOnField() and chkc:IsFacedown() and chkc:IsControler(1-tp) end
  76.     if chk==0 then return Duel.IsExistingTarget(Card.IsFacedown,tp,0,LOCATION_ONFIELD,1,nil) end
  77.     Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
  78.     local g=Duel.SelectTarget(tp,Card.IsFacedown,tp,0,LOCATION_ONFIELD,1,1,nil)
  79.     Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,#g,0,0)
  80. end
  81. function s.desop(e,tp,eg,ep,ev,re,r,rp)
  82.     local tc=Duel.GetFirstTarget()
  83.     if tc and tc:IsRelateToEffect(e) then
  84.         Duel.Destroy(tc,REASON_EFFECT)
  85.     end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement