From fc9338cb2203a5e440de079e6debcede1ec47868 Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Fri, 2 Feb 2024 14:01:42 +0900 Subject: [PATCH 1/6] add Duel.IsSummonInChain --- field.h | 1 + libduel.cpp | 9 +++++++++ operations.cpp | 16 +++++++++++++--- scriptlib.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/field.h b/field.h index e58ab3890..f105557b7 100644 --- a/field.h +++ b/field.h @@ -304,6 +304,7 @@ struct processor { uint8 coin_result[MAX_COIN_COUNT]{}; int32 coin_count{ 0 }; bool is_target_ready{ false }; + uint32 summon_action_type{ SUMMON_IN_IDLE }; uint8 to_bp{ FALSE }; uint8 to_m2{ FALSE }; diff --git a/libduel.cpp b/libduel.cpp index 29ea9a949..600e070e0 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -3630,6 +3630,14 @@ int32 scriptlib::duel_remove_overlay_card(lua_State *L) { return 1; }); } +int32 scriptlib::duel_is_summon_in_chain(lua_State *L) { + duel* pduel = interpreter::get_duel_info(L); + if(pduel->game_field->core.summon_action_type == SUMMON_IN_CHAIN) + lua_pushboolean(L, 1); + else + lua_pushboolean(L, 0); + return 1; +} int32 scriptlib::duel_hint(lua_State * L) { check_param_count(L, 3); int32 htype = (int32)lua_tointeger(L, 1); @@ -4893,6 +4901,7 @@ static const struct luaL_Reg duellib[] = { { "GetOverlayCount", scriptlib::duel_get_overlay_count }, { "CheckRemoveOverlayCard", scriptlib::duel_check_remove_overlay_card }, { "RemoveOverlayCard", scriptlib::duel_remove_overlay_card }, + { "IsSummonInChain", scriptlib::duel_is_summon_in_chain }, { "Hint", scriptlib::duel_hint }, { "HintSelection", scriptlib::duel_hint_selection }, { "SelectEffectYesNo", scriptlib::duel_select_effect_yesno }, diff --git a/operations.cpp b/operations.cpp index e496f3d99..52038209b 100644 --- a/operations.cpp +++ b/operations.cpp @@ -2668,6 +2668,7 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uint32 summon_type, uint32 action_type) { switch(step) { case 0: { + core.summon_action_type = action_type; effect_set eset; material_info info; info.limit_tuner = core.limit_tuner; @@ -2683,8 +2684,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin info.limit_link_maxc = core.limit_link_maxc; target->filter_spsummon_procedure(sumplayer, &eset, summon_type, info); target->filter_spsummon_procedure_g(sumplayer, &eset); - if(!eset.size()) + if(!eset.size()) { + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; + } core.select_effects.clear(); core.select_options.clear(); for(int32 i = 0; i < eset.size(); ++i) { @@ -2734,8 +2737,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin return FALSE; } case 2: { - if(!returns.ivalue[0]) + if(!returns.ivalue[0]) { + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; + } effect_set eset; target->filter_effect(EFFECT_SPSUMMON_COST, &eset); if(eset.size()) { @@ -2954,6 +2959,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin core.hint_timing[sumplayer] |= TIMING_SPSUMMON; add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0); } + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; } case 20: { @@ -2999,8 +3005,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin } case 22: { group* pgroup = core.units.begin()->ptarget; - if(pgroup->container.size() == 0) + if(pgroup->container.size() == 0) { + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; + } core.phase_action = TRUE; pgroup->it = pgroup->container.begin(); return FALSE; @@ -3104,6 +3112,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin core.units.begin()->ptr1 = 0; } add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0); + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; } return FALSE; @@ -3156,6 +3165,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin core.hint_timing[sumplayer] |= TIMING_SPSUMMON; add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, FALSE, 0); } + core.summon_action_type = SUMMON_IN_IDLE; return TRUE; } } diff --git a/scriptlib.h b/scriptlib.h index 324643da6..4b3826fc7 100644 --- a/scriptlib.h +++ b/scriptlib.h @@ -565,6 +565,7 @@ class scriptlib { static int32 duel_get_overlay_count(lua_State *L); static int32 duel_check_remove_overlay_card(lua_State *L); static int32 duel_remove_overlay_card(lua_State *L); + static int32 duel_is_summon_in_chain(lua_State *L); static int32 duel_hint(lua_State *L); static int32 duel_hint_selection(lua_State *L); From a77c396f023a371e7b88c523dfed16125ead5a1e Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Fri, 2 Feb 2024 14:05:27 +0900 Subject: [PATCH 2/6] add Duel.IsPlayerCanPendulumSummon, Duel.PendulumSummon --- card.cpp | 38 ++++++++++++++++++++++++++++++++++-- card.h | 3 ++- field.cpp | 8 ++++++++ field.h | 4 ++++ libduel.cpp | 37 +++++++++++++++++++++++++++++++++++ operations.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- processor.cpp | 7 +++++++ scriptlib.h | 2 ++ 8 files changed, 147 insertions(+), 4 deletions(-) diff --git a/card.cpp b/card.cpp index 0a6180cc2..0d2ff5782 100644 --- a/card.cpp +++ b/card.cpp @@ -2989,7 +2989,7 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s } } } -void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset) { +void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset, group* mg) { auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC_G); for(auto eit = pr.first; eit != pr.second;) { effect* peffect = eit->second; @@ -3005,7 +3005,8 @@ void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset) { pduel->game_field->save_lp_cost(); pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_CARD); - if(pduel->lua->check_condition(peffect->condition, 2)) + pduel->lua->add_param(mg, PARAM_TYPE_GROUP); + if(pduel->lua->check_condition(peffect->condition, 3)) peset->add_item(peffect); pduel->game_field->restore_lp_cost(); pduel->game_field->core.reason_effect = oreason; @@ -3215,6 +3216,39 @@ int32 card::is_tuner(card* scard) { return TRUE; return FALSE; } +int32 card::is_pendulum_summon(uint8 playerid, group* mg) { + uint32 acttype = pduel->game_field->core.summon_action_type; + pduel->game_field->core.summon_action_type = SUMMON_IN_CHAIN; + auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC_G); + for(auto eit = pr.first; eit != pr.second;) { + effect* peffect = eit->second; + ++eit; + if(!peffect->is_available() || !peffect->check_count_limit(playerid)) + continue; + if(current.controler != playerid && !peffect->is_flag(EFFECT_FLAG_BOTH_SIDE)) + continue; + effect* oreason = pduel->game_field->core.reason_effect; + uint8 op = pduel->game_field->core.reason_player; + pduel->game_field->core.reason_effect = peffect; + pduel->game_field->core.reason_player = this->current.controler; + pduel->game_field->save_lp_cost(); + pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT); + pduel->lua->add_param(this, PARAM_TYPE_CARD); + pduel->lua->add_param(mg, PARAM_TYPE_GROUP); + if(pduel->lua->check_condition(peffect->condition, 3)) { + pduel->game_field->restore_lp_cost(); + pduel->game_field->core.reason_effect = oreason; + pduel->game_field->core.reason_player = op; + pduel->game_field->core.summon_action_type = acttype; + return TRUE; + } + pduel->game_field->restore_lp_cost(); + pduel->game_field->core.reason_effect = oreason; + pduel->game_field->core.reason_player = op; + } + pduel->game_field->core.summon_action_type = acttype; + return FALSE; +} int32 card::check_unique_code(card* pcard) { if(!unique_code) return FALSE; diff --git a/card.h b/card.h index 3b6f1a08d..215978fa2 100644 --- a/card.h +++ b/card.h @@ -322,7 +322,7 @@ class card { int32 filter_set_procedure(uint8 playerid, effect_set* eset, uint8 ignore_count, uint8 min_tribute, uint32 zone); int32 check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count, uint8 min_tribute, uint32 zone); void filter_spsummon_procedure(uint8 playerid, effect_set* eset, uint32 summon_type, material_info info = null_info); - void filter_spsummon_procedure_g(uint8 playerid, effect_set* eset); + void filter_spsummon_procedure_g(uint8 playerid, effect_set* eset, group* mg); effect* is_affected_by_effect(int32 code); effect* is_affected_by_effect(int32 code, card* target); int32 fusion_check(group* fusion_m, card* cg, uint32 chkf, uint8 not_material); @@ -330,6 +330,7 @@ class card { int32 check_fusion_substitute(card* fcard); int32 is_not_tuner(card* scard); int32 is_tuner(card* scard); + int32 is_pendulum_summon(uint8 playerid, group* mg); int32 check_unique_code(card* pcard); void get_unique_target(card_set* cset, int32 controler, card* icard = nullptr); diff --git a/field.cpp b/field.cpp index 4aea6128c..55befc614 100644 --- a/field.cpp +++ b/field.cpp @@ -3271,6 +3271,14 @@ int32 field::is_player_can_spsummon_count(uint8 playerid, uint32 count) { } return check_spsummon_counter(playerid, count); } +int32 field::is_player_can_pendulum_summon(uint8 playerid, group* mg) { + for(uint8 p = 0; p < 2; ++p) { + for(auto& pcard : player[p].list_szone) + if(pcard && pcard->current.pzone && pcard->is_pendulum_summon(playerid, mg)) + return TRUE; + } + return FALSE; +} int32 field::is_player_can_place_counter(uint8 playerid, card * pcard, uint16 countertype, uint16 count) { effect_set eset; filter_player_effect(playerid, EFFECT_CANNOT_PLACE_COUNTER, &eset); diff --git a/field.h b/field.h index f105557b7..5966bc75c 100644 --- a/field.h +++ b/field.h @@ -285,6 +285,7 @@ struct processor { card* limit_link_card{ nullptr }; int32 limit_link_minc{ 0 }; int32 limit_link_maxc{ 0 }; + group* limit_pendulum{ nullptr }; uint8 not_material{ FALSE }; uint8 attack_cancelable{ FALSE }; uint8 attack_rollback{ FALSE }; @@ -485,6 +486,7 @@ class field { int32 is_player_can_flipsummon(uint8 playerid, card* pcard); int32 is_player_can_spsummon_monster(uint8 playerid, uint8 toplayer, uint8 sumpos, uint32 sumtype, card_data* pdata); int32 is_player_can_spsummon_count(uint8 playerid, uint32 count); + int32 is_player_can_pendulum_summon(uint8 playerid, group* mg); int32 is_player_can_release(uint8 playerid, card* pcard, uint32 reason); int32 is_player_can_place_counter(uint8 playerid, card* pcard, uint16 countertype, uint16 count); int32 is_player_can_remove_counter(uint8 playerid, card* pcard, uint8 s, uint8 o, uint16 countertype, uint16 count, uint32 reason); @@ -595,6 +597,7 @@ class field { int32 sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget, uint8 confirm, effect* reason_effect); int32 special_summon_step(uint16 step, group* targets, card* target, uint32 zone); int32 special_summon(uint16 step, effect* reason_effect, uint8 reason_player, group* targets, uint32 zone); + int32 pendulum_summon(uint16 step, uint8 playerid, group* mg); int32 destroy_replace(uint16 step, group* targets, card* target, uint8 battle); int32 destroy(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player); int32 release_replace(uint16 step, group* targets, card* target); @@ -764,6 +767,7 @@ class field { #define PROCESSOR_SSET 65 #define PROCESSOR_SPSUMMON_STEP 66 #define PROCESSOR_SSET_G 67 +#define PROCESSOR_PENDULUM_SUMMON 68 #define PROCESSOR_DRAW 70 #define PROCESSOR_DAMAGE 71 //arg1: arguments, arg2: arguments, arg3: arguments #define PROCESSOR_RECOVER 72 //arg1: arguments, arg2: arguments, arg3: arguments diff --git a/libduel.cpp b/libduel.cpp index 600e070e0..d14a9ac70 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -422,6 +422,25 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) { } return lua_yield(L, 0); } +int32 scriptlib::duel_pendulum_summon(lua_State *L) { + check_action_permission(L); + check_param_count(L, 2); + uint32 playerid = (uint32)lua_tointeger(L, 1); + if(playerid != 0 && playerid != 1) + return 0; + duel* pduel = interpreter::get_duel_info(L); + if(pduel->game_field->core.effect_damage_step) + return 0; + group* pendulum_group = nullptr; + if(!lua_isnil(L, 2)) { + check_param(L, PARAM_TYPE_GROUP, 2); + group* pgroup = *(group**)lua_touserdata(L, 2); + pendulum_group = pduel->new_group(pgroup->container); + pendulum_group->is_readonly = 1; + } + pduel->game_field->add_process(PROCESSOR_PENDULUM_SUMMON, 0, NULL, pendulum_group, playerid, 0); + return lua_yield(L, 0); +} int32 scriptlib::duel_link_summon(lua_State *L) { check_action_permission(L); check_param_count(L, 3); @@ -4355,6 +4374,22 @@ int32 scriptlib::duel_is_player_can_spsummon_count(lua_State * L) { lua_pushboolean(L, pduel->game_field->is_player_can_spsummon_count(playerid, count)); return 1; } +int32 scriptlib::duel_is_player_can_pendulum_summon(lua_State * L) { + check_param_count(L, 1); + int32 playerid = (int32)lua_tointeger(L, 1); + if(playerid != 0 && playerid != 1) { + lua_pushboolean(L, 0); + return 1; + } + group* mg = nullptr; + if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) { + check_param(L, PARAM_TYPE_GROUP, 2); + mg = *(group**) lua_touserdata(L, 2); + } + duel* pduel = interpreter::get_duel_info(L); + lua_pushboolean(L, pduel->game_field->is_player_can_pendulum_summon(playerid, mg)); + return 1; +} int32 scriptlib::duel_is_player_can_release(lua_State * L) { check_param_count(L, 1); int32 playerid = (int32)lua_tointeger(L, 1); @@ -4753,6 +4788,7 @@ static const struct luaL_Reg duellib[] = { { "SpecialSummonRule", scriptlib::duel_special_summon_rule }, { "SynchroSummon", scriptlib::duel_synchro_summon }, { "XyzSummon", scriptlib::duel_xyz_summon }, + { "PendulumSummon", scriptlib::duel_pendulum_summon }, { "LinkSummon", scriptlib::duel_link_summon }, { "MSet", scriptlib::duel_setm }, { "SSet", scriptlib::duel_sets }, @@ -4936,6 +4972,7 @@ static const struct luaL_Reg duellib[] = { { "IsPlayerCanFlipSummon", scriptlib::duel_is_player_can_flipsummon }, { "IsPlayerCanSpecialSummonMonster", scriptlib::duel_is_player_can_spsummon_monster }, { "IsPlayerCanSpecialSummonCount", scriptlib::duel_is_player_can_spsummon_count }, + { "IsPlayerCanPendulumSummon", scriptlib::duel_is_player_can_pendulum_summon }, { "IsPlayerCanRelease", scriptlib::duel_is_player_can_release }, { "IsPlayerCanRemove", scriptlib::duel_is_player_can_remove }, { "IsPlayerCanSendtoHand", scriptlib::duel_is_player_can_send_to_hand }, diff --git a/operations.cpp b/operations.cpp index 52038209b..aa1e480cc 100644 --- a/operations.cpp +++ b/operations.cpp @@ -2683,7 +2683,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin info.limit_link_minc = core.limit_link_minc; info.limit_link_maxc = core.limit_link_maxc; target->filter_spsummon_procedure(sumplayer, &eset, summon_type, info); - target->filter_spsummon_procedure_g(sumplayer, &eset); + group* pendulum_group = nullptr; + if(core.limit_pendulum) + pendulum_group = pduel->new_group(core.limit_pendulum->container); + target->filter_spsummon_procedure_g(sumplayer, &eset, pendulum_group); if(!eset.size()) { core.summon_action_type = SUMMON_IN_IDLE; return TRUE; @@ -2970,12 +2973,19 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin core.sub_solving_event.push_back(nil_event); pduel->lua->add_param(target, PARAM_TYPE_CARD); pduel->lua->add_param(core.units.begin()->ptarget, PARAM_TYPE_GROUP); + if(core.limit_pendulum) { + pduel->lua->add_param(core.limit_pendulum, PARAM_TYPE_GROUP); + } add_process(PROCESSOR_EXECUTE_OPERATION, 0, peffect, 0, sumplayer, 0); } peffect->dec_count(sumplayer); return FALSE; } case 21: { + if(core.limit_pendulum) { + pduel->delete_group(core.limit_pendulum); + core.limit_pendulum = 0; + } group* pgroup = core.units.begin()->ptarget; for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ) { card* pcard = *cit; @@ -3394,6 +3404,46 @@ int32 field::special_summon(uint16 step, effect* reason_effect, uint8 reason_pla } return TRUE; } +int32 field::pendulum_summon(uint16 step, uint8 playerid, group* mg) { + switch(step) { + case 0: { + core.select_cards.clear(); + for(uint8 p = 0; p < 2; ++p) { + for(auto& pcard : player[p].list_szone) + if(pcard && pcard->current.pzone && pcard->is_pendulum_summon(playerid, mg)) + core.select_cards.push_back(pcard); + } + if(core.select_cards.size() == 0) { + return TRUE; + } else if(core.select_cards.size() == 1) { + returns.bvalue[1] = 0; + } else { + pduel->write_buffer8(MSG_HINT); + pduel->write_buffer8(HINT_SELECTMSG); + pduel->write_buffer8(playerid); + pduel->write_buffer32(574); + add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid, 0x10001); + } + return FALSE; + } + case 1: { + card* pcard = core.select_cards[returns.bvalue[1]]; + core.limit_pendulum = mg; + core.summon_cancelable = FALSE; + if(pduel->game_field->core.current_chain.size()) { + pduel->game_field->special_summon_rule(playerid, pcard, 0, SUMMON_IN_CHAIN); + pduel->game_field->core.summon_reserved = pduel->game_field->core.subunits.back(); + pduel->game_field->core.subunits.pop_back(); + pduel->game_field->core.summoning_card = pcard; + } + else { + pduel->game_field->special_summon_rule(playerid, pcard, 0, SUMMON_IN_IDLE); + } + return FALSE; + } + } + return TRUE; +} int32 field::destroy_replace(uint16 step, group* targets, card* target, uint8 battle) { if(target->current.location & (LOCATION_GRAVE | LOCATION_REMOVED)) { target->current.reason = target->temp.reason; diff --git a/processor.cpp b/processor.cpp index 17d87baed..424184d9d 100644 --- a/processor.cpp +++ b/processor.cpp @@ -419,6 +419,13 @@ uint32 field::process() { ++it->step; return pduel->message_buffer.size(); } + case PROCESSOR_PENDULUM_SUMMON: { + if (pendulum_summon(it->step, it->arg1, it->ptarget)) { + core.units.pop_front(); + } else + ++it->step; + return pduel->message_buffer.size(); + } case PROCESSOR_DRAW : { if (draw(it->step, it->peffect, it->arg1, (it->arg2 >> 4) & 0xf, (it->arg2) & 0xf, it->arg3)) core.units.pop_front(); diff --git a/scriptlib.h b/scriptlib.h index 4b3826fc7..e60ec8f1c 100644 --- a/scriptlib.h +++ b/scriptlib.h @@ -411,6 +411,7 @@ class scriptlib { static int32 duel_special_summon_rule(lua_State *L); static int32 duel_synchro_summon(lua_State *L); static int32 duel_xyz_summon(lua_State *L); + static int32 duel_pendulum_summon(lua_State *L); static int32 duel_link_summon(lua_State *L); static int32 duel_setm(lua_State *L); static int32 duel_sets(lua_State *L); @@ -602,6 +603,7 @@ class scriptlib { static int32 duel_is_player_can_flipsummon(lua_State *L); static int32 duel_is_player_can_spsummon_monster(lua_State *L); static int32 duel_is_player_can_spsummon_count(lua_State *L); + static int32 duel_is_player_can_pendulum_summon(lua_State *L); static int32 duel_is_player_can_release(lua_State *L); static int32 duel_is_player_can_remove(lua_State *L); static int32 duel_is_player_can_send_to_hand(lua_State *L); From 20c0e31cc5be191460711d5566736f689e37d7f6 Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Fri, 2 Feb 2024 14:06:09 +0900 Subject: [PATCH 3/6] add Duel.IsPlayerCanAdditionalPendulumSummon, Duel.SetAdditionalPendulumSummon --- field.h | 1 + libduel.cpp | 26 ++++++++++++++++++++++++++ processor.cpp | 1 + scriptlib.h | 2 ++ 4 files changed, 30 insertions(+) diff --git a/field.h b/field.h index 5966bc75c..25f0cacb0 100644 --- a/field.h +++ b/field.h @@ -293,6 +293,7 @@ struct processor { int32 battle_damage[2]{}; int32 summon_count[2]{}; uint8 extra_summon[2]{}; + uint8 extra_pendulum_summon[2]{}; int32 spe_effect[2]{}; int32 duel_options{ 0 }; int32 duel_rule{ CURRENT_RULE }; //current rule: 5, Master Rule 2020 diff --git a/libduel.cpp b/libduel.cpp index d14a9ac70..af6d35070 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -3649,6 +3649,16 @@ int32 scriptlib::duel_remove_overlay_card(lua_State *L) { return 1; }); } +int32 scriptlib::duel_set_additional_pendulum_summon(lua_State *L) { + check_action_permission(L); + check_param_count(L, 1); + int32 playerid = (int32)lua_tointeger(L, 1); + if(playerid != 0 && playerid != 1) + return 0; + duel* pduel = interpreter::get_duel_info(L); + pduel->game_field->core.extra_pendulum_summon[playerid] = TRUE; + return 0; +} int32 scriptlib::duel_is_summon_in_chain(lua_State *L) { duel* pduel = interpreter::get_duel_info(L); if(pduel->game_field->core.summon_action_type == SUMMON_IN_CHAIN) @@ -4500,6 +4510,20 @@ int32 scriptlib::duel_is_player_can_additional_summon(lua_State * L) { lua_pushboolean(L, 0); return 1; } +int32 scriptlib::duel_is_player_can_additional_pendulum_summon(lua_State * L) { + check_param_count(L, 1); + int32 playerid = (int32)lua_tointeger(L, 1); + if(playerid != 0 && playerid != 1) { + lua_pushboolean(L, 0); + return 1; + } + duel* pduel = interpreter::get_duel_info(L); + if(pduel->game_field->core.extra_pendulum_summon[playerid] == 0) + lua_pushboolean(L, 1); + else + lua_pushboolean(L, 0); + return 1; +} int32 scriptlib::duel_is_chain_negatable(lua_State * L) { check_param_count(L, 1); lua_pushboolean(L, 1); @@ -4937,6 +4961,7 @@ static const struct luaL_Reg duellib[] = { { "GetOverlayCount", scriptlib::duel_get_overlay_count }, { "CheckRemoveOverlayCard", scriptlib::duel_check_remove_overlay_card }, { "RemoveOverlayCard", scriptlib::duel_remove_overlay_card }, + { "SetAdditionalPendulumSummon", scriptlib::duel_set_additional_pendulum_summon }, { "IsSummonInChain", scriptlib::duel_is_summon_in_chain }, { "Hint", scriptlib::duel_hint }, { "HintSelection", scriptlib::duel_hint_selection }, @@ -4979,6 +5004,7 @@ static const struct luaL_Reg duellib[] = { { "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave }, { "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck }, { "IsPlayerCanAdditionalSummon", scriptlib::duel_is_player_can_additional_summon }, + { "IsPlayerCanAdditionalPendulumSummon", scriptlib::duel_is_player_can_additional_pendulum_summon }, { "IsChainNegatable", scriptlib::duel_is_chain_negatable }, { "IsChainDisablable", scriptlib::duel_is_chain_disablable }, { "IsChainDisabled", scriptlib::duel_is_chain_disabled }, diff --git a/processor.cpp b/processor.cpp index 424184d9d..2f2cd53ca 100644 --- a/processor.cpp +++ b/processor.cpp @@ -3702,6 +3702,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { core.battled_count[p] = 0; core.summon_count[p] = 0; core.extra_summon[p] = 0; + core.extra_pendulum_summon[p] = 0; core.spsummon_once_map[p].clear(); } for(auto& peffect : effects.rechargeable) diff --git a/scriptlib.h b/scriptlib.h index e60ec8f1c..beabca5a6 100644 --- a/scriptlib.h +++ b/scriptlib.h @@ -566,6 +566,7 @@ class scriptlib { static int32 duel_get_overlay_count(lua_State *L); static int32 duel_check_remove_overlay_card(lua_State *L); static int32 duel_remove_overlay_card(lua_State *L); + static int32 duel_set_additional_pendulum_summon(lua_State *L); static int32 duel_is_summon_in_chain(lua_State *L); static int32 duel_hint(lua_State *L); @@ -610,6 +611,7 @@ class scriptlib { static int32 duel_is_player_can_send_to_grave(lua_State *L); static int32 duel_is_player_can_send_to_deck(lua_State *L); static int32 duel_is_player_can_additional_summon(lua_State *L); + static int32 duel_is_player_can_additional_pendulum_summon(lua_State *L); static int32 duel_is_chain_negatable(lua_State *L); static int32 duel_is_chain_disablable(lua_State *L); static int32 duel_is_chain_disabled(lua_State *L); From ab44c5ce36c791b66c31aaa3f038904cf3506407 Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Sat, 3 Feb 2024 08:45:02 +0900 Subject: [PATCH 4/6] rename functions these functions haven't check EFFECT_EXTRA_PENDULUM_SUMMON. --- field.h | 2 +- libduel.cpp | 12 ++++++------ processor.cpp | 2 +- scriptlib.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/field.h b/field.h index 25f0cacb0..faa9957b0 100644 --- a/field.h +++ b/field.h @@ -293,7 +293,7 @@ struct processor { int32 battle_damage[2]{}; int32 summon_count[2]{}; uint8 extra_summon[2]{}; - uint8 extra_pendulum_summon[2]{}; + uint8 default_pendulum_summon[2]{}; int32 spe_effect[2]{}; int32 duel_options{ 0 }; int32 duel_rule{ CURRENT_RULE }; //current rule: 5, Master Rule 2020 diff --git a/libduel.cpp b/libduel.cpp index af6d35070..56905d483 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -3649,14 +3649,14 @@ int32 scriptlib::duel_remove_overlay_card(lua_State *L) { return 1; }); } -int32 scriptlib::duel_set_additional_pendulum_summon(lua_State *L) { +int32 scriptlib::duel_default_pendulum_summoned(lua_State *L) { check_action_permission(L); check_param_count(L, 1); int32 playerid = (int32)lua_tointeger(L, 1); if(playerid != 0 && playerid != 1) return 0; duel* pduel = interpreter::get_duel_info(L); - pduel->game_field->core.extra_pendulum_summon[playerid] = TRUE; + pduel->game_field->core.default_pendulum_summon[playerid] = TRUE; return 0; } int32 scriptlib::duel_is_summon_in_chain(lua_State *L) { @@ -4510,7 +4510,7 @@ int32 scriptlib::duel_is_player_can_additional_summon(lua_State * L) { lua_pushboolean(L, 0); return 1; } -int32 scriptlib::duel_is_player_can_additional_pendulum_summon(lua_State * L) { +int32 scriptlib::duel_is_player_default_pendulum_summoned(lua_State * L) { check_param_count(L, 1); int32 playerid = (int32)lua_tointeger(L, 1); if(playerid != 0 && playerid != 1) { @@ -4518,7 +4518,7 @@ int32 scriptlib::duel_is_player_can_additional_pendulum_summon(lua_State * L) { return 1; } duel* pduel = interpreter::get_duel_info(L); - if(pduel->game_field->core.extra_pendulum_summon[playerid] == 0) + if(pduel->game_field->core.default_pendulum_summon[playerid]) lua_pushboolean(L, 1); else lua_pushboolean(L, 0); @@ -4961,7 +4961,7 @@ static const struct luaL_Reg duellib[] = { { "GetOverlayCount", scriptlib::duel_get_overlay_count }, { "CheckRemoveOverlayCard", scriptlib::duel_check_remove_overlay_card }, { "RemoveOverlayCard", scriptlib::duel_remove_overlay_card }, - { "SetAdditionalPendulumSummon", scriptlib::duel_set_additional_pendulum_summon }, + { "DefaultPendulumSummoned", scriptlib::duel_default_pendulum_summoned }, { "IsSummonInChain", scriptlib::duel_is_summon_in_chain }, { "Hint", scriptlib::duel_hint }, { "HintSelection", scriptlib::duel_hint_selection }, @@ -5004,7 +5004,7 @@ static const struct luaL_Reg duellib[] = { { "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave }, { "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck }, { "IsPlayerCanAdditionalSummon", scriptlib::duel_is_player_can_additional_summon }, - { "IsPlayerCanAdditionalPendulumSummon", scriptlib::duel_is_player_can_additional_pendulum_summon }, + { "IsPlayerDefaultPendulumSummoned", scriptlib::duel_is_player_default_pendulum_summoned }, { "IsChainNegatable", scriptlib::duel_is_chain_negatable }, { "IsChainDisablable", scriptlib::duel_is_chain_disablable }, { "IsChainDisabled", scriptlib::duel_is_chain_disabled }, diff --git a/processor.cpp b/processor.cpp index 2f2cd53ca..3866b0fe6 100644 --- a/processor.cpp +++ b/processor.cpp @@ -3702,7 +3702,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { core.battled_count[p] = 0; core.summon_count[p] = 0; core.extra_summon[p] = 0; - core.extra_pendulum_summon[p] = 0; + core.default_pendulum_summon[p] = 0; core.spsummon_once_map[p].clear(); } for(auto& peffect : effects.rechargeable) diff --git a/scriptlib.h b/scriptlib.h index beabca5a6..8c17d1948 100644 --- a/scriptlib.h +++ b/scriptlib.h @@ -566,7 +566,7 @@ class scriptlib { static int32 duel_get_overlay_count(lua_State *L); static int32 duel_check_remove_overlay_card(lua_State *L); static int32 duel_remove_overlay_card(lua_State *L); - static int32 duel_set_additional_pendulum_summon(lua_State *L); + static int32 duel_default_pendulum_summoned(lua_State *L); static int32 duel_is_summon_in_chain(lua_State *L); static int32 duel_hint(lua_State *L); @@ -611,7 +611,7 @@ class scriptlib { static int32 duel_is_player_can_send_to_grave(lua_State *L); static int32 duel_is_player_can_send_to_deck(lua_State *L); static int32 duel_is_player_can_additional_summon(lua_State *L); - static int32 duel_is_player_can_additional_pendulum_summon(lua_State *L); + static int32 duel_is_player_default_pendulum_summoned(lua_State *L); static int32 duel_is_chain_negatable(lua_State *L); static int32 duel_is_chain_disablable(lua_State *L); static int32 duel_is_chain_disabled(lua_State *L); From cce8c482e37be150d7792a280ba5055ac0006a59 Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Sat, 3 Feb 2024 09:02:28 +0900 Subject: [PATCH 5/6] rename Duel.DefaultPendulumSummoned to Duel.UseDefaultPendulumSummon --- libduel.cpp | 4 ++-- scriptlib.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libduel.cpp b/libduel.cpp index 56905d483..b739200b1 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -3649,7 +3649,7 @@ int32 scriptlib::duel_remove_overlay_card(lua_State *L) { return 1; }); } -int32 scriptlib::duel_default_pendulum_summoned(lua_State *L) { +int32 scriptlib::duel_use_default_pendulum_summon(lua_State *L) { check_action_permission(L); check_param_count(L, 1); int32 playerid = (int32)lua_tointeger(L, 1); @@ -4961,7 +4961,7 @@ static const struct luaL_Reg duellib[] = { { "GetOverlayCount", scriptlib::duel_get_overlay_count }, { "CheckRemoveOverlayCard", scriptlib::duel_check_remove_overlay_card }, { "RemoveOverlayCard", scriptlib::duel_remove_overlay_card }, - { "DefaultPendulumSummoned", scriptlib::duel_default_pendulum_summoned }, + { "UseDefaultPendulumSummon", scriptlib::duel_use_default_pendulum_summon }, { "IsSummonInChain", scriptlib::duel_is_summon_in_chain }, { "Hint", scriptlib::duel_hint }, { "HintSelection", scriptlib::duel_hint_selection }, diff --git a/scriptlib.h b/scriptlib.h index 8c17d1948..f0a0e3173 100644 --- a/scriptlib.h +++ b/scriptlib.h @@ -566,7 +566,7 @@ class scriptlib { static int32 duel_get_overlay_count(lua_State *L); static int32 duel_check_remove_overlay_card(lua_State *L); static int32 duel_remove_overlay_card(lua_State *L); - static int32 duel_default_pendulum_summoned(lua_State *L); + static int32 duel_use_default_pendulum_summon(lua_State *L); static int32 duel_is_summon_in_chain(lua_State *L); static int32 duel_hint(lua_State *L); From b01ad24a7d1514a1ecd5ea84cca665cf10bbff63 Mon Sep 17 00:00:00 2001 From: chronogenexx Date: Mon, 12 Feb 2024 16:29:49 +0900 Subject: [PATCH 6/6] use nullptr --- libduel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libduel.cpp b/libduel.cpp index b739200b1..abce82175 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -438,7 +438,7 @@ int32 scriptlib::duel_pendulum_summon(lua_State *L) { pendulum_group = pduel->new_group(pgroup->container); pendulum_group->is_readonly = 1; } - pduel->game_field->add_process(PROCESSOR_PENDULUM_SUMMON, 0, NULL, pendulum_group, playerid, 0); + pduel->game_field->add_process(PROCESSOR_PENDULUM_SUMMON, 0, nullptr, pendulum_group, playerid, 0); return lua_yield(L, 0); } int32 scriptlib::duel_link_summon(lua_State *L) {