Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import javax.swing.JPanel;
- import java.util.Scanner;
- import java.awt.Color;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import java.awt.image.BufferedImage;
- import java.awt.*;
- import java.lang.*;
- import javax.swing.*;
- import java.io.Writer;
- import java.util.concurrent.ThreadLocalRandom;
- //////////////////////////////
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.*;
- //////////////////////////////
- public class RPG extends JPanel{ //implements KeyListener{
- public static String name;
- public static String profession;
- public static String weapon;
- public static int Phealth = 200;
- public static int Pdamage;
- public static int Pspeed;
- public static int Pcrit;
- //WEAPONS//
- public static int axeDamage;
- public static int axeSpeed;
- public static int axeCritChance;
- public static String axePhrase;
- //--//
- public static int bowDamage;
- public static int bowSpeed;
- public static int bowCritChance;
- public static String bowPhrase;
- //--//
- public static int fistDamage;
- public static int fistSpeed;
- public static int fistCritChance;
- public static String fistPhrase;
- //--//
- //BASE ENEMIES//
- public static int damage;
- public static int speed;
- public static int crit;
- public static int Enemyhealth;
- //--//
- public static Items its = new Items();
- public static void main(String[] args){
- LoopTester();
- }
- public static void LoopTester(){
- boolean contin = false;
- while(contin == false){
- Scanner typing = new Scanner(System.in);
- System.out.println("Would You Like To Start? Y/N");
- String scan = typing.nextLine();
- if(scan.equalsIgnoreCase("y")){ contin = true; runIntro(); }
- else if(contin = false);
- }
- }
- public static void runIntro(){
- its.GrantHealthPack();
- Scanner typing = new Scanner(System.in);
- Print("Input Name!");
- name = typing.nextLine();
- System.out.println("Now it is time to fight for glory!");
- System.out.println("Now " + name + " you must take on one foe in battle before proving yourself worthy to his highness! DO YOU ACCEPT MY QUEST! Y/N");
- String YN = typing.nextLine();
- if(YN.equalsIgnoreCase("y")) { }
- else{Print("Now " + name + " you must take on one foe in battle before proving yourself worthy to his highness! DO YOU ACCEPT MY QUEST! Y/N"); YN = typing.nextLine(); }
- Print("What Weapon Shall You weild!");
- Print("Axe,Bow,Fists");
- weapon = typing.nextLine();
- if(weapon.equalsIgnoreCase("Axe")){ WeaponIndex(); Print(axePhrase); System.out.println("Damage: " + axeDamage + " Speed: " + axeSpeed + " CritChance: " + axeCritChance);Pdamage = axeDamage;Pspeed = axeSpeed;Pcrit = axeCritChance;}
- else if(weapon.equalsIgnoreCase("Bow")){ WeaponIndex(); Print(bowPhrase); System.out.println("Damage: " + bowDamage + " Speed: " + bowSpeed + " CritChance: " + bowCritChance);Pdamage = bowDamage;Pspeed = bowSpeed;Pcrit = bowCritChance;}
- else if(weapon.equalsIgnoreCase("fists")){ WeaponIndex(); Print(fistPhrase); System.out.println("Damage: " + fistDamage + " Speed: " + fistSpeed + " CritChance: " + fistCritChance);Pdamage = bowDamage;Pspeed = bowSpeed;Pcrit = bowCritChance;}
- else{Print("What Weapon Shall You weild!");Print("Axe,Bow,Fists");weapon = typing.nextLine();}
- firstFight();
- Print("Well done! You have completed your first quest!");
- System.out.println("It is time for you to see the king " + name);
- System.out.println("So what profession were you before becoming a warrior?");
- profession = typing.nextLine();
- PrintExclam(profession + " Really! I would have never thought!");
- System.out.println("Something funny about " + profession + "... even " + profession + "'s cant steal my place next to the king!");
- System.out.println("I fight to the death! I shall not see the day you enter the kings court!");
- Print("Player recieved weapon powerup! <");
- Pdamage = Pdamage+5;
- System.out.println("Damage: " + Pdamage);
- fightIntroMechanics();
- System.out.println("I shall not see the day, for i have passed. many lifetimes shall pass and NO ONE will remember you...");
- Print("Player recieved healthpack!");
- its.GrantHealthPack();
- Print("Player recieved grenade!");
- its.GrantGrenade();
- mainGame();
- }
- public static void mainGame(){
- Scanner typing = new Scanner(System.in);
- Print("Player's " + weapon + " granted +3 damage and +1 speed!");
- Pdamage = Pdamage+3;
- Pspeed = Pspeed+1;
- Print("You meet a man on the side of the road do you talk(T) or walk past him(W)");
- String ans = typing.nextLine();
- if(ans.equalsIgnoreCase("t")){ dialogTraver(); }
- else{}
- Print("you apprach a hill about 100 yards out, you have to decide on a forest or up the hill. Your not sure what is up the hill but the forest has been documented a low risk area.");
- System.out.println("Do you A: Go Forest(F)?");
- System.out.println("Or B: Go Hill(H)?");
- ans = typing.nextLine();
- if(ans.equalsIgnoreCase("F")){ forestStory(); }
- else if(ans.equalsIgnoreCase("H")){ Print("you found no one on your way to the top, it was a peacfull walk, but no benafits have come your way except the silence and peace in your mind."); }
- else{Print("you apprach a hill about 100 yards out, you have to decide on a forest or up the hill. Your not sure what is up the hill but the forest has been documented a low risk area.");
- System.out.println("Do you A: Go Forest(F)?");
- System.out.println("Or B: Go Hill(H)?");
- ans = typing.nextLine();}
- }
- //Forest Story-Branchoff includes +3 Damage buff and + 2 crit chance, or an offer to change weapon//
- public static void forestStory(){
- Print("As you walk in the forest a rumble comees from behind, you noptice the entrance from which you came is on longer there, you keep walking and the bright forest you saw from the outside turns into a dark and eerie place, as if it was night.");
- Print("Suddenly, you get startled but only by a fluffy little bunny, it seems innocent at first until it warps right in front of you in a beast only the darkesat mind could conjour, your worst nightmare. Brought upon yourself by your own imagination");
- fight("nightmare");
- }
- public static void dialogTraver(){
- if(randomRoll()==1){
- Print("The traveler was evil!");
- fight("basicLV2");
- }
- else{ Print("turns out the man is just a normal everyday hiker out on a stroll!");}
- }
- ////FIGHT SCENES////
- public static void firstFight(){
- boolean fighting = true;
- EnemyIndex("basic");
- Scanner typing = new Scanner(System.in);
- while(fighting==true){
- if(Enemyhealth<0){fighting = false; Print("you won!");}
- if(Phealth<0){ Print("You Died! Ressurecting..."); Ressurect();}
- Print("Strike(S),Dodge(D),Check Health(C), or Use Item(U)?");
- String Ans = typing.nextLine();
- if(Ans.equalsIgnoreCase("S")){if(randomCrits()==1){Enemyhealth = Enemyhealth-(Pdamage*Pcrit);}else if(randomCrits()==2){}else if(randomCrits()==3){Enemyhealth = (Enemyhealth-Pdamage);Print("> The Enemy was damaged: " + Pdamage);}}
- else if(Ans.equalsIgnoreCase("C")){checkHealth();}
- else if(Ans.equalsIgnoreCase("u")){useItems();}
- else{ if(randomRoll()==1){Print("> No Damage Taken");}else{Print("> Player Took " + damage + " Damage!"); Phealth = (Phealth - damage);}
- if(Enemyhealth<0){fighting = false; Print("> You won!");}
- }
- }
- }
- public static void fightIntroMechanics(){
- boolean fighting = true;
- EnemyIndex("boss1");
- Scanner typing = new Scanner(System.in);
- while(fighting==true){
- if(Enemyhealth<0){fighting = false; Print("you won!");}
- if(Phealth<0){ Print("You Died! Ressurecting..."); Ressurect();}
- Print("Strike(S),Dodge(D),Check Health(C), or Use Item(U)?");
- String Ans = typing.nextLine();
- if(Ans.equalsIgnoreCase("S")){if(randomCrits()==1){Enemyhealth = Enemyhealth-(Pdamage*Pcrit);}else if(randomCrits()==2){}else if(randomCrits()==3){Enemyhealth = (Enemyhealth-Pdamage);Print("> The Enemy was damaged: " + Pdamage);}}
- else if(Ans.equalsIgnoreCase("C")){checkHealth();}
- else if(Ans.equalsIgnoreCase("u")){useItems();}
- else{ if(randomRoll()==1){Print("> No Damage Taken");}else{Print("> Player Took " + damage + " Damage!"); Phealth = (Phealth - damage);}
- if(Enemyhealth<0){fighting = false; Print("> You won!");}
- }
- }
- }
- public static void fight(String enemyIndexType){
- boolean fighting = true;
- EnemyIndex(enemyIndexType);
- Scanner typing = new Scanner(System.in);
- while(fighting==true){
- if(Enemyhealth<0){fighting = false; Print("you won!");}
- if(Phealth<0){ Print("You Died! Ressurecting..."); Ressurect();}
- Print("Strike(S),Dodge(D),Check Health(C), or Use Item(U)?");
- String Ans = typing.nextLine();
- if(Ans.equalsIgnoreCase("hhh")){Print("Pdamage: " + Pdamage + ", Pspeed: " + Pspeed + ", Pcrit: " + Pcrit);}
- else if(Ans.equalsIgnoreCase("S")){if(randomCrits()==1){Enemyhealth = Enemyhealth-(Pdamage*Pcrit);}else if(randomCrits()==2){}else if(randomCrits()==3){Enemyhealth = (Enemyhealth-Pdamage);Print("> The Enemy was damaged: " + Pdamage);}if(Enemyhealth<0){fighting = false; Print("> You won!");}}
- else if(Ans.equalsIgnoreCase("C")){checkHealth();}
- else if(Ans.equalsIgnoreCase("u")){useItems();}
- else{ if(randomRoll()==1){Print("> No Damage Taken");}else{Print("> Player Took " + damage + " Damage!"); Phealth = (Phealth - damage);}
- if(Enemyhealth<1){fighting = false; Print("you won!");}
- }
- }
- }
- ////END OF FIGHT SCENES////
- ////BASIC MECHANICS////
- public static void useItems(){
- Scanner typing = new Scanner(System.in);
- System.out.println("> Which item: "); System.out.println("Healthpack(" + its.healthPackAmount + ") Grendade("+ its.grenades + ")"); String anse = typing.nextLine(); if(anse.equalsIgnoreCase("healthpack")){ its.useHealthPack();} else if(anse.equalsIgnoreCase("Grenade")){Items.UseGrenade();}
- }
- //}
- public static void Ressurect(){
- System.out.println("Gathering life shards...");
- System.out.println("Extracting life force from goat...");
- System.out.println("Reconstructing soul, and inserting life force...");
- System.out.println("Inserting life into beggining of fight!");
- Phealth = 120;
- }
- public static void checkHealth(){
- //Scanner typing = new Scanner(System.in);
- //System.out.println("Check health? Y/N");
- //String healthCheck = typing.nextLine();
- //if(healthCheck.equalsIgnoreCase("Y")){
- Print("Your health is: " + Phealth);
- Print("Your enemie's health is: " + Enemyhealth);
- //}
- //else{}
- }
- public static int randomCrits(){
- int secRan = Phealth/22+((Pspeed/100)*Phealth);
- int raN = ThreadLocalRandom.current().nextInt(1, 8 + 1);
- int critDamage = Pcrit+Pdamage;
- if((Pcrit*raN)+secRan >= 115){System.out.println("> CRIT! " + critDamage + " damage done!"); return 1;}
- if((Pcrit*raN)+secRan < 30){System.out.println("> You got hit! You took " + damage + " amount of damage!");Phealth = Phealth-damage;return 2;}
- else{return 3;}
- }
- public static int randomRoll(){
- int raN = ThreadLocalRandom.current().nextInt(1, 11 + 1);
- int rollChance = (int)raN*Pspeed;
- if(rollChance>130){return 1;}
- else{return 2;}
- }
- ////END OF BASIC MECHANICS////
- ////INDEX SECTION////
- public static void EnemyIndex(String EnemyType){
- if(EnemyType.equalsIgnoreCase("basic")){
- int raN = ThreadLocalRandom.current().nextInt(2, 6 + 1);
- damage = Pdamage*(raN*1);
- speed = Pspeed*(raN*1);
- crit = Pcrit*(raN*1);
- Enemyhealth = 120;
- }
- else if(EnemyType.equalsIgnoreCase("boss1")){
- int raN = ThreadLocalRandom.current().nextInt(2, 7 + 1);
- damage = Pdamage*(raN*1);
- speed = Pspeed*(raN*1);
- crit = Pcrit*(raN*1);
- Enemyhealth = 320;
- }
- else if(EnemyType.equalsIgnoreCase("basicLV2")){
- int raN = ThreadLocalRandom.current().nextInt(2, 6 + 1);
- damage = Pdamage*(raN*2);
- speed = Pspeed*(raN*2);
- crit = Pcrit*(raN*2);
- Enemyhealth = 200;
- }
- else if(EnemyType.equalsIgnoreCase("nightmare")){
- int raN = ThreadLocalRandom.current().nextInt(4, 7 + 1);
- //Should be equal to players stats + some//
- damage = Pdamage + (2*raN);
- speed = Pspeed + (2 + raN);
- crit = Pcrit + (2 + raN);
- Enemyhealth = Phealth + (Phealth/raN);
- }
- }
- public static void WeaponIndex(){
- int raN = ThreadLocalRandom.current().nextInt(2, 6 + 1);
- //AXE//
- axeDamage = 9*raN;
- axeSpeed = 2*raN;
- axeCritChance = 4*raN;
- axePhrase = "You Have wielded the trusty axe, its very nslow but sure to pack a huge punch!";
- //BOW/
- bowDamage = 6*raN;
- bowSpeed = 5*raN;
- bowCritChance = 3*raN;
- bowPhrase = "The Trust bow, besat for great accuracy but a bit lacking in damage, overall a great choice in any archers hands";
- //FISTS//
- fistDamage = 2*raN;
- fistSpeed = 9*raN;
- fistCritChance = 2*raN;
- fistPhrase = "Your good ole' hands, the thing you know best. although they cant pack a lot of damage, they make up in speed!";
- }
- ////END OF INDEX SECTION////
- ////PRINT SECTION////
- public static void Print(String s){
- //System.out.println("");
- System.out.println("> "+s);
- //System.out.println("");
- }
- public static void PrintExclam(String s){
- //System.out.println("");
- System.out.println(">>>>>>>"+" " + s + " " +"<<<<<<");
- }
- //(IN CASE I WANT KEY LISTENER)//
- /*public void keyTyped(KeyEvent e){int key = e.getKeyCode();
- if(key = KeyEvent.
- }
- public void keyPressed(KeyEvent e){}
- public void keyReleased(KeyEvent e){}*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement