Commit 042d26ef authored by Fluorohydride's avatar Fluorohydride

Merge pull request #484 from VanillaSalt/patch61

fix
parents 5020be26 7bc642dc
......@@ -52,7 +52,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
client_base = 0;
return false;
}
connect_state = 1;
connect_state = 0x1;
rnd.reset(time(0));
if(!create_game) {
timeval timeout = {5, 0};
......@@ -63,7 +63,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
return true;
}
void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
if(connect_state == 2)
if(connect_state == 0x7)
return;
if(!is_closing) {
mainGame->btnCreateHost->setEnabled(true);
......@@ -76,7 +76,7 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
event_base_loopbreak(client_base);
}
void DuelClient::StopClient(bool is_exiting) {
if(connect_state != 2)
if(connect_state != 0x7)
return;
is_closing = is_exiting;
if(!is_closing) {
......@@ -129,18 +129,18 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
SendPacketToServer(CTOS_JOIN_GAME, csjg);
}
bufferevent_enable(bev, EV_READ);
connect_state = 2;
connect_state |= 0x2;
} else if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
bufferevent_disable(bev, EV_READ);
if(!is_closing) {
if(connect_state == 1) {
if(connect_state == 0x1) {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
mainGame->gMutex.Lock();
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock();
} else if(connect_state == 2) {
} else if(connect_state == 0x7) {
if(!mainGame->dInfo.isStarted && !mainGame->is_building) {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
......@@ -367,6 +367,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock();
connect_state |= 0x4;
break;
}
case STOC_TYPE_CHANGE: {
......
......@@ -1455,7 +1455,7 @@ int32 scriptlib::duel_disable_attack(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
card* attacker = pduel->game_field->core.attacker;
if(!attacker
|| (attacker->fieldid_r != pduel->game_field->core.pre_field[0] && attacker->fieldid_r != pduel->game_field->core.pre_field[1])
|| (pduel->game_field->infos.phase == PHASE_DAMAGE && attacker->fieldid_r != pduel->game_field->core.pre_field[0] && attacker->fieldid_r != pduel->game_field->core.pre_field[1])
|| (attacker->current.position & POS_FACEDOWN)
|| attacker->is_affected_by_effect(EFFECT_ATTACK_DISABLED)
|| !attacker->is_affect_by_effect(pduel->game_field->core.reason_effect))
......
......@@ -26,5 +26,5 @@ function c11760174.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.RegisterEffect(e1,tp)
end
function c11760174.aclimit(e,re,tp)
return re:IsHasType(EFFECT_TYPE_ACTIVATE)
return re:IsActiveType(TYPE_SPELL+TYPE_TRAP)
end
......@@ -31,7 +31,7 @@ function c12117532.initial_effect(c)
c:RegisterEffect(e3)
end
function c12117532.filter(c)
return c:IsFaceup() and c:IsType(TYPE_EFFECT)
return c:IsFaceup()
end
function c12117532.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c12117532.filter(chkc) end
......@@ -54,7 +54,7 @@ function c12117532.descon(e,tp,eg,ep,ev,re,r,rp)
return tc and eg:IsContains(tc) and tc:IsReason(REASON_DESTROY)
end
function c12117532.desop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(), REASON_EFFECT)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
function c12117532.atkcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp and e:GetHandler():GetFirstCardTarget()~=nil
......@@ -69,7 +69,7 @@ function c12117532.atkop(e,tp,eg,ep,ev,re,r,rp)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_OWNER_RELATE)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-300)
e1:SetValue(-500)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetCondition(c12117532.rcon)
tc:RegisterEffect(e1,true)
......
......@@ -23,7 +23,7 @@ end
function c14462257.condition(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_ONFIELD)
and c:IsPreviousPosition(POS_FACEUP)
and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler()==tp
and Duel.IsExistingMatchingCard(Card.IsRace,tp,LOCATION_GRAVE,0,3,nil,RACE_SPELLCASTER)
end
function c14462257.filter(c)
......
......@@ -19,6 +19,6 @@ function c19012345.operation(e,tp,eg,ep,ev,re,r,rp)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END)
e1:SetReset(RESET_EVENT+0x1ff0000)
c:RegisterEffect(e1)
end
......@@ -21,7 +21,7 @@ function c21977828.initial_effect(c)
e3:SetDescription(aux.Stringid(21977828,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY+EFFECT_FLAG_CHAIN_UNIQUE)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCondition(c21977828.spcon)
e3:SetTarget(c21977828.sptg)
......
......@@ -23,7 +23,7 @@ function c23118924.discon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
and Duel.IsExistingMatchingCard(c23118924.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_EARTH)
and Duel.IsExistingMatchingCard(c23118924.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_EARTH)
end
function c23118924.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......@@ -43,7 +43,7 @@ function c23118924.atcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsChainAttackable()
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c23118924.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_WIND)
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c23118924.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WIND)
end
function c23118924.atop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChainAttack()
......
......@@ -22,13 +22,13 @@ function c30314994.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att)
end
function c30314994.atkcon(e)
return Duel.IsExistingMatchingCard(c30314994.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_FIRE)
return Duel.IsExistingMatchingCard(c30314994.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_FIRE)
end
function c30314994.atcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsChainAttackable()
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c30314994.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_WIND)
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c30314994.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WIND)
end
function c30314994.atop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChainAttack()
......
......@@ -15,7 +15,7 @@ function c36562627.initial_effect(c)
c:RegisterEffect(e2)
end
function c36562627.coincon(e,tp,eg,ep,ev,re,r,rp)
return rp==tp and Duel.GetFlagEffect(tp,36562627)==0
return ep==tp and Duel.GetFlagEffect(tp,36562627)==0
end
function c36562627.coinop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFlagEffect(tp,36562627)~=0 then return end
......
......@@ -11,6 +11,7 @@ function c55888045.initial_effect(c)
e1:SetCode(EVENT_CHAINING)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCondition(c55888045.negcon)
e1:SetOperation(c55888045.negop)
c:RegisterEffect(e1)
......
......@@ -31,5 +31,5 @@ function c60682203.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.RegisterEffect(e2,tp)
end
function c60682203.aclimit(e,re,tp)
return re:GetHandler():IsType(TYPE_SPELL+TYPE_TRAP)
return re:IsActiveType(TYPE_SPELL+TYPE_TRAP)
end
......@@ -21,13 +21,13 @@ function c65260293.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att)
end
function c65260293.ctlcon(e)
return Duel.IsExistingMatchingCard(c65260293.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_WATER)
return Duel.IsExistingMatchingCard(c65260293.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WATER)
end
function c65260293.atcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsChainAttackable()
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c65260293.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_WIND)
and not c:IsDisabled() and Duel.IsExistingMatchingCard(c65260293.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WIND)
end
function c65260293.atop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChainAttack()
......
......@@ -20,13 +20,13 @@ function c66712593.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att)
end
function c66712593.ctlcon(e)
return Duel.IsExistingMatchingCard(c66712593.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_WATER)
return Duel.IsExistingMatchingCard(c66712593.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WATER)
end
function c66712593.discon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
and Duel.IsExistingMatchingCard(c66712593.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_EARTH)
and Duel.IsExistingMatchingCard(c66712593.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_EARTH)
end
function c66712593.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -19,15 +19,17 @@ function c6836211.filter(c,e,tp)
return c:IsSetCard(0x5a) and not c:IsCode(6836211) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c6836211.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c6836211.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c6836211.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c6836211.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<=0 then return end
if ft>2 then ft=2 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c6836211.filter,tp,LOCATION_DECK,0,1,2,nil,e,tp)
local g=Duel.SelectMatchingCard(tp,c6836211.filter,tp,LOCATION_DECK,0,1,ft,nil,e,tp)
if g:GetCount()~=0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
......@@ -21,8 +21,8 @@ function c75252099.filter(c,e,tp)
end
function c75252099.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>1
and Duel.IsExistingMatchingCard(c75252099.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
and Duel.IsExistingMatchingCard(c75252099.filter,tp,LOCATION_DECK,0,2,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_DECK)
end
function c75252099.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end
......
......@@ -51,6 +51,6 @@ end
function c7634581.spop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.SpecialSummon(e:GetHandler(),0,tp,tp,true,false,POS_FACEUP)
e:GetHandler():CompleteProcedure()
end
e:GetHandler():CompleteProcedure()
end
......@@ -35,7 +35,7 @@ function c79205581.operation1(e,tp,eg,ep,ev,re,r,rp)
end
end
function c79205581.condition2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_BATTLE
return Duel.GetCurrentPhase()==PHASE_BATTLE and not e:GetHandler():IsStatus(STATUS_CHAINING)
end
function c79205581.cost2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_ONFIELD,0,1,e:GetHandler()) end
......
......@@ -16,13 +16,13 @@ end
function c90263923.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c90263923.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c90263923.filter,tp,0,LOCATION_MZONE,1,nil)
and Duel.IsExistingMatchingCard(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end
and Duel.IsExistingMatchingCard(Card.IsPosition,tp,LOCATION_MZONE,0,1,nil,POS_FACEUP_ATTACK) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectTarget(tp,c90263923.filter,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SelectTarget(tp,c90263923.filter,tp,0,LOCATION_MZONE,1,1,nil)
end
function c90263923.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,0,nil)
local g=Duel.GetMatchingGroup(Card.IsPosition,tp,LOCATION_MZONE,0,nil,POS_FACEUP_ATTACK)
if g:GetCount()>0 and tc:IsRelateToEffect(e) and tc:IsFaceup() then
local sc=g:GetFirst()
local atk=tc:GetAttack()
......
......@@ -21,13 +21,13 @@ function c92755808.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att)
end
function c92755808.atkcon(e)
return Duel.IsExistingMatchingCard(c92755808.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_FIRE)
return Duel.IsExistingMatchingCard(c92755808.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_FIRE)
end
function c92755808.discon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
and Duel.IsExistingMatchingCard(c92755808.filter,tp,LOCATION_MZONE,0,1,nil,ATTRIBUTE_EARTH)
and Duel.IsExistingMatchingCard(c92755808.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_EARTH)
end
function c92755808.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -21,7 +21,7 @@ function c94573223.initial_effect(c)
e3:SetDescription(aux.Stringid(94573223,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY+EFFECT_FLAG_CHAIN_UNIQUE)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCondition(c94573223.spcon)
e3:SetTarget(c94573223.sptg)
......
......@@ -22,8 +22,8 @@ function c97623219.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att)
end
function c97623219.atkcon(e)
return Duel.IsExistingMatchingCard(c97623219.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_FIRE)
return Duel.IsExistingMatchingCard(c97623219.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_FIRE)
end
function c97623219.ctlcon(e)
return Duel.IsExistingMatchingCard(c97623219.filter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil,ATTRIBUTE_WATER)
return Duel.IsExistingMatchingCard(c97623219.filter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil,ATTRIBUTE_WATER)
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