Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Text-based-Game/enemyLandHitChance.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (22 sloc)
604 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "enemyLandHitChance.h" | |
int enemyLandHit() | |
{ | |
int enemyHit; | |
srand (time(NULL)); | |
int enemyHitChance = (rand() % 100) + 1; | |
if (enemyHitChance<=30){ | |
enemyHit = 0; | |
return enemyHit; | |
} | |
else if (enemyHitChance>30 and enemyHitChance<75){ | |
enemyHit = 1; | |
return enemyHit; | |
//enemy hits, dealing damage = weaponDamage*playerArmour | |
} | |
else if (enemyHitChance>=75){ | |
enemyHit = 2; | |
return enemyHit; | |
//enemy lands a critical hit, dealing damage = (weaponDamage*2*playerArmour) | |
//if hit = 0, attack misses. if hit = 1, attack hits with normal damage. | |
} | |
} |