Skip to content

Commit

Permalink
Fix "Cyber Larva (Manga)"
Browse files Browse the repository at this point in the history
Was not reducing effect damage to 0/script polish and modernization.
  • Loading branch information
TheRazgriz authored Jan 21, 2025
1 parent c3f6503 commit 9ef4f1e
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions unofficial/c511005701.lua
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
--Cyber Larva (Anime)
--サイバー・ラーバァ (Manga)
--Cyber Larva (Manga)
--Scripted by GameMaster()
--cleaned up by MLD
local s,id=GetID()
function s.initial_effect(c)
--avoid battle damage
--Controller takes no battle damage for the rest of this turn
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_DESTROYED)
e1:SetCondition(s.con)
e1:SetOperation(s.op1)
e1:SetCondition(function(e) return e:GetHandler():IsReason(REASON_BATTLE|REASON_EFFECT) end)
e1:SetOperation(s.nodamop)
c:RegisterEffect(e1)
--special summon
--Special Summon 1 card with the same name as this card from your Deck
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_DESTROYED)
e2:SetCondition(s.con)
e2:SetTarget(s.target)
e2:SetOperation(s.operation)
e2:SetCondition(function(e) return e:GetHandler():IsReason(REASON_BATTLE|REASON_EFFECT) end)
e2:SetTarget(s.sptg)
e2:SetOperation(s.spop)
c:RegisterEffect(e2)
end
s.listed_names={35050257}
function s.con(e,c)
return e:GetHandler():IsReason(REASON_BATTLE+REASON_EFFECT)
end
function s.op1(e,tp,eg,ep,ev,re,r,rp)
function s.nodamop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetValue(1)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetValue(s.damval)
e1:SetReset(RESET_PHASE|PHASE_END,1)
Duel.RegisterEffect(e1,tp)
end
function s.filter(c,e,tp)
return c:IsCode(35050257) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
function s.damval(e,re,dam,r,rp,rc)
if r&(REASON_BATTLE|REASON_EFFECT)~=0 then
return 0
else return dam end
end
function s.spfilter(c,e,tp,cid)
return c:IsCode(cid) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp,e:GetHandler():GetCode()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
function s.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local tc=Duel.GetFirstMatchingCard(s.filter,tp,LOCATION_DECK,0,nil,e,tp)
local tc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp,e:GetHandler():GetCode()):GetFirst()
if tc then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
Expand Down

0 comments on commit 9ef4f1e

Please sign in to comment.