Yea I just ordered all things and made source more clear.
But the problem is, for example create attack combat..
When you click on mob, then it will save data into list and that list:
Code:
void CClientSession::SendAttackBegin(CNtlPacket * pPacket, CGameServer * app)
{
printf("--- ATTACK BEGIN --- \n");
sUG_CHAR_ATTACK_BEGIN* req = (sUG_CHAR_ATTACK_BEGIN *)pPacket->GetPacketData();
if(req->byType == 0)
{
app->AddAttackBegin(this->GetTargetSerialId());
}
else if(req->byType == 1)
{
printf("ATTACK FOR TYPE 1 NOT EXIST \n");
}
}
AddAttackBegin -> I have inside main thread
Code:
void CGameServer::AddAttackBegin(RwUInt32 uiSerialId)
{
SBattleData *pBattleData = new SBattleData;
printf("ADDATTACKBEGIN SERIAL %i \n", uiSerialId);
pBattleData->uiSerialId = uiSerialId;
pBattleData->uiTargetSerialId = 0xffffffff;
pBattleData->bAttackMode = TRUE;
pBattleData->dwCurrTime = timeGetTime();
m_listAttackBegin.push_back(pBattleData);
}
now the work from the loop should appear and do this:
Code:
SBattleData *pBattleData;
ListAttackBegin::iterator it;
for(it = m_listAttackBegin.begin(); it != m_listAttackBegin.end(); it++)
{
pBattleData = (*it);
if(timeGetTime() - pBattleData->dwCurrTime >= 1000)
{
SendCharActionAttack(pBattleData->uiSerialId);
pBattleData->dwCurrTime = timeGetTime();
}
}
but the problem: for
Code:
SendCharActionAttack(pBattleData->uiSerialId);
I need current char session...
SendCharActionAttack:
Code:
void CClientSession::SendCharActionAttack(RwUInt32 uiSerialId)
{
static RwUInt8 byChainAttack = 0;
RwBool bDamageApply = TRUE;
CNtlPacket packet(sizeof(sGU_CHAR_ACTION_ATTACK));
sGU_CHAR_ACTION_ATTACK * res = (sGU_CHAR_ACTION_ATTACK *)packet.GetPacketData();
res->wOpCode = GU_CHAR_ACTION_ATTACK;
res->hSubject = this->GetavatarHandle();
res->hTarget = this->GetTargetSerialId();
res->bChainAttack = TRUE;
res->wAttackResultValue = 150;
res->byAttackSequence = rand()%2;
if(res->byAttackSequence == 6)
{
if(rand()%2)
res->byAttackResult = BATTLE_ATTACK_RESULT_KNOCKDOWN;
else
res->byAttackResult = BATTLE_ATTACK_RESULT_SLIDING;
}
else
{
RwInt32 iRandValue = rand()%5;
if(iRandValue <= 2)
res->byAttackResult = BATTLE_ATTACK_RESULT_HIT;
else if(iRandValue == 3)
{
bDamageApply = FALSE;
res->byAttackResult = BATTLE_ATTACK_RESULT_DODGE;
}
else
{
bDamageApply = FALSE;
res->byAttackResult = BATTLE_ATTACK_RESULT_BLOCK;
}
}
packet.SetPacketLen( sizeof(sGU_CHAR_ACTION_ATTACK) );
int rc = g_pApp->Send( this->GetHandle(), &packet );
byChainAttack++;
}
- - - Updated - - -
Well here are 2 screens.. Maybe you will understand the error I have with the main loop and why I opened this thread
