diff --git a/field.cpp b/field.cpp index f731182a..f6113375 100644 --- a/field.cpp +++ b/field.cpp @@ -35,6 +35,10 @@ void chain::set_triggering_state(card* pcard) { } triggering_sequence = pcard->current.sequence; triggering_position = pcard->current.position; + triggering_status = pcard->status; + triggering_summon_type = pcard->summon.type & 0xff00ffff; + triggering_summon_location = pcard->summon.location; + triggering_summon_proc_complete = pcard->is_status(STATUS_PROC_COMPLETE); triggering_state.code = pcard->get_code(); triggering_state.code2 = pcard->get_another_code(); triggering_state.level = pcard->get_level(); @@ -44,6 +48,10 @@ void chain::set_triggering_state(card* pcard) { triggering_state.race = pcard->get_race(); triggering_state.attack = pcard->get_attack(); triggering_state.defense = pcard->get_defense(); + //For the triggering archetypes: + auto& setcode = triggering_state.setcodes; + setcode.clear(); + pcard->get_set_card(setcode); } bool tevent::operator< (const tevent& v) const { return std::memcmp(this, &v, sizeof(tevent)) < 0; diff --git a/field.h b/field.h index 9e39b42c..6c5b7db1 100644 --- a/field.h +++ b/field.h @@ -55,6 +55,10 @@ struct chain { uint16_t triggering_location; uint32_t triggering_sequence; uint8_t triggering_position; + uint32_t triggering_status{}; + uint32_t triggering_summon_type{}; + uint8_t triggering_summon_location{}; + bool triggering_summon_proc_complete{}; //properly summoned or not card_state triggering_state; effect* triggering_effect; group* target_cards; @@ -734,6 +738,11 @@ enum class CHAININFO : uint16_t { TRIGGERING_RACE, TRIGGERING_ATTACK, TRIGGERING_DEFENSE, + TRIGGERING_STATUS, + TRIGGERING_SUMMON_LOCATION, + TRIGGERING_SUMMON_TYPE, + TRIGGERING_SUMMON_PROC_COMPLETE, + TRIGGERING_SETCODES, }; //Timing diff --git a/libduel.cpp b/libduel.cpp index 411a82b2..0d142105 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -1925,11 +1925,9 @@ LUA_STATIC_FUNCTION(GetChainInfo) { lua_pushinteger(L, 0); else lua_pushinteger(L, 1); - } - else if(ch->triggering_location & LOCATION_FZONE) { + } else if(ch->triggering_location & LOCATION_FZONE) { lua_pushinteger(L, 0); - } - else if(ch->triggering_location & LOCATION_EMZONE) { + } else if(ch->triggering_location & LOCATION_EMZONE) { lua_pushinteger(L, ch->triggering_sequence - 5); } else lua_pushinteger(L, ch->triggering_sequence); @@ -1990,6 +1988,29 @@ LUA_STATIC_FUNCTION(GetChainInfo) { case CHAININFO::EXTTYPE: lua_pushinteger(L, ch->triggering_effect->card_type); break; + case CHAININFO::TRIGGERING_STATUS: + lua_pushinteger(L, ch->triggering_status); + break; + case CHAININFO::TRIGGERING_SUMMON_LOCATION: + lua_pushinteger(L, ch->triggering_summon_location); + break; + case CHAININFO::TRIGGERING_SUMMON_TYPE: + lua_pushinteger(L, ch->triggering_summon_type); + break; + case CHAININFO::TRIGGERING_SUMMON_PROC_COMPLETE: + lua_pushboolean(L, ch->triggering_summon_proc_complete); + break; + case CHAININFO::TRIGGERING_SETCODES: { + const auto& setcodes = ch->triggering_state.setcodes; + lua_createtable(L, setcodes.size(), 0); + int i = 1; + for(const auto& setcode : setcodes) { + lua_pushinteger(L, i++); + lua_pushinteger(L, setcode); + lua_settable(L, -3); + } + break; + } default: lua_error(L, "Passed invalid CHAININFO flag."); }