Skip to content

Commit 9ef4f1e

Browse files
authored
Fix "Cyber Larva (Manga)"
Was not reducing effect damage to 0/script polish and modernization.
1 parent c3f6503 commit 9ef4f1e

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

unofficial/c511005701.lua

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
1-
--Cyber Larva (Anime)
1+
--サイバー・ラーバァ (Manga)
2+
--Cyber Larva (Manga)
23
--Scripted by GameMaster()
34
--cleaned up by MLD
45
local s,id=GetID()
56
function s.initial_effect(c)
6-
--avoid battle damage
7+
--Controller takes no battle damage for the rest of this turn
78
local e1=Effect.CreateEffect(c)
89
e1:SetDescription(aux.Stringid(id,0))
910
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
1011
e1:SetCode(EVENT_DESTROYED)
11-
e1:SetCondition(s.con)
12-
e1:SetOperation(s.op1)
12+
e1:SetCondition(function(e) return e:GetHandler():IsReason(REASON_BATTLE|REASON_EFFECT) end)
13+
e1:SetOperation(s.nodamop)
1314
c:RegisterEffect(e1)
14-
--special summon
15+
--Special Summon 1 card with the same name as this card from your Deck
1516
local e2=Effect.CreateEffect(c)
1617
e2:SetDescription(aux.Stringid(id,1))
1718
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
1819
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
1920
e2:SetCode(EVENT_DESTROYED)
20-
e2:SetCondition(s.con)
21-
e2:SetTarget(s.target)
22-
e2:SetOperation(s.operation)
21+
e2:SetCondition(function(e) return e:GetHandler():IsReason(REASON_BATTLE|REASON_EFFECT) end)
22+
e2:SetTarget(s.sptg)
23+
e2:SetOperation(s.spop)
2324
c:RegisterEffect(e2)
2425
end
25-
s.listed_names={35050257}
26-
function s.con(e,c)
27-
return e:GetHandler():IsReason(REASON_BATTLE+REASON_EFFECT)
28-
end
29-
function s.op1(e,tp,eg,ep,ev,re,r,rp)
26+
function s.nodamop(e,tp,eg,ep,ev,re,r,rp)
3027
local e1=Effect.CreateEffect(e:GetHandler())
3128
e1:SetType(EFFECT_TYPE_FIELD)
32-
e1:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
29+
e1:SetCode(EFFECT_CHANGE_DAMAGE)
3330
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
3431
e1:SetTargetRange(1,0)
35-
e1:SetValue(1)
36-
e1:SetReset(RESET_PHASE+PHASE_END)
32+
e1:SetValue(s.damval)
33+
e1:SetReset(RESET_PHASE|PHASE_END,1)
3734
Duel.RegisterEffect(e1,tp)
3835
end
39-
function s.filter(c,e,tp)
40-
return c:IsCode(35050257) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
36+
function s.damval(e,re,dam,r,rp,rc)
37+
if r&(REASON_BATTLE|REASON_EFFECT)~=0 then
38+
return 0
39+
else return dam end
40+
end
41+
function s.spfilter(c,e,tp,cid)
42+
return c:IsCode(cid) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
4143
end
42-
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
44+
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
4345
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
44-
and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
46+
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp,e:GetHandler():GetCode()) end
4547
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
4648
end
47-
function s.operation(e,tp,eg,ep,ev,re,r,rp)
49+
function s.spop(e,tp,eg,ep,ev,re,r,rp)
4850
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
49-
local tc=Duel.GetFirstMatchingCard(s.filter,tp,LOCATION_DECK,0,nil,e,tp)
51+
local tc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp,e:GetHandler():GetCode()):GetFirst()
5052
if tc then
5153
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
5254
end

0 commit comments

Comments
 (0)