Source Development Function to decide how your Portal looks

ximboliex

Pirate
Registered
LV
0
 
Joined
Jan 29, 2026
Messages
14
Reaction score
8
Points
8
Location
Panama
As the title says, sometimes we want to change things that weren't made to be easily modified whenever we want, so I'm bringing you this function that occurred to me while reviewing the whole portal thing (I have something else to show later, I'll bring other curious portal functions xD)
OK

Src/GameServer/src/MapEntry.h:

Search: class CDynMapEntryCell and inside public paste this:

C++:
    void             SetEffectID(dbc::Long lEffectID){m_lEffectID = lEffectID;}
    dbc::Long         GetEffectID(void){return m_lEffectID;}

and Inside private paste this :
C++:
    dbc::Long    m_lEffectID;

Now Src/GameServer/src/Entity.cpp serch void Entity::WriteEventInfo and Remplace for :
C++:
void Entity::WriteEventInfo(WPACKET &pk)
{
    WRITE_LONG(pk, GetID());

    if (IsCharacter())
        WRITE_CHAR(pk, 1);
    else
        WRITE_CHAR(pk, 2);

    GetEvent().WriteInfo(pk);

    long lEffectID = 0;

    CDynMapEntryCell* pEntry =
        (CDynMapEntryCell*)GetEvent().GetTableRec();

    if( pEntry )
    {
        lEffectID = pEntry->GetEffectID();
    }

    WRITE_LONG(pk, lEffectID);
}

Now Src/GameServer/src/Expand.h and search : lua_SetMapEntryEntiID an Reemplace for this:
C++:
inline int lua_SetMapEntryEntiID(lua_State *pLS)
{
    bool bSuccess = true;

#ifdef defPARSE_LOG
    g_pCLogObj->Log(
        "Set the map entrance instance ID : SetMapEntryEntiID\n"
    );
#endif

    int nParaNum = lua_gettop(pLS);

    // Now:
    // entry, entiID, eventID
    // or:
    // entry, entiID, eventID, effectID
    if (nParaNum < 3)
    {
#ifdef defPARSE_LOG
        g_pCLogObj->Log(
            "\tThe parameter numbers [%d] is unlawful, transfer failed!\n",
            nParaNum
        );
#endif
        bSuccess = false;
        goto End;
    }

    {
        CDynMapEntryCell* pEntry =
            (CDynMapEntryCell*)lua_touserdata(pLS, 1);

        if (!pEntry)
        {
#ifdef defPARSE_LOG
            g_pCLogObj->Log(
                "\tEntrance object inexistence, transfer failed\n"
            );
#endif
            bSuccess = false;
            goto End;
        }

        // entity id
        pEntry->SetEntiID(
            (int)lua_tonumber(pLS, 2)
        );

        // event id
        pEntry->SetEventID(
            (int)lua_tonumber(pLS, 3)
        );

        //////////////////////////////////////////////////////////////////////////
        // NEW EFFECT ID
        //////////////////////////////////////////////////////////////////////////
        if (nParaNum >= 4)
        {
            pEntry->SetEffectID(
                (int)lua_tonumber(pLS, 4)
            );
        }
        else
        {
            // fallback default
            pEntry->SetEffectID(0);
        }
    }

End:

    if (bSuccess)
    {
#ifdef defPARSE_LOG
        g_pCLogObj->Log(
            "Set the map entrance instance ID(%d) succeed\n",
            (int)lua_tonumber(pLS, 2)
        );
#endif

        lua_pushnumber(pLS, 1);
    }
    else
    {
        lua_pushnumber(pLS, 0);
    }

    return 1;
}

Now Client/src/PacketCmd_SC.cpp search: void ReadEntEventPacket(LPRPACKET pk,stNetEvent &SNetEvent,const char *szLogName) and Reemplace this fuction whit :
C++:
void ReadEntEventPacket(LPRPACKET pk,stNetEvent &SNetEvent,const char *szLogName)
{
    SNetEvent.lEntityID = pk.ReadLong();

    SNetEvent.chEntityType = pk.ReadChar();

    SNetEvent.usEventID = pk.ReadShort();

    SNetEvent.cszEventName = pk.ReadString();

    // EFFECT
    SNetEvent.lEffectID = pk.ReadLong();

    if (szLogName)
    {
        LG(szLogName,
            "===Recieve(Event)\tTick:[%u]\n",
            GetTickCount());

        LG(szLogName,
            "\tEntityID: %u, EventID: %u, EffectID: %u, EventName: %s\n",
            SNetEvent.lEntityID,
            SNetEvent.usEventID,
            SNetEvent.lEffectID,
            SNetEvent.cszEventName,
            SNetEvent.lEffectID);

        LG(szLogName, "\n");
    }
}


and Done! now you can do in your map entry.lua and now you can have any map you want with different effects if you wish.
Don't worry about compatibility with older systems; if you don't specify anything, it will simply ignore the requirement.

Code:
function config_entry(entry)
  SetMapEntryEntiID(entry, 193, 1,204) --204 is effect from sceneeffecinfo.txt
end
 

Attachments