Programacion Skill
Enviado por skillpunk • 19 de Julio de 2013 • 1.585 Palabras (7 Páginas) • 316 Visitas
void CMagicProcess::ExecuteType3(int magicid, int sid, int tid, int data1, int data2, int data3) // Applied when a magical attack, healing, and mana restoration is done.
{
int damage = 0, duration_damage = 0, send_index = 0, result = 1; // Variable initialization. result == 1 : success, 0 : fail
char send_buff[128]; memset( send_buff, NULL, 128);
char strLogData[128]; memset( strLogData, NULL, 128);
BOOL bFlag = FALSE;
CNpc* pMon = NULL;
/*if(!UserRegionCheck(sid,tid,magicid,10,data1,data3))
return;
*/
int casted_member[MAX_USER], party_index = 0 ;
for (int h = 0 ; h < MAX_USER ; h++) {
casted_member[h] = -1;
}
// //TRACE(execute type 3 - 1\n");
_MAGIC_TABLE* pMagic = NULL;
pMagic = m_pMain->m_MagictableArray.GetData( magicid ); // Get main magic table.
if( !pMagic ) return;
_MAGIC_TYPE3* pType = NULL;
pType = m_pMain->m_Magictype3Array.GetData(magicid); // Get magic skill table type 3.
if( !pType ) return;
if (sid >= NPC_BAND) {
bFlag = TRUE;
pMon = m_pMain->m_arNpcArray.GetData(sid);
if( !pMon || pMon->m_NpcState == NPC_DEAD ) return;
/* if(pTUser->m_sDuration[91] + pTUser->m_fStartTime[91] > TimeGet() )
if(magicid == 300139)
return;
*/ }
// //TRACE(execute type 3 - 2\n");
if (tid == -1) { // If the target was the source's party....
for (int i = 0 ; i < MAX_USER ; i++) { // Maximum number of users in the server....
CUser* pTUser = NULL ; // Pointer initialization!
pTUser = (CUser*)m_pMain->m_Iocport.m_SockArray[i]; // Get target info.
// if( !pTUser || pTUser->m_bResHpType == USER_DEAD || pTUser->m_bResHpType == USER_BLINKING) continue ;
if( !pTUser || pTUser->m_bResHpType == USER_DEAD || pTUser->m_bAbnormalType == ABNORMAL_BLINKING) continue ;
// if (UserRegionCheck(sid, i, magicid, pType->bRadius)) {
if (UserRegionCheck(sid, i, magicid, pType->bRadius, data1, data3)) {
casted_member[party_index] = i ;
party_index++ ;
// //TRACE(%d casted \n",i);
}
}
// //TRACE(execute type 3 - 3\n");
if (party_index == 0) { // If none of the members are in the region, return.
/*
SetByte( send_buff, WIZ_MAGIC_PROCESS, send_index );
SetByte( send_buff, MAGIC_FAIL, send_index );
SetDWORD( send_buff, magicid, send_index );
SetShort( send_buff, sid, send_index );
SetShort( send_buff, tid, send_index );
SetShort( send_buff, 0, send_index );
SetShort( send_buff, 0, send_index );
SetShort( send_buff, 0, send_index );
SetShort( send_buff, 0, send_index );
SetShort( send_buff, 0, send_index );
SetShort( send_buff, 0, send_index );
if (!bFlag) {
m_pMain->Send_Region( send_buff, send_index, m_pSrcUser->m_pUserData->m_bZone, m_pSrcUser->m_RegionX, m_pSrcUser->m_RegionZ, NULL, false );
}
else {
m_pMain->Send_Region( send_buff, send_index, pMon->m_sCurZone, pMon->m_sRegion_X, pMon->m_sRegion_Z, NULL, false );
}
return;*/
}
}
else
{ // If the target was another single player.
CUser* pTUser = NULL ; // Pointer initialization!
if (tid < 0 || tid >= MAX_USER) return;
pTUser = (CUser*)m_pMain->m_Iocport.m_SockArray[tid]; // Get target info.
if( !pTUser ) return; // Check if target exists and not already dead.
casted_member[0] = tid ;
party_index = 1 ;
}
for ( int j = 0 ; j < party_index ; j++) { // THIS IS WHERE THE FUN STARTS!!!
CUser* pTUser = NULL ; // Pointer initialization!
if (casted_member[j] < 0 || casted_member[j] >= MAX_USER) continue;
pTUser = (CUser*)m_pMain->m_Iocport.m_SockArray[casted_member[j]]; // Get target info.
if (pTUser->m_sDuration[91]+pTUser->m_fStartTime[91] > TimeGet()) continue;
if (!pTUser|| pTUser->m_bResHpType == USER_DEAD) continue;
if( !pTUser || pTUser->m_bResHpType == USER_DEAD) { // Check if target exists and not already dead.
result = 0 ;
goto packet_send ;
}
// if (pType->sFirstDamage < 0) { // If you are casting an attack spell.
if ((pType->sFirstDamage < 0) && (pType->bDirectType == 1) && (magicid < 400000)) { // If you are casting an attack spell.
damage = GetMagicDamage(sid, casted_member[j], pType->sFirstDamage, pType->bAttribute) ; // Get Magical damage point.
TRACE("Magic id : %d",magicid);
if(damage > 0)
{
if(damage < 500)
{
damage = damage + 538;
}
damage = 0-damage;
}
}
else damage = pType->sFirstDamage ;
// ´«½Î¿òÀüÀïÁ¸¿¡¼ ´«½Î¿òÁßÀ̶ó¸é °ø°ÝÀº ´«À» ´øÁö´Â °Í¸¸ °¡´ÉÇϵµ·Ï,,,
if( m_pSrcUser ) {
if( m_pSrcUser->m_pUserData->m_bZone == ZONE_SNOW_BATTLE && m_pMain->m_byBattleOpen == SNOW_BATTLE ) {
damage = -10;
}
}
if (pType->bDirectType == 18)
{
TRACE("Anger basildi \n\n\n\n");
m_pSrcUser->m_sAnger=0;
m_pSrcUser->RFullAnger();
duration_damage = ((m_pSrcUser->m_pUserData->m_bLevel * 50)/10)+30 ;
if(m_pSrcUser->m_pUserData->m_bLevel > 65 ){
duration_damage = duration_damage*2;
}
duration_damage = 0 - duration_damage;
TRACE("Damage %d \n",duration_damage);
pTUser->m_fHPStartTime[19] = pTUser->m_fHPLastTime[19] = TimeGet(); // The durational magic routine.
pTUser->m_bHPDuration[19] = pType->sDuration;
pTUser->m_bHPInterval[19]
...