Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Input:
- * cth : chance to hit, 0-100.
- * karma : the player's karma rating before attacking
- * Output:
- * karma : the player's karma rating after attacking
- * return : whether or not this attack hit
- */
- bool attack(int cth, int& karma)
- {
- int rng = rand() % 100;
- int revise_cth = max(5,min(95,cth+karma*min(cth,100-cth)/100));
- bool hit = (rng < revised_cth);
- //update karma
- if(hit)
- karma -= (100-cth); //chance to miss
- else
- karma += cth;
- return hit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement