[C++][Release]Group drop dungeon

  • Hi dev ! I share this tutoriel, This system gives a similar drop at the same time to all players in your group during a dungeon. In a quest that gives this example:

    Code
    1. quest drop_dungeon begin state start begin when kill begin d.drop(299) -- Drop a full moon sword +9 to all group members. end endend

    1. Open your questlua_dungeon.cpp 2. After the function int dungeon_notice (lua_State * L) add this:

    Code
    1. int dungeon_drop(lua_State* L) { CQuestManager& q = CQuestManager::instance(); LPDUNGEON pDungeon = q.GetCurrentDungeon(); if (pDungeon) pDungeon->Drop(lua_tonumber(L, 1)); return 0; }

    3.After line { "notice", dungeon_notice}, add this:

    Code
    1. { "drop", dungeon_drop },

    4. Open your file dungeon.h 5. Find the function void Notice(const char* msg); and add this function:

    Code
    1. // DUNGEON_DROP void Drop(int vnum); // END_OF_DUNGEON_DROP

    6.Open your file dungeon.cpp 7.Search function void CDungeon::Notice(const char* msg) and add the following function:

    Code
    1. // DUNGEON_DROPvoid CDungeon::Drop(int vnum){ sys_log(1, "XXX Dungeon DROP %p %d", this, vnum); LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); if (!pMap) { sys_err("cannot find map by index %d", m_lMapIndex); return; } FDROP f(vnum); pMap->for_each(f);}// END_OF_DUNGEON_DROP

    8. Search the struct FNotice thereafter add the following structure:

    Code
    1. struct FDROP { FDROP(int vnum) : m_vnum(vnum) { } void operator() (LPENTITY ent) { if (ent->IsType(ENTITY_CHARACTER)) { LPCHARACTER ch = (LPCHARACTER) ent; if (ch->IsPC()) { LPITEM item = NULL; item = ITEM_MANAGER::instance().CreateItem(m_vnum); item->SetOwnership( ch ); PIXEL_POSITION pos; pos.x = ch->GetX() + number(-200, 200); pos.y = ch->GetY() + number(-200, 200); item->AddToGround(ch->GetMapIndex(), pos); item->StartDestroyEvent(); } } } int m_vnum; };

    Compile the game. Open the quest_function and add " d.drop " Jin.

    2 Mal editiert, zuletzt von .Santana ()

  • Dieses Thema enthält 12 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind, bitte registrieren Sie sich oder melden Sie sich an um diese lesen zu können.