codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <ctime> using namespace std; int main() { int T; int hp=80; int mana=0; int heal; int day=1; int event; int turn=0; int dmg=5; int gold=0; int loot; string name; //while (T!=0) //{ srand(time(0)); //a = rand()%100 + 1; //cout << a; cout<<" ---Hello, stranger! What is your name?---"<<endl<<"- "; cin>>name; cout<<" ---I will call you 'stranger'.---\n"<<endl; cout<<" ---Where are you want to go?---"<<endl<<"1. Forest \n2. Cave \n3. Dungeon\n\n"; cin>>T; if (T !=1) {cout<<" ---We dont have caves or dungeons!---\n"; T=1;} if (T==1) { cout<<" ---Take my axe and bring me a log!---\n\n You walk in forest..."<<endl; while (hp>0) { cout<<"\n\n1. Chop tree \n2. Search for mushrooms \n" "3. Look for treasure and adventure \n4. Make bonfire and fall asleep\n"; cin>>T; if (T==1) {cout<<"\n *Tree choped, but log is too heavy. You cant pick it.*\n\n";} if (T==2) { if (hp<96) {hp=hp+5; cout<<"\n* hp is now "<<hp<<"*";} else { cout<<"\n *you dont find anything, but you damage you leg!*"; hp=hp-10; cout<<"\n hp is now "<<hp;} } if (T==3) { event = rand()%100 +1; if (event<=8) { cout<<"\n You found a note, read it?\n1. Yes\n2. No\n"; cin>>T; if (T==1) { cout<<"\n It says "<<name<<" pidor"; } if (T==2) { cout<<"\n You left note"; } } if (event>8&&event<=32) { loot=rand()%30+1; cout<<" You found small amount of gold"; gold=gold+loot; cout<<"\n gold - "<<gold; } if (event>32) { cout<<"\n You are attacked by wolf! (25 hp, 12 dmg)\n"; int wolfhp=25, wolfdmg=12; turn=1; while(wolfhp>0&&hp>0) { cout<<"\nturn "<<turn<<"\nyour hp - "<<hp<<"\nEnemy hp - "<<wolfhp<<endl; cout<<"\n1. Attack\n2. Magick attack\n3. Sleep\n"; cin>>T; if (T==1) { cout<<" You attack for "<<dmg; wolfhp=wolfhp-dmg; } if (T==2) { if (mana>24) { cout<<" You prepare magic something"; mana=mana-25; wolfhp=wolfhp-20; } else { cout<<"\n Not enough mana!"; } } cout<<" Wolf attack you for "<<wolfdmg<<endl; hp=hp-wolfdmg; turn++; } loot=rand()%100+1; if (loot<85&&hp>0) { gold=gold+loot; cout<<"\n You found "<<loot<<" gold!"; } if (loot>=85&&hp>0) { cout<<"\n You find tiny log, that you can pick up! Mission complete!"; hp=0; } } } if (T==4) { if (hp<100) { heal=100-hp; hp=100; cout<<"\n You are healed for "<<heal;} if (mana<100) { mana=100; cout<<"\n Mana restored"<<endl; } cout<<"\n hp - "<<hp<<endl<<" mana - "<<mana<<endl<<" gold - "<<gold<<endl; day++; cout<<"\n Day "<<day; } } cout<<"\n\n END GAME on Day "<<day; } return 0; }
Private
[
?
]
Run code
Submit