Commit 6dae5c4d authored by DailyShana's avatar DailyShana Committed by nekrozar

update EFFECT_OVERLAY_REMOVE_REPLACE (#229)

fix Fluorohydride/ygopro#2220
parent 511f2f9f
......@@ -1347,7 +1347,7 @@ int32 scriptlib::card_remove_overlay_card(lua_State *L) {
pduel->game_field->remove_overlay_card(reason, pcard, playerid, 0, 0, min, max);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushboolean(L, pduel->game_field->returns.ivalue[0]);
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
return 1;
});
}
......
......@@ -3314,7 +3314,7 @@ int32 scriptlib::duel_remove_overlay_card(lua_State *L) {
pduel->game_field->remove_overlay_card(reason, 0, playerid, s, o, min, max);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushboolean(L, pduel->game_field->returns.ivalue[0]);
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
return 1;
});
}
......
......@@ -765,8 +765,7 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
return FALSE;
}
case 1: {
effect* peffect = core.select_effects[returns.ivalue[0]];
if(peffect) {
if(effect* peffect = core.select_effects[returns.ivalue[0]]) {
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
......@@ -775,9 +774,24 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
e.reason_effect = core.reason_effect;
e.reason_player = rplayer;
solve_continuous(rplayer, peffect, e);
core.units.begin()->step = 3;
core.units.begin()->peffect = peffect;
}
return FALSE;
}
case 2: {
uint16 cancelable = FALSE;
if(core.units.begin()->peffect) {
int32 replace_count = returns.ivalue[0];
if(replace_count >= max)
return TRUE;
min -= replace_count;
max -= replace_count;
if(min <= 0) {
cancelable = TRUE;
min = 0;
}
core.units.begin()->arg4 = replace_count;
}
core.select_cards.clear();
if(pcard) {
for(auto& mcard : pcard->xyz_materials)
......@@ -792,21 +806,18 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(rplayer);
pduel->write_buffer32(519);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, rplayer, min + (max << 16));
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, rplayer + (cancelable << 16), min + (max << 16));
return FALSE;
}
case 2: {
case 3: {
card_set cset;
for(int32 i = 0; i < returns.bvalue[0]; ++i)
cset.insert(core.select_cards[returns.bvalue[i + 1]]);
send_to(&cset, core.reason_effect, reason, rplayer, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
return FALSE;
}
case 3: {
return FALSE;
}
case 4: {
returns.ivalue[0] = 1;
returns.ivalue[0] += core.units.begin()->arg4;
return TRUE;
}
}
......
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