Commit 7fdecbd9 authored by VanillaSalt's avatar VanillaSalt

fix

for Acid Trap Hole
parent 21e46a9a
......@@ -286,7 +286,9 @@ public:
#define POS_FACEDOWN 0xa
#define POS_ATTACK 0x3
#define POS_DEFENCE 0xc
//Flip effect flags
#define NO_FLIP_EFFECT 0x10000
#define FLIP_SET_AVAILABLE 0x20000
//Types
#define TYPE_MONSTER 0x1 //
#define TYPE_SPELL 0x2 //
......
......@@ -207,12 +207,13 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
if(handler->is_affected_by_effect(EFFECT_CANNOT_TRIGGER))
return FALSE;
} else if(!(type & EFFECT_TYPE_CONTINUOUS)) {
if((handler->data.type & TYPE_MONSTER) && (handler->current.location & LOCATION_SZONE)
if((handler->data.type & TYPE_MONSTER) && (handler->current.location & LOCATION_SZONE)
&& !in_range(handler->current.location, handler->current.sequence))
return FALSE;
// effects with EFFECT_FLAG_SET_AVAILABLE or cards with STATUS_SET_AVAILABLE can be activated while face-down
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))
&& !is_flag(EFFECT_FLAG_SET_AVAILABLE) && !handler->is_status(STATUS_SET_AVAILABLE)
&& (code != EVENT_FLIP || !(e.event_value & (FLIP_SET_AVAILABLE >> 16)))
&& (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE;
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))
......
......@@ -481,8 +481,8 @@ public:
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 move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = FALSE, uint32 is_equip = FALSE);
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 noflip, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 noflip, 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);
int32 remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count);
int32 remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 min, uint16 max);
......
......@@ -548,18 +548,19 @@ int32 scriptlib::duel_change_form(lua_State *L) {
} else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 au = lua_tointeger(L, 2);
uint32 ad = au, du = au, dd = au, noflip = 0;
uint32 ad = au, du = au, dd = au, flag = 0;
uint32 top = lua_gettop(L);
if(top > 2) ad = lua_tointeger(L, 3);
if(top > 3) du = lua_tointeger(L, 4);
if(top > 4) dd = lua_tointeger(L, 5);
if(top > 5) noflip = lua_toboolean(L, 6);
if(top > 5 && lua_toboolean(L, 6)) flag |= NO_FLIP_EFFECT;
if(top > 6 && lua_toboolean(L, 7)) flag |= FLIP_SET_AVAILABLE;
if(pcard) {
field::card_set cset;
cset.insert(pcard);
pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, noflip, TRUE);
pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
} else
pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, noflip, TRUE);
pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
pduel->game_field->core.subunits.begin()->type = PROCESSOR_CHANGEPOS_S;
return lua_yield(L, 0);
}
......
......@@ -280,7 +280,7 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin
target->operation_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions;
add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (is_equip << 8));
}
void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 noflip, 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);
ng->is_readonly = TRUE;
for(auto cit = targets->begin(); cit != targets->end(); ++cit) {
......@@ -289,17 +289,15 @@ void field::change_position(card_set* targets, effect* reason_effect, uint32 rea
else if(pcard->current.position == POS_FACEDOWN_DEFENCE) pcard->operation_param = dd;
else if(pcard->current.position == POS_FACEUP_DEFENCE) pcard->operation_param = du;
else pcard->operation_param = ad;
if(noflip)
pcard->operation_param |= NO_FLIP_EFFECT;
pcard->operation_param |= flag;
}
add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable);
}
void field::change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 noflip, uint32 enable) {
void field::change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable) {
group* ng = pduel->new_group(target);
ng->is_readonly = TRUE;
target->operation_param = npos;
if(noflip)
target->operation_param |= NO_FLIP_EFFECT;
target->operation_param |= flag;
add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable);
}
int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 playerid, uint32 count) {
......@@ -3756,15 +3754,14 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
card_set flips;
card_set ssets;
card_set pos_changed;
uint8 npos, opos, noflip;
card_vector cv(targets->container.begin(), targets->container.end());
if(cv.size() > 1)
std::sort(cv.begin(), cv.end(), card::card_operation_sort);
for(auto cvit = cv.begin(); cvit != cv.end(); ++cvit) {
card* pcard = *cvit;
npos = pcard->operation_param & 0xff;
opos = pcard->current.position;
noflip = pcard->operation_param >> 16;
uint8 npos = pcard->operation_param & 0xff;
uint8 opos = pcard->current.position;
uint8 flag = pcard->operation_param >> 16;
if(pcard->is_status(STATUS_SUMMONING) || pcard->overlay_target || !(pcard->current.location & LOCATION_ONFIELD)
|| !pcard->is_affect_by_effect(reason_effect) || npos == opos
|| (!(pcard->data.type & TYPE_TOKEN) && (opos & POS_FACEUP) && (npos & POS_FACEDOWN) && !pcard->is_capable_turn_set(reason_player))
......@@ -3789,7 +3786,7 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
if((opos & POS_FACEDOWN) && (npos & POS_FACEUP)) {
pcard->fieldid = infos.field_id++;
if(pcard->current.location == LOCATION_MZONE) {
raise_single_event(pcard, 0, EVENT_FLIP, reason_effect, 0, reason_player, 0, noflip);
raise_single_event(pcard, 0, EVENT_FLIP, reason_effect, 0, reason_player, 0, flag);
flips.insert(pcard);
}
if(enable) {
......
......@@ -2325,26 +2325,20 @@ int32 field::process_instant_event() {
int32 field::process_single_event() {
if(core.single_event.size() == 0)
return TRUE;
card* starget;
uint32 ev;
effect_set eset;
effect* peffect;
effect_vector tp;
effect_vector ntp;
event_list tev;
event_list ntev;
effect_vector::iterator eit;
event_list::iterator evit;
for(auto elit = core.single_event.begin(); elit != core.single_event.end(); ++elit) {
starget = elit->trigger_card;
ev = elit->event_code;
card* starget = elit->trigger_card;
uint32 ev = elit->event_code;
auto pr = starget->single_effect.equal_range(ev);
const tevent& e = *elit;
for(; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
effect* peffect = pr.first->second;
if(!(peffect->type & EFFECT_TYPE_ACTIONS))
continue;
if((peffect->type & EFFECT_TYPE_FLIP) && e.event_value)
if((peffect->type & EFFECT_TYPE_FLIP) && (e.event_value & (NO_FLIP_EFFECT >> 16)))
continue;
//continuous & trigger (single)
if(peffect->type & EFFECT_TYPE_CONTINUOUS) {
......@@ -2404,6 +2398,8 @@ int32 field::process_single_event() {
}
}
}
effect_vector::iterator eit;
event_list::iterator evit;
for(eit = tp.begin(), evit = tev.begin(); eit != tp.end(); ++eit, ++evit) {
core.sub_solving_event.push_back(*evit);
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, (*eit), 0, (*eit)->get_handler_player(), 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