Index: ai_pet_dummy.cpp =================================================================== --- ai_pet_dummy.cpp (revision 4164) +++ ai_pet_dummy.cpp (working copy) @@ -136,8 +136,25 @@ TransitionBack(true); return; } + // find correct targe + if(m_PMobSkill->getValidTargets() & TARGET_SELF) + { //self + m_PBattleSubTarget = m_PPet; + } + else if(m_PMobSkill->getValidTargets() & TARGET_PLAYER_PARTY) + { + m_PBattleSubTarget = m_PPet->PMaster; + } + else + { + if(m_PBattleTarget != NULL) + { + m_PBattleSubTarget = m_PBattleTarget; + } + DSP_DEBUG_BREAK_IF(m_PBattleSubTarget == NULL); + } - preparePetAbility(m_PBattleTarget); + preparePetAbility(m_PBattleSubTarget); return; } return; @@ -150,7 +167,26 @@ m_MasterCommand = MASTERCOMMAND_NONE; if(m_PPet->PetSkills.size()>0){ m_PMobSkill = m_PPet->PetSkills.at(rand() % m_PPet->PetSkills.size()); - preparePetAbility(m_PBattleTarget); + + // find correct targe + if(m_PMobSkill->getValidTargets() & TARGET_SELF) + { //self + m_PBattleSubTarget = m_PPet; + } + else if(m_PMobSkill->getValidTargets() & TARGET_PLAYER_PARTY) + { + m_PBattleSubTarget = m_PPet->PMaster; + } + else + { + if(m_PBattleTarget != NULL) + { + m_PBattleSubTarget = m_PBattleTarget; + } + DSP_DEBUG_BREAK_IF(m_PBattleSubTarget == NULL); + } + + preparePetAbility(m_PBattleSubTarget); return; } } @@ -160,7 +196,26 @@ if(m_PPet->PetSkills[i]->getAnimationTime() == m_MasterCommand){ m_PMobSkill = m_PPet->PetSkills[i]; m_MasterCommand = MASTERCOMMAND_NONE; - preparePetAbility(m_PPet); + + // find correct targe + if(m_PMobSkill->getValidTargets() & TARGET_SELF) + { //self + m_PBattleSubTarget = m_PPet; + } + else if(m_PMobSkill->getValidTargets() & TARGET_PLAYER_PARTY) + { + m_PBattleSubTarget = m_PPet->PMaster; + } + else + { + if(m_PBattleTarget != NULL) + { + m_PBattleSubTarget = m_PBattleTarget; + } + DSP_DEBUG_BREAK_IF(m_PBattleSubTarget == NULL); + } + + preparePetAbility(m_PBattleSubTarget); return; } } @@ -202,30 +257,54 @@ m_PBattleSubTarget = NULL; //TODO: CHECK FOR STATUS EFFECTS FOR REMOVE- BREATH (higher priority than healing breaths) - // if(m_PPet->PMaster->PParty==NULL){//solo with master-kun + CBattleEntity* HBTarget = NULL; + uint16 masterHead = ((CCharEntity*)(m_PPet->PMaster))->getStorage(LOC_INVENTORY)->GetItem(((CCharEntity*)(m_PPet->PMaster))->equip[SLOT_HEAD])->getID(); - if(((CCharEntity*)(m_PPet->PMaster))->objtype == TYPE_PC && (masterHead == 12519 || masterHead == 15238)) { //Check for player & AF head, or +1 - if(m_PPet->PMaster->GetHPP() <= 50 && wyverntype == WYVERNTYPE_DEFENSIVE){//healer wyvern - m_PBattleSubTarget = m_PPet->PMaster; + bool bHigherHPThreshold = false; + + if(((CCharEntity*)(m_PPet->PMaster))->objtype == TYPE_PC && (masterHead == 12519 || masterHead == 15238 || masterHead == 27676)) //check for Drachen Armet, Drachen Armet +1 and the new Vishap Armet. + bHigherHPThreshold = true; + + uint8 HPP = m_PPet->PMaster->GetHPP(); + + if(bHigherHPThreshold && HPP <= 50 && wyverntype == WYVERNTYPE_DEFENSIVE) //Armet & Defensive only. + { + HBTarget = m_PPet->PMaster; + } + else if(HPP <= 33 && (bHigherHPThreshold && wyverntype == WYVERNTYPE_MULTIPURPOSE ||wyverntype == WYVERNTYPE_DEFENSIVE )) //check for Armet & Multipurpose or no Armet and Defensive. + { + HBTarget = m_PPet->PMaster; + } + else if(HPP <= 25 && wyverntype == WYVERNTYPE_MULTIPURPOSE) // No armet & multipurpose only. + { + HBTarget = m_PPet->PMaster; + } + + if(HBTarget == NULL && m_PPet->PMaster->PParty != NULL) //Master doesn't need to be healed, find a party member if there is a party. + { + for (uint8 i = 0; i < m_PPet->PMaster->PParty->members.size(); ++i) + { + HPP = m_PPet->PMaster->PParty->members[i]->GetHPP(); + if(bHigherHPThreshold && HPP <= 50 && wyverntype == WYVERNTYPE_DEFENSIVE) //Armet & Defensive only. + { + HBTarget = m_PPet->PMaster->PParty->members[i]; + } + else if(HPP <= 33 && (bHigherHPThreshold && wyverntype == WYVERNTYPE_MULTIPURPOSE || wyverntype == WYVERNTYPE_DEFENSIVE )) //check for Armet & Multipurpose or no Armet and Defensive. + { + HBTarget = m_PPet->PMaster->PParty->members[i]; + } + else if(HPP <= 25 && wyverntype == WYVERNTYPE_MULTIPURPOSE) // No armet & multipurpose only. + { + HBTarget = m_PPet->PMaster->PParty->members[i]; + } + if (HBTarget != NULL) + break; } - else if(m_PPet->PMaster->GetHPP() <= 33 && wyverntype == WYVERNTYPE_MULTIPURPOSE){//hybrid wyvern - m_PBattleSubTarget = m_PPet->PMaster; - } - } else { - if(m_PPet->PMaster->GetHPP() <= 33 && wyverntype == WYVERNTYPE_DEFENSIVE) - {//healer wyvern - m_PBattleSubTarget = m_PPet->PMaster; - } - else if(m_PPet->PMaster->GetHPP() <= 25 && wyverntype == WYVERNTYPE_MULTIPURPOSE) - {//hybrid wyvern - m_PBattleSubTarget = m_PPet->PMaster; - } } - // } - // else{ //group play - // //for( int i=0; i< - // } + + m_PBattleSubTarget = HBTarget; + if(m_PBattleSubTarget != NULL){ //target to heal //get highest breath for wyverns level m_PMobSkill = NULL; @@ -263,25 +342,9 @@ apAction_t Action; m_PPet->m_ActionList.clear(); - // find correct targe - if(m_PMobSkill->getValidTargets() & TARGET_SELF) - { //self - m_PBattleSubTarget = m_PPet; - } - else if(m_PMobSkill->getValidTargets() & TARGET_PLAYER_PARTY) - { - m_PBattleSubTarget = m_PPet->PMaster; - } - else - { - if(m_PBattleTarget != NULL) - { - m_PBattleSubTarget = m_PBattleTarget; - } - DSP_DEBUG_BREAK_IF(m_PBattleSubTarget == NULL); - } + m_PBattleSubTarget = PTarg; //Action target and subtarget must be the same since it's what we're actually going to use an ability on. - Action.ActionTarget = m_PBattleSubTarget; + Action.ActionTarget = PTarg; Action.reaction = REACTION_HIT; Action.speceffect = SPECEFFECT_HIT; Action.animation = 0;