Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Link
- local s,id=GetID()
- function s.initial_effect(c)
- --atk up
- local e1=Effect.CreateEffect(c)
- e1:SetType(EFFECT_TYPE_SINGLE)
- e1:SetCode(EFFECT_UPDATE_ATTACK)
- e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
- e1:SetRange(LOCATION_MZONE)
- e1:SetValue(s.atkval)
- c:RegisterEffect(e1)
- --equip
- local e2=Effect.CreateEffect(c)
- e2:SetDescription(aux.Stringid(id,0))
- e2:SetCategory(CATEGORY_EQUIP)
- e2:SetType(EFFECT_TYPE_IGNITION)
- e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_NO_TURN_RESET)
- e2:SetRange(LOCATION_MZONE)
- e2:SetCountLimit(1,id,EFFECT_COUNT_CODE_OATH) --to prevent using the effect more than once per turn
- e2:SetTarget(s.eqtg) --the function that checks if the effect can be activated
- e2:SetOperation(s.eqop) --the function that performs the effect
- c:RegisterEffect(e2)
- end
- function s.atkval(e,c) --the function that calculates the ATK gain
- return c:GetEquipCount()*300
- end
- function s.filter(c) --the filter for valid targets to equip
- return c:IsFaceup() and c:IsControler(1-e:GetHandlerPlayer())
- end
- function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) --the target function for the equip effect
- if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc) end --if there is a previous target, check if it is valid
- if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 --check if there is a free Spell/Trap Zone to equip to
- and Duel.IsExistingTarget(s.filter,tp,0,LOCATION_MZONE,1,nil) end --check if there is a valid target to equip from the opponent's field
- Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) --prompt the player to select a target
- local g=Duel.SelectTarget(tp,s.filter,tp,0,LOCATION_MZONE,1,1,nil) --select one target from the opponent's field
- Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0) --declare that this effect will equip a card
- end
- function s.eqlimit(e,c) --the function that limits what can be equipped by this effect (only Link itself in this case)
- return e:GetOwner()==c
- end
- function s.eqop(e,tp,eg,ep,ev,re,r,rp) --the operation function for the equip effect
- local c=e:GetHandler() --get Link itself as a local variable c
- if not c:IsRelateToEffect(e) or c:IsFacedown() then return end --if Link is not on the field or face-down when resolving the effect, do nothing
- local tc=Duel.GetFirstTarget() --get the first (and only) target as a local variable tc
- if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsControler(1-tp) then --if the target still exists and meets all conditions
- if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end --if there is no free Spell/Trap Zone to equip to, do nothing
- Duel.Equip(tp,tc,c,false,true,true,true,e:GetHandler()) --equip tc to Link without triggering other effects
- local atk=tc:GetTextAttack()/2 --get half of tc's original ATK as a local variable atk
- if atk<0 then atk=0 end --if atk is negative (for some reason), set it to zero
- local e3=Effect.CreateEffect(c)--create an Equip Effect that gives Link extra ATK equal to half of tc's original ATK
- e3:SetType(EFFECT_TYPE_EQUIP)--set its type as Equip Effect
- e3:SetCode(EFFECT_UPDATE_ATTACK)--set its code as updating ATK
- e3:SetValue(atk)--set its value as atk
- e3:SetReset(RESET_EVENT+RESETS_STANDARD)--reset it when it leaves the field or changes control
- tc:RegisterEffect(e3)--register it on tc
- end
- Duel.EquipComplete() --complete equipping process
- end
Advertisement
Add Comment
Please, Sign In to add comment