Commit 1f82a3bd authored by DailyShana's avatar DailyShana Committed by GitHub

update Duel.MoveToField (#304)

parent e80d151a
...@@ -548,7 +548,7 @@ public: ...@@ -548,7 +548,7 @@ public:
void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player); void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player);
void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position);
void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position);
void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 is_equip = FALSE, uint32 zone = 0xff); void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff);
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE);
void operation_replace(int32 type, int32 step, group* targets); void operation_replace(int32 type, int32 step, group* targets);
...@@ -580,7 +580,7 @@ public: ...@@ -580,7 +580,7 @@ public:
int32 send_replace(uint16 step, group* targets, card* target); int32 send_replace(uint16 step, group* targets, card* target);
int32 send_to(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player); int32 send_to(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player);
int32 discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reason); int32 discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reason);
int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 is_equip, uint32 zone); int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 pzone, uint32 zone);
int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable); int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable);
int32 operation_replace(uint16 step, effect* replace_effect, group* targets, card* target, int32 is_destroy); int32 operation_replace(uint16 step, effect* replace_effect, group* targets, card* target, int32 is_destroy);
int32 activate_effect(uint16 step, effect* peffect); int32 activate_effect(uint16 step, effect* peffect);
......
...@@ -767,10 +767,19 @@ int32 scriptlib::duel_move_to_field(lua_State *L) { ...@@ -767,10 +767,19 @@ int32 scriptlib::duel_move_to_field(lua_State *L) {
uint32 zone = 0xff; uint32 zone = 0xff;
if(lua_gettop(L) > 6) if(lua_gettop(L) > 6)
zone = (uint32)lua_tointeger(L, 7); zone = (uint32)lua_tointeger(L, 7);
if(destination == LOCATION_FZONE) {
destination = LOCATION_SZONE;
zone = 0x1 << 5;
}
uint32 pzone = FALSE;
if(destination == LOCATION_PZONE) {
destination = LOCATION_SZONE;
pzone = TRUE;
}
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
pcard->enable_field_effect(false); pcard->enable_field_effect(false);
pduel->game_field->adjust_instant(); pduel->game_field->adjust_instant();
pduel->game_field->move_to_field(pcard, move_player, playerid, destination, positions, enable, 0, FALSE, zone); pduel->game_field->move_to_field(pcard, move_player, playerid, destination, positions, enable, 0, pzone, zone);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx; duel* pduel = (duel*)ctx;
lua_pushboolean(L, pduel->game_field->returns.ivalue[0]); lua_pushboolean(L, pduel->game_field->returns.ivalue[0]);
...@@ -794,7 +803,7 @@ int32 scriptlib::duel_return_to_field(lua_State *L) { ...@@ -794,7 +803,7 @@ int32 scriptlib::duel_return_to_field(lua_State *L) {
pcard->enable_field_effect(false); pcard->enable_field_effect(false);
pduel->game_field->adjust_instant(); pduel->game_field->adjust_instant();
pduel->game_field->refresh_location_info_instant(); pduel->game_field->refresh_location_info_instant();
pduel->game_field->move_to_field(pcard, pcard->previous.controler, pcard->previous.controler, pcard->previous.location, pos, TRUE, 1, 0, zone); pduel->game_field->move_to_field(pcard, pcard->previous.controler, pcard->previous.controler, pcard->previous.location, pos, TRUE, 1, pcard->previous.pzone, zone);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx; duel* pduel = (duel*)ctx;
lua_pushboolean(L, pduel->game_field->returns.ivalue[0]); lua_pushboolean(L, pduel->game_field->returns.ivalue[0]);
......
...@@ -282,13 +282,13 @@ void field::send_to(card* target, effect* reason_effect, uint32 reason, uint32 r ...@@ -282,13 +282,13 @@ void field::send_to(card* target, effect* reason_effect, uint32 reason, uint32 r
tset.insert(target); tset.insert(target);
send_to(&tset, reason_effect, reason, reason_player, playerid, destination, sequence, position); send_to(&tset, reason_effect, reason, reason_player, playerid, destination, sequence, position);
} }
void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable, uint32 ret, uint32 is_equip, uint32 zone) { void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable, uint32 ret, uint32 pzone, uint32 zone) {
if(!(destination & LOCATION_ONFIELD) || !positions) if(!(destination & LOCATION_ONFIELD) || !positions)
return; return;
if(destination == target->current.location && playerid == target->current.controler) if(destination == target->current.location && playerid == target->current.controler)
return; return;
target->to_field_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions; target->to_field_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions;
add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (is_equip << 8), zone); add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (pzone << 8), zone);
} }
void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) { void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) {
group* ng = pduel->new_group(*targets); group* ng = pduel->new_group(*targets);
...@@ -1463,7 +1463,7 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta ...@@ -1463,7 +1463,7 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta
return FALSE; return FALSE;
} }
equip_card->enable_field_effect(false); equip_card->enable_field_effect(false);
move_to_field(equip_card, equip_player, equip_player, LOCATION_SZONE, (up || equip_card->is_position(POS_FACEUP)) ? POS_FACEUP : POS_FACEDOWN, FALSE, 0, TRUE); move_to_field(equip_card, equip_player, equip_player, LOCATION_SZONE, (up || equip_card->is_position(POS_FACEUP)) ? POS_FACEUP : POS_FACEDOWN);
return FALSE; return FALSE;
} }
case 1: { case 1: {
...@@ -2386,7 +2386,7 @@ int32 field::sset(uint16 step, uint8 setplayer, uint8 toplayer, card * target, e ...@@ -2386,7 +2386,7 @@ int32 field::sset(uint16 step, uint8 setplayer, uint8 toplayer, card * target, e
} }
case 1: { case 1: {
target->enable_field_effect(false); target->enable_field_effect(false);
move_to_field(target, setplayer, toplayer, LOCATION_SZONE, POS_FACEDOWN); move_to_field(target, setplayer, toplayer, LOCATION_SZONE, POS_FACEDOWN, FALSE, 0, FALSE, (target->data.type & TYPE_FIELD) ? 0x1 << 5 : 0xff);
return FALSE; return FALSE;
} }
case 2: { case 2: {
...@@ -4363,7 +4363,7 @@ int32 field::discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reaso ...@@ -4363,7 +4363,7 @@ int32 field::discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reaso
// move a card from anywhere to field, including sp_summon, Duel.MoveToField(), Duel.ReturnToField() // move a card from anywhere to field, including sp_summon, Duel.MoveToField(), Duel.ReturnToField()
// ret: 0 = default, 1 = return after temporarily banished, 2 = trap_monster return to LOCATION_SZONE // ret: 0 = default, 1 = return after temporarily banished, 2 = trap_monster return to LOCATION_SZONE
// call move_card() in step 2 // call move_card() in step 2
int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 is_equip, uint32 zone) { int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 pzone, uint32 zone) {
uint32 move_player = (target->to_field_param >> 24) & 0xff; uint32 move_player = (target->to_field_param >> 24) & 0xff;
uint32 playerid = (target->to_field_param >> 16) & 0xff; uint32 playerid = (target->to_field_param >> 16) & 0xff;
uint32 location = (target->to_field_param >> 8) & 0xff; uint32 location = (target->to_field_param >> 8) & 0xff;
...@@ -4373,7 +4373,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4373,7 +4373,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
if((ret == 1) && (!(target->current.reason & REASON_TEMPORARY) || (target->current.reason_effect->owner != core.reason_effect->owner))) if((ret == 1) && (!(target->current.reason & REASON_TEMPORARY) || (target->current.reason_effect->owner != core.reason_effect->owner)))
return TRUE; return TRUE;
if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) { if(location == LOCATION_SZONE && zone == 0x1 << 5 && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) {
card* pcard = get_field_card(playerid, LOCATION_SZONE, 5); card* pcard = get_field_card(playerid, LOCATION_SZONE, 5);
if(pcard) { if(pcard) {
if(core.duel_rule >= 3) if(core.duel_rule >= 3)
...@@ -4382,7 +4382,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4382,7 +4382,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
destroy(pcard, 0, REASON_RULE, pcard->current.controler); destroy(pcard, 0, REASON_RULE, pcard->current.controler);
adjust_all(); adjust_all();
} }
} else if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM)) { } else if(pzone && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM)) {
uint32 flag = 0; uint32 flag = 0;
if(is_location_useable(playerid, LOCATION_PZONE, 0)) if(is_location_useable(playerid, LOCATION_PZONE, 0))
flag |= 0x1u << (core.duel_rule >= 4 ? 8 : 14); flag |= 0x1u << (core.duel_rule >= 4 ? 8 : 14);
...@@ -4443,7 +4443,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4443,7 +4443,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
case 1: { case 1: {
uint32 seq = returns.bvalue[2]; uint32 seq = returns.bvalue[2];
if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) if(location == LOCATION_SZONE && zone == 0x1 << 5 && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL))
seq = 5; seq = 5;
if(ret != 1) { if(ret != 1) {
if(location != target->current.location) { if(location != target->current.location) {
...@@ -4509,9 +4509,6 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4509,9 +4509,6 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
if(target->overlay_target) if(target->overlay_target)
target->overlay_target->xyz_remove(target); target->overlay_target->xyz_remove(target);
// call move_card() // call move_card()
uint8 pzone = FALSE;
if(!is_equip && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM))
pzone = TRUE;
move_card(playerid, target, location, target->temp.sequence, pzone); move_card(playerid, target, location, target->temp.sequence, pzone);
target->current.position = returns.ivalue[0]; target->current.position = returns.ivalue[0];
target->set_status(STATUS_LEAVE_CONFIRMED, FALSE); target->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
......
...@@ -3990,7 +3990,9 @@ int32 field::add_chain(uint16 step) { ...@@ -3990,7 +3990,9 @@ int32 field::add_chain(uint16 step) {
} }
phandler->enable_field_effect(false); phandler->enable_field_effect(false);
phandler->set_status(STATUS_ACT_FROM_HAND, TRUE); phandler->set_status(STATUS_ACT_FROM_HAND, TRUE);
move_to_field(phandler, phandler->current.controler, phandler->current.controler, LOCATION_SZONE, POS_FACEUP, FALSE, 0, FALSE, zone); if(phandler->data.type & TYPE_FIELD)
zone = 0x1 << 5;
move_to_field(phandler, phandler->current.controler, phandler->current.controler, LOCATION_SZONE, POS_FACEUP, FALSE, 0, (phandler->data.type & TYPE_PENDULUM) ? TRUE : FALSE, zone);
} else { } else {
phandler->set_status(STATUS_ACT_FROM_HAND, FALSE); phandler->set_status(STATUS_ACT_FROM_HAND, FALSE);
change_position(phandler, 0, phandler->current.controler, POS_FACEUP, 0); change_position(phandler, 0, phandler->current.controler, POS_FACEUP, 0);
......
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