Hello! Today I will share this system with the comm. Maybe you know it. I know you know it. But not full completed. You can complete this system. I'm sure somebody see this system(Code Stacks.) but passed through. (In pseudocode.) I think this system is very good.
Let's Start! [ANALYSE]
As first we have this quest trigger code;
As we can see, this trigger triggering real system. Now let's look to main system:
Here we have bool trigger (true,false), it shows to us event status;
Battle arena map check; (I will give dif about that, later.)
Map ID's: 190,191,192
Event status change (We saw it at real system.);
It should be calculate trigger for players. I'm not sure.
I am not sure but, it may be flag...
Spawn boss for event.
Spawn random stone for event;
End event.
Force end event. (Reboot, By Quest etc.)
That's all. You can explain pseudecodo codes. For having idea. :)
Also you can start event with ba.start(empire id 1,2,3) . For test. (In quest.)
Enjoy! If you have idea please share with us . :)
1# [Only registered and activated users can see links. Click Here To Register...]
Let's Start! [ANALYSE]
As first we have this quest trigger code;
PHP Code:
int __cdecl quest::ba_start(int a1)
{
int v1; // eax@1
int v2; // ecx@1
int result; // eax@2
int v4; // edx@4
double v5; // [sp+10h] [bp-28h]@4
int v6; // [sp+2Ch] [bp-Ch]@1
v6 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
LOBYTE(v1) = lua_isnumber(a1, 1);
if ( v1 )
{
v5 = lua_tonumber(a1, 1);
if ( !singleton<CBattleArena>::ms_singleton )
__assert("instance", "../../common/singleton.h", 26);
CBattleArena::Start(
singleton<CBattleArena>::ms_singleton,
v4,
singleton<CBattleArena>::ms_singleton,
(signed int)v5);
}
result = 0;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v6 )
__stack_chk_fail(v2, *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v6);
return result;
}
PHP Code:
signed int __fastcall CBattleArena::Start(int a1, int a2, int a3, int a4)
{
signed int result; // eax@3
int v5; // eax@6
int v6; // ebx@6
int v7; // edx@6
int v8; // ecx@6
int v9; // eax@6
int v10; // edx@6
int v11; // ecx@6
int v12; // eax@6
int v13; // eax@6
int v14; // edx@6
int v15; // ecx@6
int v16; // eax@6
signed int v17; // eax@7
int v18; // edx@8
int v19; // ecx@8
int v20; // ebx@8
int v21; // ebx@9
int v22; // eax@14
int v23; // esi@14
int v24; // edx@16
int v25; // [sp+10h] [bp-418h]@8
int v26; // [sp+14h] [bp-414h]@6
char v27; // [sp+1Ah] [bp-40Eh]@18
char v28; // [sp+1Bh] [bp-40Dh]@8
char arg; // [sp+1Ch] [bp-40Ch]@6
int v30; // [sp+41Ch] [bp-Ch]@1
v30 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
if ( *(_DWORD *)(a3 + 8) || (unsigned int)(a4 - 1) > 2 )
{
result = 0;
}
else
{
v5 = *(_DWORD *)&nBATTLE_ARENA_MAP[4 * a4];
*(_DWORD *)(a3 + 16) = a4;
*(_DWORD *)(a3 + 12) = v5;
v6 = locale_find(a1, a4, (int)&g_nation_name[32 * (unsigned __int8)a4]);
v9 = locale_find(v8, v7, (int)&unk_8337EE8);
snprintf(&arg, 0x400u, (const char *)v9, v6);
BroadcastNotice(&arg);
v12 = locale_find(v11, v10, (int)&unk_8337F14);
BroadcastNotice((const char *)v12);
v13 = AllocEventInfo<SBattleArenaInfo>((int)&v26);
v14 = v26;
v15 = v13;
*(_DWORD *)(v26 + 4) = *(_DWORD *)(a3 + 12);
v16 = *(_DWORD *)(a3 + 16);
*(_DWORD *)(v14 + 8) = 0;
*(_DWORD *)(v14 + 12) = 0;
*(_DWORD *)v14 = v16;
if ( test_server )
v17 = 60 * passes_per_sec;
else
v17 = 300 * passes_per_sec;
*(_DWORD *)(a3 + 4) = event_create_ex((int)battle_arena_event, v15, v17);
CBattleArena::SetStatus(v19, v18, a3, 1);
v20 = *(_DWORD *)(a3 + 12);
std::string::string(&v25, "battle_arena", &v28);
if ( !singleton<quest::CQuestManager>::ms_singleton )
__assert("instance", "../../common/singleton.h", 26);
quest::CQuestManager::RequestSetEventFlag(singleton<quest::CQuestManager>::ms_singleton, (int)&v25, v20);
v21 = v25 - 12;
if ( (char *)(v25 - 12) == std::string::_Rep::_S_empty_rep_storage )
goto LABEL_27;
v22 = _gthread_active;
v23 = v21 + 8;
if ( _gthread_active < 0 )
{
if ( pthread_once )
{
pthread_mutex_lock(&__gthread_active_p_void_::__gthread_active_mutex);
pthread_once(&__gthread_active_p_void_::__gthread_active_once, (void (*)(void))__gthread_trigger);
pthread_mutex_unlock(&__gthread_active_p_void_::__gthread_active_mutex);
}
if ( _gthread_active < 0 )
_gthread_active = 0;
v22 = _gthread_active;
}
if ( v22 )
v24 = __gnu_cxx::__exchange_and_add(v21 + 8, -1);
else
v24 = (*(_DWORD *)v23)--;
if ( v24 > 0 )
{
LABEL_27:
result = 1;
}
else
{
std::string::_Rep::_M_destroy(v21, &v27);
result = 1;
}
}
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v30 )
__stack_chk_fail(a1, *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v30);
return result;
}
PHP Code:
bool __fastcall CBattleArena::IsRunning(int a1, int a2, int a3)
{
bool result; // eax@1
result = *(_DWORD *)(a3 + 8) != 0;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != *(_DWORD *)_stack_chk_guard__FBSD_1_0 )
__stack_chk_fail(a1, *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ *(_DWORD *)_stack_chk_guard__FBSD_1_0);
return result;
}
Map ID's: 190,191,192
PHP Code:
bool __fastcall CBattleArena::IsBattleArenaMap(int a1, int a2, int a3)
{
bool result; // eax@3
if ( a3 == 190 || a3 == 191 )
result = 1;
else
result = a3 == 192;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != *(_DWORD *)_stack_chk_guard__FBSD_1_0 )
__stack_chk_fail(a1, *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ *(_DWORD *)_stack_chk_guard__FBSD_1_0);
return result;
}
PHP Code:
int __fastcall CBattleArena::SetStatus(int a1, int a2, int a3, int a4)
{
int v4; // ST14_4@1
int result; // eax@1
v4 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
*(_DWORD *)(a3 + 8) = a4;
result = *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v4;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v4 )
__stack_chk_fail(a1, a4);
return result;
}
PHP Code:
int __fastcall CBattleArena::CBattleArena(int a1, int a2, int a3)
{
int v3; // eax@1
char v4; // zf@3
int result; // eax@3
int v6; // [sp+20h] [bp-8h]@1
v6 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
v3 = singleton<CBattleArena>::ms_singleton;
*(_DWORD *)a3 = 137593144;
if ( v3 )
__assert("singleton", "../../common/singleton.h", 13);
result = *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v6;
v4 = *(_DWORD *)_stack_chk_guard__FBSD_1_0 == v6;
singleton<CBattleArena>::ms_singleton = a3;
*(_DWORD *)a3 = 137593128;
*(_DWORD *)(a3 + 4) = 0;
*(_DWORD *)(a3 + 8) = 0;
*(_DWORD *)(a3 + 12) = 0;
*(_DWORD *)(a3 + 16) = 0;
*(_BYTE *)(a3 + 20) = 0;
if ( !v4 )
__stack_chk_fail(a1, a2);
return result;
}
PHP Code:
int __fastcall _global_constructor_keyed_to_CBattleArena::CBattleArena(int a1, int a2)
{
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != *(_DWORD *)_stack_chk_guard__FBSD_1_0 )
__stack_chk_fail(a1, a2);
return __static_initialization_and_destruction_0(1, 65535);
}
PHP Code:
int __fastcall CBattleArena::SpawnLastBoss(int a1, int a2, int a3)
{
int v3; // ebx@1
int result; // eax@4
int v5; // [sp+38h] [bp-10h]@1
v5 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
v3 = *(_DWORD *)(a3 + 12);
if ( (unsigned int)(v3 - 190) <= 2 )
{
if ( !singleton<CHARACTER_MANAGER>::ms_singleton )
__assert("instance", "../../common/singleton.h", 26);
CHARACTER_MANAGER::SpawnMob(
(int)singleton<CHARACTER_MANAGER>::ms_singleton,
8616,
v3,
*(_DWORD *)&CBattleArena::SpawnLastBoss_void_::position[8 * (v3 - 190)],
*(_DWORD *)&CBattleArena::SpawnLastBoss_void_::position[8 * (v3 - 190) + 4],
0,
0,
0xFFFFFFFFu,
1);
}
result = *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v5;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v5 )
__stack_chk_fail(a1, a2);
return result;
}
PHP Code:
int __fastcall CBattleArena::SpawnRandomStone(int a1, int a2, int a3)
{
int v3; // ebx@1
int result; // eax@1
int v5; // eax@4
int v6; // edi@4
int v7; // esi@4
int v8; // [sp+30h] [bp-28h]@4
int v9; // [sp+34h] [bp-24h]@4
int v10; // [sp+38h] [bp-20h]@4
int v11; // [sp+48h] [bp-10h]@1
v11 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
v3 = *(_DWORD *)(a3 + 12);
result = v3 - 190;
if ( (unsigned int)(v3 - 190) <= 2 )
{
v5 = 16 * result;
v6 = *(_DWORD *)&CBattleArena::SpawnRandomStone_void_::region_info[v5];
v8 = *(_DWORD *)(v5 + 137592748);
v9 = *(_DWORD *)(v5 + 137592744);
v10 = *(_DWORD *)(v5 + 137592740);
v7 = *(_DWORD *)&CBattleArena::SpawnRandomStone_void_::vnum[4 * number_ex(0, 6, (int)"BattleArena.cpp", 299)];
if ( !singleton<CHARACTER_MANAGER>::ms_singleton )
__assert("instance", "../../common/singleton.h", 26);
result = CHARACTER_MANAGER::SpawnMobRange(
(int)singleton<CHARACTER_MANAGER>::ms_singleton,
v7,
v3,
v6,
v10,
v9,
v8,
0,
1,
0);
}
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v11 )
__stack_chk_fail(a1, *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v11);
return result;
}
PHP Code:
int __cdecl CBattleArena::End(int a1)
{
int v1; // edx@2
int v2; // ecx@2
int v3; // ebx@2
int result; // eax@3
int v5; // eax@7
int v6; // esi@7
int v7; // [sp+14h] [bp-14h]@1
char v8; // [sp+1Ah] [bp-Eh]@11
char v9; // [sp+1Bh] [bp-Dh]@1
int v10; // [sp+1Ch] [bp-Ch]@1
v10 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
*(_BYTE *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 8) = 0;
std::string::string(&v7, "battle_arena", &v9);
if ( !singleton<quest::CQuestManager>::ms_singleton )
__assert("instance", "../../common/singleton.h", 26);
quest::CQuestManager::RequestSetEventFlag(singleton<quest::CQuestManager>::ms_singleton, (int)&v7, 0);
v3 = v7 - 12;
if ( (char *)(v7 - 12) != std::string::_Rep::_S_empty_rep_storage )
{
v5 = _gthread_active;
v6 = v3 + 8;
if ( _gthread_active < 0 )
{
if ( pthread_once )
{
pthread_mutex_lock(&__gthread_active_p_void_::__gthread_active_mutex);
pthread_once(&__gthread_active_p_void_::__gthread_active_once, (void (*)(void))__gthread_trigger);
pthread_mutex_unlock(&__gthread_active_p_void_::__gthread_active_mutex);
}
if ( _gthread_active < 0 )
_gthread_active = 0;
v5 = _gthread_active;
}
if ( v5 )
v1 = __gnu_cxx::__exchange_and_add(v3 + 8, -1);
else
v1 = (*(_DWORD *)v6)--;
if ( v1 <= 0 )
std::string::_Rep::_M_destroy(v3, &v8);
}
result = *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v10;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v10 )
__stack_chk_fail(v2, v1);
return result;
}
PHP Code:
int __fastcall CBattleArena::ForceEnd(int a1, unsigned int a2, int a3)
{
int v3; // eax@2
int v4; // eax@4
int result; // eax@5
int v6; // [sp+1Ch] [bp-Ch]@4
int v7; // [sp+20h] [bp-8h]@1
v7 = *(_DWORD *)_stack_chk_guard__FBSD_1_0;
if ( !*(_BYTE *)(a3 + 20) )
{
v3 = *(_DWORD *)(a3 + 4);
*(_BYTE *)(a3 + 20) = 1;
if ( v3 )
event_cancel(a1, a2, (unsigned int *)(a3 + 4));
v4 = AllocEventInfo<SBattleArenaInfo>((int)&v6);
a1 = v6;
*(_DWORD *)(v6 + 4) = *(_DWORD *)(a3 + 12);
a2 = *(_DWORD *)(a3 + 16);
*(_DWORD *)(a1 + 8) = 3;
*(_DWORD *)a1 = a2;
event_create_ex((int)battle_arena_event, v4, 5 * passes_per_sec);
}
result = *(_DWORD *)_stack_chk_guard__FBSD_1_0 ^ v7;
if ( *(_DWORD *)_stack_chk_guard__FBSD_1_0 != v7 )
__stack_chk_fail(a1, a2);
return result;
}
Also you can start event with ba.start(empire id 1,2,3) . For test. (In quest.)
Enjoy! If you have idea please share with us . :)
1# [Only registered and activated users can see links. Click Here To Register...]