Commit ec0a2f8a authored by salix5's avatar salix5

STATUS_BATTLE_RESULT

http://www.db.yugioh-card.com/yugiohdb/faq_search.action?ope=5&fid=16935&keyword=&tag=-1
Now destroy replacement is handled before EVENT_BATTLED.
parent 2d839c23
...@@ -404,7 +404,7 @@ public: ...@@ -404,7 +404,7 @@ public:
#define STATUS_PROC_COMPLETE 0x0008 // #define STATUS_PROC_COMPLETE 0x0008 //
#define STATUS_SET_TURN 0x0010 // #define STATUS_SET_TURN 0x0010 //
#define STATUS_NO_LEVEL 0x0020 // #define STATUS_NO_LEVEL 0x0020 //
#define STATUS_SET_AVAILABLE 0x0040 // #define STATUS_BATTLE_RESULT 0x0040 //
#define STATUS_SPSUMMON_STEP 0x0080 // #define STATUS_SPSUMMON_STEP 0x0080 //
#define STATUS_FORM_CHANGED 0x0100 // #define STATUS_FORM_CHANGED 0x0100 //
#define STATUS_SUMMONING 0x0200 // #define STATUS_SUMMONING 0x0200 //
......
...@@ -2574,6 +2574,7 @@ int32 field::special_summon(uint16 step, effect * reason_effect, uint8 reason_pl ...@@ -2574,6 +2574,7 @@ int32 field::special_summon(uint16 step, effect * reason_effect, uint8 reason_pl
} }
return TRUE; return TRUE;
} }
// PROCESSOR_DESTROY_STEP goes here
int32 field::destroy(uint16 step, group * targets, card * target, uint8 battle) { int32 field::destroy(uint16 step, group * targets, card * target, uint8 battle) {
if(target->current.location & (LOCATION_GRAVE | LOCATION_REMOVED)) { if(target->current.location & (LOCATION_GRAVE | LOCATION_REMOVED)) {
target->current.reason = target->temp.reason; target->current.reason = target->temp.reason;
...@@ -2830,6 +2831,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2830,6 +2831,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if(eset[i]->check_value_condition(3)) { if(eset[i]->check_value_condition(3)) {
core.battle_destroy_rep.insert(eset[i]->handler); core.battle_destroy_rep.insert(eset[i]->handler);
sub = true; sub = true;
break;
} }
} }
if(sub) { if(sub) {
...@@ -2841,9 +2843,11 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2841,9 +2843,11 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
} }
} }
} }
auto pr = effects.continuous_effect.equal_range(EFFECT_DESTROY_REPLACE); if(targets->container.size()){
for (; pr.first != pr.second; ++pr.first) auto pr = effects.continuous_effect.equal_range(EFFECT_DESTROY_REPLACE);
add_process(PROCESSOR_OPERATION_REPLACE, 12, pr.first->second, targets, 0, 1); for (; pr.first != pr.second; ++pr.first)
add_process(PROCESSOR_OPERATION_REPLACE, 12, pr.first->second, targets, 0, 1);
}
return FALSE; return FALSE;
} }
case 11: { case 11: {
...@@ -3034,6 +3038,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3034,6 +3038,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
card_set leave_p, destroying; card_set leave_p, destroying;
for(auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) { for(auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) {
card* pcard = *cit; card* pcard = *cit;
// REASON_RULE or (REASON_EFFECT + REASON_DESTROY) => not battle destroyed
if((pcard->current.location == LOCATION_MZONE) && pcard->is_status(STATUS_BATTLE_DESTROYED) && !(pcard->current.reason & REASON_RULE) if((pcard->current.location == LOCATION_MZONE) && pcard->is_status(STATUS_BATTLE_DESTROYED) && !(pcard->current.reason & REASON_RULE)
&& (pcard->current.reason & (REASON_EFFECT + REASON_DESTROY)) != (REASON_EFFECT + REASON_DESTROY) && !(pcard->current.reason & REASON_BATTLE)) { && (pcard->current.reason & (REASON_EFFECT + REASON_DESTROY)) != (REASON_EFFECT + REASON_DESTROY) && !(pcard->current.reason & REASON_BATTLE)) {
pcard->current.reason |= REASON_DESTROY | REASON_BATTLE; pcard->current.reason |= REASON_DESTROY | REASON_BATTLE;
......
...@@ -3320,12 +3320,14 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3320,12 +3320,14 @@ int32 field::process_battle_command(uint16 step) {
uint8 pa = core.attacker->current.controler, pd; uint8 pa = core.attacker->current.controler, pd;
core.attacker->q_cache.attack = aa; core.attacker->q_cache.attack = aa;
core.attacker->q_cache.defence = ad; core.attacker->q_cache.defence = ad;
core.attacker->set_status(STATUS_BATTLE_RESULT, FALSE);
core.attacker->set_status(STATUS_BATTLE_DESTROYED, FALSE); core.attacker->set_status(STATUS_BATTLE_DESTROYED, FALSE);
if(core.attack_target) { if(core.attack_target) {
da = core.attack_target->get_attack(); da = core.attack_target->get_attack();
dd = core.attack_target->get_defence(); dd = core.attack_target->get_defence();
core.attack_target->q_cache.attack = da; core.attack_target->q_cache.attack = da;
core.attack_target->q_cache.defence = dd; core.attack_target->q_cache.defence = dd;
core.attack_target->set_status(STATUS_BATTLE_RESULT, FALSE);
core.attack_target->set_status(STATUS_BATTLE_DESTROYED, FALSE); core.attack_target->set_status(STATUS_BATTLE_DESTROYED, FALSE);
pd = core.attack_target->current.controler; pd = core.attack_target->current.controler;
if(pa != pd) { if(pa != pd) {
...@@ -3346,7 +3348,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3346,7 +3348,7 @@ int32 field::process_battle_command(uint16 step) {
pduel->write_buffer32(indestructable_effect->owner->data.code); pduel->write_buffer32(indestructable_effect->owner->data.code);
bd[0] = FALSE; bd[0] = FALSE;
} else } else
core.attacker->set_status(STATUS_BATTLE_DESTROYED, TRUE); core.attacker->set_status(STATUS_BATTLE_RESULT, TRUE);
} }
if(bd[1]) { if(bd[1]) {
effect* indestructable_effect = core.attack_target->is_affected_by_effect(EFFECT_INDESTRUCTABLE_BATTLE, core.attacker); effect* indestructable_effect = core.attack_target->is_affected_by_effect(EFFECT_INDESTRUCTABLE_BATTLE, core.attacker);
...@@ -3357,7 +3359,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3357,7 +3359,7 @@ int32 field::process_battle_command(uint16 step) {
pduel->write_buffer32(indestructable_effect->owner->data.code); pduel->write_buffer32(indestructable_effect->owner->data.code);
bd[1] = FALSE; bd[1] = FALSE;
} else } else
core.attack_target->set_status(STATUS_BATTLE_DESTROYED, TRUE); core.attack_target->set_status(STATUS_BATTLE_RESULT, TRUE);
} }
pduel->write_buffer8(MSG_BATTLE); pduel->write_buffer8(MSG_BATTLE);
pduel->write_buffer32(core.attacker->get_info_location()); pduel->write_buffer32(core.attacker->get_info_location());
...@@ -3438,7 +3440,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3438,7 +3440,7 @@ int32 field::process_battle_command(uint16 step) {
card_set des; card_set des;
effect* peffect; effect* peffect;
uint32 dest, seq; uint32 dest, seq;
if(core.attacker->is_status(STATUS_BATTLE_DESTROYED) if(core.attacker->is_status(STATUS_BATTLE_RESULT)
&& core.attacker->current.location == LOCATION_MZONE && core.attacker->fieldid_r == core.pre_field[0]) { && core.attacker->current.location == LOCATION_MZONE && core.attacker->fieldid_r == core.pre_field[0]) {
des.insert(core.attacker); des.insert(core.attacker);
core.attacker->temp.reason = core.attacker->current.reason; core.attacker->temp.reason = core.attacker->current.reason;
...@@ -3458,7 +3460,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3458,7 +3460,7 @@ int32 field::process_battle_command(uint16 step) {
} }
core.attacker->operation_param = (POS_FACEUP << 24) + (((uint32)core.attacker->owner) << 16) + (dest << 8) + seq; core.attacker->operation_param = (POS_FACEUP << 24) + (((uint32)core.attacker->owner) << 16) + (dest << 8) + seq;
} }
if(core.attack_target && core.attack_target->is_status(STATUS_BATTLE_DESTROYED) if(core.attack_target && core.attack_target->is_status(STATUS_BATTLE_RESULT)
&& core.attack_target->current.location == LOCATION_MZONE && core.attack_target->fieldid_r == core.pre_field[1]) { && core.attack_target->current.location == LOCATION_MZONE && core.attack_target->fieldid_r == core.pre_field[1]) {
des.insert(core.attack_target); des.insert(core.attack_target);
core.attack_target->temp.reason = core.attack_target->current.reason; core.attack_target->temp.reason = core.attack_target->current.reason;
...@@ -3478,9 +3480,9 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3478,9 +3480,9 @@ int32 field::process_battle_command(uint16 step) {
} }
core.attack_target->operation_param = (POS_FACEUP << 24) + (((uint32)core.attack_target->owner) << 16) + (dest << 8) + seq; core.attack_target->operation_param = (POS_FACEUP << 24) + (((uint32)core.attack_target->owner) << 16) + (dest << 8) + seq;
} }
core.attacker->set_status(STATUS_BATTLE_DESTROYED, FALSE); core.attacker->set_status(STATUS_BATTLE_RESULT, FALSE);
if(core.attack_target) if(core.attack_target)
core.attack_target->set_status(STATUS_BATTLE_DESTROYED, FALSE); core.attack_target->set_status(STATUS_BATTLE_RESULT, FALSE);
core.battle_destroy_rep.clear(); core.battle_destroy_rep.clear();
core.desrep_chain.clear(); core.desrep_chain.clear();
if(des.size()) { if(des.size()) {
...@@ -3493,6 +3495,24 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3493,6 +3495,24 @@ int32 field::process_battle_command(uint16 step) {
return FALSE; return FALSE;
} }
case 29: { case 29: {
group* des = core.units.begin()->ptarget;
if(core.battle_destroy_rep.size())
destroy(&core.battle_destroy_rep, 0, REASON_EFFECT, PLAYER_NONE);
if(core.desrep_chain.size())
add_process(PROCESSOR_OPERATION_REPLACE, 15, 0, 0, 0, 0);
if(des) {
card_set::iterator cit, rm;
for(cit = des->container.begin(); cit != des->container.end();) {
rm = cit++;
if((*rm)->current.location != LOCATION_MZONE || ((*rm)->fieldid_r != core.pre_field[0] && (*rm)->fieldid_r != core.pre_field[1]))
des->container.erase(rm);
}
add_process(PROCESSOR_DESTROY, 3, 0, des, REASON_BATTLE, PLAYER_NONE);
}
adjust_all();
return FALSE;
}
case 30: {
core.selfdes_disabled = FALSE; core.selfdes_disabled = FALSE;
group* des = core.units.begin()->ptarget; group* des = core.units.begin()->ptarget;
if(des && des->container.size()) { if(des && des->container.size()) {
...@@ -3502,14 +3522,11 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3502,14 +3522,11 @@ int32 field::process_battle_command(uint16 step) {
} }
} }
adjust_all(); adjust_all();
return FALSE;
}
case 30: {
//EVENT_BATTLE_END was here, but this timing does not exist in Master Rule 3 //EVENT_BATTLE_END was here, but this timing does not exist in Master Rule 3
core.units.begin()->arg1 = 1;
return FALSE; return FALSE;
} }
case 31: { case 31: {
core.units.begin()->arg1 = 1;
core.flip_delayed = FALSE; core.flip_delayed = FALSE;
core.new_fchain.splice(core.new_fchain.begin(), core.new_fchain_b); core.new_fchain.splice(core.new_fchain.begin(), core.new_fchain_b);
core.new_ochain.splice(core.new_ochain.begin(), core.new_ochain_b); core.new_ochain.splice(core.new_ochain.begin(), core.new_ochain_b);
...@@ -3531,21 +3548,6 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3531,21 +3548,6 @@ int32 field::process_battle_command(uint16 step) {
return FALSE; return FALSE;
} }
case 32: { case 32: {
group* des = core.units.begin()->ptarget;
if(core.battle_destroy_rep.size())
destroy(&core.battle_destroy_rep, 0, REASON_EFFECT, PLAYER_NONE);
if(core.desrep_chain.size())
add_process(PROCESSOR_OPERATION_REPLACE, 15, 0, 0, 0, 0);
if(des) {
card_set::iterator cit, rm;
for(cit = des->container.begin(); cit != des->container.end();) {
rm = cit++;
if((*rm)->current.location != LOCATION_MZONE || ((*rm)->fieldid_r != core.pre_field[0] && (*rm)->fieldid_r != core.pre_field[1]))
des->container.erase(rm);
}
add_process(PROCESSOR_DESTROY, 3, 0, des, REASON_BATTLE, PLAYER_NONE);
}
adjust_all();
return FALSE; return FALSE;
} }
case 33: { case 33: {
......
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