Skip to content

Commit 3a34387

Browse files
authored
Update "Wild Heart"
- Self-destruction effect was triggering on battle damage dealt, not on if it attacked directly with its own effect - Fixed condition check for direct attack/added handling for multiple direct attack effects on it/added check for direct attacks with its own effect - General script polish/modernization
1 parent 68c8fc6 commit 3a34387

1 file changed

Lines changed: 67 additions & 44 deletions

File tree

‎unofficial/c511000869.lua‎

Lines changed: 67 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,116 @@
1+
--ワイルド・ハート
12
--Wild Heart
23
local s,id=GetID()
34
function s.initial_effect(c)
4-
--sp summon
5+
--Special Summon this card from your if a monster card is sent from the hand to the GY
56
local e1=Effect.CreateEffect(c)
67
e1:SetDescription(aux.Stringid(id,0))
78
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
89
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
910
e1:SetProperty(EFFECT_FLAG_DELAY)
10-
e1:SetRange(LOCATION_HAND)
1111
e1:SetCode(EVENT_TO_GRAVE)
12-
e1:SetCondition(s.spcon)
13-
e1:SetTarget(s.sptg)
14-
e1:SetOperation(s.spop)
12+
e1:SetRange(LOCATION_HAND)
13+
e1:SetCondition(s.spfromhandcon)
14+
e1:SetTarget(s.spselftg)
15+
e1:SetOperation(s.spfromhandop)
1516
c:RegisterEffect(e1)
16-
--direct atk
17+
--This card can attack directly
1718
local e2=Effect.CreateEffect(c)
1819
e2:SetType(EFFECT_TYPE_SINGLE)
1920
e2:SetCode(EFFECT_DIRECT_ATTACK)
2021
c:RegisterEffect(e2)
21-
--destroy
22-
local e3=Effect.CreateEffect(c)
23-
e3:SetDescription(aux.Stringid(id,1))
24-
e3:SetCategory(CATEGORY_DESTROY)
25-
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
26-
e3:SetCode(EVENT_BATTLE_DAMAGE)
27-
e3:SetCondition(s.descon)
28-
e3:SetTarget(s.destg)
29-
e3:SetOperation(s.desop)
30-
c:RegisterEffect(e3)
31-
--sp summon again
22+
--Register flag if this card attacked directly with its own effect
23+
local e3a=Effect.CreateEffect(c)
24+
e3a:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
25+
e3a:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
26+
e3a:SetCode(EVENT_ATTACK_ANNOUNCE)
27+
e3a:SetCondition(s.regcon)
28+
e3a:SetOperation(s.regop)
29+
c:RegisterEffect(e3a)
30+
--If this card attacked directly with its own effect, destroy it at the end of the Damage Step
31+
local e3b=Effect.CreateEffect(c)
32+
e3b:SetDescription(aux.Stringid(id,1))
33+
e3b:SetCategory(CATEGORY_DESTROY)
34+
e3b:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
35+
e3b:SetCode(EVENT_DAMAGE_STEP_END)
36+
e3b:SetRange(LOCATION_MZONE)
37+
e3b:SetCountLimit(1)
38+
e3b:SetTarget(s.destg)
39+
e3b:SetOperation(s.desop)
40+
c:RegisterEffect(e3b)
41+
--If this card on the field is destroyed by a card effect, except its own, Special Summon it from the GY
3242
local e4=Effect.CreateEffect(c)
3343
e4:SetDescription(aux.Stringid(id,2))
3444
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
3545
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
3646
e4:SetCode(EVENT_DESTROYED)
37-
e4:SetCondition(s.spcon2)
38-
e4:SetTarget(s.sptg)
39-
e4:SetOperation(s.spop2)
47+
e4:SetCondition(s.spfromgycon)
48+
e4:SetTarget(s.spselftg)
49+
e4:SetOperation(s.spfromgyop)
4050
c:RegisterEffect(e4)
4151
end
42-
function s.filter(c)
52+
function s.spfromhandconfilter(c)
4353
return c:IsPreviousLocation(LOCATION_HAND) and c:IsMonster()
4454
end
45-
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
46-
return eg:IsExists(s.filter,1,nil)
55+
function s.spfromhandcon(e,tp,eg,ep,ev,re,r,rp)
56+
return eg:IsExists(s.spfromhandconfilter,1,nil)
4757
end
48-
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
49-
if chk==0 then return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
50-
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
51-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
58+
function s.spselftg(e,tp,eg,ep,ev,re,r,rp,chk)
59+
local c=e:GetHandler()
60+
if chk==0 then return c:IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
61+
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
62+
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
5263
end
53-
function s.spop(e,tp,eg,ep,ev,re,r,rp)
64+
function s.spfromhandop(e,tp,eg,ep,ev,re,r,rp)
5465
local c=e:GetHandler()
5566
if c:IsRelateToEffect(e) then
5667
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
5768
end
5869
end
59-
function s.descon(e,tp,eg,ep,ev,re,r,rp)
60-
return ep~=tp and Duel.GetAttackTarget()==nil
61-
and Duel.GetFieldGroupCount(e:GetHandlerPlayer(),0,LOCATION_MZONE)>0
70+
function s.regcon(e,tp,eg,ep,ev,re,r,rp)
71+
return Duel.GetAttackTarget()==nil and e:GetHandler():IsHasEffect(EFFECT_DIRECT_ATTACK)
72+
and Duel.IsExistingMatchingCard(aux.NOT(Card.IsHasEffect),tp,0,LOCATION_MZONE,1,nil,EFFECT_IGNORE_BATTLE_TARGET)
73+
end
74+
function s.regop(e,tp,eg,ep,ev,re,r,rp)
75+
local c=e:GetHandler()
76+
local effs={c:GetCardEffect(EFFECT_DIRECT_ATTACK)}
77+
local eg=Group.CreateGroup()
78+
for _,eff in ipairs(effs) do
79+
eg:AddCard(eff:GetOwner())
80+
end
81+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EFFECT)
82+
local ec = #eg==1 and eg:GetFirst() or eg:Select(tp,1,1,nil):GetFirst()
83+
if c==ec then
84+
c:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD|RESET_PHASE|PHASE_BATTLE,0,1)
85+
end
6286
end
6387
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk)
64-
if chk==0 then return true end
65-
Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0)
88+
local c=e:GetHandler()
89+
if chk==0 then return c:HasFlagEffect(id) end
90+
Duel.SetOperationInfo(0,CATEGORY_DESTROY,c,1,0,0)
6691
end
6792
function s.desop(e,tp,eg,ep,ev,re,r,rp)
68-
if e:GetHandler():IsRelateToEffect(e) then
69-
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
93+
local c=e:GetHandler()
94+
if c:IsRelateToEffect(e) then
95+
Duel.Destroy(c,REASON_EFFECT)
7096
end
7197
end
72-
function s.spcon2(e,tp,eg,ep,ev,re,r,rp)
98+
function s.spfromgycon(e,tp,eg,ep,ev,re,r,rp)
7399
local c=e:GetHandler()
74-
return not c:IsReason(REASON_BATTLE) and re and re:GetOwner()~=c and c:IsLocation(LOCATION_GRAVE)
100+
return c:IsReason(REASON_EFFECT) and re and re:GetOwner()~=c and c:IsLocation(LOCATION_GRAVE)
75101
end
76-
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
102+
function s.spfromgyop(e,tp,eg,ep,ev,re,r,rp)
77103
local c=e:GetHandler()
78104
if c:IsRelateToEffect(e) then
79105
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
80106
local e1=Effect.CreateEffect(c)
81107
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
108+
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
82109
e1:SetCode(EVENT_PHASE+PHASE_END)
83110
e1:SetRange(LOCATION_MZONE)
84111
e1:SetCountLimit(1)
85-
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
86-
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
87-
e1:SetOperation(s.rmop)
112+
e1:SetReset(RESETS_STANDARD_PHASE_END)
113+
e1:SetOperation(function(e) Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_EFFECT) end)
88114
c:RegisterEffect(e1)
89115
end
90116
end
91-
function s.rmop(e,tp,eg,ep,ev,re,r,rp)
92-
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_EFFECT)
93-
end

0 commit comments

Comments
 (0)