Skip to content

Commit 0b58a38

Browse files
authored
Update "Hero's Backup"
-Should be able to activate during either player's battle phase -Minor script clean-up
1 parent 7fc005b commit 0b58a38

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

unofficial/c511002398.lua

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,41 @@ function s.initial_effect(c)
66
local e1=Effect.CreateEffect(c)
77
e1:SetCategory(CATEGORY_REMOVE)
88
e1:SetType(EFFECT_TYPE_ACTIVATE)
9-
e1:SetCode(EVENT_FREE_CHAIN)
109
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
10+
e1:SetCode(EVENT_FREE_CHAIN)
1111
e1:SetHintTiming(TIMING_DAMAGE_STEP)
12-
e1:SetCondition(s.condition)
12+
e1:SetCondition(function() return Duel.IsBattlePhase() and aux.StatChangeDamageStepCondition() end)
1313
e1:SetTarget(s.target)
1414
e1:SetOperation(s.activate)
1515
c:RegisterEffect(e1)
1616
end
17-
s.listed_series={0x3008}
18-
function s.condition(e,tp,eg,ep,ev,re,r,rp)
19-
local ph=Duel.GetCurrentPhase()
20-
return Duel.IsTurnPlayer(tp) and ph>=0x08 and ph<=0x20
21-
and (ph~=PHASE_DAMAGE or not Duel.IsDamageCalculated())
17+
s.listed_series={SET_ELEMENTAL_HERO}
18+
function s.targetfilter(c,tp)
19+
return c:IsFaceup() and Duel.IsExistingMatchingCard(s.oppmonfilter,tp,0,LOCATION_MZONE,1,nil,c:GetAttack())
2220
end
23-
function s.filter(c,tp)
24-
return c:IsFaceup() and Duel.IsExistingMatchingCard(s.filter2,tp,0,LOCATION_MZONE,1,nil,c:GetAttack())
25-
end
26-
function s.filter2(c,atk)
21+
function s.oppmonfilter(c,atk)
2722
return c:IsFaceup() and c:IsAttackAbove(atk+1000)
2823
end
29-
function s.rfilter(c)
24+
function s.rmvfilter(c)
3025
return c:IsSetCard(SET_ELEMENTAL_HERO) and c:IsAbleToRemove()
3126
end
3227
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
33-
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc,tp) end
34-
if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,0,1,nil,tp)
35-
and Duel.IsExistingMatchingCard(s.rfilter,tp,LOCATION_GRAVE,0,1,nil) end
28+
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.targetfilter(chkc,tp) end
29+
if chk==0 then return Duel.IsExistingTarget(s.targetfilter,tp,LOCATION_MZONE,0,1,nil,tp)
30+
and Duel.IsExistingMatchingCard(s.rmvfilter,tp,LOCATION_GRAVE,0,1,nil) end
3631
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
37-
Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,0,1,1,nil,tp)
38-
local g=Duel.GetMatchingGroup(s.rfilter,tp,LOCATION_GRAVE,0,nil)
32+
Duel.SelectTarget(tp,s.targetfilter,tp,LOCATION_MZONE,0,1,1,nil,tp)
33+
local g=Duel.GetMatchingGroup(s.rmvfilter,tp,LOCATION_GRAVE,0,nil)
3934
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
4035
end
4136
function s.activate(e,tp,eg,ep,ev,re,r,rp)
4237
local c=e:GetHandler()
4338
local tc=Duel.GetFirstTarget()
4439
if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then
4540
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
46-
local tg=Duel.SelectMatchingCard(tp,s.rfilter,tp,LOCATION_GRAVE,0,1,1,nil):GetFirst()
47-
if tg and Duel.Remove(tg,POS_FACEUP,REASON_EFFECT)>0 then
48-
local e1=Effect.CreateEffect(e:GetHandler())
49-
e1:SetType(EFFECT_TYPE_SINGLE)
50-
e1:SetCode(EFFECT_UPDATE_ATTACK)
51-
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
52-
e1:SetValue(tg:GetAttack())
53-
tc:RegisterEffect(e1)
41+
local rg=Duel.SelectMatchingCard(tp,s.rmvfilter,tp,LOCATION_GRAVE,0,1,1,nil):GetFirst()
42+
if rg and Duel.Remove(rg,POS_FACEUP,REASON_EFFECT)>0 then
43+
tc:UpdateAttack(rg:GetBaseAttack(),RESET_EVENT|RESETS_STANDARD,c)
5444
end
5545
end
56-
end
46+
end

0 commit comments

Comments
 (0)