Commit 2645a02c authored by Fluorohydride's avatar Fluorohydride

Merge pull request #353 from VanillaSalt/patch42

fix
parents bd073551 53692950
......@@ -1500,6 +1500,7 @@ int32 card::is_can_be_summoned(uint8 playerid, uint8 ignore_count, effect* peffe
}
int32 card::get_summon_tribute_count() {
int32 min = 0, max = 0;
int32 minul = 0, maxul = 0;
int32 level = get_level();
if(level < 5)
return 0;
......@@ -1510,12 +1511,19 @@ int32 card::get_summon_tribute_count() {
effect_set eset;
filter_effect(EFFECT_DECREASE_TRIBUTE, &eset);
for(int32 i = 0; i < eset.count; ++i) {
if((eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) == 0)
continue;
int32 dec = eset[i]->get_value(this);
min -= dec & 0xffff;
max -= dec >> 16;
if(!(eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT)) {
if(minul < (dec & 0xffff))
minul = dec & 0xffff;
if(maxul < (dec >> 16))
maxul = dec >> 16;
} else if((eset[i]->reset_count & 0xf00) > 0) {
min -= dec & 0xffff;
max -= dec >> 16;
}
}
min -= minul;
max -= maxul;
if(min < 0) min = 0;
if(max < min) max = min;
return min + (max << 16);
......
......@@ -1197,12 +1197,15 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
if(min > 0) {
effect_set eset;
target->filter_effect(EFFECT_DECREASE_TRIBUTE, &eset);
int32 minul = 0;
for(int32 i = 0; i < eset.count; ++i) {
if(!(eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT)) {
int32 dec = eset[i]->get_value(target);
min -= dec & 0xffff;
if(minul < (dec & 0xffff))
minul = dec & 0xffff;
}
}
min -= minul;
for(int32 i = 0; i < eset.count && min > 0; ++i) {
if((eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) > 0 && eset[i]->target) {
int32 dec = eset[i]->get_value(target);
......
......@@ -36,7 +36,7 @@ function c14745409.initial_effect(c)
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(14745409,0))
e5:SetCategory(CATEGORY_EQUIP)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CHAIN_UNIQUE)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_CHAIN_UNIQUE)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetCondition(c14745409.eqcon)
......@@ -47,6 +47,7 @@ function c14745409.initial_effect(c)
end
function c14745409.eqlimit(e,c)
return c:IsRace(RACE_WARRIOR)
and not Duel.IsExistingMatchingCard(c14745409.cfilter,e:GetHandlerPlayer(),LOCATION_ONFIELD,0,1,e:GetHandler())
end
function c14745409.cfilter(c)
return c:IsFaceup() and c:IsCode(14745409)
......@@ -105,7 +106,8 @@ function c14745409.eqfilter2(c)
end
function c14745409.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c14745409.eqfilter2(chkc) end
if chk==0 then return Duel.IsExistingTarget(c14745409.eqfilter2,tp,LOCATION_MZONE,0,1,nil) end
if chk==0 then return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c14745409.eqfilter2,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c14745409.eqfilter2,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
......
......@@ -17,12 +17,37 @@ function c15894048.initial_effect(c)
e3:SetCondition(c15894048.facon)
e3:SetValue(1)
c:RegisterEffect(e3)
if not c15894048.global_check then
c15894048.global_check=true
c15894048[0]=0
c15894048[1]=0
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_ATTACK_ANNOUNCE)
ge1:SetOperation(c15894048.checkop)
Duel.RegisterEffect(ge1,0)
local ge2=Effect.CreateEffect(c)
ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge2:SetCode(EVENT_PHASE_START+PHASE_BATTLE)
ge2:SetOperation(c15894048.clear)
Duel.RegisterEffect(ge2,0)
end
end
function c15894048.filter(c)
return c:GetAttackAnnouncedCount()>0
function c15894048.checkop(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
if c15894048[tc:GetControler()]==0 then
c15894048[tc:GetControler()]=1
tc:RegisterFlagEffect(15894048,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_BATTLE,0,1)
elseif tc:GetFlagEffect(15894048)==0 then
c15894048[tc:GetControler()]=2
end
end
function c15894048.clear(e,tp,eg,ep,ev,re,r,rp)
c15894048[0]=0
c15894048[1]=0
end
function c15894048.facon(e)
local tp=e:GetHandlerPlayer()
return Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>0
and not Duel.IsExistingMatchingCard(c15894048.filter,tp,LOCATION_MZONE,0,1,e:GetHandler())
and (c15894048[tp]~=2 or e:GetHandler():GetFlagEffect(15894048)~=0)
end
......@@ -15,6 +15,7 @@ function c38589847.initial_effect(c)
e2:SetCondition(c38589847.otcon)
e2:SetTarget(c38589847.ottg)
e2:SetOperation(c38589847.otop)
e2:SetValue(SUMMON_TYPE_ADVANCE)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EFFECT_SET_PROC)
......
......@@ -25,8 +25,8 @@ function c39537362.target1(e,tp,eg,ep,ev,re,r,rp,chk)
if Duel.CheckEvent(EVENT_ATTACK_ANNOUNCE) and tp~=Duel.GetTurnPlayer()
and Duel.SelectYesNo(tp,aux.Stringid(39537362,1)) then
e:SetLabel(1)
Duel.SetTargetCard(Duel.GetAttacker())
else e:SetLabel(0) end
Duel.SetTargetCard(Duel.GetAttacker())
end
function c39537362.condition(e,tp,eg,ep,ev,re,r,rp)
return tp~=Duel.GetTurnPlayer()
......
......@@ -13,8 +13,9 @@ function c52158283.initial_effect(c)
c:RegisterEffect(e1)
end
function c52158283.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
if chk==0 then return Duel.GetFlagEffect(tp,52158283)==0 and e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
Duel.RegisterFlagEffect(tp,52158283,RESET_PHASE+PHASE_END,0,1)
end
function c52158283.filter(c)
return c:IsAttackPos() and c:IsLevelAbove(3)
......
......@@ -49,7 +49,7 @@ function c52404456.shtg(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c52404456.shop(e,tp,eg,ep,ev,re,r,rp)
if not Duel.IsExistingMatchingCard(c52404456.cfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,e:GetHandler()) then return end
if not Duel.IsExistingMatchingCard(c52404456.cfilter,tp,LOCATION_MZONE,0,1,e:GetHandler()) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c52404456.filter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
......
......@@ -40,7 +40,7 @@ function c52512994.tdtg(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end
function c52512994.rfilter(c)
return c:IsLocation(LOCATION_DECK) and c:IsRace(RACE_ZOMBIE) and bit.band(c:GetPreviousPosition(),POS_FACEUP)~=0
return c:IsLocation(LOCATION_DECK+LOCATION_EXTRA) and c:IsRace(RACE_ZOMBIE) and bit.band(c:GetPreviousPosition(),POS_FACEUP)~=0
end
function c52512994.tdop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsAbleToDeck,tp,LOCATION_MZONE,LOCATION_MZONE,e:GetHandler())
......
......@@ -4,7 +4,6 @@ function c62476197.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(62476197,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DAMAGE)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetRange(LOCATION_HAND)
e1:SetCode(EVENT_CHAINING)
......
......@@ -32,7 +32,7 @@ function c83438826.initial_effect(c)
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(83438826,1))
e5:SetCategory(CATEGORY_EQUIP)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CHAIN_UNIQUE)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_CHAIN_UNIQUE)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetCondition(c83438826.eqcon)
......@@ -43,6 +43,7 @@ function c83438826.initial_effect(c)
end
function c83438826.eqlimit(e,c)
return c:IsRace(RACE_WARRIOR)
and not Duel.IsExistingMatchingCard(c83438826.cfilter,e:GetHandlerPlayer(),LOCATION_ONFIELD,0,1,e:GetHandler())
end
function c83438826.cfilter(c)
return c:IsFaceup() and c:IsCode(83438826)
......@@ -113,7 +114,8 @@ function c83438826.eqfilter2(c)
end
function c83438826.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c83438826.eqfilter2(chkc) end
if chk==0 then return Duel.IsExistingTarget(c83438826.eqfilter2,tp,LOCATION_MZONE,0,1,nil) end
if chk==0 then return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c83438826.eqfilter2,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c83438826.eqfilter2,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
......
......@@ -54,11 +54,11 @@ function c87046457.desop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(c,REASON_EFFECT)
end
end
function c87046457.filter(c,e)
return c:IsFaceup() and c:IsRace(RACE_PLANT) and c:IsPreviousLocation(LOCATION_GRAVE) and (not e or c:IsRelateToEffect(e))
function c87046457.filter(c,e,tp)
return c:IsFaceup() and c:IsRace(RACE_PLANT) and c:IsControler(tp) and c:IsPreviousLocation(LOCATION_GRAVE) and (not e or c:IsRelateToEffect(e))
end
function c87046457.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return eg:IsExists(c87046457.filter,1,nil) end
if chk==0 then return eg:IsExists(c87046457.filter,1,nil,nil,tp) end
Duel.SetTargetCard(eg)
end
function c87046457.operation(e,tp,eg,ep,ev,re,r,rp)
......@@ -69,7 +69,7 @@ function c87046457.operation(e,tp,eg,ep,ev,re,r,rp)
c:RegisterFlagEffect(87046457,RESET_EVENT+0x1ff0000,0,1)
atkg:Clear()
end
local g=eg:Filter(c87046457.filter,nil,e)
local g=eg:Filter(c87046457.filter,nil,e,tp)
local tc=g:GetFirst()
while tc do
tc:RegisterFlagEffect(87046457,RESET_EVENT+0x1fe0000,0,1)
......
......@@ -35,6 +35,7 @@ function c92001300.initial_effect(c)
e4:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x7))
e4:SetCondition(c92001300.sumcon)
e4:SetOperation(c92001300.sumop)
e4:SetValue(SUMMON_TYPE_ADVANCE)
c:RegisterEffect(e4)
local e5=e4:Clone()
e5:SetCode(EFFECT_SET_PROC)
......
......@@ -5,6 +5,7 @@ function c96704018.initial_effect(c)
e1:SetDescription(aux.Stringid(96704018,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c96704018.target)
e1:SetOperation(c96704018.operation)
c:RegisterEffect(e1)
local e2=e1:Clone()
......@@ -18,6 +19,9 @@ end
function c96704018.filter(c)
return c:IsFaceup() and c:IsLevelAbove(5)
end
function c96704018.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c96704018.filter,tp,LOCATION_MZONE,0,1,nil) end
end
function c96704018.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c96704018.filter,tp,LOCATION_MZONE,0,nil)
local tc=g:GetFirst()
......
......@@ -47,6 +47,21 @@ function c97403510.initial_effect(c)
e5:SetCondition(c97403510.atkcon)
e5:SetOperation(c97403510.atkop)
c:RegisterEffect(e5)
if not c97403510.global_check then
c97403510.global_check=true
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_SSET)
ge1:SetOperation(c97403510.checkop)
Duel.RegisterEffect(ge1,0)
end
end
function c97403510.checkop(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
while tc do
tc:RegisterFlagEffect(97403510,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
tc=eg:GetNext()
end
end
function c97403510.rmcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp
......@@ -56,7 +71,7 @@ function c97403510.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function c97403510.filter(c,turn)
return c:GetTurnID()==turn and c:IsAbleToRemove()
return (c:IsLocation(LOCATION_MZONE) or c:GetFlagEffect(97403510)~=0) and c:GetTurnID()==turn and c:IsAbleToRemove()
end
function c97403510.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c97403510.filter,tp,0,LOCATION_ONFIELD,1,nil,Duel.GetTurnCount()) end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment