I'm currently making my first Text-Based RPG but I can't seem to find a way about making a Combat System, what I have so far:
System.Threading.Thread.Sleep(500); // Stops all code from running for 0.5 second
Console.WriteLine("What do you want to do?"); // Fight Screen
Console.WriteLine("Attack"); // Attacks enemy
Console.WriteLine("Bag"); // Opens your bag - able to use potions and spells (if added)
Console.WriteLine("Block"); // Will block all damage from the next attack but will take away your turn.
string fight = Console.ReadLine(); // If the user types something in the battle screen it will be converted to the "fight" variable used below
if (fight == "Attack") // Attack Code that uses the code above.
{
enemyHealth[0] = enemyHealth[0] - AtkDmg; // Takes the attack damage from the rat's health giving the rat's health a new value.
Console.WriteLine("You lunge your sword at the Giant Rat"); // Attack Message
Console.WriteLine("Giant Rat's Health: " + enemyHealth[0] + " / 10");
charHealth = charHealth - enemyAtkDmg[0];
Console.WriteLine("The Giant Rat charges at you, headbutting you, knocking you back.");
Console.WriteLine("Your Health: " + charHealth + " / 20");
}
if (enemyHealth[0] == 0)
{
System.Threading.Thread.Sleep(1500);
Console.WriteLine("You have killed the Giant Rat");
Console.WriteLine("The Giant Rat Dropped 10 Gold");
Console.WriteLine("*You pick up the gold and put it in your purse");
}
do{
gold++;
} while (gold != 10);
Console.Write("You now have " + gold + " Gold Pieces.");
Back OT:
My current code isn't working how I'd really like it to, I'd like the damage to be randomised from the character's attack damage +1 or -1 so if the Attack Damage of the player is 4 he can do 3,4, or 5 damage (5 being a critical hit).
I would also like to know if anyone knows of a better way to randomise the money gained from killing a monster from 1-10 or something instead of having it set to 10 every time.
If you need any other resources that I may have, please just leave a comment and I will get you anything you need if it may help you find some answers.
If you find a way to improve my code or make it more tidy, please leave a comment as well.