int TMonsterAIAgro::GetMaxAgroUserIndex(int iMonsterIndex) { int iMaxAgroUserIndex = -1; int iMaxAgro = -1; for ( int i=0;i<MAX_MONSTER_AI_AGRO;i++) { if ( this->m_Agro[i].GetUserIndex() != -1 ) { LPOBJ lpObj = &gObj[this->m_Agro[i].GetUserIndex()]; if ( (lpObj->Authority&2) == 2 ) continue; if ( !gObjIsConnected(lpObj) ) { this->m_Agro[i].Reset(); continue; } if ( lpObj->Live == FALSE ) { this->m_Agro[i].Reset(); continue; } if ( gObjCalDistance(&gObj[iMonsterIndex], lpObj) > 7 ) continue; BYTE btAttr = MapC[lpObj->MapNumber].GetAttr(lpObj->X, lpObj->Y); if ( (btAttr&1) != 0 ) continue; if ( this->m_Agro[i].GetAgroValue() > iMaxAgro ) { iMaxAgroUserIndex = this->m_Agro[i].GetUserIndex(); iMaxAgro = this->m_Agro[i].GetAgroValue(); } } } return iMaxAgroUserIndex; }
//===================================== // 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); }
TMonsterAIGroupMember * TMonsterAIGroup::FindGroupMemberToHeal(int iObjIndex, int iGroupNumber, int iGuid, int iDistance) { if ( TMonsterAIGroup::s_iMonsterAIGroupMemberCount[iGroupNumber] == 0 ) return NULL; int iMinHPGuid = -1; int iMinHP = 100000000; int iCount = TMonsterAIGroup::s_iMonsterAIGroupMemberCount[iGroupNumber]; for ( int i=0;i<iCount;i++) { if ( TMonsterAIGroup::s_MonsterAIGroupMemberArray[iGroupNumber][i].m_iGroupNumber == iGroupNumber ) { LPOBJ lpTargetObj = &gObj[TMonsterAIGroup::s_MonsterAIGroupMemberArray[iGroupNumber][i].m_iObjIndex]; if ( lpTargetObj == NULL ) continue; if ( gObjCalDistance(&gObj[iObjIndex], lpTargetObj) > iDistance ) continue; int iMaxLife = int(lpTargetObj->MaxLife + 1.0); int iPercentHP = int(lpTargetObj->Life * 100.0 / iMaxLife); if ( iPercentHP < 60 ) { if ( lpTargetObj->m_Index == iObjIndex ) iPercentHP = 1; if ( iPercentHP < iMinHP ) { iMinHP = iPercentHP; iMinHPGuid = lpTargetObj->m_iGroupMemberGuid; } } } } if ( iMinHPGuid != -1 ) return &TMonsterAIGroup::s_MonsterAIGroupMemberArray[iGroupNumber][iMinHPGuid]; return NULL; }
// ---------------------------------------------------------------------------------------------------------------------- void CDarkSpirit::ModeAttackWithMaster() { LPOBJ lpObj = &gObj[this->m_iMasterIndex]; int count = 0; int dis; if ( this->m_iTargetIndex == -1 ) { return; } if ( lpObj->MapNumber == gObj[this->m_iTargetIndex].MapNumber ) { if ( gObj[this->m_iTargetIndex].Life > 0.0f ) { dis = gObjCalDistance(lpObj, &gObj[this->m_iTargetIndex]); if ( dis < RAVEN_ATTACK_DISTANCE ) { int criticaldamage = 0; if ( (rand()%10) < 3 ) { criticaldamage = FALSE; } if ( criticaldamage != FALSE ) { this->SendAttackMsg(lpObj->m_Index, this->m_iTargetIndex, criticaldamage, 0); } else { this->RangeAttack(lpObj->m_Index, this->m_iTargetIndex); } } } else { this->ReSetTarget(this->m_iTargetIndex); } } }
int cOffExp::SearchTarget(LPOBJ lpObj) { int dis; int searchtarget = -1; int tObjNum; BYTE attr; int TargetIndex[MAX_VIEWPORT_MONSTER]; int TargetCount = 0; int IndexNumber; 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) { TargetIndex[TargetCount] = tObjNum; TargetCount++; } } } } } if(TargetCount == 0) return -1; IndexNumber = rand()%TargetCount; searchtarget = TargetIndex[IndexNumber]; return searchtarget; }
int gObjAddBuffEffectWideArea(LPOBJ lpTargetObj,int nDistance,int & nAffectedCount,int iBuffIndex,BYTE EffectType1,int EffectValue1,BYTE EffectType2,int EffectValue2,int Duration) { if(lpTargetObj == NULL) return FALSE; for(int iIndex = OBJ_STARTUSERINDEX; iIndex < OBJMAX; iIndex++) { LPOBJ lpObj = &gObj[iIndex]; if(lpObj->Type == OBJ_USER && gObjIsConnected(iIndex) != FALSE) { if(lpObj->MapNumber == lpTargetObj->MapNumber) { if(gObjCalDistance(lpTargetObj,lpObj) < nDistance) { gObjAddBuffEffect(lpObj, iBuffIndex, EffectType1, EffectValue1, EffectType2, EffectValue2, Duration); nAffectedCount+= 1; } } } } return TRUE; }
void CCannonTower::CannonTowerAct(int iIndex) { if ( (rand()%2) != 0 ) return; LPOBJ lpObj = &gObj[iIndex]; int tObjNum; int count = 0; PMSG_BEATTACK_COUNT pCount; PMSG_BEATTACK pAttack; BYTE AttackSendBuff[256]; int ASBOfs = 0; pCount.h.c = 0xC1; pCount.h.headcode = 0x10; pCount.h.size = 0; pCount.MagicNumberH = 0; pCount.MagicNumberL = 0; pCount.Count = 0; pCount.X = lpObj->X; pCount.Y = lpObj->Y; ASBOfs = sizeof(pCount); while ( true ) { if ( lpObj->VpPlayer2[count].state ) { if ( lpObj->VpPlayer2[count].type == OBJ_USER ) { tObjNum = lpObj->VpPlayer2[count].number; if ( tObjNum >= 0 ) { if ( gObj[tObjNum].m_btCsJoinSide != 1 ) { if ( gObjCalDistance(lpObj, &gObj[tObjNum]) < 7 ) { pAttack.NumberH = SET_NUMBERH(tObjNum); pAttack.NumberL = SET_NUMBERL(tObjNum); memcpy(&AttackSendBuff[ASBOfs], &pAttack, sizeof(pAttack)); ASBOfs += sizeof(pAttack); pCount.Count++; } } } } } count++; if ( count > MAX_VIEWPORT-1 ) break; } if ( pCount.Count > 0 ) { pCount.h.size = ASBOfs; memcpy(AttackSendBuff, &pCount, sizeof(pCount)); CGBeattackRecv(AttackSendBuff, lpObj->m_Index, 1); PMSG_DURATION_MAGIC_SEND pMsg; C3HeadSet((LPBYTE)&pMsg, 0x1E, sizeof(pMsg)); pMsg.MagicNumberH = 0x00; pMsg.MagicNumberL = 50; pMsg.X = lpObj->X; pMsg.Y = lpObj->Y; pMsg.Dir = 0; pMsg.NumberH = SET_NUMBERH(iIndex); pMsg.NumberL = SET_NUMBERL(iIndex); gSendProto.VPMsgSend(lpObj, (LPBYTE)&pMsg, pMsg.h.size); } }
//===================================== // 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); }
TMonsterAIState * TMonsterAIAutomata::RunAutomata(int iIndex) { LPOBJ lpObj = &gObj[iIndex]; if ( MAX_AI_STATE_RANGE(lpObj->m_iCurrentAIState) == FALSE ) return NULL; LPOBJ lpTargetObj = NULL; int iMaxAgro = -1; int iTargetIndex = lpObj->m_Agro.GetMaxAgroUserIndex(lpObj->m_Index); // Search The user with Max Agro to make its enemy if ( iTargetIndex != -1 ) { lpTargetObj = &gObj[iTargetIndex]; if ( MONSTER_UTIL.FindMonViewportObj(lpObj->m_Index, lpTargetObj->m_Index) ) { iMaxAgro = lpObj->m_Agro.GetAgro(iTargetIndex); lpObj->TargetNumber = iTargetIndex; } else { lpObj->TargetNumber = -1; lpTargetObj = NULL; } } BOOL bRateSuccess = FALSE; int iCurrentState = lpObj->m_iCurrentAIState; int iMaxStateTransCount = this->m_AIStateTransCount[iCurrentState]; for ( int iPriority=0;iPriority<iMaxStateTransCount;iPriority++) { TMonsterAIState * AIState = &this->m_AIState[iCurrentState][iPriority]; BOOL bTransition = MAI_STATE_TRANS_VALUE_; // If there is an apropiate Value it is set to TRUE // Choose the right action according Transation Type switch ( AIState->m_iTransitionType ) { case MAI_STATE_TRANS_NO_ENEMY: if ( lpTargetObj == NULL ) { bTransition = TRUE; } break; case MAI_STATE_TRANS_IN_ENEMY: if ( lpTargetObj ) { if ( gObjCalDistance(lpObj, lpTargetObj) <= lpObj->m_AttackRange ) { bTransition = TRUE; } } break; case MAI_STATE_TRANS_OUT_ENEMY: if ( lpTargetObj ) { if ( gObjCalDistance(lpObj, lpTargetObj) > lpObj->m_AttackRange ) { bTransition = TRUE; } } break; //case MAI_STATE_TRANS_DIE_ENEMY: case MAI_STATE_TRANS_DEC_HP: if ( AIState->m_iTransitionValue > lpObj->Life ) { bTransition = TRUE; } break; case MAI_STATE_TRANS_IMMEDIATELY: bTransition = TRUE; break; case MAI_STATE_TRANS_DEC_HP_PER: { AIState->m_iTransitionValue = (AIState->m_iTransitionValue > 0)? AIState->m_iTransitionValue : 0; AIState->m_iTransitionValue = (AIState->m_iTransitionValue < 100 )? AIState->m_iTransitionValue : 100 ; int iLife = ((float)lpObj->AddLife + lpObj->MaxLife) * (float)AIState->m_iTransitionValue / 100.0f; if ( iLife > lpObj->Life ) { bTransition = TRUE; } } break; case MAI_STATE_TRANS_AGRO_UP: if ( lpTargetObj ) { if ( iMaxAgro >= AIState->m_iTransitionValue ) { bTransition = TRUE; } } break; case MAI_STATE_TRANS_AGRO_DOWN: if ( lpTargetObj ) { if ( iMaxAgro <= AIState->m_iTransitionValue ) { bTransition = TRUE; } } break; case MAI_STATE_TRANS_GROUP_SOMMON: if ( lpObj->m_iGroupNumber ) { if ( TMonsterAIGroup::FindGroupMemberToSommon(lpObj->m_Index, lpObj->m_iGroupNumber, lpObj->m_iGroupMemberGuid) ) { bTransition = TRUE; } } case MAI_STATE_TRANS_GROUP_HEAL: if ( lpObj->m_iGroupNumber ) { if ( TMonsterAIGroup::FindGroupMemberToHeal(lpObj->m_Index, lpObj->m_iGroupNumber, lpObj->m_iGroupMemberGuid, 5) ) { bTransition = TRUE; } } break; } // If is Wrong State if ( bTransition == FALSE ) continue; if ( (rand()%100) < AIState->m_iTransitionRate ) { bRateSuccess = TRUE; lpObj->m_iLastAutomataDelay = AIState->m_iDelayTime; return &this->m_AIState[iCurrentState][iPriority]; } } return NULL; }
void CCannonTower::CannonTowerAct(int iIndex) // 0x00560940 1.00.19 { if( ( rand() % 2 ) != 0 ) // review this { return; } LPOBJ lpObj = &gObj[iIndex]; int count = 0; int ASBOfs = 0; PMSG_BEATTACK_COUNT pCount; PMSG_BEATTACK pAttack; pCount.h.c = 0xC1; pCount.h.headcode = 0x1D; pCount.h.size = 0x00; pCount.MagicNumberH = SET_NUMBERH(0); pCount.MagicNumberL = SET_NUMBERL(0); //pCount.MagicNumber = 0x00; pCount.Count = 0x00; pCount.X = lpObj->X; pCount.Y = lpObj->Y; ASBOfs = sizeof(PMSG_BEATTACK_COUNT); unsigned char AttackSendBuff[256]; while( true ) { if( lpObj->VpPlayer2[count].state ) { if( lpObj->VpPlayer2[count].type == OBJ_USER ) { int tObjNum = lpObj->VpPlayer2[count].number; if( tObjNum >= 0 ) { if( gObj[tObjNum].m_btCsJoinSide ) { if( gObjCalDistance(lpObj, &gObj[tObjNum]) < 7 ) { pAttack.NumberH = SET_NUMBERH(tObjNum); pAttack.NumberL = SET_NUMBERL(tObjNum); memcpy( (AttackSendBuff+ASBOfs), (PBYTE)&pAttack, sizeof(PMSG_BEATTACK)); ASBOfs += sizeof(PMSG_BEATTACK); pCount.Count++; } } } } } count++; if( count > MAX_VIEWPORT-1 ) break; } if( pCount.Count > 0 ) { pCount.h.size = ASBOfs; memcpy(AttackSendBuff, (LPBYTE)&pCount, sizeof(PMSG_BEATTACK_COUNT)); CGBeattackRecv(AttackSendBuff, lpObj->m_Index, 1); struct PMSG_UNKNOW_STRUCT { PBMSG_HEAD h; // C3:1E BYTE NumberX; // 3 BYTE NumberH; // 4 BYTE NumberL; // 5 BYTE X; // 6 BYTE Y; // 7 BYTE btUnk; // 8 }; PMSG_UNKNOW_STRUCT pSend; // this is not the right Struct, but this will work PHeadSetBE((LPBYTE)&pSend, 0x1E, sizeof(PMSG_UNKNOW_STRUCT)); pSend.NumberX = 0x32; pSend.X = lpObj->X; pSend.Y = lpObj->Y; pSend.btUnk = 0; pSend.NumberH = SET_NUMBERH(iIndex); pSend.NumberL = SET_NUMBERL(iIndex); ::MsgSendV2(lpObj, (PBYTE)&pSend, pSend.h.size); } }
// ---------------------------------------------------------------------------------------------------------------------- void CDarkSpirit::RangeAttack(int aIndex, int aTargetIndex) { LPOBJ lpObj = &gObj[aIndex]; int StartDis = 1; int tObjNum; int count = 0; int loopcount = 0; int attackcheck; int EnableAttack; int HitCount = 0; this->SendAttackMsg(lpObj->m_Index, aTargetIndex, 0, 0); while ( true ) { if ( lpObj->VpPlayer2[count].state != 0 ) { tObjNum = lpObj->VpPlayer2[count].number; if ( tObjNum >= 0 && aTargetIndex != tObjNum ) { EnableAttack = FALSE; if ( lpObj->VpPlayer2[count].type == OBJ_MONSTER && gObj[tObjNum].m_RecallMon < 0) { EnableAttack = TRUE; } else if ( tObjNum == aTargetIndex ) { EnableAttack = TRUE; } else { int lc10 = gObj[tObjNum].m_Index; if ( gObj[tObjNum].Type == OBJ_MONSTER ) { if ( gObj[tObjNum].m_RecallMon >= 0 ) { lc10 = gObj[gObj[tObjNum].m_RecallMon].m_Index; } } if ( gObjTargetGuildWarCheck(lpObj, &gObj[lc10]) == TRUE ) { EnableAttack = TRUE; } } if ( EnableAttack != FALSE ) { attackcheck = FALSE; if ( loopcount == 0 ) { attackcheck = TRUE; } else if ( (rand()%3) == 0 ) { attackcheck = TRUE; } if ( attackcheck != FALSE ) { if ( gObjCalDistance(&gObj[aTargetIndex], &gObj[tObjNum]) < RAVEN_ATTACK_DISTANCE-3 ) { this->SendAttackMsg(lpObj->m_Index, tObjNum, 2, 0); HitCount++; if ( HitCount > 3 ) { break; } } } } } } count++; if ( count > MAX_VIEWPORT-1 ) { break; } } }
void TMonsterSkillManager::UseMonsterSkill(int iIndex, int iTargetIndex, int iMonsterSkillUnitType) { LPOBJ lpObj = &gObj[iIndex]; LPOBJ lpTargetObj = &gObj[iTargetIndex]; TMonsterSkillInfo * lpMonsterSkillInfo = &TMonsterSkillManager::s_MonsterSkillInfoArray[lpObj->Class]; if ( lpMonsterSkillInfo->IsValid() == FALSE ) return; TMonsterSkillUnit * lpMonsterSkillUnit = TMonsterSkillManager::FindMonsterSkillUnit(iIndex, iMonsterSkillUnitType); if ( lpMonsterSkillUnit == NULL ) { LogAddC(2, "[Monster Skill Manager] SkillUnit is NULL "); return; } GCUseMonsterSkillSend(lpObj, lpTargetObj, lpMonsterSkillUnit->m_iUnitNumber); if ( lpMonsterSkillUnit->m_iUnitScopeType == -1 ) { 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 ) { lpMonsterSkillUnit->RunSkill(iIndex, iRangeTargetIndex); } } } } iCount++; if ( iCount > MAX_VIEWPORT_MONSTER-1) break; } } }
// ---------------------------------------------------------------------------------------------------------------------- void CDarkSpirit::ModeAttackRandom() { LPOBJ lpObj = &gObj[this->m_iMasterIndex]; int tObjNum; int count = 0; int FindObj[MAX_VIEWPORT]; int FindObjCount = 0; int dis; int DuelIndex = lpObj->m_iDuelUser; BOOL EnableAttack; int criticaldamage = 0; if ( (rand()%10) < 3 ) { criticaldamage = 1; } while ( true ) { if ( lpObj->VpPlayer2[count].state != 0 ) { if ( lpObj->VpPlayer2[count].type == OBJ_MONSTER ) { tObjNum = lpObj->VpPlayer2[count].number; if ( tObjNum >= 0 ) { EnableAttack = FALSE; if ( gObj[tObjNum].Life > 0.0f && (gObj[tObjNum].Class < 100 || gObj[tObjNum].Class > 110 ) ) { if ( lpObj->VpPlayer2[count].type == OBJ_MONSTER && gObj[tObjNum].m_RecallMon < 0) { EnableAttack = TRUE; } else if ( DuelIndex == tObjNum ) { EnableAttack = TRUE; } else { int lc85 = gObj[tObjNum].m_Index; if ( gObj[tObjNum].Type == OBJ_MONSTER ) { if ( gObj[tObjNum].m_RecallMon >= 0 ) { lc85 = gObj[gObj[tObjNum].m_RecallMon].m_Index; } } if ( gObjTargetGuildWarCheck(lpObj, &gObj[lc85]) == TRUE ) { EnableAttack = TRUE; } } if ( EnableAttack != FALSE ) { if ( lpObj->MapNumber == gObj[tObjNum].MapNumber ) { dis = gObjCalDistance(lpObj, &gObj[tObjNum]); if ( dis < RAVEN_ATTACK_DISTANCE-2 ) { FindObj[FindObjCount] = tObjNum; FindObjCount++; } } } } } } } count++; if ( count > MAX_VIEWPORT-1 ) { break; } } if ( FindObjCount != 0 ) { if ( criticaldamage != 0 ) { int target = FindObj[rand()%FindObjCount]; this->SendAttackMsg( lpObj->m_Index, target, criticaldamage, 0); } else { int target = FindObj[rand()%FindObjCount]; this->RangeAttack( lpObj->m_Index, target); } } }
void MonsterHerd::MonsterBaseAct(LPOBJ lpObj) { LPOBJ lpTargetObj = NULL; if ( lpObj->TargetNumber >= 0 ) { lpTargetObj = &gObj[lpObj->TargetNumber]; } else { lpObj->m_ActState.Emotion = 0; } switch ( lpObj->m_ActState.Emotion ) { case 0: { if ( lpObj->m_ActState.Attack != 0 ) { lpObj->m_ActState.Attack = 0; lpObj->TargetNumber = -1; lpObj->NextActionTime = 500; } int actcode1 = rand() % 2; if ( actcode1 == 0 ) { lpObj->m_ActState.Rest = 1; lpObj->NextActionTime = 500; } else if ( lpObj->m_MoveRange > 0 ) { if ( lpObj->m_SkillHarden == 0 ) { this->MonsterMoveAction(lpObj); } } if ( lpObj->m_bIsMonsterAttackFirst != false ) { lpObj->TargetNumber = gObjMonsterSearchEnemy(lpObj, OBJ_USER); if ( lpObj->TargetNumber >= 0 ) { lpObj->m_ActState.EmotionCount = 30; lpObj->m_ActState.Emotion = 1; } } } break; case 1: if ( lpObj->m_ActState.EmotionCount > 0 ) { lpObj->m_ActState.EmotionCount --; } else { lpObj->m_ActState.Emotion = 0; } if ( lpObj->TargetNumber >= 0 && lpObj->PathStartEnd == 0 ) { int dis = gObjCalDistance(lpObj, lpTargetObj); int attackRange; if ( lpObj->m_AttackType >= 100 ) { attackRange = lpObj->m_AttackRange + 2; } else { attackRange = lpObj->m_AttackRange; } if ( dis <= attackRange ) { int tuser = lpObj->TargetNumber; int map = gObj[tuser].MapNumber; if ( MapC[map].CheckWall(lpObj->X, lpObj->Y, gObj[tuser].X, gObj[tuser].Y) == TRUE ) { BYTE attr = MapC[map].GetAttr(gObj[tuser].X, gObj[tuser].Y); if ( (attr&1) != 1 ) { lpObj->m_ActState.Attack = 1; lpObj->m_ActState.EmotionCount = (rand()%30+20); } else { lpObj->TargetNumber = -1; lpObj->m_ActState.EmotionCount = 30; lpObj->m_ActState.Emotion = 1; } lpObj->Dir = GetPathPacketDirPos(lpTargetObj->X-lpObj->X, lpTargetObj->Y-lpObj->Y); lpObj->NextActionTime = lpObj->m_AttackSpeed; } } else { if ( gObjMonsterGetTargetPos(lpObj) == TRUE ) { if ( MapC[lpObj->MapNumber].CheckWall(lpObj->X, lpObj->Y, lpObj->MTX, lpObj->MTY) == TRUE ) { lpObj->m_ActState.Move = 1; lpObj->NextActionTime = 400; lpObj->Dir = GetPathPacketDirPos(lpTargetObj->X - lpObj->X, lpTargetObj->Y-lpObj->Y); } else { this->MonsterMoveAction(lpObj); lpObj->m_ActState.Emotion = 3; lpObj->m_ActState.EmotionCount = 10; } } else { this->MonsterMoveAction(lpObj); lpObj->m_ActState.Emotion = 3; lpObj->m_ActState.EmotionCount = 10; } } } break; case 3: if ( lpObj->m_ActState.EmotionCount > 0 ) { lpObj->m_ActState.EmotionCount--; } else { lpObj->m_ActState.Emotion = 0; } lpObj->m_ActState.Move = 0; lpObj->m_ActState.Attack = 0; lpObj->NextActionTime = 400; break; } }
// ----------------------------------------------------------------------------------------------------------------------- void CIllusionTemple::UseSkillProc(OBJECTSTRUCT* lpObj, PMSG_ILLUSION_USESKILL* pMsg) { LPOBJ lpTargetObj = &gObj[pMsg->m_TargetIndex]; int TargePosx = lpTargetObj->X; int TargePosy = lpTargetObj->Y; int iangle = gObjUseSkill.GetAngle(lpObj->X,lpObj->Y,TargePosx,TargePosy); if(!(IT_FLOOR_RANGE(lpObj->m_IllusionIndex) && IT_MAP_RANGE(lpObj->MapNumber))) { GCMagicAttackNumberSend(lpObj, (BYTE)pMsg->m_SkillIndex, lpObj->m_Index, 1); return; } int SkillPoint = MagicDamageC.CheckKillCount(pMsg->m_SkillIndex, lpObj->m_IllusionKillCount); if(SkillPoint < 0) { GCMagicAttackNumberSend(lpObj, (BYTE)pMsg->m_SkillIndex, lpObj->m_Index, 1); CLog.LogAddC(2, "[IllusionTemple][%s] Use skill without enough points (%d)(%d)", lpObj->Name, lpObj->m_IllusionKillCount, pMsg->m_SkillIndex); return; } switch(pMsg->m_SkillIndex) { case IT_SKILL_SHIELD: { if(lpObj->m_IllusionShieldSkillTime > 0) { GCMagicAttackNumberSend(lpObj, AT_SKILL_ITSHIELD, lpObj->m_Index, 0); return; } if(lpObj->Mana < MagicDamageC.SkillGetMana(IT_SKILL_SHIELD)) { GCMagicAttackNumberSend(lpObj, AT_SKILL_ITSHIELD, lpObj->m_Index, 0); return; } lpObj->Mana -= MagicDamageC.SkillGetMana(IT_SKILL_SHIELD); GCManaSend(lpObj->m_Index, (short)lpObj->Mana, 0xFF, 0, lpObj->BP); lpObj->m_IllusionShieldSkillTime = MagicDamageC.GetDelayTime(IT_SKILL_SHIELD); GCStateInfoSend(lpObj, 1, eVS_ILLUSION_PROTECTION); gObjSetIllusionKillCount(lpObj->m_Index, KILLCOUNT_DECREASE, MagicDamageC.GetKillCount(IT_SKILL_SHIELD)); GCMagicAttackNumberSend(lpObj, AT_SKILL_ITSHIELD, lpObj->m_Index, 1); }break; case IT_SKILL_RESIST: { if(lpObj->Type != OBJ_USER ) { CLog.LogAddC(2, "[IllusionTemple][%s] can't use Skill (%d) in normal state,only in PVP", lpObj->Name, pMsg->m_SkillIndex ); return; } if(gObjCalDistance(lpObj,lpTargetObj) <= 4) { if(SkillElectricSparkHitBox.HitCheck(iangle,lpObj->X,lpObj->Y,lpObj->X,lpObj->Y)) { lpTargetObj->m_btSkillRestraintOrder = TRUE; lpTargetObj->m_btSkillRestraintOrderTime = 15; //this->GCEffectSkillSend(aIndex,lpTargetObj->m_Index,lpMagic->m_Skill,btType); gObjSetPosition(lpObj->m_Index,lpObj->X,lpObj->Y); } } }break; case IT_SKILL_TRACK: { if(lpObj->m_Index != this->m_IllusionTemple[lpObj->m_IllusionIndex].m_BallOwner) { if(OBJMAX_RANGE(this->m_IllusionTemple[lpObj->m_IllusionIndex].m_BallOwner)) { gObjSetIllusionKillCount(lpObj->m_Index, KILLCOUNT_DECREASE, MagicDamageC.GetKillCount(IT_SKILL_TRACK)); gObjTeleport(lpObj->m_Index, gObj[this->m_IllusionTemple[lpObj->m_IllusionIndex].m_BallOwner].MapNumber, gObj[this->m_IllusionTemple[lpObj->m_IllusionIndex].m_BallOwner].X, gObj[this->m_IllusionTemple[lpObj->m_IllusionIndex].m_BallOwner].Y); } } }break; case IT_SKILL_FREEZE: { if(lpObj->Type != OBJ_USER ) { CLog.LogAddC(2, "[IllusionTemple][%s] can't use Skill (%d) in normal state,only in PVP", lpObj->Name, pMsg->m_SkillIndex ); return; } lpObj->iShield -= (lpObj->iMaxShield / 2); if( lpObj->iShield < 0 ) { lpObj->iShield = 0; } GCReFillSend(lpObj->m_Index,(WORD)lpObj->Life,0xFF,0,lpObj->iShield); GCSendEffectInfo(lpTargetObj->m_Index, 17); }break; } }
//===================================== // 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); }
void CDevilSquare::gObjExpParty(LPOBJ lpObj, LPOBJ lpTargetObj, int AttackDamage, BOOL MSBFlag) { int n; __int64 exp; __int64 maxexp = 0; __int64 totalexp; int level = ((lpTargetObj->Level + 25) * lpTargetObj->Level) / 3; int number; int partynum = 0; int totallevel = 0; int partylevel; int partycount; int dis[6]; int viewplayer = 0; int viewpercent = 100; BOOL bApplaySetParty = FALSE; bool bCheckSetParty[6]; partynum = lpObj->PartyNumber; LPOBJ lpPartyObj; int toplevel = 0; int distance; for (n=0; n<MAX_USER_IN_PARTY; n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; distance = gObjCalDistance(lpObj,lpPartyObj); if( distance < 10 ) { if(lpPartyObj->Level > toplevel) { toplevel = lpPartyObj->Level; } } } } if ( OBJMAX_RANGE(partynum) == FALSE ) { LogAdd("error : %s %d", __FILE__, __LINE__); return; } partycount = gParty.m_PartyS[partynum].Count; for ( n =0; n<MAX_USER_IN_PARTY; n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; if ( lpTargetObj->MapNumber ==lpPartyObj->MapNumber ) { dis[n] = gObjCalDistance(lpTargetObj, &gObj[number]); if ( dis[n] < 10 ) { lpPartyObj = &gObj[number]; if ( toplevel >= (lpPartyObj->Level + 200 ) ) // #formula { totallevel = totallevel + lpPartyObj->Level + 200; } else { totallevel += lpPartyObj->Level; } viewplayer++; bCheckSetParty[lpPartyObj->Class] = true; } } } } viewpercent += gParty.GetExpBonus(lpObj, lpTargetObj, partynum); if ( viewplayer > 1 ) { partylevel = totallevel / viewplayer; } else { partylevel = totallevel; } if ( (lpTargetObj->Level +10) < partylevel ) { level = (level * (lpTargetObj->Level+10) ) / partylevel; } if ( lpTargetObj->Level >= 65 ) { if ( viewplayer == 1 ) { level += (lpTargetObj->Level - 64) * (lpTargetObj->Level/ 4); } else { level += (int)(200.0 - (lpObj->Level * 0.2)); } } if ( level > 0 ) { maxexp = level / 2; } else { level = 0; } if ( maxexp < 1 ) { totalexp = level; } else { totalexp = level + rand()%maxexp; } if ( lpTargetObj->Type == OBJ_MONSTER ) { lpTargetObj->Money = (int)totalexp; } for ( n=0; n<MAX_USER_IN_PARTY; n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; if ( lpTargetObj->MapNumber == lpPartyObj->MapNumber ) { if ( dis[n] < 10 ) { DWORD myexp = gLevelExperience[lpPartyObj->Level]; exp = ((totalexp * viewpercent* lpPartyObj->Level ) / totallevel ) / 100; if ( exp > myexp ) { exp = myexp; } if( lpPartyObj->Type == OBJ_USER ) { if ( lpTargetObj->Type == OBJ_USER ) { exp = 0; } } if ( g_MasterExp.IsEnabled(lpPartyObj) == FALSE ) { exp += (exp * m_ObjBill[lpPartyObj->m_Index].GetExp()) / 100; exp = int(exp * g_MapRateInfo.GetExp(lpPartyObj->MapNumber)); } if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE) { exp = (exp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100; } if ( exp > 0 ) { if ( lpPartyObj->Type == OBJ_USER ) { CheckItemOptForGetExpEx(lpPartyObj,exp,0); lpPartyObj->Experience += (DWORD)exp; lpPartyObj->m_nEventExp += (int)exp; if ( gObjLevelUp(lpPartyObj, &exp, lpTargetObj->Class, EVENT_TYPE_PARTY) == false ) { continue; } } } if ( lpPartyObj->Type == OBJ_USER ) { GCKillPlayerExpSend(lpPartyObj->m_Index, lpTargetObj->m_Index,(int)exp, AttackDamage, MSBFlag); } } } } } }
//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 CDevilSquare::gObjExpParty(LPOBJ lpObj, LPOBJ lpTargetObj, int AttackDamage, BOOL MSBFlag) { int n; DWORD exp; DWORD maxexp = 0; int totalexp; int level = ((lpTargetObj->Level + 25) * lpTargetObj->Level) / 3; int number; int partynum = 0; int totallevel = 0; int partylevel; int partycount; int dis[MAX_USER_IN_PARTY]; int viewplayer = 0; int viewpercent = 100; BOOL bApplaySetParty = FALSE; bool bCheckSetParty[MAX_TYPE_PLAYER]; partynum = lpObj->PartyNumber; LPOBJ lpPartyObj; int toplevel = 0; for (n=0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; if ( lpPartyObj->Level > toplevel ) { toplevel = lpPartyObj->Level; } } } if ( OBJMAX_RANGE(partynum) == FALSE ) { LogAdd("error : %s %d", __FILE__, __LINE__); return; } partycount = gParty.m_PartyS[partynum].Count; for ( n =0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; if ( lpTargetObj->MapNumber ==lpPartyObj->MapNumber ) { dis[n] = gObjCalDistance(lpTargetObj, &gObj[number]); if ( dis[n] < 10 ) { lpPartyObj = &gObj[number]; if ( toplevel >= (lpPartyObj->Level + 200 ) ) // #formula { totallevel = totallevel + lpPartyObj->Level + 200; } else { totallevel += lpPartyObj->Level; } viewplayer++; bCheckSetParty[lpPartyObj->Class] = true; } } } } if ( bCheckSetParty[0] != false && bCheckSetParty[1] != false && bCheckSetParty[2] != false ) { bApplaySetParty = TRUE; } if ( viewplayer > 1 ) { if ( bApplaySetParty != FALSE ) { if ( viewplayer == 3 ) { viewpercent = 230; } else if ( viewplayer == 4 ) { viewpercent = 270; } else if ( viewplayer >= 5 ) { viewpercent = 300; } else { viewpercent = 120; } } else { if ( viewplayer == 2 ) { viewpercent = 160; } else if ( viewplayer == 3 ) { viewpercent = 180; } else if ( viewplayer == 4 ) { viewpercent = 200; } else if ( viewplayer >= 5 ) { viewpercent = 220; } else { viewpercent = 120; } } partylevel = totallevel / viewplayer; } else { partylevel = totallevel; } if ( (lpTargetObj->Level +10) < partylevel ) { level = (level * (lpTargetObj->Level+10) ) / partylevel; } if ( lpTargetObj->Level >= 65 ) { if ( viewplayer == 1 ) { level += (lpTargetObj->Level - 64) * (lpTargetObj->Level/ 4); } else { level += int(200.0 - (lpObj->Level * 0.2)); } } if ( level > 0 ) { maxexp = level / 2; } else { level = 0; } if ( maxexp < 1 ) { totalexp = level; } else { totalexp = level + Random(0,maxexp); } if ( lpTargetObj->Type == OBJ_MONSTER ) { lpTargetObj->Money = totalexp; } for ( n=0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyS[partynum].Number[n]; if ( number >= 0 ) { lpPartyObj = &gObj[number]; if ( lpTargetObj->MapNumber == lpPartyObj->MapNumber ) { if ( dis[n] < 10 ) { DWORD myexp = gLevelExperience[lpPartyObj->Level]; exp = ((totalexp * viewpercent* lpPartyObj->Level ) / totallevel ) / 100; if ( exp > myexp ) { exp = myexp; } if( lpPartyObj->Type == OBJ_USER ) { if ( lpTargetObj->Type == OBJ_USER ) { exp = 0; } } //exp *= (DWORD)gAddExperience; exp *= VipSystem_MapExp[lpObj->VipType][lpObj->MapNumber]; if ( lpPartyObj->m_wExprienceRate == 0 ) exp = 0; else exp = DWORD( (double)exp * ((double)lpPartyObj->m_wExprienceRate / 100.0) ); if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE) { exp = (exp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100; } if ( exp > 0 ) { if ( lpPartyObj->Type == OBJ_USER ) { if ( lpPartyObj->m_wExprienceRate > 0 ) { lpPartyObj->Experience += exp; lpPartyObj->m_nEventExp += exp; } if ( gObjLevelUp(lpPartyObj, exp, lpTargetObj->Class, EVENT_TYPE_PARTY) == false ) { continue; } } } if ( lpPartyObj->Type == OBJ_USER ) { if ( lpPartyObj->m_wExprienceRate > 0 ) { GCKillPlayerExpSend(lpPartyObj->m_Index, lpTargetObj->m_Index, exp, AttackDamage, MSBFlag); } } } } } } }
void CheckItemOptForGetExpEx(LPOBJ lpObj,__int64 & iExp,int bRewardExp) { __int64 iRetExp = iExp; int iAddExpRate = 100; if ( gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj, AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else if ( gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_SEAL_OF_ASCENSION) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_SEAL_OF_WEALTH) || gObjCheckUsedBuffEffect(lpObj, AT_PCBANG_SEAL_OF_ASCENSION) || gObjCheckUsedBuffEffect(lpObj, AT_PCBANG_SEAL_OF_WEALTH) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_SEAL_OF_HEALING) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_ASCENSION) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_WEALTH) ) { iAddExpRate = gObjGetTotalValueOfEffect(lpObj, ADD_OPTION_EXPERIENCE); if( g_MasterExp.IsEnabled(lpObj) ) { if ( gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_ASCENSION) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_WEALTH) ) { if ( bRewardExp ) iAddExpRate = 100; } else { iAddExpRate = 100; } } else { if ( gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_ASCENSION) || gObjCheckUsedBuffEffect(lpObj, AT_CSHOP_MASTER_SEAL_OF_WEALTH) ) { iAddExpRate = 100; } else { if ( bRewardExp ) iAddExpRate = 100; } } //iRetExp = iRetExp * iAddExpRate / 100; } else if ( gObjCheckUsedBuffEffect(lpObj, AT_PARTY_EXP_BONUS) ) { iAddExpRate = 190; if ( lpObj->PartyNumber >= 0 ) { for (int i = 0; i < MAX_USER_IN_PARTY; ++i ) { LPOBJ lpPartyObj = &gObj[gParty.m_PartyS[lpObj->PartyNumber].Number[i]]; // wz bug ? need to check for -1 int iPartyDis = gObjCalDistance(lpObj, lpObj); if ( lpObj->m_Index != lpPartyObj->m_Index && lpObj->MapNumber == lpPartyObj->MapNumber && iPartyDis < 10 ) iAddExpRate += 10; } } // g_MasterLevelSystem.IsMasterLevelUser(lpObj) ) if ( bRewardExp || g_MasterExp.IsEnabled(lpObj) ) iAddExpRate = 100; //iRetExp = iRetExp * iAddExpRate / 100; } else if ( gObjCheckUsedBuffEffect(lpObj, AT_NEWPVPSYSTEM_REWARD) ) { // g_MasterLevelSystem.IsMasterLevelUser(lpObj) ) if( g_MasterExp.IsEnabled(lpObj) ) return; // webzen error ? ... #if (ENABLETEST_NEWPVP == 1) if (g_NewPVP.IsVulcanusMap(lpObj->MapNumber) && iRetExp == iExp) { iExp = iRetExp * gObjGetTotalValueOfEffect(lpObj, 60) / 100 + iRetExp; return; } #endif } if( (lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,77) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,77) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired)) { if( gObjCheckUsedBuffEffect(lpObj,AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj,AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else { if( bRewardExp ) { iAddExpRate = 100; } else { iAddExpRate += 30; } //iRetExp = iRetExp * iAddExpRate / 100; } } if( (lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,78) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,78) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired)) { if( gObjCheckUsedBuffEffect(lpObj,AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj,AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else { if( bRewardExp ) { iAddExpRate = 100; } else { iAddExpRate += 50; } //iRetExp = iRetExp * iAddExpRate / 100; } } if( lpObj->pInventory[8].IsItem() && lpObj->pInventory[8].m_Type == ITEMGET(13,80) && lpObj->pInventory[8].m_Durability > 0.0 && !lpObj->pInventory[8].m_bExpired ) { if( gObjCheckUsedBuffEffect(lpObj,AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj,AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else { if( bRewardExp ) { iAddExpRate = 100; } else { iAddExpRate += 50; } //iRetExp = iRetExp * iAddExpRate / 100; } } if( lpObj->pInventory[8].IsItem() && lpObj->pInventory[8].m_Type == ITEMGET(13,123) && lpObj->pInventory[8].m_Durability > 0.0 && !lpObj->pInventory[8].m_bExpired ) { if( gObjCheckUsedBuffEffect(lpObj,AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj,AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else { if( bRewardExp ) { iAddExpRate = 100; } else { iAddExpRate += 30; } //iRetExp = iRetExp * iAddExpRate / 100; } } if(((lpObj->pInventory[8].IsItem() && lpObj->pInventory[8].m_Type == ITEMGET(13,80) && lpObj->pInventory[8].m_Durability > 0.0 && !lpObj->pInventory[8].m_bExpired) || (lpObj->pInventory[8].IsItem() && lpObj->pInventory[8].m_Type == ITEMGET(13,123) && lpObj->pInventory[8].m_Durability > 0.0 && !lpObj->pInventory[8].m_bExpired)) && ((lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,76) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,76) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired) || (lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,77) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,77) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired) || (lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,78) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,78) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired) || (lpObj->pInventory[10].IsItem() && lpObj->pInventory[10].m_Type == ITEMGET(13,122) && lpObj->pInventory[10].m_Durability > 0.0 && !lpObj->pInventory[10].m_bExpired) || (lpObj->pInventory[11].IsItem() && lpObj->pInventory[11].m_Type == ITEMGET(13,122) && lpObj->pInventory[11].m_Durability > 0.0 && !lpObj->pInventory[11].m_bExpired) )) { if( gObjCheckUsedBuffEffect(lpObj,AT_CSHOP_SEAL_OF_SUSTENANCE) || gObjCheckUsedBuffEffect(lpObj,AT_PCBANG_SEAL_OF_SUSTENANCE) ) { iRetExp = 0; } else { if( bRewardExp ) { iAddExpRate = 100; } else { iAddExpRate += 30; } //iRetExp = iRetExp * iAddExpRate / 100; } } iRetExp = iRetExp * iAddExpRate / 100; #if ( __CUSTOM__ == 1) if( !g_MasterExp.IsEnabled(lpObj) ) { iRetExp = gCustomExp.GetResetExp(lpObj,iRetExp); } #endif iExp = iRetExp; }
void CCannonTower::CannonTowerAct(int iIndex) { if( ( rand() % 2 ) != 0 ) { return; } LPOBJ lpObj = &gObj[iIndex]; int tObjNum; int count = 0; PMSG_BEATTACK_COUNT pCount; PMSG_BEATTACK pAttack; BYTE AttackSendBuff[256]; int ASBOfs; ASBOfs = 0; pCount.h.c = 0xC1; pCount.h.headcode = PROTOCOL_BEATTACK; pCount.h.size = 0x00; pCount.MagicNumberH = 0x00; pCount.MagicNumberL = 0x00; pCount.Count = 0x00; pCount.X = lpObj->X; pCount.Y = lpObj->Y; ASBOfs = sizeof(PMSG_BEATTACK_COUNT); while( true ) { if( lpObj->VpPlayer2[count].state ) { if( lpObj->VpPlayer2[count].type == OBJ_USER ) { tObjNum = lpObj->VpPlayer2[count].number; if( tObjNum >= 0 ) { if( gObj[tObjNum].m_btCsJoinSide != 1 ) { if( gObjCalDistance(lpObj, &gObj[tObjNum]) < 7 ) { pAttack.NumberH = SET_NUMBERH(tObjNum); pAttack.NumberL = SET_NUMBERL(tObjNum); memcpy( (AttackSendBuff+ASBOfs), (LPBYTE)&pAttack, sizeof(PMSG_BEATTACK)); ASBOfs += sizeof(PMSG_BEATTACK); pCount.Count++; } } } } } count++; if( count > MAX_VIEWPORT-1 ) break; } if( pCount.Count > 0 ) { pCount.h.size = ASBOfs; memcpy(AttackSendBuff, (LPBYTE)&pCount, sizeof(PMSG_BEATTACK_COUNT)); CGBeattackRecv(AttackSendBuff, lpObj->m_Index, 1); PMSG_DURATION_MAGIC_SEND pSend; PHeadSetBE((LPBYTE)&pSend, 0x1E, sizeof(PMSG_DURATION_MAGIC_SEND)); pSend.MagicNumberH = 0; pSend.MagicNumberL = 0x32; pSend.X = lpObj->X; pSend.Y = lpObj->Y; pSend.Dir = 0; pSend.NumberH = SET_NUMBERH(iIndex); pSend.NumberL = SET_NUMBERL(iIndex); ::MsgSendV2(lpObj, (LPBYTE)&pSend, pSend.h.size); } }