Commit c1f69377 authored by DailyShana's avatar DailyShana

update handling of effect activated in deck

parent 86c1f543
......@@ -191,7 +191,7 @@ enum effect_flag : uint32 {
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
};
enum effect_flag2 : uint32 {
EFFECT_FLAG2_NAGA = 0x0001,
// EFFECT_FLAG2_NAGA = 0x0001,
EFFECT_FLAG2_COF = 0x0002,
};
inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
......
......@@ -610,6 +610,7 @@ public:
#define CHAIN_CONTINUOUS_CARD 0x08
#define CHAIN_ACTIVATING 0x10
#define CHAIN_HAND_TRIGGER 0x20
#define CHAIN_DECK_EFFECT 0x40
#define CHAININFO_CHAIN_COUNT 0x01
#define CHAININFO_TRIGGERING_EFFECT 0x02
#define CHAININFO_TRIGGERING_PLAYER 0x04
......
......@@ -3619,44 +3619,30 @@ int32 scriptlib::duel_is_chain_negatable(lua_State * L) {
check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
int32 res = 0;
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size())
res = FALSE;
else {
effect* peffect;
if(chaincount == 0)
peffect = pduel->game_field->core.current_chain.back().triggering_effect;
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
}
lua_pushboolean(L, res);
chain* ch = pduel->game_field->get_chain(chaincount);
if(!ch)
return 0;
if(ch->flag & CHAIN_DECK_EFFECT)
lua_pushboolean(L, 0);
else
lua_pushboolean(L, 1);
return 1;
}
int32 scriptlib::duel_is_chain_disablable(lua_State * L) {
check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
int32 res = 0;
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size())
res = FALSE;
else {
effect* peffect;
if(chaincount == 0)
peffect = pduel->game_field->core.current_chain.back().triggering_effect;
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
if(pduel->game_field->core.chain_solving)
res = pduel->game_field->is_chain_disablable(chaincount);
if(pduel->game_field->core.chain_solving) {
lua_pushboolean(L, pduel->game_field->is_chain_disablable(chaincount));
return 1;
}
lua_pushboolean(L, res);
chain* ch = pduel->game_field->get_chain(chaincount);
if(!ch)
return 0;
if(ch->flag & CHAIN_DECK_EFFECT)
lua_pushboolean(L, 0);
else
lua_pushboolean(L, 1);
return 1;
}
int32 scriptlib::duel_check_chain_target(lua_State *L) {
......
......@@ -29,7 +29,7 @@ int32 field::negate_chain(uint8 chaincount) {
}
pduel->write_buffer8(MSG_CHAIN_NEGATED);
pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA))
if(pchain.flag & CHAIN_DECK_EFFECT)
return FALSE;
return TRUE;
}
......@@ -48,7 +48,7 @@ int32 field::disable_chain(uint8 chaincount) {
core.current_chain[chaincount - 1].disable_player = core.reason_player;
pduel->write_buffer8(MSG_CHAIN_DISABLED);
pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA))
if(pchain.flag & CHAIN_DECK_EFFECT)
return FALSE;
return TRUE;
}
......
......@@ -1697,6 +1697,14 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
}
uint8 tp = clit->triggering_player;
bool act = true;
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
&& clit->triggering_location == LOCATION_DECK && (phandler->current.location & LOCATION_DECK)) {
if((peffect->type & EFFECT_TYPE_SINGLE) && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)
&& peffect->code == EVENT_TO_DECK || (peffect->range & LOCATION_DECK))
clit->flag |= CHAIN_DECK_EFFECT;
else
act = false;
}
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit))
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE
......@@ -1777,6 +1785,14 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
|| peffect->range && !peffect->in_range(*clit))
act = false;
}
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
&& clit->triggering_location == LOCATION_DECK && (phandler->current.location & LOCATION_DECK)) {
if((peffect->type & EFFECT_TYPE_SINGLE) && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)
&& peffect->code == EVENT_TO_DECK || (peffect->range & LOCATION_DECK))
clit->flag |= CHAIN_DECK_EFFECT;
else
act = false;
}
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit))
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE
......
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