Commit 4dfc0d2e authored by VanillaSalt's avatar VanillaSalt

fix

parent 47530d68
...@@ -2058,13 +2058,11 @@ int32 scriptlib::duel_select_synchro_material(lua_State *L) { ...@@ -2058,13 +2058,11 @@ int32 scriptlib::duel_select_synchro_material(lua_State *L) {
int32 max = lua_tointeger(L, 6); int32 max = lua_tointeger(L, 6);
card* smat = 0; card* smat = 0;
group* mg = 0; group* mg = 0;
if(lua_gettop(L) >= 7) { if(lua_gettop(L) >= 7 && !lua_isnil(L, 7)) {
if(!lua_isnil(L, 7))
check_param(L, PARAM_TYPE_CARD, 7); check_param(L, PARAM_TYPE_CARD, 7);
smat = *(card**) lua_touserdata(L, 7); smat = *(card**) lua_touserdata(L, 7);
} }
if(lua_gettop(L) >= 8) { if(lua_gettop(L) >= 8 && !lua_isnil(L, 8)) {
if(!lua_isnil(L, 8))
check_param(L, PARAM_TYPE_GROUP, 8); check_param(L, PARAM_TYPE_GROUP, 8);
mg = *(group**) lua_touserdata(L, 8); mg = *(group**) lua_touserdata(L, 8);
} }
...@@ -2089,13 +2087,11 @@ int32 scriptlib::duel_check_synchro_material(lua_State *L) { ...@@ -2089,13 +2087,11 @@ int32 scriptlib::duel_check_synchro_material(lua_State *L) {
int32 max = lua_tointeger(L, 5); int32 max = lua_tointeger(L, 5);
card* smat = 0; card* smat = 0;
group* mg = 0; group* mg = 0;
if(lua_gettop(L) >= 6) { if(lua_gettop(L) >= 6 && !lua_isnil(L, 6)) {
if(!lua_isnil(L, 6))
check_param(L, PARAM_TYPE_CARD, 6); check_param(L, PARAM_TYPE_CARD, 6);
smat = *(card**) lua_touserdata(L, 6); smat = *(card**) lua_touserdata(L, 6);
} }
if(lua_gettop(L) >= 7) { if(lua_gettop(L) >= 7 && !lua_isnil(L, 7)) {
if(!lua_isnil(L, 7))
check_param(L, PARAM_TYPE_GROUP, 7); check_param(L, PARAM_TYPE_GROUP, 7);
mg = *(group**) lua_touserdata(L, 7); mg = *(group**) lua_touserdata(L, 7);
} }
...@@ -2119,8 +2115,7 @@ int32 scriptlib::duel_select_tuner_material(lua_State *L) { ...@@ -2119,8 +2115,7 @@ int32 scriptlib::duel_select_tuner_material(lua_State *L) {
int32 min = lua_tointeger(L, 6); int32 min = lua_tointeger(L, 6);
int32 max = lua_tointeger(L, 7); int32 max = lua_tointeger(L, 7);
group* mg = 0; group* mg = 0;
if(lua_gettop(L) >= 8) { if(lua_gettop(L) >= 8 && !lua_isnil(L, 8)) {
if(!lua_isnil(L, 8))
check_param(L, PARAM_TYPE_GROUP, 8); check_param(L, PARAM_TYPE_GROUP, 8);
mg = *(group**) lua_touserdata(L, 8); mg = *(group**) lua_touserdata(L, 8);
} }
...@@ -2156,8 +2151,7 @@ int32 scriptlib::duel_check_tuner_material(lua_State *L) { ...@@ -2156,8 +2151,7 @@ int32 scriptlib::duel_check_tuner_material(lua_State *L) {
int32 min = lua_tointeger(L, 5); int32 min = lua_tointeger(L, 5);
int32 max = lua_tointeger(L, 6); int32 max = lua_tointeger(L, 6);
group* mg = 0; group* mg = 0;
if(lua_gettop(L) >= 7) { if(lua_gettop(L) >= 7 && !lua_isnil(L, 7)) {
if(!lua_isnil(L, 7))
check_param(L, PARAM_TYPE_GROUP, 7); check_param(L, PARAM_TYPE_GROUP, 7);
mg = *(group**) lua_touserdata(L, 7); mg = *(group**) lua_touserdata(L, 7);
} }
......
...@@ -3836,7 +3836,10 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -3836,7 +3836,10 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
} }
case 1: { case 1: {
card* tuner = core.select_cards[returns.bvalue[1]]; card* tuner = core.select_cards[returns.bvalue[1]];
core.units.begin()->ptarget = (group*)tuner; effect* pcheck = tuner->is_affected_by_effect(EFFECT_SYNCHRO_CHECK);
if(pcheck)
pcheck->get_value(tuner);
core.limit_tuner = tuner;
effect* peffect; effect* peffect;
if((peffect = tuner->is_affected_by_effect(EFFECT_SYNCHRO_MATERIAL_CUSTOM, pcard))) { if((peffect = tuner->is_affected_by_effect(EFFECT_SYNCHRO_MATERIAL_CUSTOM, pcard))) {
if(!peffect->operation) if(!peffect->operation)
...@@ -3857,24 +3860,23 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -3857,24 +3860,23 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
lua_pop(pduel->lua->current_state, 2); lua_pop(pduel->lua->current_state, 2);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pgroup->container = core.synchro_materials; pgroup->container = core.synchro_materials;
pgroup->container.insert((card*)core.units.begin()->ptarget); pgroup->container.insert(core.limit_tuner);
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
pduel->restore_assumes(); pduel->restore_assumes();
core.limit_tuner = 0;
return TRUE; return TRUE;
} }
case 3: { case 3: {
card* tuner = (card*)core.units.begin()->ptarget; if(!smat) {
effect* pcheck = tuner->is_affected_by_effect(EFFECT_SYNCHRO_CHECK); returns.ivalue[0] = TRUE;
if(pcheck) return FALSE;
pcheck->get_value(tuner); }
card* tuner = core.limit_tuner;
int32 l = tuner->get_synchro_level(pcard); int32 l = tuner->get_synchro_level(pcard);
int32 l1 = l & 0xffff; int32 l1 = l & 0xffff;
//int32 l2 = l >> 16; //int32 l2 = l >> 16;
int32 lv = pcard->get_level(); int32 lv = pcard->get_level();
lv -= l1; lv -= l1;
if(smat) {
if(pcheck)
pcheck->get_value(smat);
l = smat->get_synchro_level(pcard); l = smat->get_synchro_level(pcard);
l1 = l & 0xffff; l1 = l & 0xffff;
lv -= l1; lv -= l1;
...@@ -3887,8 +3889,6 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -3887,8 +3889,6 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, playerid, 210); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, playerid, 210);
} else } else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
} else
returns.ivalue[0] = TRUE;
return FALSE; return FALSE;
} }
case 4: { case 4: {
...@@ -3896,7 +3896,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -3896,7 +3896,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
core.units.begin()->step = 5; core.units.begin()->step = 5;
return FALSE; return FALSE;
} }
card* tuner = (card*)core.units.begin()->ptarget; card* tuner = core.limit_tuner;
effect* pcheck = tuner->is_affected_by_effect(EFFECT_SYNCHRO_CHECK); effect* pcheck = tuner->is_affected_by_effect(EFFECT_SYNCHRO_CHECK);
int32 l = tuner->get_synchro_level(pcard); int32 l = tuner->get_synchro_level(pcard);
int32 l1 = l & 0xffff; int32 l1 = l & 0xffff;
...@@ -3939,20 +3939,22 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -3939,20 +3939,22 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
pcard = core.select_cards[returns.bvalue[i + 1]]; pcard = core.select_cards[returns.bvalue[i + 1]];
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
pgroup->container.insert((card*)core.units.begin()->ptarget); pgroup->container.insert(core.limit_tuner);
if(smat) if(smat)
pgroup->container.insert(smat); pgroup->container.insert(smat);
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
pduel->restore_assumes(); pduel->restore_assumes();
core.limit_tuner = 0;
return TRUE; return TRUE;
} }
case 6: { case 6: {
lua_pop(pduel->lua->current_state, 2); lua_pop(pduel->lua->current_state, 2);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pgroup->container.insert((card*)core.units.begin()->ptarget); pgroup->container.insert(core.limit_tuner);
pgroup->container.insert(smat); pgroup->container.insert(smat);
pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP); pduel->lua->add_param(pgroup, PARAM_TYPE_GROUP);
pduel->restore_assumes(); pduel->restore_assumes();
core.limit_tuner = 0;
return TRUE; return TRUE;
} }
} }
......
...@@ -765,7 +765,7 @@ int32 field::process() { ...@@ -765,7 +765,7 @@ int32 field::process() {
return pduel->bufferlen; return pduel->bufferlen;
} }
case PROCESSOR_SELECT_SYNCHRO: { case PROCESSOR_SELECT_SYNCHRO: {
int32 ret = 0; int32 ret = TRUE;
if(!(it->arg1 >> 16)) if(!(it->arg1 >> 16))
ret = select_synchro_material(it->step, it->arg1 & 0xffff, (card*)it->ptarget, it->arg2 & 0xffff, it->arg2 >> 16, 0, (group*)it->peffect); ret = select_synchro_material(it->step, it->arg1 & 0xffff, (card*)it->ptarget, it->arg2 & 0xffff, it->arg2 >> 16, 0, (group*)it->peffect);
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