Commit 3fc1ec0d authored by mercury233's avatar mercury233
parents 6e14677a 82cc1830
......@@ -818,9 +818,12 @@ int32 scriptlib::duel_raise_event(lua_State *L) {
pduel = pgroup->pduel;
} else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
check_param(L, PARAM_TYPE_EFFECT, 3);
uint32 code = lua_tointeger(L, 2);
effect* peffect = *(effect**) lua_touserdata(L, 3);
effect* peffect = 0;
if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_EFFECT, 3);
peffect = *(effect**)lua_touserdata(L, 3);
}
uint32 r = lua_tointeger(L, 4);
uint32 rp = lua_tointeger(L, 5);
uint32 ep = lua_tointeger(L, 6);
......@@ -836,10 +839,13 @@ int32 scriptlib::duel_raise_single_event(lua_State *L) {
check_action_permission(L);
check_param_count(L, 7);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_EFFECT, 3);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 code = lua_tointeger(L, 2);
effect* peffect = *(effect**) lua_touserdata(L, 3);
effect* peffect = 0;
if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_EFFECT, 3);
peffect = *(effect**)lua_touserdata(L, 3);
}
uint32 r = lua_tointeger(L, 4);
uint32 rp = lua_tointeger(L, 5);
uint32 ep = lua_tointeger(L, 6);
......@@ -1264,9 +1270,14 @@ int32 scriptlib::duel_calculate_damage(lua_State *L) {
check_action_permission(L);
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2);
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;
if(lua_gettop(L) >= 3)
new_attack = lua_toboolean(L, 3);
......
......@@ -3672,7 +3672,7 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
core.attack_target = (card*)core.units.begin()->ptarget;
core.units.begin()->ptarget = (group*)tmp;
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;
return FALSE;
}
......@@ -3684,19 +3684,23 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
attack_all_target_check();
pduel->write_buffer8(MSG_ATTACK);
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;
pduel->write_buffer8(MSG_DAMAGE_STEP_START);
core.pre_field[0] = core.attacker->fieldid_r;
core.attacker->attacked_count++;
if(core.attack_target)
if(core.attack_target) {
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
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;
}
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