Skip to content

Commit 00a828b

Browse files
authored
Update "Darkness Half"
-Tokens should be Level 2 -Card should equip itself to the monster -Added handling for equippable Continuous Traps
1 parent 43d6d6f commit 00a828b

1 file changed

Lines changed: 46 additions & 51 deletions

File tree

unofficial/c511001528.lua

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,69 @@
1+
--ダークネス・ハーフ
12
--Darkness Half
23
local s,id=GetID()
4+
local TOKEN_DARK=id+1
35
function s.initial_effect(c)
4-
aux.AddPersistentProcedure(c,0,s.filter,CATEGORY_ATKCHANGE+CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN,EFFECT_FLAG_DAMAGE_STEP,TIMING_DAMAGE_STEP,TIMING_DAMAGE_STEP,s.condition,nil,s.target,s.operation)
5-
--atk
6+
--Activate
67
local e1=Effect.CreateEffect(c)
7-
e1:SetType(EFFECT_TYPE_FIELD)
8-
e1:SetCode(EFFECT_SET_BASE_ATTACK)
9-
e1:SetRange(LOCATION_SZONE)
10-
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
11-
e1:SetTarget(aux.PersistentTargetFilter)
12-
e1:SetValue(s.atkval)
8+
e1:SetDescription(aux.Stringid(id,0))
9+
e1:SetCategory(CATEGORY_EQUIP)
10+
e1:SetType(EFFECT_TYPE_ACTIVATE)
11+
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
12+
e1:SetCode(EVENT_FREE_CHAIN)
13+
e1:SetHintTiming(TIMING_DAMAGE_STEP|TIMING_BATTLE_PHASE)
14+
e1:SetCondition(aux.StatChangeDamageStepCondition)
15+
e1:SetCost(aux.RemainFieldCost)
16+
e1:SetTarget(s.target)
17+
e1:SetOperation(s.operation)
1318
c:RegisterEffect(e1)
14-
--Destroy
15-
local e2=Effect.CreateEffect(c)
16-
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
17-
e2:SetRange(LOCATION_SZONE)
18-
e2:SetCode(EVENT_LEAVE_FIELD)
19-
e2:SetCondition(s.descon)
20-
e2:SetOperation(s.desop)
21-
c:RegisterEffect(e2)
22-
--Destroy
23-
local e3=Effect.CreateEffect(c)
24-
e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
25-
e3:SetCode(EVENT_LEAVE_FIELD)
26-
e3:SetOperation(s.desop2)
27-
c:RegisterEffect(e3)
2819
end
29-
function s.atkval(e,c)
30-
return c:GetBaseAttack()/2
31-
end
32-
function s.condition(e,tp,eg,ep,ev,re,r,rp)
33-
return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated()
34-
end
35-
function s.cfilter(c,atk)
20+
s.listed_names={TOKEN_DARK}
21+
function s.atkfilter(c,atk)
3622
return c:IsFaceup() and c:GetAttack()>atk
3723
end
38-
function s.filter(c,e,tp)
39-
return c:IsFaceup() and not Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_MZONE,0,1,nil,c:GetAttack())
24+
function s.eqfilter(c,tp)
25+
return c:IsFaceup() and not Duel.IsExistingMatchingCard(s.atkfilter,tp,LOCATION_MZONE,0,1,nil,c:GetAttack())
4026
end
41-
function s.target(e,tp,eg,ep,ev,re,r,rp,tc,chk)
42-
if chk==0 then return Duel.GetLocationCount(1-tp,LOCATION_MZONE)>1 and not Duel.IsPlayerAffectedByEffect(1-tp,CARD_BLUEEYES_SPIRIT)
43-
and Duel.IsPlayerCanSpecialSummonMonster(tp,id+1,0,TYPES_TOKEN,1000,1000,3,RACE_FIEND,ATTRIBUTE_DARK,POS_FACEUP_ATTACK,1-tp) end
27+
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
28+
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.eqfilter(chkc,tp) end
29+
if chk==0 then return Duel.IsExistingTarget(s.eqfilter,tp,LOCATION_MZONE,0,1,nil,tp) and not Duel.IsPlayerAffectedByEffect(1-tp,CARD_BLUEEYES_SPIRIT) end
30+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
31+
local g=Duel.SelectTarget(tp,s.eqfilter,tp,LOCATION_MZONE,0,1,1,nil,tp)
32+
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
4433
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,2,0,0)
4534
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,0)
4635
end
4736
function s.operation(e,tp,eg,ep,ev,re,r,rp)
4837
local c=e:GetHandler()
38+
if not c:IsLocation(LOCATION_SZONE) or not c:IsRelateToEffect(e) or c:IsStatus(STATUS_LEAVE_CONFIRMED) then return end
4939
local tc=Duel.GetFirstTarget()
40+
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
41+
Duel.Equip(tp,c,tc)
42+
--Equipped monster's original ATK is halved
43+
local e1=Effect.CreateEffect(c)
44+
e1:SetType(EFFECT_TYPE_EQUIP)
45+
e1:SetCode(EFFECT_SET_BASE_ATTACK)
46+
e1:SetValue(tc:GetBaseAttack()/2)
47+
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
48+
c:RegisterEffect(e1)
49+
--Equip limit
50+
local e2=Effect.CreateEffect(c)
51+
e2:SetType(EFFECT_TYPE_SINGLE)
52+
e2:SetCode(EFFECT_EQUIP_LIMIT)
53+
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
54+
e2:SetValue(1)
55+
e2:SetReset(RESET_EVENT|RESETS_STANDARD)
56+
c:RegisterEffect(e2)
57+
else
58+
c:CancelToGrave(false)
59+
end
5060
if not tc or Duel.GetLocationCount(1-tp,LOCATION_MZONE)<=1 or Duel.IsPlayerAffectedByEffect(1-tp,CARD_BLUEEYES_SPIRIT)
51-
or not Duel.IsPlayerCanSpecialSummonMonster(tp,id+1,0,TYPES_TOKEN,1000,1000,3,RACE_FIEND,ATTRIBUTE_DARK,POS_FACEUP_ATTACK,1-tp) then return end
61+
or not Duel.IsPlayerCanSpecialSummonMonster(tp,TOKEN_DARK,0,TYPES_TOKEN,1000,1000,2,RACE_FIEND,ATTRIBUTE_DARK,POS_FACEUP_ATTACK,1-tp) then return end
5262
if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
5363
for i=1,2 do
54-
local token=Duel.CreateToken(tp,id+1)
64+
local token=Duel.CreateToken(tp,TOKEN_DARK)
5565
Duel.SpecialSummonStep(token,0,tp,1-tp,false,false,POS_FACEUP_ATTACK)
5666
end
5767
Duel.SpecialSummonComplete()
5868
end
5969
end
60-
function s.descon(e,tp,eg,ep,ev,re,r,rp)
61-
local c=e:GetHandler()
62-
if c:IsStatus(STATUS_DESTROY_CONFIRMED) then return false end
63-
local tc=c:GetFirstCardTarget()
64-
return tc and eg:IsContains(tc)
65-
end
66-
function s.desop(e,tp,eg,ep,ev,re,r,rp)
67-
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
68-
end
69-
function s.desop2(e,tp,eg,ep,ev,re,r,rp)
70-
local tc=e:GetHandler():GetFirstCardTarget()
71-
if tc and tc:IsLocation(LOCATION_MZONE) then
72-
Duel.Destroy(tc,REASON_EFFECT)
73-
end
74-
end

0 commit comments

Comments
 (0)