Commit e265c2c4 authored by VanillaSalt's avatar VanillaSalt

fix

parent 85396c94
......@@ -155,7 +155,7 @@ int32 effect::is_activateable(uint8 playerid, tevent& e, int32 neglect_cond, int
return FALSE;
} else if(!(type & EFFECT_TYPE_CONTINUOUS)) {
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))
&& (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
&& !(code & EVENT_FLIP) && (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE;
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))) {
if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !(flag & EFFECT_FLAG_DAMAGE_STEP))
......
......@@ -413,6 +413,7 @@ public:
#define EVENT_LEVEL_UP 1200
#define EVENT_PAY_LPCOST 1201
#define EVENT_DETACH_MATERIAL 1202
#define EVENT_CONFIRM 1203
#define EVENT_TURN_END 1210
#define EVENT_PHASE 0x1000
#define EVENT_PHASE_START 0x2000
......
......@@ -53,8 +53,10 @@ field::field(duel* pduel) {
core.shuffle_deck_check[i] = FALSE;
core.shuffle_hand_check[i] = FALSE;
}
core.pre_field[0] = 0;
core.pre_field[1] = 0;
for (int i = 0; i < 5; ++i)
core.pre_field[i] = 0;
core.opp_mzone[i] = 0;
core.summoning_card = 0;
core.summon_depth = 0;
core.chain_limit = 0;
......
......@@ -214,7 +214,8 @@ struct processor {
std::unordered_set<card*> unique_cards[2];
ptr temp_var[4];
uint32 global_flag;
uint16 pre_field[5];
uint16 pre_field[2];
uint16 opp_mzone[5];
int32 chain_limit;
uint8 chain_limp;
int32 chain_limit_p;
......
......@@ -89,6 +89,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetUnionCount", scriptlib::card_get_union_count },
{ "GetOverlayGroup", scriptlib::card_get_overlay_group },
{ "GetOverlayCount", scriptlib::card_get_overlay_count },
{ "GetOverlayTarget", scriptlib::card_get_overlay_target },
{ "CheckRemoveOverlayCard", scriptlib::card_check_remove_overlay_card },
{ "RemoveOverlayCard", scriptlib::card_remove_overlay_card },
{ "GetAttackedGroup", scriptlib::card_get_attacked_group },
......
......@@ -607,6 +607,13 @@ int32 scriptlib::card_get_overlay_count(lua_State *L) {
lua_pushinteger(L, pcard->xyz_materials.size());
return 1;
}
int32 scriptlib::card_get_overlay_target(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
interpreter::card2value(L, pcard->overlay_target);
return 1;
}
int32 scriptlib::card_check_remove_overlay_card(lua_State *L) {
check_param_count(L, 4);
check_param(L, PARAM_TYPE_CARD, 1);
......
......@@ -637,6 +637,7 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) {
}
}
}
field::card_set cset;
auto cit = pduel->game_field->player[playerid].list_main.rbegin();
pduel->write_buffer8(MSG_CONFIRM_DECKTOP);
pduel->write_buffer8(playerid);
......@@ -646,8 +647,10 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) {
pduel->write_buffer8((*cit)->current.controler);
pduel->write_buffer8((*cit)->current.location);
pduel->write_buffer8((*cit)->current.sequence);
cset.insert(*cit);
}
pduel->game_field->add_process(PROCESSOR_WAIT, 0, 0, 0, 0, 0);
pduel->game_field->raise_event(&cset, EVENT_CONFIRM, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, 0, 0);
pduel->game_field->process_instant_event();
return lua_yield(L, 0);
}
int32 scriptlib::duel_confirm_cards(lua_State *L) {
......@@ -685,7 +688,11 @@ int32 scriptlib::duel_confirm_cards(lua_State *L) {
pduel->write_buffer8((*cit)->current.sequence);
}
}
pduel->game_field->add_process(PROCESSOR_WAIT, 0, 0, 0, 0, 0);
if(pcard)
pduel->game_field->raise_event(pcard, EVENT_CONFIRM, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, 0, 0);
else
pduel->game_field->raise_event(&pgroup->container, EVENT_CONFIRM, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, 0, 0);
pduel->game_field->process_instant_event();
return lua_yield(L, 0);
}
int32 scriptlib::duel_sort_decktop(lua_State *L) {
......
......@@ -478,7 +478,7 @@ int32 field::process() {
if(it->step == 0) {
card* attacker = core.attacker;
if(!attacker
|| (infos.phase == PHASE_DAMAGE && attacker->fieldid_r != core.pre_field[0] && attacker->fieldid_r != core.pre_field[1])
|| (attacker->fieldid_r != core.pre_field[0])
|| (attacker->current.position & POS_FACEDOWN)
|| attacker->is_affected_by_effect(EFFECT_ATTACK_DISABLED)
|| !attacker->is_affect_by_effect(core.reason_effect)) {
......@@ -2831,6 +2831,10 @@ int32 field::process_battle_command(uint16 step) {
core.attack_target = 0;
else
core.attack_target = core.select_cards[returns.bvalue[1]];
if(core.attack_target)
core.pre_field[1] = core.attack_target->fieldid_r;
else
core.pre_field[1] = 0;
return FALSE;
}
case 7: {
......@@ -2852,9 +2856,9 @@ int32 field::process_battle_command(uint16 step) {
}
for(uint32 i = 0; i < 5; ++i) {
if(player[1 - infos.turn_player].list_mzone[i])
core.pre_field[i] = player[1 - infos.turn_player].list_mzone[i]->fieldid_r;
core.opp_mzone[i] = player[1 - infos.turn_player].list_mzone[i]->fieldid_r;
else
core.pre_field[i] = 0;
core.opp_mzone[i] = 0;
}
//core.units.begin()->arg1 ---> is rollbacked
if(!core.units.begin()->arg1) {
......@@ -2996,7 +3000,7 @@ int32 field::process_battle_command(uint16 step) {
return FALSE;
}
uint8 seq = core.chain_attack_target->current.sequence;
if(core.pre_field[seq] != core.chain_attack_target->fieldid_r) {
if(core.opp_mzone[seq] != core.chain_attack_target->fieldid_r) {
core.units.begin()->step = -1;
reset_phase(PHASE_DAMAGE);
return FALSE;
......@@ -3008,12 +3012,12 @@ int32 field::process_battle_command(uint16 step) {
core.units.begin()->arg2 = get_attack_target(core.attacker, &core.select_cards, core.chain_attack);
for(uint32 i = 0; i < 5; ++i) {
if(player[1 - infos.turn_player].list_mzone[i]) {
if(!core.pre_field[i] || core.pre_field[i] != player[1 - infos.turn_player].list_mzone[i]->fieldid_r) {
if(!core.opp_mzone[i] || core.opp_mzone[i] != player[1 - infos.turn_player].list_mzone[i]->fieldid_r) {
rollback = true;
break;
}
} else {
if(core.pre_field[i]) {
if(core.opp_mzone[i]) {
rollback = true;
break;
}
......@@ -4407,10 +4411,14 @@ int32 field::break_effect() {
core.hint_timing[1] = 0;
for (auto chit = core.new_ochain.begin(); chit != core.new_ochain.end();) {
auto rm = chit++;
if (!(rm->triggering_effect->flag & EFFECT_FLAG_DELAY)) {
pduel->write_buffer8(MSG_MISSED_EFFECT);
pduel->write_buffer32(rm->triggering_effect->handler->get_info_location());
pduel->write_buffer32(rm->triggering_effect->handler->data.code);
effect* peffect = rm->triggering_effect;
if (!(peffect->flag & EFFECT_FLAG_DELAY)) {
if ((peffect->flag & EFFECT_FLAG_FIELD_ONLY)
|| !(peffect->type & EFFECT_TYPE_FIELD) || (peffect->range & rm->triggering_location)) {
pduel->write_buffer8(MSG_MISSED_EFFECT);
pduel->write_buffer32(peffect->handler->get_info_location());
pduel->write_buffer32(peffect->handler->data.code);
}
core.new_ochain.erase(rm);
}
}
......
......@@ -91,6 +91,7 @@ public:
static int32 card_get_union_count(lua_State *L);
static int32 card_get_overlay_group(lua_State *L);
static int32 card_get_overlay_count(lua_State *L);
static int32 card_get_overlay_target(lua_State *L);
static int32 card_check_remove_overlay_card(lua_State *L);
static int32 card_remove_overlay_card(lua_State *L);
static int32 card_get_attacked_group(lua_State *L);
......
......@@ -39,5 +39,7 @@ function c14644902.operation(e,tp,eg,ep,ev,re,r,rp)
end
end
function c14644902.desop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
if not e:GetHandler():IsHasEffect(66235877) then
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
end
......@@ -13,7 +13,7 @@ function c3027001.cfilter(c,tp)
return c:IsType(TYPE_TRAP) and c:IsControler(tp)
end
function c3027001.condition(e,tp,eg,ep,ev,re,r,rp)
if rp==tp then return end
if rp==tp then return false end
local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_DESTROY)
return ex and tg~=nil and tg:GetCount()==tc and tg:IsExists(c3027001.cfilter,1,e:GetHandler(),tp)
end
......
......@@ -39,7 +39,7 @@ function c36076683.atkop(e,tp,eg,ep,ev,re,r,rp)
e2:SetCode(EVENT_PRE_BATTLE_DAMAGE)
e2:SetCondition(c36076683.rdcon)
e2:SetOperation(c36076683.rdop)
e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e2:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END)
c:RegisterEffect(e2)
end
end
......
......@@ -30,6 +30,7 @@ end
function c40607210.condition(e,tp,eg,ep,ev,re,r,rp)
local rc=re:GetHandler()
return rc and rc:IsRace(RACE_ZOMBIE) and eg:IsExists(c40607210.cfilter,1,nil,tp)
and (re:GetCode()~=EFFECT_SPSUMMON_PROC or not rc:IsStatus(STATUS_REVIVE_LIMIT))
end
function c40607210.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFlagEffect(tp,40607210)==0 and Duel.CheckLPCost(tp,2000) end
......
......@@ -16,6 +16,7 @@ function c44178886.initial_effect(c)
e2:SetDescription(aux.Stringid(44178886,1))
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCondition(c44178886.discon)
e2:SetTarget(c44178886.distg)
e2:SetOperation(c44178886.disop)
......@@ -36,8 +37,7 @@ function c44178886.discon(e,tp,eg,ep,ev,re,r,rp)
return tp==Duel.GetTurnPlayer()
end
function c44178886.distg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetFlagEffect(44178886)==0 end
e:GetHandler():RegisterFlagEffect(44178886,RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END,EFFECT_FLAG_OATH,1)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DECKDES,nil,0,tp,3)
end
function c44178886.disop(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -4,15 +4,18 @@ function c53656677.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_BE_BATTLE_TARGET)
e1:SetTarget(c53656677.target)
e1:SetOperation(c53656677.operation)
c:RegisterEffect(e1)
end
function c53656677.target(e,tp,eg,ep,ev,re,r,rp,chk)
function c53656677.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc==Duel.GetAttackTarget() end
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
if chk==0 then return d and d:IsControler(tp) and d:IsFaceup() and d:GetAttack()<a:GetAttack() end
if chk==0 then return d and d:IsControler(tp) and d:IsFaceup() and d:IsCanBeEffectTarget(e)
and d:GetAttack()<a:GetAttack() end
Duel.SetTargetCard(d)
end
function c53656677.operation(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -33,14 +33,15 @@ function c57421866.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
end
function c57421866.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:GetLevel()<2 then return end
if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsImmuneToEffect(e) or tc:GetLevel()<2 then return end
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(-1)
if tc:RegisterEffect(e1) and c:IsRelateToEffect(e) then
tc:RegisterEffect(e1)
if c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
......@@ -13,20 +13,20 @@ function c59019082.initial_effect(c)
c:RegisterEffect(e1)
end
function c59019082.cfilter(c)
return c:GetPreviousLocation()==LOCATION_DECK
return c:IsPreviousLocation(LOCATION_DECK)
end
function c59019082.condtion(e,tp,eg,ep,ev,re,r,rp)
if not re then return false end
local rc=re:GetHandler()
return rp==tp and bit.band(r,REASON_EFFECT)~=0 and not rc:IsCode(59019082) and rc:IsSetCard(0x38) and rc:IsType(TYPE_MONSTER)
and eg:IsExists(c59019082.cfilter,1,nil)
and re:GetActivateLocation()==LOCATION_MZONE and eg:IsExists(c59019082.cfilter,1,nil)
end
function c59019082.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DECKDES,nil,0,tp,2)
end
function c59019082.filter(c)
return c:GetLocation()==LOCATION_GRAVE and c:IsSetCard(0x38) and c:IsType(TYPE_MONSTER)
return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(0x38) and c:IsType(TYPE_MONSTER)
end
function c59019082.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -12,6 +12,7 @@ function c60741115.initial_effect(c)
c:RegisterEffect(e1)
end
function c60741115.condition(e,tp,eg,ep,ev,re,r,rp)
if rp==tp or Duel.GetTurnPlayer()==tp then return false end
local ex,cg,ct,cp,cv=Duel.GetOperationInfo(ev,CATEGORY_DAMAGE)
if ex then return true end
ex,cg,ct,cp,cv=Duel.GetOperationInfo(ev,CATEGORY_RECOVER)
......
......@@ -18,6 +18,13 @@ function c66235877.initial_effect(c)
e2:SetRange(LOCATION_MZONE)
e2:SetOperation(c66235877.disop)
c:RegisterEffect(e2)
--
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(66235877)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
c:RegisterEffect(e3)
end
function c66235877.distg(e,c)
return c:IsType(TYPE_FLIP)
......
......@@ -4,7 +4,6 @@ function c81210420.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_POSITION+CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_BATTLE_START+TIMING_BATTLE_END)
e1:SetCondition(c81210420.condition)
......@@ -16,7 +15,7 @@ function c81210420.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp and Duel.GetCurrentPhase()==PHASE_BATTLE
end
function c81210420.filter(c)
return not c:IsType(TYPE_TOKEN)
return c:IsFacedown() or c:IsCanTurnSet()
end
function c81210420.spfilter(c,e,tp)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsCanBeSpecialSummoned(e,0,tp,true,false,POS_FACEDOWN)
......@@ -34,7 +33,7 @@ function c81210420.activate(e,tp,eg,ep,ev,re,r,rp)
if g:GetCount()<2 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local tc=Duel.SelectMatchingCard(tp,c81210420.filter,tp,LOCATION_MZONE,0,1,1,nil):GetFirst()
if not tc then return end
if not tc or tc:IsImmuneToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,2,2,nil)
if tc:IsFaceup() then
......
......@@ -77,15 +77,15 @@ function c83438826.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
local eq=c:GetEquipTarget()
if not c:IsRelateToEffect(e) or not tc:IsRelateToEffect(e) or tc:IsFaceup() or not eq:IsAttackAbove(500) then return end
if not c:IsRelateToEffect(e) or not tc:IsRelateToEffect(e) or tc:IsFaceup()
or eq:IsImmuneToEffect(e) or not eq:IsAttackAbove(500) then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-500)
e1:SetReset(RESET_EVENT+0x1fe0000)
if eq:RegisterEffect(e1) then
Duel.Destroy(tc,REASON_EFFECT)
end
eq:RegisterEffect(e1)
Duel.Destroy(tc,REASON_EFFECT)
end
function c83438826.eqcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -41,9 +41,8 @@ function c95503687.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c95503687.spop(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
......
......@@ -22,11 +22,10 @@ function c99469936.initial_effect(c)
--negate
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(99469936,2))
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetCategory(CATEGORY_DISABLE)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetCountLimit(1)
e3:SetRange(LOCATION_MZONE)
e3:SetHintTiming(0,0x1c0)
e3:SetCost(c99469936.cost)
e3:SetTarget(c99469936.target)
e3:SetOperation(c99469936.operation)
......@@ -65,10 +64,8 @@ function c99469936.operation(e,tp,eg,ep,ev,re,r,rp)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetValue(RESET_TURN_SET)
e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e2)
Duel.NegateRelatedChain(tc,RESET_TURN_SET)
tc=g:GetNext()
end
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