Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // GAME RPG
- //
- // Created by Alexander Kevin on 11/29/13.
- // Copyright (c) 2013 Alexander Kevin. All rights reserved.
- //
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <Windows.h>
- #include <string.h>
- void welcome();
- void home();
- void create();
- void adventure();
- void battle();
- void enchant();
- void store();
- void about();
- void exit();
- int money=0,lv=1,plus=0,str=15,bonusstat=0,hpmaks=150,hpm,encounter=1;
- int brd=0,ktn=0,wft=0,elu=0;
- char nick[10],answer;
- FILE *nickname,*stat,*item;
- int main(){
- welcome();
- }
- void welcome(){
- printf("*********************************** VER 3.2 ************************************");
- if((nickname=fopen("nick.dat","r"))==NULL||(stat=fopen("stat.dat","r"))==NULL||(item=fopen("item.dat","r"))==NULL){
- printf("\n\n\n\n\n\nWELCOME TO RPG GAME\n===============================\nStart your Journey <enter>");
- printf(", Lets Create your Character\n");
- getchar();
- create();}
- else{
- fscanf(nickname,"%s",nick);
- printf("\n\n\n\n\n\n===========================================\nWelcome Back %s!\nLets Continue your journey\n<Y to continue,N to start a new journey>\n===========================================\n",nick);
- scanf("%c",&answer);fflush stdin;
- if(answer=='Y'||answer=='y'){
- fscanf(stat,"%d %d %d %d %d %d %d",&money,&lv,&plus,&str,&bonusstat,&hpmaks,&encounter);
- fscanf(item,"%d %d %d %d",&brd,&ktn,&wft,&elu);
- adventure();
- }
- else
- create();
- }
- }
- void create(){
- system("cls");
- do{
- printf("Input your Character Nicknames[maks 10] : ");
- gets(nick);fflush (stdin);
- printf("Your Character names is %s, OK[Y/N]? ",nick);
- scanf("%c",&answer);fflush (stdin);
- }while(answer!='Y'&&answer!='y');
- printf("\nLet The Adventure Begin");
- nickname=fopen("nick.dat","w");
- fprintf(nickname,"%s",nick);
- fclose(nickname);
- stat=fopen("stat.dat","w");
- fprintf(stat,"%d %d %d %d %d %d %d",money,lv,plus,str,bonusstat,hpmaks,encounter);
- fclose(stat);
- getchar();
- adventure();
- }
- void adventure(){
- char eq[100][100]={"Broadsword","Katana","WindFleuret","Elucidator"};
- int x;
- if (brd==1)
- x=0;
- if (ktn==1)
- x=1;
- if (wft==1)
- x=2;
- if (elu==1)
- x=3;
- system("cls");
- printf("-------------------------------------------------------------------------------\n%s, Welcome to the world of ....... !\n-------------------------------------------------------------------------------",nick);
- printf("\n\n\n%s Lv.%d\n=================================\n|Status\t\t|Point\t\t|\n=================================\n",nick,lv);
- printf("|HP\t\t|%d\t\t|\n",hpmaks);
- printf("|STR\t\t|%d(+%d)\t",str,bonusstat);
- if (bonusstat<10)
- printf("\t");
- printf("|\n");
- printf("=================================\n");
- if(brd==1||ktn==1||wft==1||elu==1)
- printf("%s+%d(STR+%d)\n",eq[x],plus,bonusstat);
- printf("GOLD %dG\n",money);
- printf("What do you want to do(B=Battle,E=Enchant,S=Store,0=exit)? ");
- scanf("%c",&answer);fflush (stdin);
- if(answer=='B'||answer=='b')
- battle();
- if(answer=='E'||answer=='e')
- enchant();
- if(answer=='S'||answer=='s')
- store();
- else
- about();
- }
- void battle(){
- system("cls");
- int att,critical,criticalm,attm,hpup,strup,hp=hpmaks,gold,boss=0;
- srand(time(NULL));
- hpm=rand()%30*lv+10*lv;
- if(hpm>=(25*lv+10*lv)){
- printf("Boss Level\n*********************************************\n");
- boss=1;
- }
- printf("\nMonster Lv.%d\n=================================\n|Status\t\t|Point\t\t|\n",encounter);
- printf("|HP\t\t|%d\t\t|\n",hpm);
- printf("=================================\nBattle Will Begin\n");
- printf("Attack Log : \nLoading Data");
- Sleep(400);
- printf(".");
- Sleep(400);
- printf(".");
- Sleep(400);
- printf(".\n\n");
- do{
- srand(time(NULL));
- critical=rand()%100+1;
- att=str+(rand()%10);
- if (critical==(11||22||33||44||55))
- att=0;
- if(critical==(66||32||21||10||43||54||77||88||99))
- att=att*(rand()%2+2);
- Sleep(2000);
- if(att!=0&&hp>0&&hpm>0){
- if(critical==(66||32||21||10||43||54||77||88||99))
- printf("CRITICAL HIT!\n");
- hpm-=att;
- if(hpm<0)
- hpm=0;
- printf("Damage %d, Monster Hp %d\n",att,hpm);
- }else if(att==0&&hp>0)
- printf("YOUR ATTACK MISS!\n");
- printf("\nMonster Lv.%d\n=================================\n|Status\t\t|Point\t\t|\n",encounter);
- printf("|HP\t\t|%d\t\t|\n",hpm);
- printf("=================================\n");
- Sleep(300);
- srand(time(NULL));
- criticalm=rand()%100+1;
- attm=str+(rand()%10)*(encounter/3+1);
- if(boss==1)
- attm+=str/3;
- if (criticalm==(77||88||99||66||1))
- attm=0;
- if(criticalm==(5||15||25||35||45||55||65||75||85||95))
- attm=attm*(rand()%2+2);
- if(attm!=0&&hpm>0&&hp>0){
- hp-=attm;
- if(criticalm==(5||15||25||35||45||55||65||75||85||95))
- printf("Monster does CRITICAL HIT!\n");
- if(hp<0)
- hp=0;
- printf("Damage Received %d, your Hp %d\n",attm,hp);
- }else if(attm==0&&hpm>0&&hp>0)
- printf("LUCKY, MONSTER ATTACK MISS!\n");
- printf("\n%s Lv.%d\n=================================\n|Status\t\t|Point\t\t|\n",nick,lv);
- printf("|HP\t\t|%d\t\t|\n",hp);
- printf("=================================\n");
- }while(hpm>0&&hp>0);
- if(hpm<=0&&hp>0){
- encounter++;
- if (boss==1){
- gold=(rand()%100+100)*lv+20;
- money+=gold;
- printf("YOU DEFEAT THE BOSS\nBonus Reward : %dG\n",money);
- }
- hpup=(rand()%3+1)*10;
- Sleep(10);
- strup=rand()%7+1;
- Sleep(10);
- gold=(rand()%50+50)*lv+20;
- money+=gold;
- str+=strup;
- hpmaks+=hpup;
- lv++;
- printf("CONGRATULATION %s, LVL UP BY 1\nSTR UP BY %d\nHP UP BY %d\nGot %dG ",nick,strup,hpup,gold);
- getchar();
- }else{
- printf("DEFEATED");
- getchar();
- }
- adventure();
- }
- void exit(){
- system("cls");
- FILE *stat;
- stat=fopen("stat.dat","w");
- fprintf(stat,"%d %d %d %d %d %d %d",money,lv,plus,str,bonusstat,hpmaks,encounter);
- fclose(stat);
- printf("\n\n\n\n\n***********************************************************\n%s, THANKS FOR PLAYING SEE U NEXT TIME\n***********************************************************\n",nick);
- printf("Program Will SelfClose in 3");
- Sleep(600);
- printf(" 2");
- Sleep(600);
- printf(" 1");
- Sleep(600);
- }
- void enchant(){
- int price,chance;
- price=plus*100;
- int times=500+plus*100;
- if (plus>=3)
- price=plus*250;
- if (plus>=6)
- price=plus*500;
- if (plus>=9)
- plus=plus*1000;
- system("cls");
- printf("-------------------------------------------------------------------------------\n%s, Welcome to the Blacksmith!\n-------------------------------------------------------------------------------\n",nick);
- printf("* +4 - +6 if fail weapon may be down by 1 level\n +7 - +13 if fail weapon will be destroyed or go down by 1/2 level\n\nYour Current Gold %dG\n\n",money);
- if(ktn==0&&elu==0&&wft==0&&brd==0){
- printf("Sorry You dont have weapon Yet!\nThanks For Stoping By\nSee You Next Time\n");
- getchar();
- adventure();
- }
- if(plus<13){
- printf("do you want to strenghtning your weapon to +%d (Price %dG)[Y/N]? ",plus+1,price);
- scanf("%c",&answer);fflush stdin;
- if ((answer=='Y'||answer=='y')&&money>=price){
- money-=price;
- printf("Enchanting your weapon \nDo NOT PRESS ANY BUTON, Loading");
- Sleep(times);
- printf(".");
- Sleep(times);
- printf(".");
- Sleep(times);
- printf(".\n\n");
- srand(time(NULL));
- chance=rand()%100+1;
- if(plus<10){
- if(chance>=plus*10){
- plus++;
- bonusstat+=bonusstat*0.1;
- if(plus>=7&&plus<10)
- bonusstat+=bonusstat*0.1+plus;
- printf("SUCCESS!!!\nYOUR WEAPON IS NOW +%d Bonus Stat(STR+%d)\n",plus,bonusstat);
- str+=bonusstat;
- }else if(plus<=3)
- printf("ENCHANCEMENT FAILED! sorry...\n");
- else if(plus>3&&plus<7){
- srand(time(NULL));
- chance=rand()%100+1;
- if(chance<10){
- plus--;
- bonusstat-=bonusstat*0.1;
- printf("ENCHANCEMENT FAILED! your weapon is now +%d Bonus Stat(STR+%d)\n",plus,bonusstat);
- }else
- printf("ENCHANCEMENT FAILED! sorry...\n");
- }else if(plus>=7){
- srand(time(NULL));
- chance=rand()%100+1;
- if(chance<25){
- plus=0;
- bonusstat=0;
- brd=0,elu=0,ktn=0,wft=0;
- printf("ENCHANCEMENT FAILED! your weapon is destroyed\n");
- }
- else if(chance>=25&&chance<=50){
- plus--;
- bonusstat-=bonusstat*0.1;
- printf("ENCHANCEMENT FAILED! your weapon is now +%d Bonus Stat(STR+%d)\n",plus,bonusstat);
- }
- else
- printf("ENCHANCEMENT FAILED! sorry...\n");
- }
- }else if(plus>=10) {
- if(chance>=(100-10+plus/2)){
- plus++;
- bonusstat+=bonusstat*0.4+plus;
- printf("SUCCESS!!!\nYOUR WEAPON IS NOW +%d Bonus Stat(STR+%d)\n",plus,bonusstat);
- str+=bonusstat;
- }
- else if(chance<65){
- plus=0;
- bonusstat=0;
- brd=0,elu=0,ktn=0,wft=0;
- printf("ENCHANCEMENT FAILED! your weapon is destroyed\n");
- }
- else if(chance>=65&&chance<(100-10+plus/2)){
- plus-=2;
- bonusstat-=bonusstat*0.2+plus;
- printf("ENCHANCEMENT FAILED! your weapon is now +%d Bonus Stat(STR+%d)\n",plus,bonusstat);
- }
- else
- printf("ENCHANCEMENT FAILED! sorry...\n");
- }
- }else if(money<price&&(answer=='Y'||answer=='y'))
- printf("Sorry You Don't have enough Gold.\n");
- FILE *stat;
- stat=fopen("stat.dat","w");
- fprintf(stat,"%d %d %d %d %d %d %d",money,lv,plus,str,bonusstat,hpmaks,encounter);
- fclose(stat);
- }else
- printf("%s, You CONGRATULATION YOU HAVE MAX-OUT YOUR WEAPON, There's nothing else you can do here\n");
- printf("Thanks For stoping bye %s!",nick);
- printf(" See U Next Time\n");
- getchar();
- adventure();
- }
- void about(){
- system("cls");
- printf("\n\n\nChanelogs :\n==============================================================\n");
- printf("Ver 1.0 Release\nVer 1.3 Fix Major Bugs\nVer 1.5 Fix Minor Bugs\nVer 2.0 Added Save Feature\nVer 2.2 Fix Enchance Feature\nVer 2.3 Fix Minor Bugs\nVer 2.8 Major Fix in Echanment Feature\n");
- printf("Ver 3.0 New Eq(Wft,Brd,Elu,Ktn), Critical Renewal, Enchant Renewal, Store FEATURE, BOSS LEVEL, NEW SAVE FEATURE\nVer 3.2 Games Rebalanced(GOLD,HP,STR,MISS)\n");
- printf("==============================================================\n");
- printf("You will be automove to the exit windows in a few second\n<DO NOT PRESS ANY BUTTON>\n");
- Sleep(4000);
- exit();
- }
- void store(){
- system("cls");
- printf("WELCOME %s TO THE ITEM STORE\n=======================================================\n",nick);
- printf("Broadsword(str+10)\t=100G(Code 0)\nKatana(str+50)\t\t=10000G(Code 1)\nWindFleuret(str+100)\t=50000G(Code 2)\nElucidator(str+200)\t=100000G(Code 3)\n");
- printf("*Keep in mind! if you buy a new eq, your current eq will be destroyed\n\nWhat do you want to buy?\nInput the code here (E to go back): ");
- scanf("%c",&answer);fflush stdin;
- if(answer=='0'&&money>=100){
- brd=1;str-=bonusstat;
- ktn=0,wft=0,elu=0;
- bonusstat=10;str+=bonusstat;
- money-=100;
- plus=0;
- printf("Success!, now your strength is %d(%d) ",str,bonusstat);
- }
- else if(answer=='1'&&money>=10000){
- ktn=1;str-=bonusstat;
- brd=0,wft=0,elu=0;
- bonusstat=50;str+=bonusstat;
- money-=10000;
- plus=0;
- printf("Success!, now your strength is %d(%d) ",str,bonusstat);
- }
- else if(answer=='2'&&money>=50000){
- ktn=0;str-=bonusstat;
- brd=0,wft=1,elu=0;
- bonusstat=100;str+=bonusstat;
- money-=50000;
- plus=0;
- printf("Success!, now your strength is %d(%d) ",str,bonusstat);
- }
- else if(answer=='3'&&money>=100000){
- ktn=0;str-=bonusstat;
- brd=0,wft=1,elu=0;
- bonusstat=200;str+=bonusstat;
- money-=100000;
- plus=0;
- printf("Success!, now your strength is %d(%d) ",str,bonusstat);
- }
- else if(answer=='9'){
- str-=bonusstat;
- elu=1;
- bonusstat=2000;
- str+=bonusstat;
- plus=0;
- printf("You Unlock A secret Elucidator!, now your strength is %d(%d) ",str,bonusstat);
- }
- else if(answer=='e'||answer=='E')
- ;
- else
- printf("Sorry You dont have enough money\n");
- printf("\nThanks for stopping Bye!");
- stat=fopen("stat.dat","w");
- fprintf(stat,"%d %d %d %d %d %d %d",money,lv,plus,str,bonusstat,hpmaks,encounter);
- fclose(stat);
- item=fopen("item.dat","w");
- fprintf(item,"%d %d %d %d ",brd,ktn,wft,elu);
- fclose(item);
- getchar();
- adventure();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement