Changeset 48 for trunk/src/hearthstone-world/GenericAI.cpp
- Timestamp:
- 09/30/09 21:44:28 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/hearthstone-world/GenericAI.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/hearthstone-world/GenericAI.cpp
r47 r48 24 24 m_lastUpdateTime = 0; 25 25 m_lastAttackTime = 0; 26 m_forceSpell = NULL; 26 27 27 28 ai->GetMoveGenerator()->SetThreatReference(&m_threat); … … 142 143 143 144 return true; 145 } 146 147 AI_Spell* GenericAI::GetNextSpell() 148 { 149 uint32 msTime = getMSTime(); 150 AISpellStorage::iterator itr = m_unit->GetAIInterface()->GetAvailableSpellsBegin(); 151 for(; itr != m_unit->GetAIInterface()->GetAvailableSpellsEnd(); ++itr) 152 { 153 AI_Spell* sp = (*itr); 154 if( sp->cooldowntime > msTime ) // We're still on cooldown. 155 continue; 156 157 if( sp->procChance < 100 && !Rand(sp->procChance) ) // It just ain't proccing. 158 continue; 159 160 // not enough mana? 161 if( sp->spell->manaCost && m_unit->GetUInt32Value(UNIT_FIELD_POWER1+POWER_TYPE_MANA) < sp->spell->manaCost ) 162 continue; 163 164 // not enough mana? 165 if( sp->spell->ManaCostPercentage && m_unit->GetManaPct() < sp->spell->ManaCostPercentage ) 166 continue; 167 168 ++sp->procCount; 169 sp->cooldowntime = msTime + sp->cooldown; 170 171 return sp; 172 } 173 174 return NULL; 144 175 } 145 176 … … 172 203 173 204 // Attack our current target, if we have one. 174 if( m_threat.GetAttackTarget() && IsInAttackRange(m_threat.GetAttackTarget()) )205 if( m_threat.GetAttackTarget() && CanMeleeAttack(m_threat.GetAttackTarget()) ) 175 206 { 176 207 // just because we're in range doesn't mean we are good to go. … … 199 230 } 200 231 201 bool GenericAI:: IsInAttackRange(Unit *u)202 { 203 return m_unit->GetAIInterface()->IsInAttackRange(u) ;232 bool GenericAI::CanMeleeAttack(Unit *u) 233 { 234 return m_unit->GetAIInterface()->IsInAttackRange(u) && !m_unit->GetCurrentSpell(); 204 235 } 205 236