BOOL TMonsterSkillElement::ApplyElementNormalAttack(int iIndex, int iTargetIndex) { LPOBJ lpObj = &gObj[iIndex]; LPOBJ lpTargetObj = &gObj[iTargetIndex]; if ( lpTargetObj->Connected < PLAYER_PLAYING ) return FALSE; if ( this->m_iNullifiedSkill == -1 ) this->m_iNullifiedSkill = 0; if ( this->m_iIncAndDecType != -1 && this->m_iIncAndDecValue != -1 ) { if ( lpTargetObj->pInventory[9].m_Type != ITEMGET(this->m_iIncAndDecType, this->m_iIncAndDecValue) && lpTargetObj->pInventory[10].m_Type != ITEMGET(this->m_iIncAndDecType, this->m_iIncAndDecValue) && lpTargetObj->pInventory[11].m_Type != ITEMGET(this->m_iIncAndDecType, this->m_iIncAndDecValue) ) { lpTargetObj->Life = 0; gObjLifeCheck(lpTargetObj, lpObj, 100, 0, 0, 0, 0 ,0); return FALSE; } } if ( this->m_iNullifiedSkill == 0 ) { gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0 ,0); } else { gObjAddMsgSendDelay(lpObj, 55, iTargetIndex, this->m_iNullifiedSkill, 0); } return FALSE; }
//===================================== // Ragi Fighter Offline Experience //===================================== void cOffExp::RageFighterOff(LPOBJ lpObj) { CMagicInf * lpMagic; lpMagic = gObjGetMagicSearch( lpObj, 264); if(lpMagic==NULL) return; gObjUseSkill.UseSkill(lpObj->m_Index, lpMagic,lpObj->X, lpObj->Y,0,0,-1); int dis; int tObjNum; BYTE attr; for (int n=0;n<MAX_VIEWPORT_MONSTER;n++) { tObjNum = lpObj->VpPlayer2[n].number; if(lpObj->VpPlayer2[n].state == 0) continue; if ( tObjNum >= 0 ) { if ( gObj[tObjNum].Type == OBJ_MONSTER ) { attr = MapC[gObj[tObjNum].MapNumber].GetAttr(gObj[tObjNum].X, gObj[tObjNum].Y); if ( (attr&1) != 1 ) { dis = gObjCalDistance(lpObj, &gObj[tObjNum]); if(6 >= dis) { gObjAttack(lpObj, &gObj[tObjNum], lpMagic, FALSE, 1, 0, FALSE, 0 , 0); } } } } } this->UseMana(lpObj->m_Index); }
BOOL TMonsterAIElement::ApplyElementAttackArea(int iIndex, int iTargetIndex, TMonsterAIState * pAIState) { LPOBJ lpObj = &gObj[iIndex]; UTIL.SendCrywolfChattingMsg(iIndex, "Element-영역공격"); int iTargetX = this->m_iX + (rand()%5) * ((rand()%2==0)?1:-1 ) ; int iTargetY = this->m_iY + (rand()%5) * ((rand()%2==0)?1:-1 ) ; for (int i= OBJ_STARTUSERINDEX;i<OBJMAX;i++) { if ( !gObjIsConnected(i)) continue; LPOBJ lpTargetObj = &gObj[i]; if ( !lpObj->Live ) continue; if ( lpObj->MapNumber != lpTargetObj->MapNumber ) continue; int iTargetDistance = (int)sqrt(double(((lpTargetObj->X - iTargetX)*(lpTargetObj->X - iTargetX)) + ((lpTargetObj->Y - iTargetY)*(lpTargetObj->Y - iTargetY)))); if ( iTargetDistance < 10 ) { PMSG_NOTIFY_REGION_MONSTER_ATTACK pMsg; PHeadSubSetB((LPBYTE)&pMsg, 0xBD, 0x0C, sizeof(pMsg)); pMsg.btObjClassH = SET_NUMBERH(lpObj->Class); pMsg.btObjClassL = SET_NUMBERL(lpObj->Class); pMsg.btSourceX = lpObj->X; pMsg.btSourceY = lpObj->Y; pMsg.btPointX = iTargetX; pMsg.btPointY = iTargetY; DataSend(lpTargetObj->m_Index, (LPBYTE)&pMsg, sizeof(pMsg)); } if ( iTargetDistance < 6 ) { gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0, 0,0,0); } } return FALSE; }
//===================================== // Dark Knight Offline Experience //===================================== void cOffExp::DarkKnightOff(LPOBJ lpObj) { int SearchSkill = 0; CMagicInf * lpMagic; if(gObjGetMagicSearch( lpObj, 41) != NULL) SearchSkill = 41; else if(gObjGetMagicSearch( lpObj, 455) != NULL) SearchSkill = 455; else if(gObjGetMagicSearch( lpObj, 456) != NULL) SearchSkill = 456; else if(gObjGetMagicSearch( lpObj, 457) != NULL) SearchSkill = 457; else if(gObjGetMagicSearch( lpObj, 458) != NULL) SearchSkill = 458; else if(gObjGetMagicSearch( lpObj, 459) != NULL) SearchSkill = 459; else return; lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic==NULL) return; gObjUseSkill.UseSkill(lpObj->m_Index, lpMagic,lpObj->X, lpObj->Y,0,0,-1); int dis; int tObjNum; BYTE attr; for (int n=0;n<MAX_VIEWPORT_MONSTER;n++) { tObjNum = lpObj->VpPlayer2[n].number; if(lpObj->VpPlayer2[n].state == 0) continue; if ( tObjNum >= 0 ) { if ( gObj[tObjNum].Type == OBJ_MONSTER ) { attr = MapC[gObj[tObjNum].MapNumber].GetAttr(gObj[tObjNum].X, gObj[tObjNum].Y); if ( (attr&1) != 1 ) { dis = gObjCalDistance(lpObj, &gObj[tObjNum]); if(2 >= dis) { gObjAttack(lpObj, &gObj[tObjNum], lpMagic, FALSE, 1, 0, FALSE,0,0); } } } } } this->UseMana(lpObj->m_Index); }
void TMonsterSkillManager::MonsterSkillProc() { DWORD dwCurrentTick = GetTickCount(); for ( int i=0;i<MAX_MONSTER_SKILL_DELAY_INFO_ARRAY;i++) { if ( TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].bIsUsed == TRUE ) { if ( dwCurrentTick < TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].dwDelayTime ) { _ST_MONSTER_SKILL_DELAYTIME_INFO & stInfo = TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i]; if ( !stInfo.IsValid() ) { TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].RESET(); continue; } LPOBJ lpObj = &gObj[stInfo.iIndex]; LPOBJ lpTargetObj = &gObj[stInfo.iTargetIndex]; if ( !lpObj->Live || !lpTargetObj->Live ) { TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].RESET(); continue; } if ( !gObjIsConnected(lpTargetObj)) { TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].RESET(); continue; } gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0, 0); stInfo.lpMonsterSkillUnit->RunSkill(stInfo.iIndex, stInfo.iTargetIndex); TMonsterSkillManager::s_MonsterSkillDelayInfoArray[i].RESET(); } } } }
//===================================== // Magic Gladiator Offline Experience //===================================== void cOffExp::MagicGladiatorOff(LPOBJ lpObj) { int skill; int NormDis; CMagicInf * lpMagic; int SearchSkill = 0; if(lpObj->pInventory[0].m_Type >= ITEMGET(5,0) && lpObj->pInventory[0].m_Type < ITEMGET(6,0)) { if(gObjGetMagicSearch( lpObj, 9) != NULL) SearchSkill = 9; else if(gObjGetMagicSearch( lpObj, 530) != NULL) SearchSkill = 530; else if(gObjGetMagicSearch( lpObj, 531) != NULL) SearchSkill = 531; else if(gObjGetMagicSearch( lpObj, 532) != NULL) SearchSkill = 532; else if(gObjGetMagicSearch( lpObj, 533) != NULL) SearchSkill = 533; else if(gObjGetMagicSearch( lpObj, 534) != NULL) SearchSkill = 534; else return; skill = SearchSkill; NormDis = 6; } else { if(gObjGetMagicSearch( lpObj, 41) != NULL) SearchSkill = 41; else if(gObjGetMagicSearch( lpObj, 495) != NULL) SearchSkill = 495; else if(gObjGetMagicSearch( lpObj, 496) != NULL) SearchSkill = 496; else if(gObjGetMagicSearch( lpObj, 497) != NULL) SearchSkill = 497; else if(gObjGetMagicSearch( lpObj, 498) != NULL) SearchSkill = 498; else if(gObjGetMagicSearch( lpObj, 499) != NULL) SearchSkill = 499; else return; skill = SearchSkill; NormDis = 2; } lpMagic = gObjGetMagicSearch( lpObj, skill); //Twisting Slash 41 if(lpMagic==NULL) return; gObjUseSkill.UseSkill(lpObj->m_Index, lpMagic,lpObj->X, lpObj->Y,0,0,-1); int dis; int tObjNum; BYTE attr; for (int n=0;n<MAX_VIEWPORT_MONSTER;n++) { tObjNum = lpObj->VpPlayer2[n].number; if(lpObj->VpPlayer2[n].state == 0) continue; if ( tObjNum >= 0 ) { if ( gObj[tObjNum].Type == OBJ_MONSTER ) { attr = MapC[gObj[tObjNum].MapNumber].GetAttr(gObj[tObjNum].X, gObj[tObjNum].Y); if ( (attr&1) != 1 ) { dis = gObjCalDistance(lpObj, &gObj[tObjNum]); if(NormDis >= dis) { gObjAttack(lpObj, &gObj[tObjNum], lpMagic, FALSE, 1, 0, FALSE, 0 , 0); } } } } } this->UseMana(lpObj->m_Index); }
//===================================== // Fairy Elf Offline Experience //===================================== void cOffExp::FairyElfOff(LPOBJ lpObj) { int SearchSkill = 0; int dis; int tObjNum; BYTE attr; CMagicInf * lpMagic; //Buff SYSTEMTIME time; GetLocalTime(&time); if( time.wSecond == 0 || time.wSecond == 10 || time.wSecond == 20 || time.wSecond == 30 || time.wSecond == 40 || time.wSecond == 50 ) { int partynum = -1; int partycount; int number; LPOBJ lpPartyObj; partynum = lpObj->PartyNumber; if(partynum != -1) { partycount = gParty.m_PartyS[partynum].Count; for(int j = 0; j < MAX_USER_IN_PARTY; j++) { number = gParty.m_PartyS[partynum].Number[j]; if(number >= 0) { lpPartyObj = &gObj[number]; if(lpObj->MapNumber == lpPartyObj->MapNumber) { dis = gObjCalDistance(lpObj,&gObj[number]); if(dis < 6) { //Defence Baf if(gObjGetMagicSearch( lpObj, 27) != NULL) SearchSkill = 27; else if(gObjGetMagicSearch( lpObj, 480) != NULL) SearchSkill = 480; else if(gObjGetMagicSearch( lpObj, 481) != NULL) SearchSkill = 481; else if(gObjGetMagicSearch( lpObj, 482) != NULL) SearchSkill = 482; else if(gObjGetMagicSearch( lpObj, 483) != NULL) SearchSkill = 483; else if(gObjGetMagicSearch( lpObj, 484) != NULL) SearchSkill = 484; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } //Damage Baf if(gObjGetMagicSearch( lpObj, 28) != NULL) SearchSkill = 28; else if(gObjGetMagicSearch( lpObj, 485) != NULL) SearchSkill = 485; else if(gObjGetMagicSearch( lpObj, 486) != NULL) SearchSkill = 486; else if(gObjGetMagicSearch( lpObj, 487) != NULL) SearchSkill = 487; else if(gObjGetMagicSearch( lpObj, 488) != NULL) SearchSkill = 488; else if(gObjGetMagicSearch( lpObj, 489) != NULL) SearchSkill = 489; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } //Heal Baf if(gObjGetMagicSearch( lpObj, 26) != NULL) SearchSkill = 26; else if(gObjGetMagicSearch( lpObj, 475) != NULL) SearchSkill = 475; else if(gObjGetMagicSearch( lpObj, 476) != NULL) SearchSkill = 476; else if(gObjGetMagicSearch( lpObj, 477) != NULL) SearchSkill = 477; else if(gObjGetMagicSearch( lpObj, 478) != NULL) SearchSkill = 478; else if(gObjGetMagicSearch( lpObj, 479) != NULL) SearchSkill = 479; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } } } } } } else { //Defence Baf if(gObjGetMagicSearch( lpObj, 27) != NULL) SearchSkill = 27; else if(gObjGetMagicSearch( lpObj, 480) != NULL) SearchSkill = 480; else if(gObjGetMagicSearch( lpObj, 481) != NULL) SearchSkill = 481; else if(gObjGetMagicSearch( lpObj, 482) != NULL) SearchSkill = 482; else if(gObjGetMagicSearch( lpObj, 483) != NULL) SearchSkill = 483; else if(gObjGetMagicSearch( lpObj, 484) != NULL) SearchSkill = 484; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } //Damage Baf if(gObjGetMagicSearch( lpObj, 28) != NULL) SearchSkill = 28; else if(gObjGetMagicSearch( lpObj, 485) != NULL) SearchSkill = 485; else if(gObjGetMagicSearch( lpObj, 486) != NULL) SearchSkill = 486; else if(gObjGetMagicSearch( lpObj, 487) != NULL) SearchSkill = 487; else if(gObjGetMagicSearch( lpObj, 488) != NULL) SearchSkill = 488; else if(gObjGetMagicSearch( lpObj, 489) != NULL) SearchSkill = 489; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } //Heal Baf if(gObjGetMagicSearch( lpObj, 26) != NULL) SearchSkill = 26; else if(gObjGetMagicSearch( lpObj, 475) != NULL) SearchSkill = 475; else if(gObjGetMagicSearch( lpObj, 476) != NULL) SearchSkill = 476; else if(gObjGetMagicSearch( lpObj, 477) != NULL) SearchSkill = 477; else if(gObjGetMagicSearch( lpObj, 478) != NULL) SearchSkill = 478; else if(gObjGetMagicSearch( lpObj, 479) != NULL) SearchSkill = 479; else SearchSkill = 0; if(SearchSkill != 0) { lpMagic = gObjGetMagicSearch( lpObj, SearchSkill); if(lpMagic!=NULL) gObjUseSkill.UseSkill(lpObj->m_Index, lpObj->m_Index, lpMagic); } } } lpMagic = gObjGetMagicSearch( lpObj, 235); //Multi-Shot 235 if(lpMagic==NULL) return; int NumDir[6] = {0, 50, 100, 150, 200, 250 }; int StartDir = NumDir[rand()%6]; gObjUseSkill.UseSkill(lpObj->m_Index, lpMagic,lpObj->X, lpObj->Y,StartDir,0,-1); for (int n=0;n<MAX_VIEWPORT_MONSTER;n++) { tObjNum = lpObj->VpPlayer2[n].number; if(lpObj->VpPlayer2[n].state == 0) continue; if ( tObjNum >= 0 ) { if ( gObj[tObjNum].Type == OBJ_MONSTER ) { attr = MapC[gObj[tObjNum].MapNumber].GetAttr(gObj[tObjNum].X, gObj[tObjNum].Y); if ( (attr&1) != 1 ) { dis = gObjCalDistance(lpObj, &gObj[tObjNum]); if(5 >= dis) { gObjAttack(lpObj, &gObj[tObjNum], lpMagic, FALSE, 1, 0, FALSE, 0 , 0); } } } } } this->UseMana(lpObj->m_Index); }
//good void TMonsterSkillManager::UseMonsterSkill(int iIndex, int iTargetIndex, int iMonsterSkillUnitType, int iMonsterSkillUnit,CMagicInf * lpMagic) { if (iIndex >= OBJ_MAXMONSTER || iIndex < 0) { LogAddC(2,"[TMonsterSkillManager][UserMonsterSkill] error: iIndex(%d)",iIndex); return; } if (iTargetIndex >= OBJMAX || iTargetIndex < 0) { LogAddC(2,"[TMonsterSkillManager][UserMonsterSkill] error: iTargetIndex(%d)",iTargetIndex); return; } LPOBJ lpObj = &gObj[iIndex]; //loc1 LPOBJ lpTargetObj = &gObj[iTargetIndex]; //loc2 TMonsterSkillInfo * lpMonsterSkillInfo = &TMonsterSkillManager::s_MonsterSkillInfoArray[lpObj->Class]; //loc3 if ( lpMonsterSkillInfo->IsValid() == FALSE ) return; TMonsterSkillUnit * lpMonsterSkillUnit = NULL; //loc4 if ( iMonsterSkillUnit > -1) //arg4 { int iMonsterSkill = iMonsterSkillUnit; //loc5 lpMonsterSkillUnit = lpMonsterSkillInfo->m_lpSkillUnitArray[iMonsterSkill]; } else { lpMonsterSkillUnit = TMonsterSkillManager::FindMonsterSkillUnit(iIndex, iMonsterSkillUnitType); } if ( lpMonsterSkillUnit == NULL ) { LogAddC(2, "[Monster Skill Manager] SkillUnit is NULL : ObjIndex[%d], SkillUnitType[%d] ",iIndex,iMonsterSkillUnitType); return; } GCUseMonsterSkillSend(lpObj, lpTargetObj, lpMonsterSkillUnit->m_iUnitNumber); //TEST //char szTemp[256]; //wsprintf(szTemp, "[USEMONSTERSKILL] %d", lpMonsterSkillUnit->m_iUnitNumber); //GCServerMsgStringSend(szTemp, lpTargetObj->m_Index, 1); if ( lpMonsterSkillUnit->m_iUnitScopeType == -1 ) { if ( lpObj->MapNumber == MAP_INDEX_RAKLION ) { gObjAttack(lpObj, lpTargetObj, NULL, FALSE, 0, 0, FALSE); } if ( lpObj->MapNumber == MAP_INDEX_RAKLION_BOSS ) { if ( lpObj->Class == 459 ) { if ( lpMonsterSkillUnit->m_iUnitNumber == 40 ) { gObjAttack(lpObj, lpTargetObj, NULL, FALSE, 0, 0, FALSE); } else { if ( lpMagic ) { gObjAttack(lpObj, lpTargetObj,lpMagic, 0, 0, 0, 0); } } } else { gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0, 0); } } lpMonsterSkillUnit->RunSkill(iIndex, iTargetIndex); } else { int iCount = 0; int iRangeTargetIndex = -1; int iAngle = gObjUseSkill.GetAngle(lpObj->X, lpObj->Y, lpTargetObj->X, lpTargetObj->Y); while ( true ) { if ( lpObj->VpPlayer2[iCount].state ) { iRangeTargetIndex = lpObj->VpPlayer2[iCount].number; if ( OBJMAX_RANGE(iRangeTargetIndex)) { if ( gObj[iRangeTargetIndex].Type == OBJ_USER ) { BOOL bTargetOK = FALSE; if ( lpMonsterSkillUnit->m_iUnitScopeType == 0 ) { if ( gObjCalDistance(lpObj, &gObj[iRangeTargetIndex]) < lpMonsterSkillUnit->m_iUnitScopeValue ) { bTargetOK = TRUE; } } else if ( lpMonsterSkillUnit->m_iUnitScopeType == 1 ) { if ( SkillElectricSparkHitBox.HitCheck(iAngle, lpObj->X, lpObj->Y, gObj[iRangeTargetIndex].X, gObj[iRangeTargetIndex].Y) ) { bTargetOK = TRUE; } } else if ( lpMonsterSkillUnit->m_iUnitScopeType == 2 ) { bTargetOK = TRUE; } else if ( lpMonsterSkillUnit->m_iUnitScopeType == 3 ) { bTargetOK = TRUE; } if ( bTargetOK ) { if ( lpObj->MapNumber == MAP_INDEX_RAKLION ) { gObjAttack(lpObj, lpTargetObj, NULL, FALSE, 0, 0, FALSE); } if ( lpObj->MapNumber == MAP_INDEX_RAKLION_BOSS ) { if ( lpObj->Class == 459 ) { if ( lpMonsterSkillUnit->m_iUnitNumber == 40 ) { gObjAttack(lpObj, lpTargetObj, NULL, FALSE, 0, 0, FALSE); } else { if ( lpMagic ) { gObjAttack(lpObj, lpTargetObj,lpMagic, 0, 0, 0, 0); } } } else { gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0, 0); } } lpMonsterSkillUnit->RunSkill(iIndex, iRangeTargetIndex); } } } } iCount++; if ( iCount > MAX_VIEWPORT_MONSTER-1) break; } } }
void TMonsterAI::ProcessStateMsg(LPOBJ lpObj, int iMsgCode, int iIndex, int aMsgSubCode) { switch ( iMsgCode ) { case 1: gObjMonsterDieGiveItem(lpObj, &gObj[iIndex]); break; case 2: if ( gObj[iIndex].Live != FALSE ) { gObjBackSpring(lpObj, &gObj[iIndex]); } break; case 3: if ( lpObj->TargetNumber != -1 ) { lpObj->m_Agro.DelAgro(lpObj->TargetNumber); } lpObj->TargetNumber = -1; lpObj->LastAttackerID = -1; lpObj->m_ActState.Emotion = 0; lpObj->m_ActState.Attack = 0; lpObj->m_ActState.Move = 0; lpObj->NextActionTime = 1000; break; case 4: lpObj->m_ActState.Emotion = 3; lpObj->m_ActState.EmotionCount = 1; break; case 55: gObjAttack(lpObj, &gObj[iIndex], NULL, FALSE, FALSE, 0, FALSE, 0, 0); break; case 56: { LPOBJ lpTargetObj = &gObj[iIndex]; if(gObjCheckUsedBuffEffect(lpTargetObj, AT_POISON) == 0) { if ( retResistance(lpTargetObj, 1) == FALSE ) { lpTargetObj->lpAttackObj = lpObj; gObjAddBuffEffect(lpTargetObj, AT_POISON, 19, 3, 0, 0, aMsgSubCode); } } } break; case 57: { LPOBJ lpTargetObj = &gObj[iIndex]; gObjBackSpring2(lpTargetObj, lpObj, aMsgSubCode); } break; } }
BOOL TMonsterAIElement::ApplyElementAttack(int iIndex, int iTargetIndex, TMonsterAIState * pAIState) { LPOBJ lpObj = &gObj[iIndex]; UTIL.SendCrywolfChattingMsg(iIndex, "Element-공격"); if ( TMonsterSkillManager::CheckMonsterSkill(lpObj->Class) ) { BOOL bEnableAttack = TRUE; if ( lpObj->TargetNumber < 0 ) { lpObj->TargetNumber = -1; lpObj->m_ActState.Emotion = 0; lpObj->m_ActState.Attack = 0; lpObj->m_ActState.Move = 0; lpObj->NextActionTime = 1000; return FALSE; } if ( !gObj[lpObj->TargetNumber].Live || gObj[lpObj->TargetNumber].Teleport ) bEnableAttack = FALSE; if ( gObj[lpObj->TargetNumber].Connected <= PLAYER_LOGGED || gObj[lpObj->TargetNumber].CloseCount != -1 ) { bEnableAttack = FALSE; } if ( !bEnableAttack ) { lpObj->TargetNumber = -1; lpObj->m_ActState.Emotion = 0; lpObj->m_ActState.Attack = 0; lpObj->m_ActState.Move = 0; lpObj->NextActionTime = 1000; return FALSE; } LPOBJ lpTargetObj = &gObj[lpObj->TargetNumber]; lpObj->Dir = GetPathPacketDirPos(lpTargetObj->X - lpObj->X, lpTargetObj->Y - lpObj->Y); if ( (rand()%4) == 0 ) { PMSG_ATTACK pAttackMsg; pAttackMsg.AttackAction = 0x78; pAttackMsg.DirDis = lpObj->Dir; pAttackMsg.NumberH = SET_NUMBERH(lpObj->TargetNumber); pAttackMsg.NumberL = SET_NUMBERL(lpObj->TargetNumber); GCActionSend(lpObj, 0x78, lpObj->m_Index, 0); gObjAttack(lpObj, &gObj[lpObj->TargetNumber], 0, 0, 0, 0, 0,0,0); } else { TMonsterSkillManager::UseMonsterSkill(lpObj->m_Index, lpObj->TargetNumber, 0, -1, 0); } lpObj->m_ActState.Attack = 0; return FALSE; } else { if( lpObj->TargetNumber < 0 ) return FALSE; LPOBJ lpTargetObj = &gObj[lpObj->TargetNumber]; lpObj->Dir = GetPathPacketDirPos(lpTargetObj->X - lpObj->X, lpTargetObj->Y - lpObj->Y); PMSG_ATTACK pAttackMsg; pAttackMsg.AttackAction = 0x78; pAttackMsg.DirDis = lpObj->Dir; pAttackMsg.NumberH = SET_NUMBERH(lpObj->TargetNumber); pAttackMsg.NumberL = SET_NUMBERL(lpObj->TargetNumber); CGAttack((PMSG_ATTACK *)&pAttackMsg, lpObj->m_Index); GCActionSend(lpObj, 0x78, lpObj->m_Index, lpTargetObj->m_Index); gObjAttack(lpObj, &gObj[lpObj->TargetNumber], 0, 0, 0, 0, 0,0,0); return FALSE; } }
void TMonsterAI::ProcessStateMsg(LPOBJ lpObj, int iMsgCode, int iIndex, int aMsgSubCode) { switch ( iMsgCode ) { case 1: gObjMonsterDieGiveItem(lpObj, &gObj[iIndex]); break; case 2: if ( gObj[iIndex].Live != FALSE ) { gObjBackSpring(lpObj, &gObj[iIndex]); } break; case 3: if ( lpObj->TargetNumber != -1 ) { lpObj->m_Agro.DelAgro(lpObj->TargetNumber); } lpObj->TargetNumber = -1; lpObj->LastAttackerID = -1; lpObj->m_ActState.Emotion = 0; lpObj->m_ActState.Attack = 0; lpObj->m_ActState.Move = 0; lpObj->NextActionTime = 1000; break; case 4: lpObj->m_ActState.Emotion = 3; lpObj->m_ActState.EmotionCount = 1; break; case 55: gObjAttack(lpObj, &gObj[iIndex], NULL, FALSE, FALSE, 0, FALSE); break; case 56: { LPOBJ lpTargetObj = &gObj[iIndex]; if ( lpTargetObj->m_PoisonType == 0 ) { if ( retResistance(lpTargetObj, R_POISON) == FALSE ) { lpTargetObj->m_PoisonType = 1; lpTargetObj->m_PoisonBeattackCount = aMsgSubCode; lpTargetObj->lpAttackObj = lpObj; lpTargetObj->m_ViewSkillState |= 1; GCSkillInfoSend(lpTargetObj, 1, 0x37); } } } break; case 57: { LPOBJ lpTargetObj = &gObj[iIndex]; gObjBackSpring2(lpTargetObj, lpObj, aMsgSubCode); } break; } }