ServersMU - Comunidad

Zona Programadores => Sources => Mensaje iniciado por: Applayo en Abril 25, 2021, 12:15:42 am

Título: Custom Monsters without NPC Animation BUG 1.04e
Publicado por: Applayo en Abril 25, 2021, 12:15:42 am
Copiando e colando


Este código foi usado nos arquivos do meu servidor por cerca de 1 ano e não tem bugs.
Tenha um bom dia =)


[code]#define sub_969C50_Addr        ((int(__thiscall*)(int This, signed int a2)) 0x969C50)
#define pOpenMonsterModel        ((void(__cdecl*)(int MonsterID)) 0x61FDE0)
#define pLoadModel                ((void(__cdecl*)(int ResourceID, char * Path, char * File, int Arg4)) 0x614D10)
#define pLoadTexture            ((void(__cdecl*)(int TextureID, char * Folder, int GLREPEAT, int GLNEAREST, int GLTRUE)) 0x614710)
#define pGetViewStruct            ((lpViewObj(__cdecl*)(int a1, signed int a2, unsigned __int8 a3, unsigned __int8 a4, float a5)) 0x57EEC0)
#define pShowMonster            ((lpViewObj(__cdecl*)(int MonsterID, int X, int Y, int a4)) 0x580FC0)

lpViewObj cCustomMonsters::ShowMonster(int MonsterID, int a2, int a3, int a4)
{
    CUSTOMMONSTERS_DATA* lpInfo = gCustomMonsters.GetInfoByMonsterID(MonsterID);

    if (lpInfo == nullptr)
    {
        return pShowMonster(MonsterID, a2, a3, a4);
    }

    if (lpInfo->Type == 0)
    {
        int ModelID = MonsterID + MONSTER_MODEL;
        int BMD = sub_969C50_Addr(sub_4CDA10_Addr(), ModelID);

        pLoadModel(ModelID, lpInfo->Dir, lpInfo->BMDFile, -1);
        pLoadTexture(ModelID, lpInfo->Folder, 0x2901, 0x2600, 1);

        for ( int m = 0; ; ++m )
        {
            if ( m >= *(signed __int16 *)(BMD + 38) )
                break;
            *(float *)(*(DWORD *)(BMD + 48) + 16 * m + 4) = 0.25;
        }
    }
    else
    {
        pOpenMonsterModel(MonsterID);
    }

    lpViewObj Object = pGetViewStruct(a4, MonsterID + MONSTER_MODEL, a2, a3, 0.0);

    if ( Object == nullptr )
    {
        return pShowMonster(MonsterID, a2, a3, a4);
    }
    // ----
    memcpy(Object->Name, lpInfo->Name, sizeof(lpInfo->Name));
    // ----
    if(lpInfo->Type == 0)
    {
        Object->m_Model.ObjectType = emNPC;
    }
    else
    {
        Object->m_Model.ObjectType = emMonster;
    }

    Object->m_Model.Scale = lpInfo->Size;
    Object->ID = MonsterID;

    cCustomMonsters::SetMainAttribute(Object, MonsterID);

    return Object;
}[/code]



Créditos: LTP Team
Título: Re: Custom Monsters without NPC Animation BUG 1.04e
Publicado por: robins1998 en Mayo 27, 2021, 02:28:23 am
Very helpful, thanks for sharing.