Commit 93c62a6e authored by salix5's avatar salix5

position_param, direct_attackable

parent 2ec2856b
...@@ -113,6 +113,8 @@ public: ...@@ -113,6 +113,8 @@ public:
uint32 operation_param; uint32 operation_param;
uint32 release_param; uint32 release_param;
uint32 sum_param; uint32 sum_param;
uint32 position_param;
uint8 direct_attackable;
uint8 announce_count; uint8 announce_count;
uint8 attacked_count; uint8 attacked_count;
uint8 attack_all_target; uint8 attack_all_target;
......
...@@ -1713,7 +1713,7 @@ int32 field::get_attack_target(card* pcard, card_vector* v, uint8 chain_attack) ...@@ -1713,7 +1713,7 @@ int32 field::get_attack_target(card* pcard, card_vector* v, uint8 chain_attack)
card_vector only_be_attack; card_vector only_be_attack;
effect_set eset; effect_set eset;
// find the universal set pv // find the universal set pv
pcard->operation_param = 0; pcard->direct_attackable = 0;
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
card* atarget = player[1 - p].list_mzone[i]; card* atarget = player[1 - p].list_mzone[i];
if(atarget) { if(atarget) {
...@@ -1873,7 +1873,7 @@ int32 field::get_attack_target(card* pcard, card_vector* v, uint8 chain_attack) ...@@ -1873,7 +1873,7 @@ int32 field::get_attack_target(card* pcard, card_vector* v, uint8 chain_attack)
} }
if((mcount == 0 || pcard->is_affected_by_effect(EFFECT_DIRECT_ATTACK) || core.attack_player) if((mcount == 0 || pcard->is_affected_by_effect(EFFECT_DIRECT_ATTACK) || core.attack_player)
&& !pcard->is_affected_by_effect(EFFECT_CANNOT_DIRECT_ATTACK) && dir) && !pcard->is_affected_by_effect(EFFECT_CANNOT_DIRECT_ATTACK) && dir)
pcard->operation_param = 1; pcard->direct_attackable = 1;
return atype; return atype;
} }
// return: core.attack_target is valid or not // return: core.attack_target is valid or not
......
...@@ -1616,7 +1616,7 @@ int32 scriptlib::card_is_chain_attackable(lua_State *L) { ...@@ -1616,7 +1616,7 @@ int32 scriptlib::card_is_chain_attackable(lua_State *L) {
} }
pduel->game_field->core.select_cards.clear(); pduel->game_field->core.select_cards.clear();
pduel->game_field->get_attack_target(attacker, &pduel->game_field->core.select_cards, TRUE); pduel->game_field->get_attack_target(attacker, &pduel->game_field->core.select_cards, TRUE);
if(pduel->game_field->core.select_cards.size() == 0 && (monsteronly || attacker->operation_param == 0)) if(pduel->game_field->core.select_cards.size() == 0 && (monsteronly || attacker->direct_attackable == 0))
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
else else
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
...@@ -2244,7 +2244,7 @@ int32 scriptlib::card_get_attackable_target(lua_State *L) { ...@@ -2244,7 +2244,7 @@ int32 scriptlib::card_get_attackable_target(lua_State *L) {
group* newgroup = pduel->new_group(); group* newgroup = pduel->new_group();
newgroup->container.insert(targets.begin(), targets.end()); newgroup->container.insert(targets.begin(), targets.end());
interpreter::group2value(L, newgroup); interpreter::group2value(L, newgroup);
lua_pushboolean(L, pcard->operation_param); lua_pushboolean(L, (int32)pcard->direct_attackable);
return 2; return 2;
} }
int32 scriptlib::card_set_hint(lua_State *L) { int32 scriptlib::card_set_hint(lua_State *L) {
......
...@@ -296,22 +296,22 @@ void field::change_position(card_set* targets, effect* reason_effect, uint32 rea ...@@ -296,22 +296,22 @@ void field::change_position(card_set* targets, effect* reason_effect, uint32 rea
for(auto cit = targets->begin(); cit != targets->end(); ++cit) { for(auto cit = targets->begin(); cit != targets->end(); ++cit) {
card* pcard = *cit; card* pcard = *cit;
if(pcard->current.position == POS_FACEUP_ATTACK) if(pcard->current.position == POS_FACEUP_ATTACK)
pcard->operation_param = au; pcard->position_param = au;
else if(pcard->current.position == POS_FACEDOWN_DEFENSE) else if(pcard->current.position == POS_FACEDOWN_DEFENSE)
pcard->operation_param = dd; pcard->position_param = dd;
else if(pcard->current.position == POS_FACEUP_DEFENSE) else if(pcard->current.position == POS_FACEUP_DEFENSE)
pcard->operation_param = du; pcard->position_param = du;
else else
pcard->operation_param = ad; pcard->position_param = ad;
pcard->operation_param |= flag; pcard->position_param |= flag;
} }
add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable); 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 flag, 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); group* ng = pduel->new_group(target);
ng->is_readonly = TRUE; ng->is_readonly = TRUE;
target->operation_param = npos; target->position_param = npos;
target->operation_param |= flag; target->position_param |= flag;
add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable); 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) { int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 playerid, uint32 count) {
...@@ -634,6 +634,8 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost) { ...@@ -634,6 +634,8 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost) {
} }
return TRUE; return TRUE;
} }
// rplayer rmoves counter from pcard or the field
// s,o: binary value indicating the available side
int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count) { int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count) {
switch(step) { switch(step) {
case 0: { case 0: {
...@@ -3945,9 +3947,9 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec ...@@ -3945,9 +3947,9 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
std::sort(cv.begin(), cv.end(), card::card_operation_sort); std::sort(cv.begin(), cv.end(), card::card_operation_sort);
for(auto cvit = cv.begin(); cvit != cv.end(); ++cvit) { for(auto cvit = cv.begin(); cvit != cv.end(); ++cvit) {
card* pcard = *cvit; card* pcard = *cvit;
uint8 npos = pcard->operation_param & 0xff; uint8 npos = pcard->position_param & 0xff;
uint8 opos = pcard->current.position; uint8 opos = pcard->current.position;
uint8 flag = pcard->operation_param >> 16; uint8 flag = pcard->position_param >> 16;
if(pcard->is_status(STATUS_SUMMONING) || pcard->overlay_target || !(pcard->current.location & LOCATION_ONFIELD) if(pcard->is_status(STATUS_SUMMONING) || pcard->overlay_target || !(pcard->current.location & LOCATION_ONFIELD)
|| !pcard->is_affect_by_effect(reason_effect) || npos == opos || !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)) || (!(pcard->data.type & TYPE_TOKEN) && (opos & POS_FACEUP) && (npos & POS_FACEDOWN) && !pcard->is_capable_turn_set(reason_player))
......
...@@ -40,7 +40,7 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) { ...@@ -40,7 +40,7 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence); pduel->write_buffer8(pcard->current.sequence);
pduel->write_buffer8(pcard->operation_param); pduel->write_buffer8(pcard->direct_attackable);
} }
//M2, EP //M2, EP
if(core.to_m2) if(core.to_m2)
......
...@@ -2823,7 +2823,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -2823,7 +2823,7 @@ int32 field::process_battle_command(uint16 step) {
chain_attack = TRUE; chain_attack = TRUE;
core.select_cards.clear(); core.select_cards.clear();
get_attack_target(pcard, &core.select_cards, chain_attack); get_attack_target(pcard, &core.select_cards, chain_attack);
if(core.select_cards.size() == 0 && pcard->operation_param == 0) if(core.select_cards.size() == 0 && pcard->direct_attackable == 0)
continue; continue;
core.attackable_cards.push_back(pcard); core.attackable_cards.push_back(pcard);
if(pcard->is_affected_by_effect(EFFECT_FIRST_ATTACK)) if(pcard->is_affected_by_effect(EFFECT_FIRST_ATTACK))
...@@ -3134,7 +3134,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3134,7 +3134,7 @@ int32 field::process_battle_command(uint16 step) {
return FALSE; return FALSE;
} }
// attack canceled // attack canceled
if(!core.select_cards.size() && !core.attacker->operation_param) { if(!core.select_cards.size() && !core.attacker->direct_attackable) {
core.chain_attack = FALSE; core.chain_attack = FALSE;
core.units.begin()->step = -1; core.units.begin()->step = -1;
reset_phase(PHASE_DAMAGE); reset_phase(PHASE_DAMAGE);
...@@ -5157,7 +5157,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -5157,7 +5157,7 @@ int32 field::adjust_step(uint16 step) {
pos = eset.get_last()->get_value(); pos = eset.get_last()->get_value();
if((pos & 0xff) != pcard->current.position) { if((pos & 0xff) != pcard->current.position) {
pos_adjust.insert(pcard); pos_adjust.insert(pcard);
pcard->operation_param = pos; pcard->position_param = pos;
if(pcard->is_status(STATUS_JUST_POS)) if(pcard->is_status(STATUS_JUST_POS))
pcard->set_status(STATUS_CONTINUOUS_POS, TRUE); pcard->set_status(STATUS_CONTINUOUS_POS, TRUE);
else else
......
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