# Search
void RegisterDungeonFunctionTable()
# Add before
#ifdef __DUNGEON_INFO__
struct FDungeonInfoUpdate
{
void operator () (LPENTITY ent)
{
if (true == ent->IsType(ENTITY_CHARACTER))
{
LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
if (pChar->IsPC())
pChar->SendDungeonCooldown(0);
}
}
};
int dungeon_update_info(lua_State* L)
{
CQuestManager& q = CQuestManager::instance();
LPDUNGEON pDungeon = q.GetCurrentDungeon();
if (!pDungeon)
return 0;
LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(pDungeon->GetMapIndex());
if (NULL != pSectree)
{
FDungeonInfoUpdate func;
pSectree->for_each(func);
}
return 0;
}
struct FDungeonInfoFlagCompleted
{
std::string flag;
int value;
FDungeonInfoFlagCompleted(const char* szFlag, int _value) : flag(szFlag), value(_value){}
void operator () (LPENTITY ent)
{
if (true == ent->IsType(ENTITY_CHARACTER))
{
LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
if (pChar->IsPC())
pChar->SetQuestFlag(flag.c_str(), pChar->GetQuestFlag(flag.c_str()) + value);
}
}
};
int dungeon_increase_completed(lua_State* L)
{
CQuestManager& q = CQuestManager::instance();
LPDUNGEON pDungeon = q.GetCurrentDungeon();
if (!pDungeon)
return 0;
if (!lua_isnumber(L, 1))
return 0;
char buf[124];
snprintf(buf, sizeof(buf), "dungeon.%u_completed", (int)lua_tonumber(L, 1));
LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(pDungeon->GetMapIndex());
if (NULL != pSectree)
{
FDungeonInfoFlagCompleted func(buf, 1);
pSectree->for_each(func);
}
return 0;
}
struct FDungeonInfoFlagFastest
{
std::string flag;
int value;
FDungeonInfoFlagFastest(const char* szFlag, int _value) : flag(szFlag), value(_value) {}
void operator () (LPENTITY ent)
{
if (true == ent->IsType(ENTITY_CHARACTER))
{
LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
if (pChar->IsPC())
{
if (pChar->GetQuestFlag(flag.c_str()) > value)
pChar->SetQuestFlag(flag.c_str(), value);
}
}
}
};
int dungeon_set_fastest(lua_State* L)
{
CQuestManager& q = CQuestManager::instance();
LPDUNGEON pDungeon = q.GetCurrentDungeon();
if (!pDungeon)
return 0;
if (!lua_isnumber(L, 1) || !lua_isnumber(L, 1))
return 0;
char buf[124];
snprintf(buf, sizeof(buf), "dungeon.%u_fastest", (int)lua_tonumber(L, 1));
LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(pDungeon->GetMapIndex());
if (NULL != pSectree)
{
FDungeonInfoFlagFastest func(buf, (int)lua_isnumber(L, 2));
pSectree->for_each(func);
}
return 0;
}
#endif
# Search
{ "join", dungeon_join },
# Add after
#ifdef __DUNGEON_INFO__
{ "update_info", dungeon_update_info },
{ "increase_completed", dungeon_increase_completed },
{ "set_fastest", dungeon_set_fastest },
#endif