peonso

voidcore bugadasso kkkkk

Dec 20th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. void Monster::doAttacking(uint32_t interval)
  2. {
  3.     if(!attackedCreature || (isSummon() && attackedCreature == this)) {
  4.         return;
  5.     }
  6.    
  7.     bool result = false;
  8.     bool updateLook = true;
  9.     bool outOfRange = true;
  10.  
  11.     resetTicks = interval != 0;
  12.     attackTicks += interval;
  13.  
  14.     const Position& myPos = getPosition();
  15.     const Position& targetPos = attackedCreature->getPosition();
  16.     for(SpellList::iterator it = mType->spellAttackList.begin(); it != mType->spellAttackList.end(); ++it){
  17.  
  18.         bool inRange = false;
  19.  
  20.         if(canUseSpell(myPos, targetPos, *it, interval, inRange)){
  21.             //if(it->chance >= (uint32_t)random_range(1, 100)){
  22.             bool castChance = false;
  23.             //if monster is fleeing it has 1/3 of default chance to cast the spell
  24.             if (isFleeing()) {
  25.                 if (it->chance >= (uint32_t)random_range(1, 300)) {
  26.                     castChance = true;
  27.                 }
  28.             } else {
  29.                 if (it->chance >= (uint32_t)random_range(1, 100)) {
  30.                     castChance = true;
  31.                 }
  32.             }
  33.  
  34.             if (castChance) {
  35.                 if(updateLook) {
  36.                     updateLookDirection();
  37.                     updateLook = false;
  38.                 }
  39.                 double multiplier;
  40.                 minCombatValue = (int32_t)(it->minCombatValue * multiplier);
  41.                 maxCombatValue = (int32_t)(it->maxCombatValue * multiplier);
  42.                 it->spell->castSpell(this, attackedCreature);
  43.                 if (it->isMelee) {
  44.                     lastMeleeAttack = OTSYS_TIME() + 2000;
  45.                     extraMeleeAttack = false;
  46.                 }
  47. #ifdef __DEBUG__
  48.                 static uint64_t prevTicks = OTSYS_TIME();
  49.                 std::clog << "doAttacking ticks: " << OTSYS_TIME() - prevTicks << std::endl;
  50.                 prevTicks = OTSYS_TIME();
  51. #endif
  52.             }
  53.         }
  54.         if (!inRange && it->isMelee) {
  55.             //melee swing out of reach
  56.             extraMeleeAttack = true;
  57.         }
  58.     }
  59.  
  60.     if(updateLook){
  61.         updateLookDirection();
  62.     }
  63.    
  64.     if(resetTicks) {
  65.         attackTicks = 0;
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment