Commit 5298ad05 authored by VanillaSalt's avatar VanillaSalt

update

parent fa74957a
......@@ -234,6 +234,7 @@ int32 scriptlib::duel_special_summon_rule(lua_State *L) {
return 0;
card* pcard = *(card**)lua_touserdata(L, 2);
duel * pduel = pcard->pduel;
pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, 0);
return lua_yield(L, 0);
}
......@@ -260,6 +261,7 @@ int32 scriptlib::duel_synchro_summon(lua_State *L) {
duel * pduel = pcard->pduel;
pduel->game_field->core.limit_tuner = tuner;
pduel->game_field->core.limit_syn = mg;
pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_SYNCHRO);
return lua_yield(L, 0);
}
......@@ -278,6 +280,7 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) {
}
duel * pduel = pcard->pduel;
pduel->game_field->core.limit_xyz = materials;
pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ);
return lua_yield(L, 0);
}
......
......@@ -2052,27 +2052,6 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
core.limit_syn = syn;
if(!eset.size())
return TRUE;
eset.clear();
target->filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
}
}
return FALSE;
}
case 1: {
effect_set eset;
target->material_cards.clear();
card* tuner = core.limit_tuner;
group* materials = core.limit_xyz;
group* syn = core.limit_syn;
target->filter_spsummon_procedure(sumplayer, &eset, summon_type);
target->filter_spsummon_procedure_g(sumplayer, &eset);
core.limit_tuner = tuner;
core.limit_xyz = materials;
core.limit_syn = syn;
core.select_effects.clear();
core.select_options.clear();
for(int32 i = 0; i < eset.size(); ++i) {
......@@ -2085,13 +2064,43 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, sumplayer, 0);
return FALSE;
}
case 2: {
case 1: {
effect* peffect = core.select_effects[returns.ivalue[0]];
core.units.begin()->peffect = peffect;
if(peffect->code == EFFECT_SPSUMMON_PROC_G) {
core.units.begin()->step = 19;
return FALSE;
}
returns.ivalue[0] = TRUE;
if(peffect->target) {
pduel->lua->add_param(target, PARAM_TYPE_CARD);
if(core.limit_tuner || core.limit_syn) {
pduel->lua->add_param(core.limit_tuner, PARAM_TYPE_CARD);
pduel->lua->add_param(core.limit_syn, PARAM_TYPE_GROUP);
} else if(core.limit_xyz) {
pduel->lua->add_param(core.limit_xyz, PARAM_TYPE_GROUP);
}
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_TARGET, 0, peffect, 0, sumplayer, 0);
}
return FALSE;
}
case 2: {
if(!returns.ivalue[0])
return TRUE;
effect_set eset;
target->filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
}
}
return FALSE;
}
case 3: {
effect* peffect = core.units.begin()->peffect;
target->material_cards.clear();
target->summon_info = (peffect->get_value(target) & 0xf00ffff) | SUMMON_TYPE_SPECIAL | ((uint32)target->current.location << 16);
if(peffect->operation) {
pduel->lua->add_param(target, PARAM_TYPE_CARD);
......@@ -2111,7 +2120,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
peffect->dec_count(sumplayer);
return FALSE;
}
case 3: {
case 4: {
effect* peffect = core.units.begin()->peffect;
uint8 targetplayer = sumplayer;
uint8 positions = POS_FACEUP;
......@@ -2137,7 +2146,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
break_effect();
return FALSE;
}
case 4: {
case 5: {
uint8 targetplayer = target->current.controler;
if(target->owner != targetplayer)
set_control(target, targetplayer, 0, 0);
......@@ -2152,7 +2161,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
pduel->write_buffer8(target->current.position);
return FALSE;
}
case 5: {
case 6: {
effect* proc = core.units.begin()->peffect;
int32 matreason = proc->value == SUMMON_TYPE_SYNCHRO ? REASON_SYNCHRO : proc->value == SUMMON_TYPE_XYZ ? REASON_XYZ : REASON_SPSUMMON;
if (target->material_cards.size()) {
......@@ -2164,7 +2173,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
process_instant_event();
return FALSE;
}
case 6: {
case 7: {
if (core.current_chain.size() == 0) {
if (target->is_affected_by_effect(EFFECT_CANNOT_DISABLE_SPSUMMON))
core.units.begin()->step = 14;
......@@ -4105,7 +4114,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(playerid);
pduel->write_buffer32(512);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid, 0x10001);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + ((uint32)core.summon_cancelable << 16), 0x10001);
return FALSE;
}
}
......@@ -4129,10 +4138,16 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(playerid);
pduel->write_buffer32(512);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid, 0x10001);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + ((uint32)core.summon_cancelable << 16), 0x10001);
return FALSE;
}
case 1: {
if(returns.ivalue[0] == -1) {
lua_pop(pduel->lua->current_state, 2);
pduel->lua->add_param((void*)0, PARAM_TYPE_GROUP);
core.limit_tuner = 0;
return TRUE;
}
card* tuner = core.select_cards[returns.bvalue[1]];
effect* pcheck = tuner->is_affected_by_effect(EFFECT_SYNCHRO_CHECK);
if(pcheck)
......@@ -4348,12 +4363,16 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(playerid);
pduel->write_buffer32(513);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid, min + (max << 16));
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + ((uint32)core.summon_cancelable << 16), min + (max << 16));
} else
core.units.begin()->step = 1;
return FALSE;
}
case 1: {
if(returns.ivalue[0] == -1) {
pduel->lua->add_param((void*)0, PARAM_TYPE_GROUP);
return TRUE;
}
group* pgroup = pduel->new_group();
for(int32 i = 0; i < returns.bvalue[0]; ++i) {
card* pcard = core.select_cards[returns.bvalue[i + 1]];
......@@ -4371,10 +4390,14 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(playerid);
pduel->write_buffer32(513);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid, min + (min << 16));
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + ((uint32)core.summon_cancelable << 16), min + (min << 16));
return FALSE;
}
case 3: {
if(returns.ivalue[0] == -1) {
pduel->lua->add_param((void*)0, PARAM_TYPE_GROUP);
return TRUE;
}
int32 pv = 0;
for(int32 i = 0; i < returns.bvalue[0]; ++i) {
card* pcard = core.select_cards[returns.bvalue[i + 1]];
......
......@@ -2752,6 +2752,7 @@ int32 field::process_idle_command(uint16 step) {
}
case 6: {
card* target = core.spsummonable_cards[returns.ivalue[0] >> 16];
core.summon_cancelable = TRUE;
special_summon_rule(infos.turn_player, target, 0);
core.units.begin()->step = -1;
return FALSE;
......
......@@ -120,6 +120,7 @@ function Auxiliary.AddSynchroProcedure(c,f1,f2,ct)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(Auxiliary.SynCondition(f1,f2,ct,99))
e1:SetTarget(Auxiliary.SynTarget(f1,f2,ct,99))
e1:SetOperation(Auxiliary.SynOperation(f1,f2,ct,99))
e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1)
......@@ -138,8 +139,8 @@ function Auxiliary.SynCondition(f1,f2,minct,maxc)
return Duel.CheckSynchroMaterial(c,f1,f2,minc,maxc,smat,mg)
end
end
function Auxiliary.SynOperation(f1,f2,minct,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,c,smat,mg)
function Auxiliary.SynTarget(f1,f2,minct,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,smat,mg)
local g=nil
local ft=Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)
local ct=-ft
......@@ -150,8 +151,19 @@ function Auxiliary.SynOperation(f1,f2,minct,maxc)
else
g=Duel.SelectSynchroMaterial(c:GetControler(),c,f1,f2,minc,maxc,smat,mg)
end
if g then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
end
function Auxiliary.SynOperation(f1,f2,minct,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,c,smat,mg)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
g:DeleteGroup()
end
end
--Synchro monster, 1 tuner + 1 monster
......@@ -162,6 +174,7 @@ function Auxiliary.AddSynchroProcedure2(c,f1,f2)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(Auxiliary.SynCondition(f1,f2,1,1))
e1:SetTarget(Auxiliary.SynTarget(f1,f2,1,1))
e1:SetOperation(Auxiliary.SynOperation(f1,f2,1,1))
e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1)
......@@ -190,9 +203,11 @@ function Auxiliary.AddXyzProcedure(c,f,lv,ct,alterf,desc,maxct,op)
if not maxct then maxct=ct end
if alterf then
e1:SetCondition(Auxiliary.XyzCondition2(f,lv,ct,maxct,alterf,desc,op))
e1:SetTarget(Auxiliary.XyzTarget2(f,lv,ct,maxct,alterf,desc,op))
e1:SetOperation(Auxiliary.XyzOperation2(f,lv,ct,maxct,alterf,desc,op))
else
e1:SetCondition(Auxiliary.XyzCondition(f,lv,ct,maxct))
e1:SetTarget(Auxiliary.XyzTarget(f,lv,ct,maxct))
e1:SetOperation(Auxiliary.XyzOperation(f,lv,ct,maxct))
end
e1:SetValue(SUMMON_TYPE_XYZ)
......@@ -210,6 +225,20 @@ function Auxiliary.XyzCondition(f,lv,minc,maxc)
return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
end
end
function Auxiliary.XyzTarget(f,lv,minc,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og)
if og then
return true
else
local g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc)
if g then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
end
end
function Auxiliary.XyzOperation(f,lv,minc,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,c,og)
if og then
......@@ -224,7 +253,7 @@ function Auxiliary.XyzOperation(f,lv,minc,maxc)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local mg=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc)
local mg=e:GetLabelObject()
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
......@@ -235,6 +264,7 @@ function Auxiliary.XyzOperation(f,lv,minc,maxc)
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
end
end
......@@ -254,6 +284,31 @@ function Auxiliary.XyzCondition2(f,lv,minc,maxc,alterf,desc,op)
return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
end
end
function Auxiliary.XyzTarget2(f,lv,minc,maxc,alterf,desc,op)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og)
if og then
return true
else
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ct=-ft
local b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
local b2=ct<1 and Duel.IsExistingMatchingCard(Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,nil,alterf,c)
and (not op or op(e,tp,0))
if b2 and (not b1 or Duel.SelectYesNo(tp,desc)) then
e:SetLabel(1)
return true
else
e:SetLabel(0)
local g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc)
if g then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
end
end
end
function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op)
return function(e,tp,eg,ep,ev,re,r,rp,c,og)
if og then
......@@ -268,12 +323,7 @@ function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ct=-ft
local b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
local b2=ct<1 and Duel.IsExistingMatchingCard(Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,nil,alterf,c)
and (not op or op(e,tp,0))
if b2 and (not b1 or Duel.SelectYesNo(tp,desc)) then
if e:GetLabel()==1 then
if op then op(e,tp,1) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local mg=Duel.SelectMatchingCard(tp,Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,1,nil,alterf,c)
......@@ -284,7 +334,7 @@ function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op)
c:SetMaterial(mg)
Duel.Overlay(c,mg)
else
local mg=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc)
local mg=e:GetLabelObject()
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
......@@ -295,6 +345,7 @@ function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op)
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
end
end
......
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