Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* idk what half this stuff does, but it works. */
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <ctime>
- #include <cstdlib>
- #include <math.h>
- #include <stdio.h> /* printf, scanf, puts, NULL */
- #include <stdlib.h> /* srand, rand */
- #include <time.h> /* time */
- using namespace std;
- // This is the 3 randomizers needed for the code: Attack damage randomizer, Hit chance randomizer, Move selection randomizer
- int main(){
- //Attack damage randomizer start.
- double ATTM; //Attack multiplier.
- double ATTD; //Attack default.
- double ATTB; //Attack buffer.
- srand(time(0)); //Randomzies the code by making up a random string of numbers.
- ATTB = 0.5; //Attack modifer to grant +-50%. Changes to 1 if using ATT up to make to 0~100% damage scaling.
- ATTD = 20; //Default damage if there was no multiplier, changes for each attack, set to 20 for testing.
- //Yes, I know the line is repeated twice. No, I dont know why I need to do it. Yes, it is nesesary. No, there is no other way.
- ATTM =(double)rand()/(RAND_MAX+1)+(ATTB); //The attack multiplier. Default is 0.5-1.5, AKA 50% less damage to 50% more.
- ATTM =(double)rand()/(RAND_MAX+1)+(ATTB); //Taking an attack potion should change to to 1-2, AKA default to double damage.
- //If you dont have BOTH of them, then it does not generate an actual random number. Try it yourself.
- cout << "Attack multiplier is: "; //Words
- cout << ATTM; //Final multiplier
- cout << "\nThe final damage done is: "; //Move stuff to another line
- cout << floor ((ATTD * ATTM) + 0.5 ); //Final damage caulcuation. Multiplies base damage by the multiplier, then rounds it to a whole number.
- //Attack damage randomizer end.
- //Move hit randomzier start.
- int r; //Randomizer for a number from 0-100, used for hit chance and move selection.
- int HitC; //Hit chance, the number needed for the attack to hit.
- r = rand() % 100; //Random number from 0-100
- HitC = 75; //Default chance for the attack to hit, set to 75 for testing.
- cout << "\nRandom number is: "; //Move stuff to another line
- cout << r; //prints the number
- if (r<=HitC) puts ("\nThe attack hit!"); //If the number rolled is smaller then chance to hit, the attack is sucsesful.
- else if (r>HitC) puts ("\nThe attack missed!"); //If the number rolled is greater then chance to hit, the attack missed.
- //Move hit randomzier end.
- //Move selection start
- r = rand() % 100; //Random number from 0-100
- cout << "\nNew random number: "; //Prints the new random number. Also, it seems to have an extra space when printed, idk why, its like a second \n was typed.
- cout << r;
- if (r<=20) puts ("\nMove one selected!"); //If the number is 0-20, move one (20% chance to select)
- if (r<=50&&r>20) puts ("\nMove two selected!"); //If the number is 21-50, move two (30% chance to select)
- if (r<=75&&r>50) puts ("\nMove three selected!"); //if the number is 51-75, move three (25% chance to select)
- if (r<=100&&r>75) puts ("\nMove four selected!"); //if the number is 76-100, move four (25% chance to select)
- //Move selection end
- std::cout << "\n\nPress ENTER to end program..."; //Tells user how to end the program.
- std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' ); //Will stop the program from ending prematuerly, requiers user to push ENTER.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement