Commit 76f9331c authored by salix5's avatar salix5

Duel.CalculateDamage()

Now the attack target can be null. (for c93599951)
parent b219de78
...@@ -1264,9 +1264,14 @@ int32 scriptlib::duel_calculate_damage(lua_State *L) { ...@@ -1264,9 +1264,14 @@ int32 scriptlib::duel_calculate_damage(lua_State *L) {
check_action_permission(L); check_action_permission(L);
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2);
card* attacker = *(card**)lua_touserdata(L, 1); card* attacker = *(card**)lua_touserdata(L, 1);
card* attack_target = *(card**)lua_touserdata(L, 2); card* attack_target;
if(lua_isnil(L, 2))
attack_target = NULL;
else {
check_param(L, PARAM_TYPE_CARD, 2);
attack_target = *(card**)lua_touserdata(L, 2);
}
int32 new_attack = FALSE; int32 new_attack = FALSE;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
new_attack = lua_toboolean(L, 3); new_attack = lua_toboolean(L, 3);
......
...@@ -3672,7 +3672,7 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) { ...@@ -3672,7 +3672,7 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
core.attack_target = (card*)core.units.begin()->ptarget; core.attack_target = (card*)core.units.begin()->ptarget;
core.units.begin()->ptarget = (group*)tmp; core.units.begin()->ptarget = (group*)tmp;
core.units.begin()->arg1 = infos.phase; core.units.begin()->arg1 = infos.phase;
if(core.attacker->current.location != LOCATION_MZONE || core.attack_target->current.location != LOCATION_MZONE) { if(core.attacker->current.location != LOCATION_MZONE || core.attack_target && core.attack_target->current.location != LOCATION_MZONE) {
core.units.begin()->step = 2; core.units.begin()->step = 2;
return FALSE; return FALSE;
} }
...@@ -3684,19 +3684,23 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) { ...@@ -3684,19 +3684,23 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
attack_all_target_check(); attack_all_target_check();
pduel->write_buffer8(MSG_ATTACK); pduel->write_buffer8(MSG_ATTACK);
pduel->write_buffer32(core.attacker->get_info_location()); pduel->write_buffer32(core.attacker->get_info_location());
pduel->write_buffer32(core.attack_target->get_info_location()); if(core.attack_target)
pduel->write_buffer32(core.attack_target->get_info_location());
else
pduel->write_buffer32(0);
infos.phase = PHASE_DAMAGE; infos.phase = PHASE_DAMAGE;
pduel->write_buffer8(MSG_DAMAGE_STEP_START); pduel->write_buffer8(MSG_DAMAGE_STEP_START);
core.pre_field[0] = core.attacker->fieldid_r; core.pre_field[0] = core.attacker->fieldid_r;
core.attacker->attacked_count++; core.attacker->attacked_count++;
if(core.attack_target) if(core.attack_target) {
core.pre_field[1] = core.attack_target->fieldid_r; core.pre_field[1] = core.attack_target->fieldid_r;
if(core.attack_target->is_position(POS_FACEDOWN)) {
change_position(core.attack_target, 0, PLAYER_NONE, core.attack_target->current.position >> 1, 0, TRUE);
adjust_all();
}
}
else else
core.pre_field[1] = 0; core.pre_field[1] = 0;
if(core.attack_target->is_position(POS_FACEDOWN)) {
change_position(core.attack_target, 0, PLAYER_NONE, core.attack_target->current.position >> 1, 0, TRUE);
adjust_all();
}
return FALSE; return FALSE;
} }
case 1: { case 1: {
......
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