• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

CMonster::GetChase problem New AI

Newbie Spellweaver
Joined
Apr 13, 2012
Messages
15
Reaction score
0
Hi All,

i just want to know how to become Monster Aggro at a Player.(NewAI)
I found the MonsterReal__GetChasePt function. Its Only Called when a Monster become Aggro...

I Thought that i rename the Vars right but with the Monster Around Iterator as little helper to become the monsterpointers, the server crashes...

Does anyone have a idea how to fix it (or another way to the new ai) ?

Thats how i call the function: (Monster Iterator)
int *pMonster, *pObject, nRange = 4;
pObject = KemA::CPlayer::GetPlayerMonsterList(((int*) PlayerPointer)[80],&((int*) PlayerPointer)[81],nRange);

while ( pObject )
{
KemA::Server::ConsoleWriteBlue("pObject");
//KemA::CMonster::CMonsterReal__GetChasePt((int) pObject, (int) PlayerPointer, );
}

Header:
static signed int (__thiscall *CMonsterReal__GetChasePt)(int MonsterPointer, int PlayerPointer) = (signed int (__thiscall*)(int a5, int a6))0x0043E470;

thx for all suggestions


(sry for my bad english)
 
Last edited:
Experienced Elementalist
Joined
Sep 29, 2008
Messages
224
Reaction score
436
hook CMonsterReal::AI, u can get closest target/player (in monster range) with CMonsterReal::ScanSight
 
Upvote 0
Newbie Spellweaver
Joined
Apr 13, 2012
Messages
15
Reaction score
0
mmh good idea xD
but if i see it right i have to rewrite the ai function or intercept it right ?
did u do it ? when yes can u paste it ? (im lazy and not the "pro" in c++ ;) )
 
Upvote 0
Elite Diviner
Joined
Feb 8, 2012
Messages
439
Reaction score
867
I am lazy ; )

Code:
namespace CMonsterReal
    {


        void __fastcall AI (void *monsterpointer, void* _edx) 
        {
            Monster *monster = new Monster(monsterpointer);


            if ( ! Server::CMonster::IsRemoved(monsterpointer) )
            {
                if ( ! Server::CChar::IsGState( monsterpointer, 1) )
                {
                    Server::CChar::Lock(monsterpointer);


                    if ( monster->Get164() == 1 && monster->Get120()  == 1 )
                    {
                        if ( monster->Get119() == 1 )
                        {
                            void *target;
                            target = Server::CMonsterReal::ScanSight(monsterpointer);
                            if ( target )
                                (*(void (__thiscall **)(void *, void*))
                                (*(_DWORD *)monsterpointer + 188))(monsterpointer, target);
                        }
                    }


                    if ( monster->GetState() )
                    {
                        if ( ! Server::CChar::IsNormal( monster->GetState() ) )
                        {
                            (*(void (__thiscall **)(void*, void*))
                            (*(_DWORD *)monsterpointer + 132))
                            (monsterpointer, monster->GetState() );
                            (*(void (__thiscall **)(void*, _DWORD))
                            (*(_DWORD *)monsterpointer + 188))(monsterpointer, 0);
                        }
                    }


                    switch ( monster->GetAI() )
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 7:
                        (*(void (__thiscall **)(void*))
                        (*(_DWORD *)monsterpointer + 248))(monsterpointer);
                        break;
                    case 4:
                        (*(void (__thiscall **)(void*))
                        (*(_DWORD *)monsterpointer + 244))(monsterpointer);
                        break;
                    default:
                        break;
                    }
                    Server::CChar::Unlock(monsterpointer);
                }
            }
            delete monster;
        }
    }

I hope this pseudocode help you : )
 
Upvote 0
Newbie Spellweaver
Joined
Apr 13, 2012
Messages
15
Reaction score
0
thx madknight... does anyone know what ist that Get119 164 and 120 ?
 
Upvote 0
Experienced Elementalist
Joined
Sep 29, 2008
Messages
224
Reaction score
436
I am lazy ; )

