diff --git a/field.cpp b/field.cpp index 2862b923..0f8584a4 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 1e2b99dc..6f9748b5 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; @@ -733,6 +737,11 @@ enum class CHAININFO { 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 f4bd86dd..ab34a3ca 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -1907,11 +1907,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); @@ -1972,6 +1970,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."); }