SHARE
TWEET

Enemy.cpp

zCool May 17th, 2012 11 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Enemy.h"
  2. #include "Stats.h"
  3. #include "Character.h"
  4. #include<iostream>
  5. #include<time.h>
  6.  
  7. Enemy::Enemy(Stats stats):Character(stats) {}
  8.  
  9. //Calculation for when the enemy is attacked
  10. void Enemy::getHit(int attackerATK, int victimDEF, int victimHP)
  11. {
  12.         // division by zero
  13.         if(attackerATK - victimDEF == 0)
  14.         {
  15.                 m_stats.setHealth( victimHP - rand() % 4 ); // just make it 4 i don't know why
  16.         }
  17.  
  18.         else if(attackerATK - victimDEF != 0)
  19.         {
  20.                 m_stats.setHealth( victimHP - rand() % (attackerATK - victimDEF) );
  21.         }
  22. }
  23.  
  24. //Return a decision for the Enemy AI
  25. Enemy::decisionTypes Enemy::chooseWhatToDo()
  26. {
  27.         return Enemy::decisionTypes(rand() % 3);  //random number cast to enum;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top