Code:
namespace CMonsterReal
    {


        void __fastcall AI (void *monsterpointer, void* _edx) 
        {
            Monster *monster = new Monster(monsterpointer);


            if ( ! Server::CMonster::IsRemoved(monsterpointer) )
            {
                if ( ! Server::CChar::IsGState( monsterpointer, 1) )
                {
                    Server::CChar::Lock(monsterpointer);


                    if ( monster->Get164() == 1 && monster->Get120()  == 1 )
                    {
                        if ( monster->Get119() == 1 )
                        {
                            void *target;
                            target = Server::CMonsterReal::ScanSight(monsterpointer);
                            if ( target )
                                (*(void (__thiscall **)(void *, void*))
                                (*(_DWORD *)monsterpointer + 188))(monsterpointer, target);
                        }
                    }


                    if ( monster->GetState() )
                    {
                        if ( ! Server::CChar::IsNormal( monster->GetState() ) )
                        {
                            (*(void (__thiscall **)(void*, void*))
                            (*(_DWORD *)monsterpointer + 132))
                            (monsterpointer, monster->GetState() );
                            (*(void (__thiscall **)(void*, _DWORD))
                            (*(_DWORD *)monsterpointer + 188))(monsterpointer, 0);
                        }
                    }


                    switch ( monster->GetAI() )
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 7:
                        (*(void (__thiscall **)(void*))
                        (*(_DWORD *)monsterpointer + 248))(monsterpointer);
                        break;
                    case 4:
                        (*(void (__thiscall **)(void*))
                        (*(_DWORD *)monsterpointer + 244))(monsterpointer);
                        break;
                    default:
                        break;
                    }
                    Server::CChar::Unlock(monsterpointer);
                }
            }
            delete monster;
        }
    }

I hope this pseudocode help you : )

not bad but with 3k+ mob after some time server will be lag like hell
 
Upvote 0
Newbie Spellweaver
Joined
Mar 29, 2013
Messages
76
Reaction score
28
I'm wondering why you're creating a Monster object for every monster... Just use a normal constructor without allocating memory..this way you'll save performance and you need the performance with 16k+ mobs.
 
Upvote 0
Elite Diviner
Joined
Feb 8, 2012
Messages
439
Reaction score
867
because of the internal __asm structure of my classes i cant instantiate these Objects onto the Stack, so i have to use the Heap, but for sure the Stack is faster, but to avoid the Problem with lags in general the goal should be to use 4,6,8 or 12 cores instead of one core like the Mainserver.exe actually do.

So:
1. im lazy ^^
2. Monster *monster = new Monster(monsterpointer); -> Monster monster(monsterpointer);
3. try to multithread heavy mainserver calculations, then even 100k Monsters are possible (i tested it / worked on 8 core/8 threads without lags)
 
Upvote 0
Experienced Elementalist
Joined
Sep 29, 2008
Messages
224
Reaction score
436
but to avoid the Problem with lags in general the goal should be to use 4,6,8 or 12 cores instead of one core like the Mainserver.exe actually do

none of the servers have more add-ons then bango, we r using max %8 of cpu and max 3 gb ram... with ur ai source ppls will need 4,6,8,12 cores but it doesnt mean they really need them...

3. try to multithread heavy mainserver calculations, then even 100k Monsters are possible (i tested it / worked on 8 core/8 threads without lags)

my ai can handle 30~40k mobs but i am curious to see ur test, pls take a vid and show us...
 
Upvote 0
Elite Diviner
Joined
Feb 8, 2012
Messages
439
Reaction score
867
I made this some time ago and was going to release the source code, but i faced off some problems wich can happen, so i need to fix that frist.

1# Without MultiCore:
skiron - CMonster::GetChase problem New AI - RaGEZONE Forums


2# With MultiCore:
skiron - CMonster::GetChase problem New AI - RaGEZONE Forums



The #1 was terrible lagging, i couldnt even log into the game because 507k mobs was tryed to handle via one Core,wich is absolute impossible and if i moved the Mainserver window it crashed. On #2 i was able to login, my whole PC was lagging, but the Mainserver.exe did not crashed while moving the window. This was my absolut max stress test, for sure nobody wants to have 400k - 500k Monsters, i just wanted to test the difference in using up to 8 Cores.
 
Upvote 0

ToF

Master Summoner
Joined
Jun 12, 2007
Messages
513
Reaction score
170
I made this some time ago and was going to release the source code, but i faced off some problems wich can happen, so i need to fix that frist.

1# Without MultiCore:
skiron - CMonster::GetChase problem New AI - RaGEZONE Forums


2# With MultiCore:
skiron - CMonster::GetChase problem New AI - RaGEZONE Forums



The #1 was terrible lagging, i couldnt even log into the game because 507k mobs was tryed to handle via one Core,wich is absolute impossible and if i moved the Mainserver window it crashed. On #2 i was able to login, my whole PC was lagging, but the Mainserver.exe did not crashed while moving the window. This was my absolut max stress test, for sure nobody wants to have 400k - 500k Monsters, i just wanted to test the difference in using up to 8 Cores.

OR you can automatically turn off mobs/spawns if no player has been present on the map for a while, and when a players enters the map again, the spawns will activate again :p
 
Upvote 0
Back
Top