Commit 62b3d966 authored by Momobako's avatar Momobako

updc

parent 4019c484
...@@ -381,6 +381,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -381,6 +381,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_USE_EXTRA_SZONE 262 #define EFFECT_USE_EXTRA_SZONE 262
#define EFFECT_MAX_MZONE 263 #define EFFECT_MAX_MZONE 263
#define EFFECT_MAX_SZONE 264 #define EFFECT_MAX_SZONE 264
#define EFFECT_MUST_USE_MZONE 265
#define EFFECT_HAND_LIMIT 270 #define EFFECT_HAND_LIMIT 270
#define EFFECT_DRAW_COUNT 271 #define EFFECT_DRAW_COUNT 271
#define EFFECT_SPIRIT_DONOT_RETURN 280 #define EFFECT_SPIRIT_DONOT_RETURN 280
......
...@@ -569,12 +569,12 @@ int32 field::get_useable_count(card* pcard, uint8 playerid, uint8 location, uint ...@@ -569,12 +569,12 @@ int32 field::get_useable_count(card* pcard, uint8 playerid, uint8 location, uint
} }
int32 field::get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone, uint32* list) { int32 field::get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone, uint32* list) {
if(core.duel_rule >= 4 && pcard->current.location == LOCATION_EXTRA) if(core.duel_rule >= 4 && pcard->current.location == LOCATION_EXTRA)
return get_spsummonable_count_fromex(pcard, playerid, zone, list); return get_spsummonable_count_fromex(pcard, playerid, playerid, zone, list);
else else
return get_tofield_count(playerid, LOCATION_MZONE, zone, list); return get_tofield_count(playerid, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD, zone, list);
} }
int32 field::get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone, uint32* list) { int32 field::get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone, uint32* list) {
int32 count = get_tofield_count(playerid, location, zone, list); int32 count = get_tofield_count(playerid, location, uplayer, reason, zone, list);
int32 limit; int32 limit;
if(location == LOCATION_MZONE) if(location == LOCATION_MZONE)
limit = get_mzone_limit(playerid, uplayer, reason); limit = get_mzone_limit(playerid, uplayer, reason);
...@@ -584,10 +584,22 @@ int32 field::get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, ui ...@@ -584,10 +584,22 @@ int32 field::get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, ui
count = limit; count = limit;
return count; return count;
} }
int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 zone, uint32* list) { int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone, uint32* list) {
if (location != LOCATION_MZONE && location != LOCATION_SZONE) if (location != LOCATION_MZONE && location != LOCATION_SZONE)
return 0; return 0;
uint32 flag = player[playerid].disabled_location | player[playerid].used_location; uint32 flag = player[playerid].disabled_location | player[playerid].used_location;
effect_set eset;
if(location == LOCATION_MZONE && (reason & LOCATION_REASON_TOFIELD)) {
if(uplayer < 2)
filter_player_effect(uplayer, EFFECT_MUST_USE_MZONE, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
uint32 value = eset[i]->get_value();
if(eset[i]->get_handler_player() == playerid)
flag |= ~value & 0x1f;
else
flag |= ~(value >> 16) & 0x1f;
}
}
if (location == LOCATION_MZONE) if (location == LOCATION_MZONE)
flag = (flag | ~zone) & 0x1f; flag = (flag | ~zone) & 0x1f;
else else
...@@ -600,14 +612,24 @@ int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 zone, uint ...@@ -600,14 +612,24 @@ int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 zone, uint
return count; return count;
} }
int32 field::get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone, uint32* list) { int32 field::get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone, uint32* list) {
int32 count = get_spsummonable_count_fromex(pcard, playerid, zone, list); int32 count = get_spsummonable_count_fromex(pcard, playerid, uplayer, zone, list);
int32 limit = get_mzone_limit(playerid, uplayer, LOCATION_REASON_TOFIELD); int32 limit = get_mzone_limit(playerid, uplayer, LOCATION_REASON_TOFIELD);
if(count > limit) if(count > limit)
count = limit; count = limit;
return count; return count;
} }
int32 field::get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint32 zone, uint32* list) { int32 field::get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone, uint32* list) {
uint32 flag = player[playerid].disabled_location | player[playerid].used_location; uint32 flag = player[playerid].disabled_location | player[playerid].used_location;
effect_set eset;
if(uplayer < 2)
filter_player_effect(uplayer, EFFECT_MUST_USE_MZONE, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
uint32 value = eset[i]->get_value();
if(eset[i]->get_handler_player() == playerid)
flag |= ~value & 0x1f;
else
flag |= ~(value >> 16) & 0x1f;
}
uint32 linked_zone = get_linked_zone(playerid) | (1u << 5) | (1u << 6); uint32 linked_zone = get_linked_zone(playerid) | (1u << 5) | (1u << 6);
flag = flag | ~zone | ~linked_zone; flag = flag | ~zone | ~linked_zone;
if(player[playerid].list_mzone[5] && is_location_useable(playerid, LOCATION_MZONE, 6) if(player[playerid].list_mzone[5] && is_location_useable(playerid, LOCATION_MZONE, 6)
...@@ -2691,7 +2713,7 @@ int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 t ...@@ -2691,7 +2713,7 @@ int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 t
zone &= 0x1f; zone &= 0x1f;
int32 s; int32 s;
if(toplayer == pcard->current.controler) { if(toplayer == pcard->current.controler) {
int32 ct = get_tofield_count(toplayer, LOCATION_MZONE, zone); int32 ct = get_tofield_count(toplayer, LOCATION_MZONE, pcard->current.controler, LOCATION_REASON_TOFIELD, zone);
if(ct <= 0) { if(ct <= 0) {
if(max <= 0) if(max <= 0)
return FALSE; return FALSE;
......
...@@ -357,9 +357,9 @@ public: ...@@ -357,9 +357,9 @@ public:
int32 get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0); int32 get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = 0); int32 get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0); int32 get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_tofield_count(uint8 playerid, uint8 location, uint32 zone = 0xff, uint32* list = 0); int32 get_tofield_count(uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0); int32 get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = 0); int32 get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason); int32 get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason);
int32 get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason); int32 get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason);
uint32 get_linked_zone(int32 playerid); uint32 get_linked_zone(int32 playerid);
......
...@@ -1702,7 +1702,7 @@ int32 scriptlib::duel_get_location_count(lua_State *L) { ...@@ -1702,7 +1702,7 @@ int32 scriptlib::duel_get_location_count(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 uplayer = pduel->game_field->core.reason_player; uint32 uplayer = pduel->game_field->core.reason_player;
uint32 reason = LOCATION_REASON_TOFIELD; uint32 reason = LOCATION_REASON_TOFIELD;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3 && !lua_isnil(L,3))
uplayer = lua_tointeger(L, 3); uplayer = lua_tointeger(L, 3);
if(lua_gettop(L) >= 4) if(lua_gettop(L) >= 4)
reason = lua_tointeger(L, 4); reason = lua_tointeger(L, 4);
...@@ -1847,8 +1847,8 @@ int32 scriptlib::duel_get_usable_mzone_count(lua_State *L) { ...@@ -1847,8 +1847,8 @@ int32 scriptlib::duel_get_usable_mzone_count(lua_State *L) {
uint32 zone = 0xff; uint32 zone = 0xff;
if(pduel->game_field->core.duel_rule >= 4) { if(pduel->game_field->core.duel_rule >= 4) {
uint32 flag1, flag2; uint32 flag1, flag2;
int32 ct1 = pduel->game_field->get_tofield_count(playerid, LOCATION_MZONE, zone, &flag1); int32 ct1 = pduel->game_field->get_tofield_count(playerid, LOCATION_MZONE, uplayer, LOCATION_REASON_TOFIELD, zone, &flag1);
int32 ct2 = pduel->game_field->get_spsummonable_count_fromex(0, playerid, zone, &flag2); int32 ct2 = pduel->game_field->get_spsummonable_count_fromex(0, playerid, uplayer, zone, &flag2);
int32 ct3 = field::field_used_count[~(flag1 | flag2) & 0x1f]; int32 ct3 = field::field_used_count[~(flag1 | flag2) & 0x1f];
int32 count = ct1 + ct2 - ct3; int32 count = ct1 + ct2 - ct3;
int32 limit = pduel->game_field->get_mzone_limit(playerid, uplayer, LOCATION_REASON_TOFIELD); int32 limit = pduel->game_field->get_mzone_limit(playerid, uplayer, LOCATION_REASON_TOFIELD);
......
...@@ -1607,7 +1607,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui ...@@ -1607,7 +1607,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
returns.bvalue[0] = 0; returns.bvalue[0] = 0;
core.units.begin()->step = 3; core.units.begin()->step = 3;
} else { } else {
int32 ct = get_tofield_count(sumplayer, LOCATION_MZONE, zone); int32 ct = get_tofield_count(sumplayer, LOCATION_MZONE, sumplayer, LOCATION_REASON_TOFIELD, zone);
int32 fcount = get_mzone_limit(sumplayer, sumplayer, LOCATION_REASON_TOFIELD); int32 fcount = get_mzone_limit(sumplayer, sumplayer, LOCATION_REASON_TOFIELD);
if(min == 0 && ct > 0 && fcount > 0) { if(min == 0 && ct > 0 && fcount > 0) {
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 90); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 90);
...@@ -2157,7 +2157,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint ...@@ -2157,7 +2157,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint
returns.bvalue[0] = 0; returns.bvalue[0] = 0;
core.units.begin()->step = 3; core.units.begin()->step = 3;
} else { } else {
int32 ct = get_tofield_count(setplayer, LOCATION_MZONE, zone); int32 ct = get_tofield_count(setplayer, LOCATION_MZONE, setplayer, LOCATION_REASON_TOFIELD, zone);
int32 fcount = get_mzone_limit(setplayer, setplayer, LOCATION_REASON_TOFIELD); int32 fcount = get_mzone_limit(setplayer, setplayer, LOCATION_REASON_TOFIELD);
if(min == 0 && ct > 0 && fcount > 0) { if(min == 0 && ct > 0 && fcount > 0) {
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 90); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 90);
...@@ -2722,8 +2722,8 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin ...@@ -2722,8 +2722,8 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin
uint32 zone = 0xff; uint32 zone = 0xff;
if(core.duel_rule >= 4) { if(core.duel_rule >= 4) {
uint32 flag1, flag2; uint32 flag1, flag2;
int32 ct1 = get_tofield_count(sumplayer, LOCATION_MZONE, zone, &flag1); int32 ct1 = get_tofield_count(sumplayer, LOCATION_MZONE, sumplayer, LOCATION_REASON_TOFIELD, zone, &flag1);
int32 ct2 = get_spsummonable_count_fromex(pcard, sumplayer, zone, &flag2); int32 ct2 = get_spsummonable_count_fromex(pcard, sumplayer, sumplayer, zone, &flag2);
for(auto it = pgroup->it; it != pgroup->container.end(); ++it) { for(auto it = pgroup->it; it != pgroup->container.end(); ++it) {
if((*it)->current.location != LOCATION_EXTRA) if((*it)->current.location != LOCATION_EXTRA)
ct1--; ct1--;
...@@ -4265,6 +4265,23 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4265,6 +4265,23 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
if((target->previous.location == LOCATION_SZONE) && target->equiping_target) if((target->previous.location == LOCATION_SZONE) && target->equiping_target)
target->unequip(); target->unequip();
if(target->current.location == LOCATION_MZONE) {
effect_set eset;
filter_player_effect(0, EFFECT_MUST_USE_MZONE, &eset);
filter_player_effect(1, EFFECT_MUST_USE_MZONE, &eset);
for(int32 i = 0; i < eset.size();) {
effect* peffect = eset[i++];
uint32 value = peffect->get_value();
if(peffect->get_handler_player() != target->current.controler)
value = value >> 16 | value << 16;
if(value & (0x1 << target->current.sequence)) {
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
pduel->game_field->remove_effect(peffect);
else
peffect->handler->remove_effect(peffect);
}
}
}
if(enable || ((ret == 1) && target->is_position(POS_FACEUP))) if(enable || ((ret == 1) && target->is_position(POS_FACEUP)))
target->enable_field_effect(true); target->enable_field_effect(true);
if(ret == 1 && target->current.location == LOCATION_MZONE && !(target->data.type & TYPE_MONSTER)) if(ret == 1 && target->current.location == LOCATION_MZONE && !(target->data.type & TYPE_MONSTER))
...@@ -5454,7 +5471,7 @@ int32 field::select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable, ...@@ -5454,7 +5471,7 @@ int32 field::select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable,
} }
core.operated_set.clear(); core.operated_set.clear();
zone &= 0x1f; zone &= 0x1f;
int32 ct = get_tofield_count(playerid, LOCATION_MZONE, zone); int32 ct = get_tofield_count(playerid, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD, zone);
if(ct > 0) { if(ct > 0) {
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
core.units.begin()->step = 1; core.units.begin()->step = 1;
...@@ -5653,7 +5670,7 @@ int32 field::select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable, ...@@ -5653,7 +5670,7 @@ int32 field::select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable,
case 20: { case 20: {
core.operated_set.clear(); core.operated_set.clear();
zone &= 0x1f; zone &= 0x1f;
int32 ct = get_tofield_count(toplayer, LOCATION_MZONE, zone); int32 ct = get_tofield_count(toplayer, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD, zone);
if(ct > 0) { if(ct > 0) {
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
core.units.begin()->step = 21; core.units.begin()->step = 21;
......
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