Commit 906eeba6 authored by VanillaSalt's avatar VanillaSalt

fix

parent baceb2b2
...@@ -831,7 +831,7 @@ void card::apply_field_effect() { ...@@ -831,7 +831,7 @@ void card::apply_field_effect() {
if (current.controler == PLAYER_NONE) if (current.controler == PLAYER_NONE)
return; return;
for (auto it = field_effect.begin(); it != field_effect.end(); ++it) { for (auto it = field_effect.begin(); it != field_effect.end(); ++it) {
if ((current.location & it->second->range) || ((it->second->range & LOCATION_HAND) if (it->second->in_range(current.location, current.sequence) || ((it->second->range & LOCATION_HAND)
&& (it->second->type & EFFECT_TYPE_TRIGGER_O) && !(it->second->code & EVENT_PHASE))) && (it->second->type & EFFECT_TYPE_TRIGGER_O) && !(it->second->code & EVENT_PHASE)))
pduel->game_field->add_effect(it->second); pduel->game_field->add_effect(it->second);
} }
...@@ -842,7 +842,7 @@ void card::cancel_field_effect() { ...@@ -842,7 +842,7 @@ void card::cancel_field_effect() {
if (current.controler == PLAYER_NONE) if (current.controler == PLAYER_NONE)
return; return;
for (auto it = field_effect.begin(); it != field_effect.end(); ++it) { for (auto it = field_effect.begin(); it != field_effect.end(); ++it) {
if ((current.location & it->second->range) || ((it->second->range & LOCATION_HAND) if (it->second->in_range(current.location, current.sequence) || ((it->second->range & LOCATION_HAND)
&& (it->second->type & EFFECT_TYPE_TRIGGER_O) && !(it->second->code & EVENT_PHASE))) && (it->second->type & EFFECT_TYPE_TRIGGER_O) && !(it->second->code & EVENT_PHASE)))
pduel->game_field->remove_effect(it->second); pduel->game_field->remove_effect(it->second);
} }
...@@ -859,11 +859,11 @@ void card::enable_field_effect(int32 enabled) { ...@@ -859,11 +859,11 @@ void card::enable_field_effect(int32 enabled) {
set_status(STATUS_EFFECT_ENABLED, TRUE); set_status(STATUS_EFFECT_ENABLED, TRUE);
effect_container::iterator it; effect_container::iterator it;
for (it = single_effect.begin(); it != single_effect.end(); ++it) { for (it = single_effect.begin(); it != single_effect.end(); ++it) {
if ((it->second->flag & EFFECT_FLAG_SINGLE_RANGE) && (current.location & it->second->range)) if ((it->second->flag & EFFECT_FLAG_SINGLE_RANGE) && it->second->in_range(current.location, current.sequence))
it->second->id = pduel->game_field->infos.field_id++; it->second->id = pduel->game_field->infos.field_id++;
} }
for (it = field_effect.begin(); it != field_effect.end(); ++it) { for (it = field_effect.begin(); it != field_effect.end(); ++it) {
if (current.location & it->second->range) if (it->second->in_range(current.location, current.sequence))
it->second->id = pduel->game_field->infos.field_id++; it->second->id = pduel->game_field->infos.field_id++;
} }
if(current.location == LOCATION_SZONE) { if(current.location == LOCATION_SZONE) {
...@@ -950,7 +950,7 @@ int32 card::add_effect(effect* peffect) { ...@@ -950,7 +950,7 @@ int32 card::add_effect(effect* peffect) {
} }
indexer.insert(make_pair(peffect, it)); indexer.insert(make_pair(peffect, it));
peffect->handler = this; peffect->handler = this;
if ((current.location & peffect->range) && peffect->type & EFFECT_TYPE_FIELD) if (peffect->in_range(current.location, current.sequence) && (peffect->type & EFFECT_TYPE_FIELD))
pduel->game_field->add_effect(peffect); pduel->game_field->add_effect(peffect);
if (current.controler != PLAYER_NONE && check_target) { if (current.controler != PLAYER_NONE && check_target) {
if (peffect->is_disable_related()) if (peffect->is_disable_related())
...@@ -989,12 +989,12 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) { ...@@ -989,12 +989,12 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
single_effect.erase(it); single_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_FIELD) { else if (peffect->type & EFFECT_TYPE_FIELD) {
check_target = 0; check_target = 0;
if ((current.location & peffect->range) && get_status(STATUS_EFFECT_ENABLED) && !get_status(STATUS_DISABLED)) { if (peffect->in_range(current.location, current.sequence) && get_status(STATUS_EFFECT_ENABLED) && !get_status(STATUS_DISABLED)) {
if (peffect->is_disable_related()) if (peffect->is_disable_related())
pduel->game_field->update_disable_check_list(peffect); pduel->game_field->update_disable_check_list(peffect);
} }
field_effect.erase(it); field_effect.erase(it);
if (current.location & peffect->range) if (peffect->in_range(current.location, current.sequence))
pduel->game_field->remove_effect(peffect); pduel->game_field->remove_effect(peffect);
} else if (peffect->type & EFFECT_TYPE_EQUIP) { } else if (peffect->type & EFFECT_TYPE_EQUIP) {
equip_effect.erase(it); equip_effect.erase(it);
......
...@@ -259,6 +259,8 @@ public: ...@@ -259,6 +259,8 @@ public:
#define LOCATION_EXTRA 0x40 // #define LOCATION_EXTRA 0x40 //
#define LOCATION_OVERLAY 0x80 // #define LOCATION_OVERLAY 0x80 //
#define LOCATION_ONFIELD 0x0c // #define LOCATION_ONFIELD 0x0c //
#define LOCATION_FZONE 0x100 //
#define LOCATION_PZONE 0x200 //
//Positions //Positions
#define POS_FACEUP_ATTACK 0x1 #define POS_FACEUP_ATTACK 0x1
#define POS_FACEDOWN_ATTACK 0x2 #define POS_FACEDOWN_ATTACK 0x2
......
...@@ -579,3 +579,12 @@ uint8 effect::get_handler_player() { ...@@ -579,3 +579,12 @@ uint8 effect::get_handler_player() {
return effect_owner; return effect_owner;
return handler->current.controler; return handler->current.controler;
} }
int32 effect::in_range(int32 loc, int32 seq) {
if(loc != LOCATION_SZONE)
return range & loc;
if(seq < 5)
return range & LOCATION_SZONE;
if(seq == 5)
return range & LOCATION_FZONE;
return range & LOCATION_PZONE;
}
...@@ -85,6 +85,7 @@ public: ...@@ -85,6 +85,7 @@ public:
int32 get_speed(); int32 get_speed();
uint8 get_owner_player(); uint8 get_owner_player();
uint8 get_handler_player(); uint8 get_handler_player();
int32 in_range(int32 loc, int32 seq);
}; };
//status //status
......
...@@ -1680,7 +1680,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) { ...@@ -1680,7 +1680,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) {
if(pcard->data.type & TYPE_MONSTER) if(pcard->data.type & TYPE_MONSTER)
peffect->range = LOCATION_MZONE; peffect->range = LOCATION_MZONE;
else else
peffect->range = LOCATION_SZONE; peffect->range = LOCATION_SZONE | LOCATION_FZONE | LOCATION_PZONE;
pcard->add_effect(peffect); pcard->add_effect(peffect);
return 0; return 0;
} }
......
...@@ -175,7 +175,7 @@ int32 scriptlib::effect_set_type(lua_State *L) { ...@@ -175,7 +175,7 @@ int32 scriptlib::effect_set_type(lua_State *L) {
if(v & 0x550) if(v & 0x550)
v |= EFFECT_TYPE_FIELD; v |= EFFECT_TYPE_FIELD;
if(v & EFFECT_TYPE_ACTIVATE) if(v & EFFECT_TYPE_ACTIVATE)
peffect->range = LOCATION_SZONE + LOCATION_HAND; peffect->range = LOCATION_SZONE + LOCATION_FZONE + LOCATION_HAND;
if(v & EFFECT_TYPE_FLIP) { if(v & EFFECT_TYPE_FLIP) {
peffect->code = EVENT_FLIP; peffect->code = EVENT_FLIP;
if(!(v & EFFECT_TYPE_TRIGGER_O)) if(!(v & EFFECT_TYPE_TRIGGER_O))
......
...@@ -1799,7 +1799,8 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1799,7 +1799,8 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
|| (peffect->range & LOCATION_HAND))) { || (peffect->range & LOCATION_HAND))) {
core.new_ochain_h.push_back(*clit); core.new_ochain_h.push_back(*clit);
act = false; act = false;
} else if((peffect->flag & EFFECT_FLAG_FIELD_ONLY) || !(peffect->type & EFFECT_TYPE_FIELD) || (clit->triggering_location & peffect->range)) { } else if((peffect->flag & EFFECT_FLAG_FIELD_ONLY) || !(peffect->type & EFFECT_TYPE_FIELD)
|| peffect->in_range(clit->triggering_location, clit->triggering_sequence)) {
if(peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) { if(peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) {
if(tp == infos.turn_player) { if(tp == infos.turn_player) {
for(auto tpit = core.tpchain.begin(); tpit != core.tpchain.end(); ++tpit) { for(auto tpit = core.tpchain.begin(); tpit != core.tpchain.end(); ++tpit) {
...@@ -1853,7 +1854,8 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1853,7 +1854,8 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
&& (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->flag & EFFECT_FLAG_SINGLE_RANGE) && peffect->handler->is_has_relation(peffect)) && (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->flag & EFFECT_FLAG_SINGLE_RANGE) && peffect->handler->is_has_relation(peffect))
|| (peffect->range & LOCATION_HAND))) { || (peffect->range & LOCATION_HAND))) {
continue; continue;
} else if((peffect->flag & EFFECT_FLAG_FIELD_ONLY) || !(peffect->type & EFFECT_TYPE_FIELD) || (clit->triggering_location & peffect->range)) { } else if((peffect->flag & EFFECT_FLAG_FIELD_ONLY) || !(peffect->type & EFFECT_TYPE_FIELD)
|| peffect->in_range(clit->triggering_location, clit->triggering_sequence)) {
if(peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) { if(peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) {
if(tp == infos.turn_player) { if(tp == infos.turn_player) {
for(auto tpit = core.tpchain.begin(); tpit != core.tpchain.end(); ++tpit) { for(auto tpit = core.tpchain.begin(); tpit != core.tpchain.end(); ++tpit) {
...@@ -4592,7 +4594,7 @@ int32 field::break_effect() { ...@@ -4592,7 +4594,7 @@ int32 field::break_effect() {
effect* peffect = rm->triggering_effect; effect* peffect = rm->triggering_effect;
if (!(peffect->flag & EFFECT_FLAG_DELAY)) { if (!(peffect->flag & EFFECT_FLAG_DELAY)) {
if ((peffect->flag & EFFECT_FLAG_FIELD_ONLY) if ((peffect->flag & EFFECT_FLAG_FIELD_ONLY)
|| !(peffect->type & EFFECT_TYPE_FIELD) || (peffect->range & rm->triggering_location)) { || !(peffect->type & EFFECT_TYPE_FIELD) || peffect->in_range(rm->triggering_location, rm->triggering_sequence)) {
pduel->write_buffer8(MSG_MISSED_EFFECT); pduel->write_buffer8(MSG_MISSED_EFFECT);
pduel->write_buffer32(peffect->handler->get_info_location()); pduel->write_buffer32(peffect->handler->get_info_location());
pduel->write_buffer32(peffect->handler->data.code); pduel->write_buffer32(peffect->handler->data.code);
......
...@@ -10,6 +10,9 @@ LOCATION_OVERLAY =0x80 -- ...@@ -10,6 +10,9 @@ LOCATION_OVERLAY =0x80 --
LOCATION_ONFIELD =0x0c -- LOCATION_ONFIELD =0x0c --
LOCATION_DECKBOT =0x10001 LOCATION_DECKBOT =0x10001
LOCATION_DECKSHF =0x20001 LOCATION_DECKSHF =0x20001
--Locations (for SetRange)
LOCATION_FZONE =0x100 --
LOCATION_PZONE =0x200 --
--Positions --Positions
POS_FACEUP_ATTACK =0x1 POS_FACEUP_ATTACK =0x1
POS_FACEDOWN_ATTACK =0x2 POS_FACEDOWN_ATTACK =0x2
......
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