Commit f1836be9 authored by DailyShana's avatar DailyShana

update active_type

parent 462d1314
...@@ -245,8 +245,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -245,8 +245,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
return FALSE; return FALSE;
} else if(!(type & EFFECT_TYPE_CONTINUOUS)) { } else if(!(type & EFFECT_TYPE_CONTINUOUS)) {
card* phandler = get_handler(); card* phandler = get_handler();
if((phandler->data.type & TYPE_MONSTER) && (phandler->current.location & LOCATION_SZONE) if(!(phandler->get_type() & TYPE_MONSTER) && (get_active_type() & TYPE_MONSTER))
&& !in_range(phandler))
return FALSE; return FALSE;
if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) { if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) {
// effects which can be activated while face-down: // effects which can be activated while face-down:
...@@ -752,3 +751,20 @@ void effect::set_activate_location() { ...@@ -752,3 +751,20 @@ void effect::set_activate_location() {
active_location = phandler->current.location; active_location = phandler->current.location;
active_sequence = phandler->current.sequence; active_sequence = phandler->current.sequence;
} }
void effect::set_active_type() {
card* phandler = get_handler();
active_type = phandler->get_type();
if(active_type & TYPE_TRAPMONSTER)
active_type -= TYPE_TRAP;
}
uint32 effect::get_active_type() {
if(type & 0x7f0) {
if(active_type)
return active_type;
else if((type & EFFECT_TYPE_ACTIVATE) && (get_handler()->data.type & TYPE_PENDULUM))
return TYPE_PENDULUM + TYPE_SPELL;
else
return get_handler()->get_type();
} else
return owner->get_type();
}
...@@ -100,6 +100,8 @@ public: ...@@ -100,6 +100,8 @@ public:
int32 in_range(card* pcard); int32 in_range(card* pcard);
int32 in_range(const chain& ch); int32 in_range(const chain& ch);
void set_activate_location(); void set_activate_location();
void set_active_type();
uint32 get_active_type();
bool is_flag(effect_flag flag) const { bool is_flag(effect_flag flag) const {
return !!(this->flag[0] & flag); return !!(this->flag[0] & flag);
} }
......
...@@ -435,40 +435,22 @@ int32 scriptlib::effect_get_operation(lua_State *L) { ...@@ -435,40 +435,22 @@ int32 scriptlib::effect_get_operation(lua_State *L) {
interpreter::function2value(L, peffect->operation); interpreter::function2value(L, peffect->operation);
return 1; return 1;
} }
// active_type is set in add_chain()
int32 scriptlib::effect_get_active_type(lua_State *L) { int32 scriptlib::effect_get_active_type(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 atype; lua_pushinteger(L, peffect->get_active_type());
if(peffect->type & 0x7f0) {
if(peffect->active_type)
atype = peffect->active_type;
else if((peffect->type & EFFECT_TYPE_ACTIVATE) && (peffect->get_handler()->data.type & TYPE_PENDULUM))
atype = TYPE_PENDULUM + TYPE_SPELL;
else
atype = peffect->get_handler()->get_type();
} else
atype = peffect->owner->get_type();
lua_pushinteger(L, atype);
return 1; return 1;
} }
int32 scriptlib::effect_is_active_type(lua_State *L) { int32 scriptlib::effect_is_active_type(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 tpe = lua_tointeger(L, 2); uint32 type = lua_tointeger(L, 2);
uint32 atype; if(peffect->get_active_type() & type)
if(peffect->type & 0x7f0) { lua_pushboolean(L, 1);
if(peffect->active_type) else
atype = peffect->active_type; lua_pushboolean(L, 0);
else if((peffect->type & EFFECT_TYPE_ACTIVATE) && (peffect->get_handler()->data.type & TYPE_PENDULUM))
atype = TYPE_PENDULUM + TYPE_SPELL;
else
atype = peffect->get_handler()->get_type();
} else
atype = peffect->owner->get_type();
lua_pushboolean(L, atype & tpe);
return 1; return 1;
} }
int32 scriptlib::effect_is_has_property(lua_State *L) { int32 scriptlib::effect_is_has_property(lua_State *L) {
......
...@@ -1702,6 +1702,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1702,6 +1702,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
if(tp == core.current_player) if(tp == core.current_player)
core.select_chains.push_back(*clit); core.select_chains.push_back(*clit);
} else { } else {
peffect->active_type = 0;
core.new_fchain_s.erase(clit++); core.new_fchain_s.erase(clit++);
continue; continue;
} }
...@@ -1794,6 +1795,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1794,6 +1795,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
if(tp == core.current_player) if(tp == core.current_player)
core.select_chains.push_back(*clit); core.select_chains.push_back(*clit);
} else { } else {
peffect->active_type = 0;
core.new_ochain_s.erase(clit++); core.new_ochain_s.erase(clit++);
continue; continue;
} }
...@@ -1819,8 +1821,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1819,8 +1821,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
} }
case 6: { case 6: {
if(returns.ivalue[0] == -1) { if(returns.ivalue[0] == -1) {
for(const auto& ch : core.select_chains) for(const auto& ch : core.select_chains) {
ch.triggering_effect->active_type = 0;
core.new_ochain_s.remove_if([chain_id = ch.chain_id](chain ch) { return ch.chain_id == chain_id; }); core.new_ochain_s.remove_if([chain_id = ch.chain_id](chain ch) { return ch.chain_id == chain_id; });
}
if(core.new_ochain_s.size()) { if(core.new_ochain_s.size()) {
core.current_player = 1 - infos.turn_player; core.current_player = 1 - infos.turn_player;
core.units.begin()->step = 3; core.units.begin()->step = 3;
...@@ -2432,6 +2436,7 @@ int32 field::process_single_event(effect* peffect, const tevent& e, chain_list& ...@@ -2432,6 +2436,7 @@ int32 field::process_single_event(effect* peffect, const tevent& e, chain_list&
else else
core.new_fchain.push_back(newchain); core.new_fchain.push_back(newchain);
} }
peffect->set_active_type();
phandler->create_relation(newchain); phandler->create_relation(newchain);
effect* deffect; effect* deffect;
if(deffect = phandler->is_affected_by_effect(EFFECT_DISABLE_EFFECT)) { if(deffect = phandler->is_affected_by_effect(EFFECT_DISABLE_EFFECT)) {
...@@ -4258,7 +4263,7 @@ int32 field::add_chain(uint16 step) { ...@@ -4258,7 +4263,7 @@ int32 field::add_chain(uint16 step) {
peffect->card_type = phandler->get_type(); peffect->card_type = phandler->get_type();
if((peffect->card_type & 0x5) == 0x5) if((peffect->card_type & 0x5) == 0x5)
peffect->card_type -= TYPE_TRAP; peffect->card_type -= TYPE_TRAP;
peffect->active_type = peffect->card_type; peffect->set_active_type();
peffect->active_handler = peffect->handler->overlay_target; peffect->active_handler = peffect->handler->overlay_target;
clit.chain_count = core.current_chain.size() + 1; clit.chain_count = core.current_chain.size() + 1;
clit.target_cards = 0; clit.target_cards = 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