Commit 0e0e910d authored by DailyShana's avatar DailyShana

update

rename EFFECT_FORCE_MZONE to EFFECT_MUST_USE_MZONE
parent 51394c5e
......@@ -381,7 +381,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_USE_EXTRA_SZONE 262
#define EFFECT_MAX_MZONE 263
#define EFFECT_MAX_SZONE 264
#define EFFECT_FORCE_MZONE 265
#define EFFECT_MUST_USE_MZONE 265
#define EFFECT_HAND_LIMIT 270
#define EFFECT_DRAW_COUNT 271
#define EFFECT_SPIRIT_DONOT_RETURN 280
......
......@@ -571,10 +571,10 @@ int32 field::get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone, ui
if(core.duel_rule >= 4 && pcard->current.location == LOCATION_EXTRA)
return get_spsummonable_count_fromex(pcard, playerid, playerid, zone, list);
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 count = get_tofield_count(playerid, location, zone, list, reason, uplayer);
int32 count = get_tofield_count(playerid, location, uplayer, reason, zone, list);
int32 limit;
if(location == LOCATION_MZONE)
limit = get_mzone_limit(playerid, uplayer, reason);
......@@ -584,27 +584,22 @@ int32 field::get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, ui
count = limit;
return count;
}
int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 zone, uint32* list, uint32 reason, uint32 uplayer) {
int32 field::get_tofield_count(uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone, uint32* list) {
if (location != LOCATION_MZONE && location != LOCATION_SZONE)
return 0;
uint32 flag = player[playerid].disabled_location | player[playerid].used_location;
effect_set eset;
uint32 value;
if(uplayer == 2)
uplayer = playerid;
if((reason & (LOCATION_REASON_TOFIELD) != 0) && location == LOCATION_MZONE)
filter_player_effect(uplayer, EFFECT_FORCE_MZONE, &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) {
value = eset[i]->get_value();
uint32 flag1 = ~(value) & 0xff7f;
uint32 flag2 = ~(value >> 16) & 0xff7f;
if ((flag1 & flag) != flag1 && (uplayer == playerid)) {
flag |= flag1;
} else if ((flag2 & flag) != flag2 && (uplayer != playerid)) {
flag |= flag2;
uint32 value = eset[i]->get_value();
if(eset[i]->get_handler_player() == playerid)
flag |= ~value & 0x1f;
else
flag |= ~(value >> 16) & 0x1f;
}
}
eset.clear();
if (location == LOCATION_MZONE)
flag = (flag | ~zone) & 0x1f;
else
......@@ -626,19 +621,15 @@ int32 field::get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer
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;
effect_set eset;
uint32 value;
filter_player_effect(uplayer, EFFECT_FORCE_MZONE, &eset);
if(uplayer < 2)
filter_player_effect(uplayer, EFFECT_MUST_USE_MZONE, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
value = eset[i]->get_value();
uint32 flag1 = ~(value) & 0xff7f;
uint32 flag2 = ~(value >> 16) & 0xff7f;
if ((flag1 & flag) != flag1 && (uplayer == playerid)) {
flag |= flag1;
} else if ((flag2 & flag) != flag2 && (uplayer != playerid)) {
flag |= flag2;
}
uint32 value = eset[i]->get_value();
if(eset[i]->get_handler_player() == playerid)
flag |= ~value & 0x1f;
else
flag |= ~(value >> 16) & 0x1f;
}
eset.clear();
uint32 linked_zone = get_linked_zone(playerid) | (1u << 5) | (1u << 6);
flag = flag | ~zone | ~linked_zone;
if(player[playerid].list_mzone[5] && is_location_useable(playerid, LOCATION_MZONE, 6)
......@@ -2722,7 +2713,7 @@ int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 t
zone &= 0x1f;
int32 s;
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(max <= 0)
return FALSE;
......
......@@ -356,7 +356,7 @@ public:
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_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, uint32 reason = 0x1, uint32 uplayer = 2);
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_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);
......@@ -589,7 +589,6 @@ public:
//Location Use Reason
#define LOCATION_REASON_TOFIELD 0x1
#define LOCATION_REASON_CONTROL 0x2
#define LOCATION_REASON_COUNT 0x4
//Chain Info
#define CHAIN_DISABLE_ACTIVATE 0x01
#define CHAIN_DISABLE_EFFECT 0x02
......
......@@ -1681,7 +1681,7 @@ int32 scriptlib::duel_get_usable_mzone_count(lua_State *L) {
uint32 zone = 0xff;
if(pduel->game_field->core.duel_rule >= 4) {
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, uplayer, zone, &flag2);
int32 ct3 = field::field_used_count[~(flag1 | flag2) & 0x1f];
int32 count = ct1 + ct2 - ct3;
......
......@@ -1607,7 +1607,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
returns.bvalue[0] = 0;
core.units.begin()->step = 3;
} 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);
if(min == 0 && ct > 0 && fcount > 0) {
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
returns.bvalue[0] = 0;
core.units.begin()->step = 3;
} 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);
if(min == 0 && ct > 0 && fcount > 0) {
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 90);
......@@ -2722,7 +2722,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin
uint32 zone = 0xff;
if(core.duel_rule >= 4) {
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, sumplayer, zone, &flag2);
for(auto it = pgroup->it; it != pgroup->container.end(); ++it) {
if((*it)->current.location != LOCATION_EXTRA)
......@@ -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)
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)))
target->enable_field_effect(true);
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,
}
core.operated_set.clear();
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) {
returns.ivalue[0] = TRUE;
core.units.begin()->step = 1;
......@@ -5653,7 +5670,7 @@ int32 field::select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable,
case 20: {
core.operated_set.clear();
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) {
returns.ivalue[0] = TRUE;
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