Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import java.util.Scanner;
- public class Battlesim
- {
- //core vars
- static int Randint;
- static String p1Name;
- static String p2Name;
- static float p1Health;
- static float p2Health;
- static float p1Attack;
- static float p2Attack;
- static float p1RangedAttack = 0;
- static float p2RangedAttack = 0;
- static float p1Defense;
- static float p2Defense;
- static String p1Armor;
- static String p2Armor;
- static float p1Speed;
- static float p2Speed;
- static double damage;
- static String inputString;
- static int increp;
- static int repetition;
- static int p1Rounds;
- static int p2Rounds;
- static float p1MaxHealth;
- static float p2MaxHealth;
- static int distanceSeperating;
- //Status weapons
- static boolean p1Burner = false;
- static boolean p2Burner = false;
- static boolean p1Poisoner = false;
- static boolean p2Poisoner = false;
- static boolean p1RageIncrease = false;
- static boolean p2RageIncrease = false;
- static boolean p1Bludgeoner = false;
- static boolean p2Bludgeoner = false;
- //Status effects
- static boolean isP1Burning = false;
- static boolean isP2Burning = false;
- static boolean isP1Poisoned = false;
- static boolean isP2Poisoned = false;
- static boolean isP1Stunned = false;
- static boolean isP2Stunned = false;
- static boolean isP1Bleeding = false;
- static boolean isP2Bleeding = false;
- static boolean isP1Jarated = false;
- static boolean isP2Jarated = false;
- static boolean isP1Confused = false;
- static boolean isP2Confused = false;
- static boolean isP1Enraged = false;
- static boolean isP2Enraged = false;
- static boolean isP1Ranged = false;
- static boolean isP2Ranged = false;
- static boolean justchanged = true;
- static boolean didPlayerHurtSelf = false;
- static boolean noOutput = false;
- //scanner declaration
- static Scanner input = new Scanner(System.in);
- //Ranged update variables
- static double p1RangedAccuracy;
- static double p2RangedAccuracy;
- static double p1RangedScaling;
- static double p2RangedScaling;
- private static boolean noGapClose;
- /*
- * OVERALL TODO
- * Add moar weapons
- * Bug test.
- * Life steal?
- * Slow effect?
- * Buffs? (red= AD 25% increase ranged or melee. Purple= 1% true damage per turn. Blue= Cannot be affected by statuses. White= Movement speed tripled. Yellow= 15% Life steal. Green= Health regenerates. Black= No damage is taken.
- * Knockback to reinitiate ranged combat?
- * Add shields that absorb ranged damage better.
- * Add magic combat core (mana, scrolls, elemental spells that apply effects and damage) and todo.
- * Mount can die (random .25%ish chance)? Continue the combat on foot! :D
- * Incorporate a story/campaign mode MAYBE LONG TERM!
- */
- public static void main(String[] args)
- {
- System.out.println("Hello, welcome to combat simulator version 2.0, created by Mark Davis.");
- while (true)
- {
- System.out.println("To begin, please choose a game mode by entering the corresponding integer.");
- System.out.println("1) Manual value input");
- System.out.println("2) Use recommended skill values");
- System.out.println("3) Multiple computations");
- System.out.println("4) View instructions");
- System.out.println("5) Status effect info");
- System.out.println("6) Campaign mode? (Coming never most likely)");
- System.out.println("Type a number and press enter.");
- inputString = input.nextLine();
- switch (inputString.toLowerCase())
- {
- case "1":
- {
- noOutput = false;
- Inputs();
- Combat();
- break;
- }
- case "2":
- {
- noOutput = false;
- System.out.print("P1 Name?- ");
- p1Name = input.nextLine();
- System.out.print("P2 Name?- ");
- p2Name = input.nextLine();
- p1Health = 10000;
- p2Health = 10000;
- p1Attack = 10;
- p2Attack = 10;
- p1Defense = 10;
- p2Defense = 10;
- p1Speed = 1;
- p2Speed = 1;
- distanceSeperating = 0;
- p1RangedAttack = 0;
- p2RangedAttack = 0;
- CoreInputs();
- Combat();
- break;
- }
- case "3":
- {
- noOutput = true;
- System.out.println("NOTE: This feature is early beta as of version 2.1, but all known bugs have been fixed.");
- System.out.println("");
- Inputs();
- System.out.println("How many rounds to simulate?");
- System.out.println("");
- repetition = input.nextInt();
- increp = 0;
- while (repetition != increp)
- {
- Combat();
- if (p1Health > p2Health)
- {
- p1Rounds++;
- System.out.print(p1Name);
- System.out.println(" wins a round!");
- System.out.println("");
- }
- if (p2Health > p1Health)
- {
- p2Rounds++;
- System.out.print(p2Name);
- System.out.println(" wins a round!");
- System.out.println("");
- }
- p1Health = p1MaxHealth;
- p2Health = p2MaxHealth;
- increp++;
- isP1Burning = false;
- isP2Burning = false;
- isP1Poisoned = false;
- isP2Poisoned = false;
- isP1Stunned = false;
- isP2Stunned = false;
- isP1Bleeding = false;
- isP2Bleeding = false;
- isP1Jarated = false;
- isP2Jarated = false;
- isP1Confused = false;
- isP2Confused = false;
- isP1Enraged = false;
- isP2Enraged = false;
- didPlayerHurtSelf = false;
- }
- System.out.print("P1 has won ");
- System.out.println(p1Rounds);
- System.out.print("P2 has won ");
- System.out.println(p2Rounds);
- System.out.println("");
- if (p1Rounds > p2Rounds)
- System.out.println("P1 wins");
- if (p1Rounds < p2Rounds)
- System.out.println("P1 wins");
- if (p1Rounds == p2Rounds)
- System.out.println("Tie.");
- break;
- }
- case "4":
- {
- System.out.println("The objective of this program is to create a semi-realistic but far fetched combat scenario.");
- System.out.println("You can enter names, attack, defense, health, and speed values for two combatants,");
- System.out.println("in addition, you can give the combatants armor, shields, weapons, and mounts to boost their stats.");
- System.out.println("Each weapon, shield, armor and mount has unique properties and advantages.");
- System.out.println("Some weapons have special status effects that can be incurred upon the enemy, like poison or fire.");
- System.out.println("Some effects occur rarely even without special items.");
- System.out.println("After values are inputted, a combat scenario will be computed,");
- System.out.println("and the final results displayed at the bottom.");
- System.out.println("Legal note: These results do not nessescarily accurately reflect a real combat encounter.");
- System.out.println("");
- System.out.println("Press enter please.");
- input.nextLine();
- System.out.println("");
- System.out.println("");
- System.out.println("");
- break;
- }
- case "5":
- {
- System.out.println("Burning- Caused by dragons and flameswords. Does low damage over time.");
- System.out.println("Poison- Caused by poisoned daggers. Does low damage over time.");
- System.out.println("Bleeding- Occurs occasionally, independent of any special items. Does low damage over time.");
- System.out.println("Stunned- May prevent the stunned player from attacking. Occurs naturally, but chance doubles with staff.");
- System.out.println("Confused- May cause the player to attack himself. Occurs naturally, but chance doubles with staff.");
- System.out.println("Rage- Can be positive as well as negative. Causes most attacks to miss, but smash and final smash crits are possible and devastating.");
- System.out.println(" Occurs naturally, but chance of becoming enraged is x3 when equipping a battleaxe.");
- System.out.println("Jarate- Occurs naturally. Causes all attacks to hit, and deal crits and minicrits.");
- System.out.println(" Can be very painful if it doesn't go away fast.");
- System.out.println("");
- System.out.println("Press enter please.");
- input.nextLine();
- System.out.println("");
- System.out.println("");
- System.out.println("");
- break;
- }
- case "6":
- {
- noOutput = false;
- System.out.println("Not implemented yet.");
- System.out.println("Press enter please.");
- input.nextLine();
- System.out.println("");
- break;
- }
- default:
- {
- System.out.println("Uh. That's not a valid input...");
- System.out.println("");
- break;
- }
- }
- }
- }
- public static void Combat()
- {
- while (p1Health > 0 && p2Health >0)
- {
- //speed test to determine who goes first
- didPlayerHurtSelf = false;
- while (distanceSeperating > 0 && p1Health > 0 && p2Health > 0 && p1RangedAttack > 0 || p2RangedAttack > 0)
- {
- RandInt(0, p1Speed + p2Speed);
- if (Randint < p1Speed)
- {
- if (p1RangedAttack > 0)
- P1RangedTurn();
- if (p2RangedAttack > 0)
- P2RangedTurn();
- noGapClose = false;
- }
- else
- if (Randint > p2Speed)
- {
- if (p2RangedAttack > 0)
- P2RangedTurn();
- if (p1RangedAttack > 0)
- P1RangedTurn();
- noGapClose = false;
- }
- else
- {
- //If both speeds are 1, I think this will happen. This is to essentially "break the tie"
- RandInt(0, 1);
- if (Randint == 0)
- {
- p1Speed = p1Speed++;
- }
- if (Randint == 1)
- {
- p2Speed = p2Speed++;
- }
- noGapClose = true;
- }
- RandInt(5, 60);
- if (!noGapClose)
- {
- if (p1RangedAttack == 0)
- Randint = (int) (Randint + 15 + p1Speed);
- if (p2RangedAttack == 0)
- Randint = (int) (Randint + 15 + p2Speed);
- distanceSeperating = distanceSeperating - Randint;
- if (distanceSeperating >= 0)
- System.out.print(distanceSeperating);
- if (distanceSeperating < 0)
- System.out.print("0");
- System.out.println(" meters remain between the combatants.");
- System.out.println("");
- justchanged = true;
- }
- }
- if (justchanged == true)
- {
- justchanged = false;
- if (!noOutput)
- {
- System.out.println("");
- System.out.println("The champions are now engaged in melee combat!");
- System.out.println("");
- }
- }
- RandInt(0, p1Speed + p2Speed);
- if (Randint < p1Speed)
- {
- //P1's turn
- P1Turn();
- }
- else
- if (Randint > p1Speed)
- {
- //P2's turn
- P2Turn();
- }
- else
- {
- //If both speeds are 1, I think this will happen. This is to essentially "break the tie"
- RandInt(0, 1);
- if (Randint == 0)
- p1Speed = p1Speed++;
- if (Randint == 1)
- p2Speed = p2Speed++;
- }
- }
- //States winner based on results of battle
- if (!noOutput)
- CombatResolver();
- }
- private static void P1RangedTurn()
- {
- double chance = (p1RangedScaling / distanceSeperating) * 100 *p1RangedAccuracy;
- if (chance > 1)
- chance = 1;
- chance = (chance * 8)/10;
- chance = chance * 100000;
- RandInt(1,100000);
- if (chance >= Randint)
- {
- damage = 0 * damage;
- if (!noOutput)
- {
- System.out.println("Missed! : 0 damage dealt");
- System.out.println("");
- }
- }
- else
- damage = (p1RangedScaling/distanceSeperating) * 30 * p1RangedAttack;
- RandInt(60, 180);
- damage = (.8 * damage * Randint);
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p1Defense);
- RandInt(1, 100);
- if (Randint >= 87)
- {
- damage = 15 * damage;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint >= 65 && Randint < 87)
- {
- damage = 5 * damage;
- if (!noOutput)
- System.out.print("Minicrit! : ");
- }
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" deals ");
- System.out.print((int) (damage));
- System.out.print(" ranged damage; ");
- }
- p2Health = (float) (p2Health - damage);
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" has ");
- if (p2Health > 0)
- System.out.print((int) p2Health);
- if (p2Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- if (!noOutput)
- System.out.println("");
- }
- private static void P2RangedTurn()
- {
- double chance = (p2RangedScaling / distanceSeperating) * 100 *p2RangedAccuracy;
- if (chance > 1)
- chance = 1;
- chance = (chance * 8)/10;
- chance = chance * 100000;
- RandInt(1,100000);
- if (chance >= Randint)
- {
- damage = 0 * damage;
- if (!noOutput)
- {
- System.out.println("Missed! : 0 damage dealt");
- System.out.println("");
- }
- }
- else
- damage = (p2RangedScaling/distanceSeperating) * 30 * p2RangedAttack;
- RandInt(60, 180);
- damage = (.8 * damage * Randint);
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p2Defense);
- RandInt(1, 100);
- if (Randint >= 87)
- {
- damage = 15 * damage;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint >= 65 && Randint < 87)
- {
- damage = 5 * damage;
- if (!noOutput)
- System.out.print("Minicrit! : ");
- }
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" deals ");
- System.out.print((int) (damage));
- System.out.print(" ranged damage; ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" has ");
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- if (!noOutput)
- System.out.println("");
- }
- public static void P1Turn()
- {
- RandInt(60, 180);
- damage = (p1Attack * Randint);
- if (isP2Jarated)
- {
- RandInt(1,4);
- if (Randint == 4)
- {
- damage = damage * 9;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint != 4)
- {
- damage = damage * 3;
- if (!noOutput)
- System.out.print("Minicrit! : ");
- }
- }
- if (isP1Enraged)
- {
- RandInt(1,60);
- if (Randint >= 58)
- {
- damage = damage * 27;
- if (!noOutput)
- System.out.print("Smash hit! : ");
- }
- if (Randint == 60)
- {
- damage = damage * 3;
- if (!noOutput)
- System.out.print("Final smash! : ");
- }
- if (Randint < 58)
- {
- damage = damage * 0;
- if (!noOutput)
- System.out.print("Missed! : ");
- }
- }
- if (isP2Jarated == false && isP1Enraged == false)
- {
- RandInt(1, 60);
- if (Randint == 60)
- {
- damage = 3 * damage;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint >= 57)
- {
- damage = 3 * damage;
- if (Randint != 60 && !noOutput)
- System.out.print("Minicrit! : ");
- }
- if (Randint <= 7)
- {
- damage = 0 * damage;
- if (!noOutput)
- System.out.print("Missed! : ");
- }
- }
- RandInt(1,2);
- if (isP1Stunned && Randint == 2)
- {
- damage = 0 * damage;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" is stunned, and can't move! : ");
- }
- }
- RandInt(1,10);
- if (isP1Confused && Randint >= 8)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" hurt himself, because he's confused! : ");
- }
- didPlayerHurtSelf = true;
- }
- if (didPlayerHurtSelf == false)
- {
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p2Defense);
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" does ");
- System.out.print((int) (damage));
- System.out.print(" damage; ");
- }
- p2Health = (float) (p2Health - damage);
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" has ");
- if (p2Health > 0)
- System.out.print((int) p2Health);
- if (p2Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- P1PostCombatEffects();
- if (!noOutput)
- System.out.println("");
- }
- else
- {
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p1Defense);
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" does ");
- System.out.print((int) (damage));
- System.out.print(" damage; ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" has ");
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- P1PostCombatEffects();
- if (!noOutput)
- System.out.println("");
- }
- }
- public static void P2Turn()
- {
- RandInt(60, 180);
- damage = (p2Attack * Randint);
- if (isP1Jarated == true)
- {
- RandInt(1,4);
- if (Randint == 4)
- {
- damage = damage * 9;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint != 4)
- {
- damage = damage * 3;
- if (!noOutput)
- System.out.print("Minicrit! : ");
- }
- }
- if (isP2Enraged == true)
- {
- RandInt(1,60);
- if (Randint >= 58)
- {
- damage = damage * 27;
- if (!noOutput)
- System.out.print("Smash hit! : ");
- }
- if (Randint == 60)
- {
- damage = damage * 3;
- if (!noOutput)
- System.out.print("Final smash! : ");
- }
- if (Randint < 58)
- {
- damage = damage * 0;
- if (!noOutput)
- System.out.print("Missed! : ");
- }
- }
- if (isP1Jarated == false && isP2Enraged == false)
- {
- RandInt(1, 60);
- if (Randint == 60)
- {
- damage = 3 * damage;
- if (!noOutput)
- System.out.print("Critical hit! : ");
- }
- if (Randint >= 57)
- {
- damage = 3 * damage;
- if (Randint != 60 && !noOutput)
- System.out.print("Minicrit! : ");
- }
- if (Randint <= 7)
- {
- damage = 0 * damage;
- if (!noOutput)
- System.out.print("Missed! : ");
- }
- }
- RandInt(1,2);
- if (isP2Stunned == true && Randint == 2)
- {
- damage = 0 * damage;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" is stunned, and can't move! : ");
- }
- }
- RandInt(1,10);
- if (isP2Confused == true && Randint >= 8)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" hurt himself, because he's confused! : ");
- }
- didPlayerHurtSelf = true;
- }
- if (didPlayerHurtSelf == false)
- {
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p1Defense);
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" does ");
- System.out.print((int) (damage));
- System.out.print(" damage; ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" has ");
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- P2PostCombatEffects();
- if (!noOutput)
- System.out.println("");
- }
- else
- {
- RandInt(92, 97);
- damage = (float) damage / ((Randint/10) * p2Defense);
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" does ");
- System.out.print((int) (damage));
- System.out.print(" damage; ");
- }
- p2Health = (float) (p2Health - damage);
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" has ");
- if (p2Health > 0)
- System.out.print((int) p2Health);
- if (p2Health <= 0)
- System.out.print("0");
- System.out.println(" health remaining.");
- }
- P2PostCombatEffects();
- if (!noOutput)
- System.out.println("");
- }
- }
- public static void CombatResolver()
- {
- if (!noOutput)
- {
- if (p1Health <= 0)
- {
- System.out.println("");
- System.out.println("[-------------]");
- System.out.print(p2Name);
- System.out.println(" is victorious!");
- System.out.println("[-------------]");
- }
- if (p2Health <= 0)
- {
- System.out.println("");
- System.out.println("[-------------]");
- System.out.print(p1Name);
- System.out.println(" is victorious!");
- System.out.println("[-------------]");
- }
- System.out.println("");
- System.out.println("");
- System.out.println("");
- System.out.println("[------------------------------------------------------------------------------]");
- System.out.println("Did you enjoy this program?");
- System.out.println("I enjoyed making it.");
- System.out.println("This project was coded in console java entirely by Mark Davis");
- System.out.println("It is and will remain open source");
- System.out.println("Source code availible here: http://pastebin.com/XzAiZTyC");
- System.out.println("Please feel free to use it for anythng educational or otherwise non-commercial.");
- System.out.println("[------------------------------------------------------------------------------]");
- System.out.println("");
- System.out.println("Press enter to return to main menu.");
- input.nextLine();
- System.out.println("");
- }
- }
- public static void Inputs()
- {
- //Names
- System.out.print("P1 Name?- ");
- p1Name = input.nextLine();
- System.out.print("P2 Name?- ");
- p2Name = input.nextLine();
- //HP
- System.out.print(p1Name);
- System.out.print(" Health?- ");
- p1Health = input.nextFloat();
- while (p1Health < 0)
- {
- System.out.println("Invalid input.");
- p1Health = input.nextFloat();
- }
- System.out.print(p2Name);
- System.out.print(" Health?- ");
- p2Health = input.nextFloat();
- while (p2Health < 0)
- {
- System.out.println("Invalid input.");
- p2Health = input.nextFloat();
- }
- //attack
- System.out.print(p1Name);
- System.out.print(" Attack?- ");
- p1Attack = input.nextFloat();
- System.out.print(p2Name);
- System.out.print(" Attack?- ");
- p2Attack = input.nextFloat();
- //P1 defense
- System.out.print(p1Name);
- System.out.print(" Defense (100 or less please)?- ");
- p1Defense = input.nextFloat();
- while (p1Defense > 100 || p1Defense < 0)
- {
- System.out.println("Invalid input.");
- p1Defense = input.nextFloat();
- }
- //P2 defense
- System.out.print(p2Name);
- System.out.print(" Defense (100 or less please)?- ");
- p2Defense = input.nextFloat();
- while (p2Defense > 100 || p2Defense < 0)
- {
- System.out.println("Invalid input.");
- p2Defense = input.nextFloat();
- }
- //Max value for inherent defense should be 60, although it is inputted as up to 100.
- p1Defense = (p1Defense*6)/10;
- p2Defense = (p2Defense*6)/10;
- //Speed inputs
- System.out.print(p1Name);
- System.out.print(" Speed?- ");
- p1Speed = input.nextFloat();
- while (p1Speed <= 0)
- {
- System.out.println("Invalid input.");
- p1Speed = input.nextFloat();
- }
- System.out.print(p2Name);
- System.out.print(" Speed?- ");
- p2Speed = input.nextFloat();
- while (p2Speed <= 0)
- {
- System.out.println("Invalid input.");
- p2Speed = input.nextFloat();
- }
- System.out.print(p1Name);
- System.out.print(" Ranged weapon? (none, knife, spear, bow, pistol, shotgun, sniper, rocket)- ");
- p1Armor = input.next();
- switch (p1Armor.toLowerCase())
- {
- case "knife":
- p1RangedAttack = 85;
- p1RangedAccuracy = .15;
- p1RangedScaling = .15;
- break;
- case "spear":
- p1RangedAttack = 35;
- p1RangedAccuracy = .35;
- p1RangedScaling = .25;
- break;
- case "bow":
- p1RangedAttack = 85;
- p1RangedAccuracy = .45;
- p1RangedScaling = .55;
- break;
- case "pistol":
- p1RangedAttack = 70;
- p1RangedAccuracy = .75;
- p1RangedScaling = .45;
- break;
- case "shotgun":
- p1RangedAttack = 100;
- p1RangedAccuracy = .15;
- p1RangedScaling = .15;
- break;
- case "sniper":
- p1RangedAttack = 100;
- p1RangedAccuracy = .5;
- p1RangedScaling = 1;
- break;
- case "rocket":
- p1RangedAttack = 120;
- p1RangedAccuracy = .6;
- p1RangedScaling = .8;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- System.out.print(p2Name);
- System.out.print(" Ranged weapon? (none, knife, spear, bow, pistol, shotgun, sniper, rocket)- ");
- p2Armor = input.next();
- switch (p2Armor.toLowerCase())
- {
- case "knife":
- p2RangedAttack = 85;
- p2RangedAccuracy = .15;
- p2RangedScaling = .15;
- break;
- case "spear":
- p2RangedAttack = 35;
- p2RangedAccuracy = .35;
- p2RangedScaling = .25;
- break;
- case "bow":
- p2RangedAttack = 85;
- p2RangedAccuracy = .45;
- p2RangedScaling = .55;
- break;
- case "pistol":
- p2RangedAttack = 70;
- p2RangedAccuracy = .75;
- p2RangedScaling = .45;
- break;
- case "shotgun":
- p2RangedAttack = 100;
- p2RangedAccuracy = .15;
- p2RangedScaling = .15;
- break;
- case "sniper":
- p2RangedAttack = 100;
- p2RangedAccuracy = .5;
- p2RangedScaling = 1;
- break;
- case "rocket":
- p2RangedAttack = 120;
- p2RangedAccuracy = .6;
- p2RangedScaling = .8;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- System.out.println("Distance seperating combatants (meters, under 1000 please)?- ");
- distanceSeperating = input.nextInt();
- while (distanceSeperating < 0 || distanceSeperating > 1000)
- {
- System.out.println("Invalid input.");
- distanceSeperating = input.nextInt();
- }
- CoreInputs();
- }
- public static void CoreInputs()
- {
- //NESSESCARY FOR MULTIROUND COMBAT!
- p1MaxHealth = p1Health;
- p2MaxHealth = p2Health;
- //P1 Armor
- System.out.print(p1Name);
- System.out.print(" Armor? (none, leather, chainmail, iron, diamond, enchanted)- ");
- p1Armor = input.next();
- switch (p1Armor.toLowerCase())
- {
- case "leather":
- p1Defense = p1Defense +7;
- break;
- case "chainmail":
- p1Defense = p1Defense +15;
- p1Speed = (float) (p1Speed * .975);
- break;
- case "iron":
- p1Defense = p1Defense +25;
- p1Speed = (float) (p1Speed * .7);
- break;
- case "diamond":
- p1Defense = p1Defense +30;
- p1Speed = (float) (p1Speed * .85);
- break;
- case "enchanted":
- p1Defense = p1Defense +35;
- p1Speed = (float) (p1Speed * .95);
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- //P2 Armor
- System.out.print(p2Name);
- System.out.print(" Armor? (none, leather, chainmail, iron, diamond, enchanted)- ");
- p2Armor = input.next();
- switch (p2Armor.toLowerCase())
- {
- case "leather":
- p2Defense = p2Defense +7;
- break;
- case "chainmail":
- p2Defense = p2Defense +15;
- p2Speed = (float) (p2Speed * .975);
- break;
- case "iron":
- p2Defense = p2Defense +25;
- p2Speed = (float) (p2Speed * .7);
- break;
- case "diamond":
- p2Defense = p2Defense +30;
- p2Speed = (float) (p2Speed * .85);
- break;
- case "enchanted":
- p2Defense = p2Defense +35;
- p2Speed = (float) (p2Speed * .95);
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- //P1 shield
- System.out.print(p1Name);
- System.out.print(" Shield? (none, wooden, square, kite)- ");
- p1Armor = input.next();
- switch (p1Armor.toLowerCase())
- {
- case "wooden":
- p1Defense = p1Defense +5;
- break;
- case "square":
- p1Defense = p1Defense +10;
- break;
- case "kite":
- p1Defense = p1Defense +15;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- //P2 shield
- System.out.print(p2Name);
- System.out.print(" Shield? (none, wooden, square, kite)- ");
- p2Armor = input.next();
- switch (p2Armor.toLowerCase())
- {
- case "wooden":
- p2Defense = p2Defense +5;
- break;
- case "square":
- p2Defense = p2Defense +10;
- break;
- case "kite":
- p2Defense = p2Defense +15;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- //Fixes Defense values so they can be used in dmg calc.
- p1Defense = Math.abs(p1Defense - 130);
- p2Defense = Math.abs(p2Defense - 130);
- p1Defense = (float) Math.sqrt(p1Defense);
- p2Defense = (float) Math.sqrt(p2Defense);
- //Mount inputs
- System.out.print(p1Name);
- System.out.print(" Mount? (none, pig, bull, horse, battlehorse, dragon)- ");
- p1Armor = input.next();
- switch (p1Armor.toLowerCase())
- {
- case "pig":
- p1Speed = (float) (p1Speed * 1.25);
- break;
- case "bull":
- p1Speed = (float) (p1Speed * 2.5);
- p1Attack = (float) (p1Attack + 5);
- p1Defense = (float) (p1Defense + 1);
- break;
- case "horse":
- p1Speed = (float) (p1Speed * 4);
- p1Defense = (float) (p1Defense + 3);
- break;
- case "battlehorse":
- p1Speed = (float) (p1Speed * 6);
- p1Attack = (float) (p1Attack + 7);
- p1Defense = (float) (p1Defense + 10);
- break;
- case "dragon":
- p1Speed = (float) (p1Speed * 8);
- p1Attack = (float) (p1Attack + 12);
- p1Defense = (float) (p1Defense + 10);
- p1Burner = true;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- System.out.print(p2Name);
- System.out.print(" Mount? (none, pig, bull, horse, battlehorse, dragon)- ");
- p2Armor = input.next();
- switch (p2Armor.toLowerCase())
- {
- case "pig":
- p2Speed = (float) (p2Speed * 1.25);
- break;
- case "bull":
- p2Speed = (float) (p2Speed * 2.5);
- p2Attack = (float) (p2Attack + 5);
- p2Defense = (float) (p2Defense + 1);
- break;
- case "horse":
- p2Speed = (float) (p2Speed * 4);
- p2Defense = (float) (p2Defense + 3);
- break;
- case "battlehorse":
- p2Speed = (float) (p2Speed * 6);
- p2Attack = (float) (p2Attack + 7);
- p2Defense = (float) (p2Defense + 10);
- break;
- case "dragon":
- p2Speed = (float) (p2Speed * 8);
- p2Attack = (float) (p2Attack + 12);
- p2Defense = (float) (p2Defense + 10);
- p2Burner = true;
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- //Weapon inputs
- System.out.print(p1Name);
- System.out.print(" Weapon? (none, dagger, sword, whip, lance, poisondagger, flamesword, battleaxe, staff)- ");
- p1Armor = input.next();
- switch (p1Armor.toLowerCase())
- {
- case "dagger":
- p1Speed = (float) (p1Speed + 10);
- p1Attack = (float) ((p1Attack * 1.1) +5);
- break;
- case "sword":
- p1Speed = (float) (p1Speed * .9);
- p1Attack = (float) ((p1Attack * 1.3) +7);
- break;
- case "flamesword":
- p1Speed = (float) (p1Speed * .9);
- p1Attack = (float) ((p1Attack * 1.3) +7);
- p1Burner = true;
- break;
- case "whip":
- p1Attack = (float) (p1Attack * 1.5);
- break;
- case "poisondagger":
- p1Speed = (float) (p1Speed + 10);
- p1Attack = (float) ((p1Attack * 1.1) +5);
- p1Poisoner = true;
- case "lance":
- p1Attack = (p1Attack + p1Speed - 100);
- break;
- case "battleaxe":
- p1Attack = (float) (p1Attack +17);
- p1RageIncrease = true;
- break;
- case "staff":
- p1Speed = (float) (p1Speed * 1.2);
- p1Attack = (float) ((p1Attack * 1.2) +3);
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- System.out.print(p2Name);
- System.out.print(" Weapon? (none, dagger, sword, whip, lance, poisondagger, flamesword, battleaxe, staff)- ");
- p2Armor = input.next();
- switch (p2Armor.toLowerCase())
- {
- case "dagger":
- p2Speed = (float) (p2Speed + 10);
- p2Attack = (float) ((p2Attack * 1.1) +5);
- break;
- case "sword":
- p2Speed = (float) (p2Speed * .9);
- p2Attack = (float) ((p2Attack * 1.3) +7);
- break;
- case "flamesword":
- p2Speed = (float) (p2Speed * .9);
- p2Attack = (float) ((p2Attack * 1.3) +7);
- p2Burner = true;
- break;
- case "poisondagger":
- p2Speed = (float) (p2Speed + 10);
- p2Attack = (float) ((p2Attack * 1.1) +5);
- p2Poisoner = true;
- break;
- case "whip":
- p2Attack = (float) (p2Attack * 1.5);
- break;
- case "lance":
- p2Attack = (p2Attack + p2Speed - 100);
- break;
- case "battleaxe":
- p2Attack = (float) (p2Attack +17);
- p2RageIncrease = true;
- break;
- case "staff":
- p2Speed = (float) (p2Speed * 1.2);
- p2Attack = (float) ((p2Attack * 1.2) +3);
- break;
- default:
- System.out.println("Interpreted as 'none'");
- break;
- }
- System.out.println("---BATTLE---");
- System.out.println("");
- System.out.println("");
- System.out.println("");
- }
- public static int RandInt(float a, float b)
- {
- Randint = (int) (a + (Math.random() * (b - a + 1)));
- return Randint;
- }
- public static void P1PostCombatEffects()
- {
- RandInt(1,30);
- if (isP1Confused)
- {
- RandInt(1,5);
- if (Randint >= 3)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer confused.");
- }
- isP1Confused = false;
- }
- }
- if (isP2Confused == false && p1Bludgeoner == false && Randint == 30)
- {
- isP2Confused = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now confused!");
- }
- }
- if (isP2Confused == false && p1Bludgeoner == true && Randint >= 29)
- {
- isP2Confused = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now confused!");
- }
- }
- if (isP1Stunned)
- {
- RandInt(1,3);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer Stunned.");
- }
- isP1Stunned = false;
- }
- }
- RandInt(1,30);
- if (isP2Stunned == false && p1Bludgeoner == false && Randint == 30)
- {
- isP2Stunned = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now Stunned!");
- }
- }
- if (isP2Stunned == false && p1Bludgeoner && Randint >= 29)
- {
- isP2Stunned = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now Stunned!");
- }
- }
- //Others
- if (p1Burner && damage != 0 && isP2Burning == false)
- {
- RandInt(1,6);
- if (Randint == 6)
- {
- isP2Burning = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" caught fire!");
- }
- }
- }
- if (isP2Burning)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" is on fire! ");
- }
- RandInt(200, 600);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p2Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- p2Health = (float) (p2Health - damage);
- if (p2Health > 0)
- System.out.print((int) p2Health);
- if (p2Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 5);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer burning.");
- }
- isP2Burning = false;
- }
- }
- if (p1Poisoner && damage != 0 && isP2Poisoned == false)
- {
- RandInt(1,7);
- if (Randint == 6)
- {
- isP2Poisoned = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" has been poisoned!");
- }
- }
- }
- if (isP2Poisoned)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" is poisoned! ");
- }
- RandInt(300, 600);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p2Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- }
- p2Health = (float) (p2Health - damage);
- if (!noOutput)
- {
- if (p2Health > 0)
- System.out.print((int) p2Health);
- if (p2Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 4);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer poisoned.");
- isP2Poisoned = false;
- }
- }
- }
- if (damage != 0 && isP2Bleeding == false)
- {
- RandInt(1,15);
- if (Randint == 1)
- {
- isP2Bleeding = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now bleeding!");
- }
- }
- }
- if (isP2Bleeding)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.print(" is bleeding! ");
- }
- RandInt(150, 280);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p2Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- }
- p2Health = (float) (p2Health - damage);
- if (!noOutput)
- {
- if (p1Health > 0)
- System.out.print((int) p2Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 5);
- if (Randint != 5)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer bleeding.");
- }
- isP2Bleeding = false;
- }
- }
- if (isP1Enraged == true)
- {
- RandInt(1,2);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer enraged.");
- }
- isP1Enraged = false;
- }
- }
- RandInt(1,45);
- if (isP2Enraged == false && p2RageIncrease == false && Randint == 45)
- {
- isP2Enraged = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now enraged!");
- }
- }
- if (isP2Enraged == false && p2RageIncrease && Randint >= 43)
- {
- isP2Enraged = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is now enraged!");
- }
- }
- if (isP2Jarated)
- {
- RandInt(1,5);
- if (Randint == 1 || Randint == 2)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" has recovered from jarate.");
- }
- isP2Jarated = false;
- }
- }
- if (isP2Jarated == false)
- {
- RandInt(1,35);
- if (Randint == 1)
- {
- isP2Jarated = true;
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" has been jarated!");
- }
- }
- }
- }
- public static void P2PostCombatEffects()
- {
- if (isP2Confused)
- {
- RandInt(1,5);
- if (Randint >= 3)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer confused.");
- }
- isP2Confused = false;
- }
- }
- RandInt(1,30);
- if (isP1Confused == false && p2Bludgeoner == false && Randint == 30)
- {
- isP1Confused = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now confused!");
- }
- }
- if (isP1Confused == false && p2Bludgeoner && Randint >= 29)
- {
- isP1Confused = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now confused!");
- }
- }
- RandInt(1,30);
- if (isP2Stunned)
- {
- RandInt(1,3);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer Stunned.");
- }
- isP2Stunned = false;
- }
- }
- if (!isP1Stunned && !p2Bludgeoner && Randint == 30)
- {
- isP1Stunned = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now Stunned!");
- }
- }
- if (!isP1Stunned && p2Bludgeoner && Randint >= 29)
- {
- isP1Stunned = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now Stunned!");
- }
- }
- if (p2Burner && damage != 0 && !isP1Burning)
- {
- RandInt(1,6);
- if (Randint == 6)
- {
- isP1Burning = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" caught fire!");
- }
- }
- }
- if (isP1Burning)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" is on fire! ");
- }
- RandInt(200, 600);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p1Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 5);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer burning.");
- }
- isP1Burning = false;
- }
- }
- if (p2Poisoner && damage != 0 && !isP1Poisoned)
- {
- RandInt(1,7);
- if (Randint == 5)
- {
- isP1Poisoned = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" has been poisoned!");
- }
- }
- }
- if (isP1Poisoned)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" is poisoned! ");
- }
- RandInt(300, 500);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p1Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 4);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer poisoned.");
- }
- isP1Poisoned = false;
- }
- }
- if (damage != 0 && isP1Bleeding == false)
- {
- RandInt(1,15);
- if (Randint == 1)
- {
- isP1Bleeding = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now bleeding!");
- }
- }
- }
- if (isP1Bleeding)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.print(" is bleeding! ");
- }
- RandInt(150, 280);
- damage = Randint;
- RandInt(1, 2);
- damage = (float) damage / (Randint * p1Defense);
- if (!noOutput)
- {
- System.out.print((int) damage);
- System.out.print(" damage taken as a result. ");
- }
- p1Health = (float) (p1Health - damage);
- if (!noOutput)
- {
- if (p1Health > 0)
- System.out.print((int) p1Health);
- if (p1Health <= 0)
- System.out.print("0");
- System.out.println(" health left.");
- }
- RandInt(1, 5);
- if (Randint != 5)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is no longer bleeding.");
- isP1Bleeding = false;
- }
- }
- }
- if (isP2Enraged)
- {
- RandInt(1,2);
- if (Randint == 1)
- {
- if (!noOutput)
- {
- System.out.print(p2Name);
- System.out.println(" is no longer enraged.");
- }
- isP2Enraged = false;
- }
- }
- RandInt(1,45);
- if (isP1Enraged == false && p1RageIncrease == false && Randint == 45)
- {
- isP1Enraged = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now enraged!");
- }
- }
- if (isP1Enraged == false && p1RageIncrease == true && Randint >= 43)
- {
- isP1Enraged = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" is now enraged!");
- }
- }
- if (isP1Jarated)
- {
- RandInt(1,5);
- if (Randint == 1 || Randint == 2)
- {
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" has recovered from jarate.");
- }
- isP1Jarated = false;
- }
- }
- if (!isP1Jarated)
- {
- RandInt(1,35);
- if (Randint == 1)
- {
- isP1Jarated = true;
- if (!noOutput)
- {
- System.out.print(p1Name);
- System.out.println(" has been jarated!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement