Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cmath>
- #include <cstring>
- #include <cstdlib>
- #include <stdio.h>
- #include <conio.h>
- using namespace std;
- struct human {
- int hitpoints = 100, max_hitpoints = 100, regen_health = 4, hp_reduction;
- int mana = 15, max_mana = 15, regen_mana = 1, mana_reduction, damage_spell=20;
- int damage_sword, crit_chance, damage_crit;
- int evade ;
- int miss;
- //stats
- bool shield; //if hero is holding shield
- bool not_fight = 1; //stat show purpose
- int direction = 1; //direction which player is facing
- int x=0, y=4; //position
- bool blood_sword; //if the sword is healing player by small amount
- float prefix = 1.0; //damage multiplier provided by weapon
- int score; //3 needed to progress to next stages
- int floor = 0; //stage
- };
- struct enemy {
- string name;
- int hitpoints=100, max_hitpoints;
- int mana, max_mana; //only boss has mana spell dmg and also offend
- int damage, crit_chance , damage_cri;
- int damage_spell=15,chance_damage_spell;
- //stats
- int attack, defend, heal, spell, offend; //actions which enemy can take, offend lowers attack for this round and cout some shit
- };
- int main()
- {
- srand( time( NULL ) );
- human player;
- enemy enemy;
- int escape;
- char spell_choose;
- int round=1;
- char option;
- /*int crit_chance;
- // HERO
- int potion=10;
- int mana=15;
- int hp_reduction;
- int attack;
- int my_hp=100;
- int fire_ball=20;
- // enemy
- int enemy_attack;
- int enemy_hp=100;
- int enemy_crit_chance;*/
- while ((player.hitpoints > 0 && enemy.hitpoints > 0) && escape != 0)
- {
- player.crit_chance = rand()%100;
- enemy.crit_chance = rand()%100;
- player.evade = rand()%100;
- player.miss= rand()%100;
- enemy.damage=rand()%6+5;
- player.damage_sword=rand()%6+5;
- player.damage_crit=2*player.damage_sword;
- cout << "1. Attack" << endl;
- cout << "2. Fire Ball [20 dmg | cost: 10 mana]" << endl;
- cout << "3. Try to escape" << endl;
- cout << endl;
- cout << "HP: "<< player.hitpoints<<endl;
- cout << "Mana: "<< player.mana << endl;
- cout << "Enemy HP: "<< enemy.hitpoints<<endl;
- cout << "\tRound "<< round++ << endl;
- enemy.name="mimic";
- cout << endl;
- if(round==2){
- option = getch();
- }
- if (enemy.name=="mimic")
- {
- bool special_attack=1;
- switch (option)
- {
- case '1':
- // player attack
- if (player.miss > 15)
- {
- if (player.crit_chance<16)
- {
- cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
- }
- else
- {
- cout << "You deal "<< player.damage_sword << " dmg!";
- }
- }
- else
- {
- cout << "You miss! ";
- player.damage_sword=0;
- }
- cout << endl;
- // enemy attack
- if (player.evade >15)
- {
- if (enemy.hitpoints<40 && special_attack)
- {
- cout << "Mimic bite you! (-20 HP)";
- player.hitpoints-=20;
- enemy.hitpoints+=20;
- special_attack = 0;
- }
- else
- {
- if (enemy.crit_chance<16)
- {
- cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
- }
- else
- {
- cout << "You received "<< enemy.damage<< " dmg";
- }
- }
- }
- else
- {
- cout<< "You dodge!";
- enemy.damage=0;
- }
- cout << endl << "========================="<< endl;
- // RESULT
- enemy.hitpoints = enemy.hitpoints - player.damage_sword;
- player.hitpoints = player.hitpoints - enemy.damage;
- player.hitpoints+=player.regen_health;
- player.mana+=player.regen_mana;
- if (player.mana>15)
- {
- player.mana_reduction=player.mana-player.max_mana;
- player.mana-=player.mana_reduction;
- }
- if (player.hitpoints>100)
- {
- player.hp_reduction=player.hitpoints-player.max_hitpoints;
- player.hitpoints-=player.hp_reduction;
- }
- cout<< endl;
- break;
- case '2':
- if (player.mana>9)
- {
- cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
- //enemy attack
- if (player.evade >15)
- {
- if (enemy.crit_chance<16)
- {
- cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
- }
- else
- {
- cout << "You received "<< enemy.damage<< " dmg";
- }
- }
- else
- {
- cout<< "You dodge!";
- enemy.damage=0;
- }
- cout << endl << "========================="<< endl;
- //RESULT
- enemy.hitpoints-=player.damage_spell;
- player.damage_spell==0;
- player.hitpoints = player.hitpoints - enemy.damage;
- player.mana-=10;
- player.hitpoints+=player.regen_health;
- player.mana+=player.regen_mana;
- if (player.mana>15)
- {
- player.mana_reduction=player.mana-player.max_mana;
- player.mana-=player.mana_reduction;
- }
- if (player.hitpoints>100)
- {
- player.hp_reduction=player.hitpoints-player.max_hitpoints;
- player.hitpoints-=player.hp_reduction;
- }
- }
- else
- {
- cout<< "You dont have enought mana!"<<endl;
- round --;
- }
- break;
- case '3':
- escape=rand()%10;
- if (escape==0)
- {
- cout << "You just ran away like a coward...";
- break;
- }
- else
- {
- cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
- player.hitpoints-=10;
- }
- break;
- default:
- cout << "Choose another option";
- round --;
- break;
- }
- }
- else if (enemy.name=="boss")
- {
- enemy.offend=rand()%100;
- switch (option)
- {
- case '1':
- // player attack
- if (player.miss > 15)
- {
- if (player.crit_chance<16)
- {
- cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
- }
- else
- {
- cout << "You deal "<< player.damage_sword << " dmg!";
- }
- }
- else
- {
- cout << "You miss! ";
- player.damage_sword=0;
- }
- cout << endl;
- // enemy attack
- if (player.evade >15)
- {
- if(enemy.offend<10)
- {
- cout << "Jebac cie (Your dmg was reducted)";
- player.damage_sword-=10;
- if (player.damage_sword<0)
- {
- player.damage_sword = 0;
- }
- }
- else
- {
- if (enemy.crit_chance<16)
- {
- cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
- }
- else
- {
- cout << "You received "<< enemy.damage<< " dmg";
- }
- }
- }
- else
- {
- cout<< "You dodge!";
- enemy.damage=0;
- }
- cout << endl << "========================="<< endl;
- // RESULT
- enemy.hitpoints = enemy.hitpoints - player.damage_sword;
- player.hitpoints = player.hitpoints - enemy.damage;
- player.hitpoints+=player.regen_health;
- player.mana+=player.regen_mana;
- if (player.mana>15)
- {
- player.mana_reduction=player.mana-player.max_mana;
- player.mana-=player.mana_reduction;
- }
- if (player.hitpoints>100)
- {
- player.hp_reduction=player.hitpoints-player.max_hitpoints;
- player.hitpoints-=player.hp_reduction;
- }
- cout<< endl;
- break;
- case '2':
- if (player.mana>9)
- {
- cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
- //enemy attack
- if (player.evade >15)
- {
- if (enemy.crit_chance<16)
- {
- cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
- }
- else
- {
- cout << "You received "<< enemy.damage<< " dmg";
- }
- }
- else
- {
- cout<< "You dodge!";
- enemy.damage=0;
- }
- cout << endl << "========================="<< endl;
- //RESULT
- enemy.hitpoints-=player.damage_spell;
- player.damage_spell==0;
- player.hitpoints = player.hitpoints - enemy.damage;
- player.mana-=10;
- player.hitpoints+=player.regen_health;
- player.mana+=player.regen_mana;
- if (player.mana>15)
- {
- player.mana_reduction=player.mana-player.max_mana;
- player.mana-=player.mana_reduction;
- }
- if (player.hitpoints>100)
- {
- player.hp_reduction=player.hitpoints-player.max_hitpoints;
- player.hitpoints-=player.hp_reduction;
- }
- }
- else
- {
- cout<< "You dont have enought mana!"<<endl;
- round --;
- }
- break;
- case '3':
- escape=rand()%10;
- if (escape==0)
- {
- cout << "You just ran away like a coward...";
- break;
- }
- else
- {
- cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
- player.hitpoints-=10;
- }
- break;
- default:
- cout << "Choose another option";
- round --;
- break;
- }
- }
- else
- {
- }
- option = getch();
- system ("cls");
- }
- if (escape == 0)
- {
- cout << "You lost some coins along the way...";
- }
- else if (player.hitpoints > 0)
- {
- cout << "You defeated the opponent!";
- }
- else if (enemy.hitpoints>0)
- {
- cout << "GAME OVER" ;
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement