/****************************** * Horizon: Lands of Kestrel * * Started July 2 / 2002 * * Complete July 17 / 2002 * * Programmed by Carlo * ******************************/ //--------------------------------------------------------------------------= #include #include #include "horizon.h" #include #include //--------------------------------------------------------------------------= // FUNCTION DECLARATION //--------------------------------------------------------------------------= void Makecharacter(string &Name, string &OName, int &Power, int &Level, long &XP, long &NextLvl, int &HP, int &TotalHP, int &Strength, int &Dexterity, int &Intelligence, int &Wilderness, int &Barter, long &Attack, long &Defense, long &Gold, string &Weapon, string &Shield, string &Armor, string &One, string &Two, string &Three, string &Four, string &Five, int &Rations, int &Day, string &Dead, int &WeaponAR, int &ShieldDR, int &ArmorDR, string &Shielduse); void Options(int &Color, string &CustomName, int &Custom, int &Autosave); void Inventory(string &Name, int &Power, int &Level, long &XP, long &NextLvl, int &HP, int &TotalHP, int &Strength, int &Dexterity, int &Intelligence, int &Wilderness, int &Barter, long &Attack, long &Defense, long &Gold, string &Weapon, string &Shield, string &Armor, string &One, string &Two, string &Three, string &Four, string &Five, int &Rations, int &Day, int &WeaponAR, int &ShieldDR, int &ArmorDR, string &CustomName, int &Custom); void Town(string Name, int &Rations, int Barter, long &Gold, string &Weapon, string &Shield, string &Armor, int &WeaponAR, int &ShieldDR, int &ArmorDR, long &Defense, long &Attack, string &Two, string &Three, string &Four, string &Five, string &Shielduse, int &Day, long &XP, int &Strength, int &Dexterity, int &Intelligence); //**************************************************************************= int main() { Start(); //VARIABLES START-----------------------------------------------------------= string Menu1, Name = "None", OName = "None", Weapon, Shield, Armor, One, Two, Three, Four, Five, LTerrain = "Town", Action, Dead = "NO", Flee = "YES", Run = "NO", Check, Win = "NO", TryEncounter = "NO", MDead = "NO", Shielduse, CustomName = "None", Output, MerchantName, Merchant, MBuy, Found, Catalog, Tag = "NO", Wither = "NO"; int Color = 1, Level, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Rations, Power, Day = 1, RecoverHP, WeaponAR = 10, ShieldDR = 5, ArmorDR = 10, Daysout, Fleechance, Custom, Autosave = 10, MerchantNumber, FoundType, FoundGold, MFChance, Battlecounter, Noencounter = 0, Lose = 0, Wins = 0; long XP, NextLvl, Attack, Defense, Gold; //Space Filler (bring size up to 675kb) string Space1, Space2, Space3, Space4, Space5, Space6, Space7, Space8, Space9, Space10; //VARIABLES END-------------------------------------------------------------= //Create Directory----------------------------------------------------------= CreateDirectory("Horizon", NULL); CreateDirectory("Horizon\\Character", NULL); CreateDirectory("Horizon\\Custom", NULL); CreateDirectory("Horizon\\Logs", NULL); CreateDirectory("Horizon\\Output", NULL); CreateDirectory("Horizon\\Readme", NULL); CreateDirectory("Horizon\\Data", NULL); //Load File-----------------------------------------------------------------= ifstream Outcsv("Horizon\\Character\\Character.hcs", ios::nocreate); Outcsv>> OName; Outcsv.close(); Output = "Character.hcs Loaded"; Logfile(Output); ifstream Outcfg("Horizon\\Data\\Horizon.cfg", ios::nocreate); Outcfg>> Color; Outcfg>> Autosave; Outcfg.close(); Output = "Horizon.cfg Loaded"; Logfile(Output); Text(Color); //--------------------------------------------------------------------------= do{ Mainmenu: Output = "Main Menu Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Main Menu\n\n"; // Main menu cout<< "1. Enter Realm\n"; cout<< "2. Character\n"; cout<< "3. Options\n"; cout<< "4. Catalog\n"; cout<< "5. Readme\n"; cout<< "6. Exit\n"; cout<< "Selection: "; cin>> Menu1; while ((Menu1 != "1") && (Menu1 != "2") && (Menu1 != "3") && (Menu1 != "4") && (Menu1 != "5") && (Menu1 != "6")) { cout<< "\aSelection: "; cin>> Menu1; } // Error trap clrscr(); gotoxy(1,2); if (Menu1 == "2") Makecharacter(Name, OName, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, Dead, WeaponAR, ShieldDR, ArmorDR, Shielduse); else if (Menu1 == "3") Options(Color, CustomName, Custom, Autosave); else if (Menu1 == "4") { do{ Output = "Catalog Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Catalog Menu\n\n"; cout<< "1. Beastiary\n"; cout<< "2. Magic List\n"; cout<< "3. Return to Main Menu\n"; cout<< "Selection: "; cin>> Catalog; while ((Catalog != "1") && (Catalog != "2") && (Catalog != "3")) { cout<< "\aSelection: "; cin>> Catalog; } // Error trap clrscr(); gotoxy(1,2); if (Catalog == "1") Beastiary(); else if (Catalog == "2") Magiclist(); }while (Catalog != "3"); } // Catalog else if (Menu1 == "5") Readme(); }while ((Menu1 != "1") && (Menu1 != "6")); // Continue to run menu if (Menu1 == "6") Leave(); if ((Menu1 == "1") && (Name == "None")) { cout<< "No character is created.\n"; Pause(); goto Mainmenu; } // Make sure character is created if ((Menu1 == "1") && (Dead == "YES")) { cout<< "Character has died, reload or create a new one.\n"; Pause(); goto Mainmenu; } // See if character is dead //--------------------------------------------------------------------------= // MAIN GAME CODE //--------------------------------------------------------------------------= Output = (Name + " Enter Realm"); Logfile(Output); do{ AfterlevelA: LTerrain = "Town"; Wither = "NO"; clrscr(); gotoxy(1,2); if (Autosave != 0) { if ((Day%Autosave) == 0) { ASave(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); clrscr(); gotoxy(1,2); } // Autosave } if (((Armor == "Famine") || (Armor == "Isura")) && (Rations != 50)) Rations = 50; cout<< "The Lands of Kestrel\n\n"; if ((NextLvl - XP) >= 0) cout<< Name << " [" << (NextLvl - XP) << "XP to Level " << (Level + 1) << "]\n"; else cout<< Name <= NextLvl) { cout<< "Day " << Day << ": " << Name << " gains a Level!\n"; Pause(); Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); goto AfterlevelA; } // Levelup cout<< "Day " << Day << ": What do you wish to do " << Name << "? "; cin>> Action; if ((Action == "Quit") || (Action == "QUIT") || (Action == "quit")) { Save(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); Leave(); } // Quit if (((Action == "Sleep") || (Action == "SLEEP") || (Action == "sleep")) && (Rations <= 1)) { Output = "Sleep"; Logfile(Output); cout<< "You won't have enough food to survive the day.\n"; if (Gold >= 1) cout<< "Perhaps you should enter Town and purchase more Rations.\n"; if (Gold < 1) { cout<< "Instead of starving, a kind townsperson offers you a meal.\n"; RecoverHP = (10+random(20) + (Level*2)); if (Armor == "Curephase-a") RecoverHP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; cout<< "You sleep, recovering " << RecoverHP << " HP\n"; HP = (HP + RecoverHP); if (HP > TotalHP) HP = TotalHP; ofstream LogSleepRecover("Log.txt", ios::app); LogSleepRecover<< "Recovers " << RecoverHP << "hp (Sleep)\n"; LogSleepRecover.close(); } Pause(); } else if ((Action == "Sleep") || (Action == "SLEEP") || (Action == "sleep")) { RecoverHP = ((10+random(20)) + (Level*2)); if (Armor == "Curephase-a") RecoverHP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; cout<< "You sleep, recovering " << RecoverHP << " HP\n"; Pause(); HP = (HP + RecoverHP); if (HP > TotalHP) HP = TotalHP; ofstream LogSleepRecoverAgain("Log.txt", ios::app); LogSleepRecoverAgain<< "Recovers " << RecoverHP << "hp (Sleep)\n"; LogSleepRecoverAgain.close(); } // Sleep else if ((Action == "dir") || (Action == "DIR") || (Action == "Dir")) { cout<< "What do you think this is? DOS?\n"; Pause(); } // If they put in DIR else if ((Action == "Travel") || (Action == "TRAVEL") || (Action == "travel")) { cout<< "You must first choose to Adventure before you Travel.\n"; Pause(); } // Try travelling else if ((Action == "Help") || (Action == "HELP") || (Action == "help") || (Action == "?")) { Output = "Help Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Realm Help\n\n"; cout<< "Help - Opens this screen\n"; cout<< "Quit - Quits the game (saves " << Name << " on exit)\n"; cout<< "Sleep - Sleep for 1 Day, recovering Hitpoints\n"; cout<< "Inventory - Opens " << Name << "'s Inventory\n"; cout<< "Enter - Enters a Town (only if Terrain is Town)\n"; cout<< "Adventure - Leave Town and Adventure for set Days\n"; Set(); } // Help if ((Rations <= 0) && (Gold <= 0)) { Output = (Name + " Dies (Starvation)"); Logfile(Output); HP = 0; cout<< "You run out of food, starving to death.\n"; Pause(); Dead = "YES"; } // Die of starvation if (HP <= 0) { Output = (Name + " Dies"); Logfile(Output); cout<< "You are killed.\n"; Pause(); Dead = "YES"; goto Mainmenu; } // Die of HP loss if (Rations <= 0) Rations = 0; if (Day >= 9200) { Output = (Name + " Retires"); Logfile(Output); int Dieage = 80+random(10); cout<< "After years of adventuring, " << Name << " finally retires.\n"; cout<< "You live out the rest of your life happily in Misthaven, finally\n"; cout<< "passing away at the age of " << Dieage << ". You were missed.\n"; ofstream RetireFile("Horizon\\Output\\Retire.doc", ios::app); RetireFile<< Name << " (Age: " << Dieage << ") (Power: " << Power << ")\n"; RetireFile<< "Level " << Level << " [RETIRED]\n"; RetireFile<< "XP: " << XP << " Required: " << NextLvl <> Daysout; if (Rations <= 5) { cout<< "You do not have enough Rations to complete a journey that long.\n"; if (Gold <= 0) { if ((6-Rations) > 1) cout<< "Always supportive, the Town has donated " << (6-Rations) << " Rations to you.\n"; if ((6-Rations) == 1) cout<< "Always supportive, the Town has donated " << (6-Rations) << " Ration to you.\n"; Rations = ((6-Rations) + Rations); } else if (Gold > 0) cout<< "Perhaps you should enter the Town and buy some more Rations.\n"; Set(); goto AfterlevelA; } // Out of rations while ((Daysout < 5) || (Daysout > Rations)) { if (Daysout < 5) cout<< "Must adventure for at least 5 Days: "; if (Daysout > Rations) cout<< "Not enough food to adventure that long: "; cin>> Daysout; } // Error trap ofstream LogAdventuresFor("Log.txt", ios::app); LogAdventuresFor<< "Adventures for " << Daysout << " Day(s)\n"; LogAdventuresFor.close(); int Goalday = (Day + Daysout); cout<< "Will return on Day " << Goalday << " to Misthaven.\n"; ofstream LogReturnon("Log.txt", ios::app); LogReturnon<< "Return on Day " << Goalday << "\n"; LogReturnon.close(); Pause(); //--------------------------------------------------------------------------= do{ AfterlevelB: clrscr(); gotoxy(1,2); int Encounterchance = 1+random(99); TryEncounter = "NO"; if (LTerrain == "Town") { Output = "Leave Town"; Logfile(Output); Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; LTerrain = "Forest"; } if (Day >= Goalday) LTerrain = "Town"; if (Autosave != 0) { if ((Day%Autosave) == 0) { ASave(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); clrscr(); gotoxy(1,2); } // Autosave } Output = ("Enters " + LTerrain); Logfile(Output); if (((Armor == "Famine") || (Armor == "Isura")) && (Rations != 50)) Rations = 50; cout<< "The Lands of Kestrel (Adventuring)\n\n"; if ((NextLvl - XP) >= 0) cout<< Name << " [" << (NextLvl - XP) << "XP to Level " << (Level + 1) << "]\n"; else cout<< Name <= NextLvl) { cout<< "Day " << Day << ": " << Name << " gains a Level!\n"; Pause(); Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); goto AfterlevelB; } // Levelup cout<< "Day " << Day << ": What do you wish to do " << Name << "? "; cin>> Action; if ((Action == "Quit") || (Action == "QUIT") || (Action == "quit")) { Save(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); Leave(); } // Quit else if ((Action == "dir") || (Action == "DIR") || (Action == "Dir")) { cout<< "What do you think this is? DOS?\n"; Pause(); } // If they put in DIR else if ((Action == "Sleep") || (Action == "SLEEP") || (Action == "sleep")) { Output = "Sleep"; Logfile(Output); Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; TryEncounter = "YES"; } // Sleep else if ((Action == "Travel") || (Action == "TRAVEL") || (Action == "travel")) { ofstream LogTravel("Log.txt", ios::app); LogTravel<< "Travel (Day " << Day << ")\n"; LogTravel.close(); TryEncounter = "YES"; } // Travel else if ((Action == "Help") || (Action == "HELP") || (Action == "help") || (Action == "?")) { Output = "Help (Adventuring) Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Realm Help (Adventuring)\n\n"; cout<< "Help - Opens this screen\n"; cout<< "Quit - Exits the game (saves " << Name << " on exit)\n"; cout<< "Sleep - Sleep for 1 Day, recovering Hitpoints\n"; cout<< "Inventory - Opens " << Name << "'s Inventory\n"; cout<< "Travel - Journey for 1 Day\n"; Set(); } // Help if (Rations <= 0) { Output = (Name + " Dies (Starvation)"); Logfile(Output); HP = 0; cout<< "You run out of food, starving to death.\n"; Pause(); Dead = "YES"; } // Die of starvation if (HP <= 0) { Output = (Name + " Dies"); Logfile(Output); cout<< "You are killed.\n"; Pause(); Dead = "YES"; goto Mainmenu; } // Die of HP loss if (Action == "Day1") { Output = "Day1 Code Accessed"; Logfile(Output); Day = 1; } if (Action == "XP500") { Output = "XP500 Code Accessed"; Logfile(Output); XP = (XP+500); } if (Action == "Magicfind") { Output = "Magicfind Code Accessed"; Logfile(Output); Tag = "YES"; } else if ((Action == "Inventory") || (Action == "INVENTORY") || (Action == "inventory") || (Action == "I") || (Action == "i")) Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); if (TryEncounter == "YES") { int Target; Target = 80; if (((Action == "SLEEP") || (Action == "Sleep") || (Action == "sleep")) && (HP <= (HP/2))) Target = 40; if (((Action == "SLEEP") || (Action == "Sleep") || (Action == "sleep")) && (HP <= 3)) Target = 5; if (((Action == "SLEEP") || (Action == "Sleep") || (Action == "sleep")) && (HP == 1)) Target = 1; if (((Shield == "Restfull") || (Shield == "Yu-lang")) && ((Action == "SLEEP") || (Action == "Sleep") || (Action == "sleep"))) Target = 0; if (Noencounter >= 2) Target = 95; if (Day == 10) Target = 100; if (Encounterchance <= Target) { Noencounter = 0; int Encountersort = 1+random(99); if (Encountersort <= 5) { MerchantNumber = 1+random(10); if (MerchantNumber == 1) MerchantName = "Golag"; else if (MerchantNumber == 2) MerchantName = "Oupun"; else if (MerchantNumber == 3) MerchantName = "Delris"; else if (MerchantNumber == 4) MerchantName = "Kasez"; else if (MerchantNumber == 5) MerchantName = "Alhendra"; else if (MerchantNumber == 6) MerchantName = "Lyni"; else if (MerchantNumber == 7) MerchantName = "Yeruit"; else if (MerchantNumber == 8) MerchantName = "Naewel"; else if (MerchantNumber == 9) MerchantName = "Siune"; else if (MerchantNumber == 10) MerchantName = "Cheib"; if (MerchantName == Name) MerchantName = "Celes"; ofstream LogEncounterMerchant("Log.txt", ios::app); LogEncounterMerchant<< "Encounters Merchant (" << MerchantName << ")\n"; LogEncounterMerchant.close(); clrscr(); gotoxy(1,2); cout<< "Day " << Day << ": " << Name << " encounters a Merchant across a " << LTerrain << ".\n\n"; cout<< "Merchant: \"Greetings! I am " << MerchantName << ", a travelling dealer of exotic\n"; cout<< "goods. Perhaps you would like to look at my wares?\"\n"; cout<< "Trade with " << MerchantName << "? "; cin>> Check; Checktrap(Check); clrscr(); gotoxy(1,2); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = "Trade (Merchant)"; Logfile(Output); do{ int Discount = (Barter/5); if (Discount > 10) Discount = 10; if (Shield == "Syrian") Discount = (Discount + 10); if (Shield == "Yu-lang") Discount = (Discount + 15); clrscr(); gotoxy(1,2); cout<< "Merchant " << MerchantName << "\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. Equipment\n"; cout<< "2. Gamble\n"; cout<< "3. Leave " << MerchantName << "\n"; cout<< "Selection: "; cin>> Merchant; while ((Merchant != "1") && (Merchant != "2") && (Merchant != "3")) { cout<< "\aSelection: "; cin>> Merchant; } // Error trap clrscr(); gotoxy(1,2); if (Merchant == "1") { int MHealingGP, MQuickbladeGP, MPlateGP, MLargeGP; MHealingGP = (45 - Discount); MQuickbladeGP = (100 - Discount); MPlateGP = (75 - Discount); MLargeGP = (60 - Discount); if (MHealingGP <= 0) MHealingGP = 1; if (MQuickbladeGP <= 0) MQuickbladeGP = 1; if (MPlateGP <= 0) MPlateGP = 1; if (MLargeGP <= 0) MLargeGP = 1; do{ clrscr(); gotoxy(1,2); cout<< "Merchant " << MerchantName << " (Equipment)\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. 2gp / Ration / Eat one every Day\n"; cout<< "2. " << MHealingGP << "gp / Healing Potion / Restore all HP\n"; cout<< "3. " << MQuickbladeGP << "gp / Quickblade / +25AR, +5 Dexterity\n"; cout<< "4. " << MPlateGP << "gp / Plate Mail / +75DR\n"; cout<< "5. " << MLargeGP << "gp / Large Shield / +30DR\n"; cout<< "6. Equipment Information\n"; cout<< "7. Return to Merchant Menu\n"; cout<< "Selection: "; cin>> MBuy; while ((MBuy != "1") && (MBuy != "2") && (MBuy != "3") && (MBuy != "4") && (MBuy != "5") && (MBuy != "6") && (MBuy != "7")) { cout<< "\aSelection: "; cin>> MBuy; } // Error trap if ((MBuy == "1") && (Gold >= 2)) { Rations++; if (Rations > 50) { Rations--; cout<< "Cannot carry any more rations."; } else if (Rations <= 50) { Gold = (Gold-2); cout<< "Purchased Ration."; } Pause(); } // Ration else if ((MBuy == "2") && (Gold >= 45)) { string Temp = "NO"; if (Two == "Empty") { Two = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three == "Empty") && (Temp == "NO")) { Three = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three != "Empty") && (Four == "Empty") && (Temp == "NO")) { Four = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three != "Empty") && (Four != "Empty") && (Five == "Empty") && (Temp == "NO")) { Five = "Healing"; Temp = "YES"; } if (Temp == "YES") { Gold = (Gold-MHealingGP); cout<< "Purchased Healing Potion."; Pause(); } } // Healing Potion else if ((MBuy == "3") && (Gold >= 100)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-MQuickbladeGP); Weapon = "Quickblade"; WeaponAR = 25; Shielduse = "YES"; Dexterity = (Dexterity + 5); cout<< "Purchased Quickblade."; Pause(); } // Quickblade else if ((MBuy == "4") && (Gold >= 75)) { Defense = (Defense - ArmorDR); Gold = (Gold-MPlateGP); Armor = "Plate"; ArmorDR = 75; cout<< "Purchased Plate Mail."; Pause(); } // Plate Mail else if ((MBuy == "5") && (Gold >= 60) && (Shielduse == "YES")) { Defense = (Defense - ShieldDR); Gold = (Gold-MLargeGP); Shield = "Large"; ShieldDR = 30; cout<< "Purchased Large Shield."; Pause(); } // Large Shield else if (MBuy == "6") { Output = "Equipment Information Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Equipment Information\n\n"; cout<< "Quickblade--: A small curved dagger with a razor sharp edge.\n"; cout<< " The shape and weight allow the weapon to be used\n"; cout<< " for very rapid stries, granting a +5 Dexterity\n"; cout<< " bonus.\n"; cout<< "Plate Mail--: With a thick breast plate backed up by strong links\n"; cout<< " of mail, a suit of Plate Mail provides excellent\n"; cout<< " protection, while still allowing freedom of movement.\n"; cout<< "Large Shield: This heavy shield can withstand great blows. With a\n"; cout<< " thin sheet of metal between layers of hardened oak,\n"; cout<< " a Large Shield has some weight to it, but its shape\n"; cout<< " has been kept streamlined to avoid the problems a\n"; cout<< " Tower Shield faces.\n"; Set(); } // Equipment Information }while (MBuy != "7"); } // Equipment else if (Merchant == "2") { clrscr(); gotoxy(1,2); cout<< "Merchant " << MerchantName << " (Gamble)\n"; cout<< "Gold: " << Gold << "gp\n\n"; if (Gold < 50) // Not enough gold { cout<< "Gambling costs 50gp, and you do not have that much.\n"; Pause(); } if (Gold >= 50) { cout<< "Gambling costs 50gp, are you sure? "; cin>> Check; Checktrap(Check); } // Only if 50+gp if (((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) && (Gold >= 50)) { Gold = (Gold - 50); FoundType = 1+random(99); clrscr(); gotoxy(1,2); cout<< "Merchant " << MerchantName << " (Gamble)\n"; cout<< "Gold: " << Gold << "gp\n\n"; if (FoundType > 65) { Found = "Nothing"; } // Nothing cout<< "Gambling..."; Check = "Pause"; Pause(); if (FoundType <= 10) { MFChance = 100; Magicitem(MFChance, WeaponAR, ShieldDR, ArmorDR, Weapon, Shield, Armor, Shielduse, Attack, Defense, Dexterity, Level, Check, Wither); if ((Check != "No") && (Check != "NO") && (Check != "no") && (Check != "N") && (Check != "n")) Pause(); Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); } // Magic else if ((FoundType > 10) && (FoundType <= 65)) { FoundGold = 1+random(100); int GoldKind = 1+random(10); if (GoldKind <= 5) { cout<< FoundGold << "gp!\n\n"; Gold = (Gold + FoundGold); } // Gain Gold else if (GoldKind > 5) { cout<< "-" << FoundGold << "gp.\n\n"; Gold = (Gold - FoundGold); } // Lose Gold if (Gold <= 0) Gold = 0; } // Gold else cout<< Found << ".\n\n"; if (Check == "Pause"); Set(); } // Yes } // Gamble }while (Merchant != "3"); // Continue to run menu cout<< "Merchant: \"Very good to do business with you. Come again!\"\n"; Set(); Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Terrain(LTerrain); goto End; } // Yes trade else { cout<< "Merchant: \"Very well, but you must know it is your loss. I\n"; cout<< " cannot believe you can resist my most excellent\n"; cout<< " equipment. But, perhaps you are saving your gold.\n"; cout<< " By any measure, good luck on your travels.\"\n"; Set(); Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Terrain(LTerrain); goto End; } // No trade } // Merchant else MDead = "NO"; if ((Action == "Sleep") || (Action == "SLEEP") || (Action == "sleep")) { Output = "Sleep Interrupted"; Logfile(Output); cout<< "You are awoken by the sounds of something approaching. You have\n"; cout<< "no time to hide or avoid the trespasser. Warily, you draw your\n"; cout<< Weapon << " and prepare for combat.\n"; Pause(); Day--; Rations++; Output = "Encounter (Sleep)"; Logfile(Output); } // Encounter by sleep else if ((Action == "Travel") || (Action == "TRAVEL") || (Action == "travel")) { Output = "Encounter (Travel)"; Logfile(Output); cout<< "You are travelling when you see something approaching you. Perhaps\n"; cout<< "you can avoid it, or you will have to fight.\n"; Pause(); } // Encounter by travel int Monstertype, MonsterPower = 20, MonsterAttack = 10, MonsterDefense = 10, MonsterHP = 10, MonsterXP = 10, MonsterGold = 1+random(5), Factor, HPLoss, MFChance = 1; string MonsterName = "Goblin", MonsterChallenge = "Very Easy", Choice; Win = "NO"; Run = "NO"; Flee = "YES"; ChooseMonster(Monstertype, MonsterName, MonsterChallenge, MonsterPower, MonsterAttack, MonsterDefense, MonsterHP, MonsterXP, MonsterGold, MFChance, Level, Power); int TotalMonsterHP = MonsterHP; ofstream LogEncountersWhat("Log.txt", ios::app); LogEncountersWhat<< "Encounters a " << MonsterName << " (Day " << Day << ")\n"; LogEncountersWhat.close(); //--------------------------------------------------------------------------= int Notice = 1+random(99); if (Armor == "Cravenplate") Notice = 0; if (Notice <= Wilderness) { Output = "Notice Monster"; Logfile(Output); cout<< "You notice a " << MonsterName << " ahead. Do you want to fight it? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = "Notice and Attack Monster"; Logfile(Output); goto Combatstart; } else { Output = "Notice and Flee Monster"; Logfile(Output); Run = "YES"; } } while ((Run == "NO") && (Dead == "NO") && (Win == "NO")) { Combatstart: clrscr(); gotoxy(1,2); cout<< "Day " << Day << ": " << Name << " encounters a " << MonsterName << " across a " << LTerrain << ".\n\n"; cout<< Name << " (Power: " << Power << ")\n"; cout<< "Level: " << Level <> Choice; while ((Choice != "1") && (Choice != "2") && (Choice != "3") && (Choice != "4") && (Choice != "Killall")) { cout<< "\aSelection: "; cin>> Choice; } if (Choice == "Killall") { Output = "Killall Code Accessed"; Logfile(Output); MDead = "YES"; Win = "YES"; clrscr(); gotoxy(1,2); } // Kill enemy if (Choice == "4") { Save(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); Leave(); } // Quit if ((Choice == "1") && (MDead == "NO")) { Output = ("Attacks " + MonsterName); Logfile(Output); Factor = (Power / MonsterPower); if (Factor >= 5) Factor = 5; Battlecounter = 0; do{ clrscr(); gotoxy(1,2); Battlecounter++; cout<< Name << " battling a " << MonsterName << " over a " << LTerrain << ".\n\n"; cout<< Name << " HP: " << HP << " / " << TotalHP < TotalHP) HP = TotalHP; Pause(); } // Curephase set else if (Weapon == "Curephase-w") { HPRecovery = 10; cout<< Name << " regenerates " << HPRecovery << " HP (Curephase-w).\n"; HP = (HP + HPRecovery); if (HP > TotalHP) HP = TotalHP; Pause(); } // Curephase-w if (Armor == "Trollplate") { HPRecovery = 10+random(4); cout<< Name << " regenerates " << HPRecovery << " HP (Trollplate).\n"; HP = (HP + HPRecovery); if (HP > TotalHP) HP = TotalHP; Pause(); } // Trollplate if (Armor == "Isura") { HPRecovery = 5+random(3); cout<< Name << " regenerates " << HPRecovery << " HP (Isura).\n"; HP = (HP + HPRecovery); if (HP > TotalHP) HP = TotalHP; Pause(); } // Isura regenerate if (Shield == "Woundcover") { HPRecovery = 1+random(2); cout<< Name << " regenerates " << HPRecovery << " HP (Woundcover).\n"; HP = (HP + HPRecovery); if (HP > TotalHP) HP = TotalHP; Pause(); } // Woundcover if (Shield == "Yu-lang") { HPRecovery = 5+random(2); cout<< Name << " regenerates " << HPRecovery << " HP (Yu-lang).\n"; HP = (HP + HPRecovery); if (HP > TotalHP) HP = TotalHP; Pause(); } // Yu-lang regenerates int MonsterReg; if (MonsterName == "Sand Howler") { MonsterReg = 5+random(5); cout<< "Sand Howler regenerates " << MonsterReg << " HP.\n"; MonsterHP = (MonsterHP + MonsterReg); if (MonsterHP >= TotalMonsterHP) MonsterHP = TotalMonsterHP; Pause(); } // Sand Howler if (MonsterName == "Troll") { MonsterReg = 20+random(5); cout<< "Troll regenerates " << MonsterReg << " HP.\n"; MonsterHP = (MonsterHP + MonsterReg); Pause(); } // Troll if (MonsterName == "Trolog") { MonsterReg = 5; cout<< "Trolog regenerates " << MonsterReg << " HP.\n"; MonsterHP = (MonsterHP + MonsterReg); Pause(); } // Trolog if (MonsterName == "Sinoko") { MonsterReg = 10+random(2); cout<< "Sinoko regenerates " << MonsterReg << " HP.\n"; MonsterHP = (MonsterHP + MonsterReg); Pause(); } // Sinoko if (Armor == "Swordguide") Attack = (Attack + 50); if (Shield == "Sentinent") Attack = (Attack + 25); // Calculate damage to monster HPLoss = (Attack - MonsterDefense); HPLoss = (HPLoss / Factor); HPLoss = (HPLoss + (1+random(4))); if (HPLoss >= (Power/2)) HPLoss = (Power/2); if (HPLoss <= 0) HPLoss = 1+random(4); if (Weapon == "Razoredge") HPLoss = (HPLoss + (2+random(5))); if (Weapon == "Lehoma") HPLoss = (HPLoss + 10+random(5)); if (HPLoss > TotalMonsterHP) HPLoss = (TotalMonsterHP - (2+random(2))); if (MonsterName == "Dragon") { HPLoss = (HPLoss - (10+random(25))); if (HPLoss <= 0) HPLoss = 1; } // Dragon damage reduce if ((Battlecounter >= 5) && (Battlecounter < 10) && (MonsterName != "Dragon")) HPLoss = (HPLoss + (1+random(5))); if ((Battlecounter >= 10) && (Battlecounter < 15) && (MonsterName != "Dragon")) HPLoss = (HPLoss + (5+random(5))); if ((Battlecounter >= 15) && (Battlecounter < 20) && (MonsterName != "Dragon")) HPLoss = (HPLoss + (10+random(5))); if ((Battlecounter >= 20) && (Battlecounter < 25) && (MonsterName != "Dragon")) HPLoss = (HPLoss + (15+random(5))); if ((Battlecounter >= 25) && (MonsterName != "Dragon")) HPLoss = (HPLoss + (25+random(10))); if (Lose >= 2) HPLoss = (HPLoss + (20+random(20))); MonsterHP = (MonsterHP - HPLoss); cout<< Name << " attacks " << MonsterName << ": " << HPLoss << " damage.\n"; Pause(); if ((MonsterName == "Skeleton") && (Weapon != "Darkslayer") && (Weapon != "Mace")) { int Damageremove = 15+random(5); cout<< Weapon << " barely has any effect! Damage reduced by " << Damageremove << ".\n"; MonsterHP = (MonsterHP + Damageremove); if (MonsterHP >= TotalMonsterHP) MonsterHP = TotalMonsterHP; Pause(); } // Skeleton Damage reduce if (Armor == "Swordguide") Attack = (Attack - 50); if (Shield == "Sentinent") Attack = (Attack - 25); if (((Weapon != "Witherblade") && (Weapon != "Truestrike") && (Weapon != "Darkslayer") && (Weapon != "Risingsun") && (Weapon != "Curephase-w") && (Weapon != "Vampirous") && (Weapon != "Frostweaver") && (Weapon != "Destructor") && (Weapon != "Razoredge") && (Weapon != "Lehoma")) && ((MonsterName == "Vampire") || (MonsterName == "Ghost") || (MonsterName == "Slayer") || (MonsterName == "Dragon"))) { cout<< Weapon << " was ineffective!\n"; MonsterHP = (MonsterHP + HPLoss); Pause(); } // Weapon useless if (((Weapon == "Bow") || (Weapon == "Crossbow")) && ((MonsterName == "Barbarian") || (MonsterName == "Cobra") || (MonsterName == "Mummy"))) { int Bonusdamage = 5+random(5); cout<< Weapon << " struck " << MonsterName << ": " << Bonusdamage << " bonus damage.\n"; MonsterHP = (MonsterHP - Bonusdamage); Pause(); } if (((Weapon == "Bow") || (Weapon == "Crossbow")) && (MonsterName == "Lizardman")) { cout<< Weapon << " struck " << MonsterName << ": " << HPLoss << " reflected.\n"; MonsterHP = (MonsterHP + HPLoss); if (MonsterHP > TotalMonsterHP) MonsterHP = TotalMonsterHP; Pause(); } // Lizardman long range damage reduce if (Weapon == "Witherblade") { cout<< Weapon << " struck " << MonsterName << ": 5 withering damage.\n"; MonsterHP = (MonsterHP - 5); Pause(); } // Witherblade if (((Weapon == "Darkslayer") || (Weapon == "Mace")) && ((MonsterName == "Animated Armor") || (MonsterName == "Death Knight") || (MonsterName == "Ghost") || (MonsterName == "Ghoul") || (MonsterName == "Mummy") || (MonsterName == "Shadow") || (MonsterName == "Skeleton") || (MonsterName == "Vampire") || (MonsterName == "Wight") || (MonsterName == "Wraith") || (MonsterName == "Zombie"))) { cout<< Weapon << " struck an Undead creature: " << HPLoss << " damage.\n"; MonsterHP = (MonsterHP - HPLoss); Pause(); } // Darkslayer or Mace int Firedamage; if (Weapon == "Risingsun") { Firedamage = 5+random(5); cout<< Weapon << " struck " << MonsterName << ": " << Firedamage << " fire damage.\n"; MonsterHP = (MonsterHP - Firedamage); if (MonsterName == "Water Elemental") { Pause(); Firedamage = (Firedamage + 5); cout<< Weapon << " struck Water subtype: " << Firedamage << " fire damage.\n"; MonsterHP = (MonsterHP - Firedamage); } // Water Elemental if ((MonsterName == "Fire Elemental") || (MonsterName == "Demon")) { Pause(); cout<< Weapon << " struck Fire subtype: " << Firedamage << " absorbed.\n"; MonsterHP = (MonsterHP + Firedamage); if (MonsterHP >= TotalHP) MonsterHP = TotalHP; } // Fire Elemental Pause(); } // Risingsun int Stolen; if (Weapon == "Vampirous") { Stolen = (HPLoss / 5); if (Stolen <= 0) Stolen = 1; if (Stolen >= 20) Stolen = 20; cout<< Weapon << " struck " << MonsterName << ": " << Stolen << " HP stolen.\n"; HP = (HP + Stolen); if (HP > TotalHP) HP = TotalHP; Pause(); } // Vampirous int Colddamage; if (Weapon == "Frostweaver") { Colddamage = 4+random(4); cout<< Weapon << " struck " << MonsterName << ": " << Colddamage << " cold damage.\n"; MonsterHP = (MonsterHP - Colddamage); if (MonsterName == "Fire Elemental") { Pause(); Colddamage = (Colddamage * 2); cout<< Weapon << " struck Fire subtype: " << Colddamage << " cold damage.\n"; MonsterHP = (MonsterHP - Colddamage); } // Fire Elemental Pause(); } // Frostweaver int Killchance; if (Weapon == "Destructor") { Killchance = 1+random(99); if ((Killchance <= 10) && (MonsterName != "Slayer") && (MonsterName != "Dragon")) { if (MonsterHP > 0) { cout<< Weapon << " struck " << MonsterName << ": " << MonsterHP << " damage.\n"; MonsterHP = 0; Pause(); } } // Destroy target } // Destructor if (Weapon == "Lehoma") { Stolen = (HPLoss / 5); if (Stolen <= 0) Stolen = 1; if (Stolen > 25) Stolen = 25; cout<< Weapon << " struck " << MonsterName << ": " << Stolen << " HP stolen.\n"; HP = (HP + Stolen); if (HP > TotalHP) HP = TotalHP; Pause(); Killchance = 1+random(99); if ((Killchance <= 20) && (MonsterName != "Slayer") && (MonsterName != "Dragon")) { if (MonsterHP > 0) { cout<< Weapon << " struck " << MonsterName << ": " << MonsterHP << " damage.\n"; MonsterHP = 0; Pause(); } } // Destroy target } // Lehoma if (MonsterHP <= 0) { MDead = "YES"; MonsterHP = 0; } if (MDead == "NO") { // Calculate damage to character HPLoss = (MonsterAttack - Defense); HPLoss = (HPLoss / Factor); if (HPLoss >= (HP/2)) HPLoss = (HPLoss / Factor); HPLoss = (HPLoss + (1+random(2))); if ((HPLoss <= 0) && (Level != 1)) { if (Level > 40) HPLoss = (Level/2)+random(10+random(5)); if ((Level > 1) && (Level <= 40)) HPLoss = (Level/2)+random(4); } if ((HPLoss <= 0) && (Level == 1)) HPLoss = 1+random(2); if (Shield == "Bodylink") { HPLoss = (HPLoss - (1+random(3))); if ((HPLoss <= 0) && (Level != 1)) HPLoss = Level+random(4); if ((HPLoss <= 0) && (Level == 1)) HPLoss = 1+random(2); } // Bodylink if ((Weapon == "Curephase-w") && (Shield == "Curephase-s") && (Armor == "Curephase-a")) { HPLoss = (HPLoss - 5); if ((HPLoss <= 0) && (Level != 1)) HPLoss = Level+random(4); if ((HPLoss <= 0) && (Level == 1)) HPLoss = 1+random(2); } // All Curephase cout<< MonsterName << " attacks " << Name << ": " << HPLoss << " damage.\n"; Pause(); if ((Battlecounter >= 5) && (Battlecounter < 10)) HPLoss = (HPLoss + (1+random(5))); if ((Battlecounter >= 10) && (Battlecounter < 15)) HPLoss = (HPLoss + (5+random(5))); if ((Battlecounter >= 15) && (Battlecounter < 20)) HPLoss = (HPLoss + (10+random(5))); if ((Battlecounter >= 20) && (Battlecounter < 25)) HPLoss = (HPLoss + (15+random(5))); if (Battlecounter >= 25) HPLoss = (HPLoss + (25+random(10))); HP = (HP - HPLoss); //Monster abilities---------------------------------------------------------= int Specialdamage; if (MonsterName == "Air Elemental") { Specialdamage = 1+random(5); cout<< "Air Elemental struck " << Name << ": " << Specialdamage << " cold damage.\n"; HP = (HP - Specialdamage); Pause(); } // Air Elemental if (MonsterName == "Fire Elemental") { Specialdamage = 5+random(10); cout<< "Fire Aura struck " << Name << ": " << Specialdamage << " damage.\n"; HP = (HP - Specialdamage); Pause(); } // Fire Elemental if ((MonsterName == "Harpy") && (MonsterHP <= 15)) { Specialdamage = 10+random(5); cout<< "Wailing Song struck " << Name << ": " << Specialdamage << " damage.\n"; HP = (HP - Specialdamage); Pause(); } // Harpy if (MonsterName == "Mummy") { int Diseasechance = 1+random(99); Specialdamage = 20; if (Diseasechance <= 35) { cout<< "Mummy struck " << Name << ": " << Specialdamage << " disease damage.\n"; HP = (HP - Specialdamage); Pause(); } // Yes Disease } // Mummy if (MonsterName == "Thief") { Specialdamage = 40+random(40); int Stealchance = 1+random(99); if ((MonsterHP <= 10) && (Stealchance <= 50)) { cout<< "Thief steals " << Specialdamage << "gp!\n"; Gold = (Gold - Specialdamage); if (Gold <= 0) Gold = 0; Pause(); } // Yes Steal } // Thief if (MonsterName == "Water Elemental") { Specialdamage = 10+random(5); cout<< "Water Blast struck " << Name << ": " << Specialdamage << " water damage.\n"; HP = (HP - Specialdamage); Pause(); } // Water Elemental if (MonsterName == "Ghoul") { cout<< "Paralysis struck " << Name << ": 10 damage while paralysed.\n"; HP = (HP - 10); Pause(); } // Ghoul if (MonsterName == "Wight") { cout<< "Wight struck " << Name << ": " << (HPLoss / 2) << " life stolen.\n"; MonsterHP = (MonsterHP + (HPLoss / 2)); if (MonsterHP > TotalMonsterHP) MonsterHP = TotalMonsterHP; Pause(); } // Wight if (MonsterName == "Manticore") { Specialdamage = 2+random(4); cout<< "Tail Spines struck " << Name << ": " << Specialdamage << " damage.\n"; HP = (HP - Specialdamage); Pause(); } // Manticore if (MonsterName == "Death Knight") { Specialdamage = (HPLoss / 2); cout<< "Evil Blade struck " << Name << ": " << Specialdamage << " damage.\n"; HP = (HP - Specialdamage); Pause(); } // Death Knight if (MonsterName == "Sand Howler") { Specialdamage = (Level / 2); if (Specialdamage >= 100) Specialdamage = 100; cout<< "Sandstorm struck " << Name << ": " << Specialdamage << " heat damage.\n"; HP = (HP - Specialdamage); Pause(); } // Sand Howler if (MonsterName == "Bloodmaw") { Specialdamage = 50; cout<< "Bloodmaw struck " << Name << ": " << Specialdamage << " disease damage.\n"; HP = (HP - Specialdamage); Pause(); } // Bloodmaw if (MonsterName == "Basilisk") { Specialdamage = 1+random(99); if (Specialdamage <= 2) { cout<< "Basilisk turned " << Name << " to stone!\n"; HP = 0; Pause(); } // Yes turn to stone } // Basilisk if (MonsterName == "Hal'kiir") { Specialdamage = 20+random(Level/5); cout<< "Magic Burst struck " << Name << ": " << Specialdamage << " magic damage.\n"; HP = (HP - Specialdamage); Pause(); } // Hal'kiir if (MonsterName == "Sinoko") { Specialdamage = 5; cout<< "Flames of Sinoko struck " << Name << ": " << Specialdamage << " fire damage.\n"; Pause(); cout<< "Flames of Sinoko struck " << Name << ": " << Specialdamage << " fire damage.\n"; HP = (HP - 10); Pause(); } // Sinoko if (MonsterName == "Vampire") { Specialdamage = 1+random(5); cout<< "Vampire struck " << Name << ": " << Specialdamage << " life drained.\n"; HP = (HP - Specialdamage); MonsterHP = (MonsterHP + Specialdamage); if (MonsterHP >= TotalMonsterHP) MonsterHP = TotalMonsterHP; Pause(); } // Vampire if (MonsterName == "Wraith") { Specialdamage = 5+random(10), MonsterReg = 10; cout<< "Wraith struck " << Name << ": " << Specialdamage << " cold damage.\n"; HP = (HP - Specialdamage); Pause(); cout<< "Wraith struck " << Name << ": " << MonsterReg << " life stolen.\n"; MonsterHP = (MonsterHP + MonsterReg); Pause(); } // Wraith if (MonsterName == "Slayer") { Specialdamage = 100+random(50); cout<< "Inferno struck " << Name << ": " << Specialdamage << " fire damage.\n"; HP = (HP - Specialdamage); Pause(); } // Slayer if (MonsterName == "Dragon") { int Breathchance = 1+random(99); Specialdamage = 200; if (Breathchance <= 35) { cout<< "Dragon Fire struck " << Name << ": " << Specialdamage << " fire damage.\n"; HP = (HP - Specialdamage); Pause(); } // Yes Breathe } // Dragon //Monster abilities (end)---------------------------------------------------= if (HP > 0) { if (Armor == "Ember") { Firedamage = 5+random(3); cout<< Armor << " rebukes " << MonsterName << ": " << Firedamage << " fire damage.\n"; MonsterHP = (MonsterHP - Firedamage); if (MonsterName == "Water Elemental") { Pause(); Firedamage = (Firedamage + 5); cout<< Weapon << " struck Water subtype: " << Firedamage << " fire damage.\n"; MonsterHP = (MonsterHP - Firedamage); } // Water Elemental if ((MonsterName == "Fire Elemental") || (MonsterName == "Demon")) { Pause(); cout<< Weapon << " struck Fire subtype: " << Firedamage << " absorbed.\n"; MonsterHP = (MonsterHP + Firedamage); if (MonsterHP >= TotalHP) MonsterHP = TotalHP; } // Fire Elemental Pause(); } // Ember if (Armor == "Icechain") { Colddamage = 5+random(6); cout<< Armor << " rebukes " << MonsterName << ": " << Colddamage << " cold damage.\n"; MonsterHP = (MonsterHP - Colddamage); if (MonsterName == "Fire Elemental") { Pause(); Colddamage = (Colddamage * 2); cout<< Weapon << " struck Fire subtype: " << Colddamage << " cold damage.\n"; MonsterHP = (MonsterHP - Colddamage); } // Fire Elemental Pause(); } // Icechain } // Rebuke only if HP > 0 } // Monster Attacks if (HP <= 0) { Dead = "YES"; HP = 0; } if (MonsterHP <= 0) { MDead = "YES"; MonsterHP = 0; } }while ((Dead == "NO") && (MDead == "NO")); if (Dead == "YES") { Lose++; Wins = 0; Output = (Name + " defeated by a " + MonsterName); Logfile(Output); Output = (Name + " Dies"); Logfile(Output); cout<= 50) && (MonsterName != "Dragon")) MFChance = 50; if ((Tag == "YES") || (MonsterName == "Dragon")) MFChance = 100; if (Day == 10) { Wither = "YES"; MFChance = 100; } Check = "Yes"; Magicitem(MFChance, WeaponAR, ShieldDR, ArmorDR, Weapon, Shield, Armor, Shielduse, Attack, Defense, Dexterity, Level, Check, Wither); if ((Check != "No") && (Check != "NO") && (Check != "no") && (Check != "N") && (Check != "n")) Pause(); if (Check == "Inventory") Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); clrscr(); gotoxy(1,2); } // Monster dies } // Attack if ((Choice == "2") && (Flee == "NO")) { Output = "Try Fleeing (Disallowed)"; Logfile(Output); cout<< "You dare not try fleeing again.\n"; Pause(); } // Cannot flee else if ((Choice == "2") && (Flee == "YES")) { Output = "Try Fleeing (Allowed)"; Logfile(Output); Fleechance = 1+random(99); Fleechance = (Fleechance + Wilderness); if ((Fleechance <= 50) || ((Armor == "Cravenplate") || (Armor == "Isura"))) { Output = ("Flee " + MonsterName + " Successfully"); Logfile(Output); cout<< "You flee combat successfully.\n"; Pause(); Run = "YES"; } // Flee successfully else if (Fleechance > 50) { Output = "Fail Flee"; Logfile(Output); int FleeHP = 1+random(4); Flee = "NO"; cout<< MonsterName << " hits you for " << FleeHP << " damage as you try to flee.\n"; HP = (HP-FleeHP); Pause(); if (HP <= 0) { Output = (Name + " Dies"); Logfile(Output); cout<< "You are killed.\n"; Pause(); Dead = "YES"; goto Mainmenu; } // Dead goto Combatstart; } // Fail flee } // Flee else if (Choice == "3") { Inventory(Name, Power, Level, XP, NextLvl, HP, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Rations, Day, WeaponAR, ShieldDR, ArmorDR, CustomName, Custom); goto Combatstart; } if (HP <= 0) { Output = (Name + " Dies"); Logfile(Output); cout<< "You are killed.\n"; Pause(); Dead = "YES"; } // Dead } // Continue to run combat (while loop) Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Terrain(LTerrain); } // Encounter else if (Encounterchance > Target) { Noencounter++; if ((Action == "Sleep") || (Action == "SLEEP") || (Action == "sleep")) { RecoverHP = (10+random(20) + (Level*2)); if (Armor == "Curephase-a") RecoverHP = TotalHP; cout<< "You sleep, recovering " << RecoverHP << " HP\n"; HP = (HP + RecoverHP); if (HP > TotalHP) HP = TotalHP; ofstream LogRecoverHP("Log.txt", ios::app); LogRecoverHP<< "Recovers " << RecoverHP << "hp (Sleep)\n"; LogRecoverHP.close(); Pause(); } if ((Action == "Travel") || (Action == "TRAVEL") || (Action == "travel")) { ofstream LogNoEncounter("Log.txt", ios::app); LogNoEncounter<< "No Encounter (Day " << Day << ")\n"; LogNoEncounter.close(); int TravelHP = ((1+random(5)) + Level); cout<< "There is no encounter on Day " << Day << " (Recover: " << TravelHP << " HP).\n"; if (Weapon == "Lehoma") { Output = "Recover all HP (Lehoma, No Encounter Travel)"; Logfile(Output); HP = TotalHP; } HP = (HP + TravelHP); ofstream TravelHPLog("Log.txt", ios::app); TravelHPLog<< "Recovers " << TravelHP << " HP (No Encounter Travel)\n"; TravelHPLog.close(); if (HP > TotalHP) HP = TotalHP; Day++; Rations--; if (Weapon == "Lehoma") HP = TotalHP; if (Shield == "Curephase-s") HP = TotalHP; Terrain(LTerrain); Pause(); } } // No Encounter } // Travel End: }while ((Day < Goalday) && (Dead == "NO")); // Continue to adventure if (Day >= Goalday) { Output = "Return from Adventuring"; Logfile(Output); cout<< "You return to Misthaven after " << Daysout << " Days of adventuring.\n"; Pause(); } } // Adventure }while (Dead == "NO"); if (Dead == "YES") { Output = (Name + " Dies"); Logfile(Output); clrscr(); gotoxy(1,2); goto Mainmenu; } // If you die //--------------------------------------------------------------------------= Leave(); return(0); } //--------------------------------------------------------------------------= // FUNCTIONS BEGIN HERE //--------------------------------------------------------------------------= void Makecharacter(string &Name, string &OName, int &Power, int &Level, long &XP, long &NextLvl, int &HP, int &TotalHP, int &Strength, int &Dexterity, int &Intelligence, int &Wilderness, int &Barter, long &Attack, long &Defense, long &Gold, string &Weapon, string &Shield, string &Armor, string &One, string &Two, string &Three, string &Four, string &Five, int &Rations, int &Day, string &Dead, int &WeaponAR, int &ShieldDR, int &ArmorDR, string &Shielduse) { string Output; Output = "Character Menu Accessed"; Logfile(Output); string Menu3; do{ OName = "None"; Character: ifstream Outcsv("Horizon\\Character\\Character.hcs", ios::nocreate); Outcsv>> OName; Outcsv.close(); clrscr(); gotoxy(1,2); cout<< "Character\n\n"; cout<< "1. New Character\n"; cout<< "2. Save " << Name <> Menu3; while ((Menu3 != "1") && (Menu3 != "2") && (Menu3 != "3") && (Menu3 != "4") && (Menu3 != "5") && (Menu3 != "6")) { cout<< "\aSelection: "; cin>> Menu3; } if ((Menu3 == "2") && (Name == "None")) { cout<< "Cannot save, no character has been created.\n"; Pause(); } if ((Menu3 == "2") && (Dead == "YES")) { cout<< "Cannot save a dead character.\n"; Pause(); } if ((Menu3 == "3") && (OName == "None")) { cout<< "Cannot load, no character has been saved.\n"; Pause(); } if ((Menu3 == "4") && (OName == "None")) { cout<< "Cannot delete, no character has been created.\n"; Pause(); } if ((Menu3 == "5") && (Name == "None")) { cout<< "Cannot output, no character has been created.\n"; Pause(); } if (Menu3 == "1") { Output = "Create Character"; Logfile(Output); string Place; int Points = 20; // Set Variable Values Strength = 20+random(10); Dexterity = 20+random(10); Intelligence = 20+random(10); Wilderness = 0; Barter = 0; XP = 1+random(4); Level = 1; Weapon = "Sword"; Shield = "Wooden"; Armor = "Leather"; One = "Rations"; Two = "Healing"; Three = "Empty"; Four = "Empty"; Five = "Empty"; Rations = 20; WeaponAR = 10; ShieldDR = 5; ArmorDR = 10; Dead = "NO"; Shielduse = "YES"; Day = 1; clrscr(); gotoxy(1,2); cout<< "Name: "; cin>> Name; while ((Name.length() > 15) || (Name == "None") || (Name.length() < 3)) { if (Name.length() > 15) cout<< "Maximum 15 characters: "; if (Name == "None") cout<< "Reserved name, re-enter: "; if (Name.length() < 3) cout<< "Minimum 3 characters: "; cin>> Name; } clrscr(); gotoxy(1,2); cout<< "Points: 5\n"; cout<< "Place all 5 points in what statistic?\n"; cout<< "1. Strength (current: " << Strength << ")\n"; cout<< "2. Dexterity (current: " << Dexterity << ")\n"; cout<< "3. Intelligence (current: " << Intelligence << ")\n"; cout<< "Selection: "; cin>> Place; while ((Place != "1") && (Place != "2") && (Place != "3")) { cout<< "\aSelection: "; cin>> Place; } if (Place == "1") Strength = (Strength+5); else if (Place == "2") Dexterity = (Dexterity+5); else if (Place == "3") Intelligence = (Intelligence+5); clrscr(); gotoxy(1,2); cout<< "Points: 20\n"; cout<< "Must place points into Wilderness and Barter.\n"; cout<< "Wilderness: "; cin>> Wilderness; while ((Wilderness < 0) || (Wilderness > 20)) { cout<< "Wilderness: "; cin>> Wilderness; } Points = (Points - Wilderness); if ((Points > 1) || (Points == 0)) cout<< "Remaining " << Points << " points placed into Barter.\n"; if (Points == 1) cout<< "Remaining " << Points << " point placed into Barter.\n"; Barter = (Barter + Points); Gold = (5+random(20) + Barter); Set(); // Calculate Stats Attack = (Strength + WeaponAR); Defense = (Dexterity + ShieldDR + ArmorDR); HP = ((Level*5) + 10 + (Strength/10)); NextLvl = (Level*1500); if ((Level >= 50) && (Level < 100)) NextLvl = (Level*2000); if ((Level >= 100) && (Level < 200)) NextLvl = (Level*3000); if (Level >= 200) NextLvl = (Level*10000); TotalHP = HP; Power = (Strength+Dexterity+Intelligence+TotalHP+Wilderness+Barter+(Level*2)+Attack); // Show the Character cout<< Name << " (Power: " << Power << ")\n"; cout<< "Level " << Level <> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Save(Name, Power, Level, XP, NextLvl, TotalHP, Strength, Dexterity, Intelligence, Wilderness, Barter, Attack, Defense, Gold, Weapon, Shield, Armor, One, Two, Three, Four, Five, Day, WeaponAR, ShieldDR, ArmorDR, Rations); } // Choose to save } // Save else if ((Menu3 == "3") && (OName != "None")) { cout<< "Are you sure you want to load " << OName << "? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = ("Load " + OName); Logfile(Output); cout<< "Loading " << OName; cout<< "."; ifstream LCharacter("Horizon\\Character\\Character.hcs"); LCharacter>> Name; LCharacter>> Power; LCharacter>> Level; LCharacter>> XP; LCharacter>> NextLvl; LCharacter>> TotalHP; LCharacter>> Strength; LCharacter>> Dexterity; LCharacter>> Intelligence; LCharacter>> Wilderness; LCharacter>> Barter; LCharacter>> Attack; LCharacter>> Defense; LCharacter>> Gold; LCharacter>> Weapon; LCharacter>> Shield; LCharacter>> Armor; LCharacter>> Rations; LCharacter>> One; LCharacter>> Two; LCharacter>> Three; LCharacter>> Four; LCharacter>> Five; LCharacter>> Day; LCharacter>> WeaponAR; LCharacter>> ShieldDR; LCharacter>> ArmorDR; LCharacter.close(); cout<< ".."; cout<< "complete.\n"; if (Gold >= 90000) Gold = 90000; HP = TotalHP; Dead = "NO"; Set(); Output = ("View " + Name); Logfile(Output); cout<< "VIEWING " << Name << " (Power: " << Power << ")\n"; cout<< "Day: " << Day <> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = ("Delete " + OName); Logfile(Output); cout<< "Deleting " << OName << "."; remove("Horizon\\Character\\Character.hcs"); cout<< ".."; cout<< "complete.\n"; Pause(); OName = "None"; } } // Delete character else if ((Menu3 == "5") && (Name != "None")) { cout<< "Are you sure you want to output " << Name << "? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = ("Output " + Name); Logfile(Output); cout<< "Outputting " << Name << "."; ofstream Output("Horizon\\Output\\Output.doc", ios::trunc); Output<< "Character File\n"; Output<< "**************\n\n"; Output<< Name << " (Power: " << Power << ")\n"; Output<< "Level " << Level <> CustomName; Weaponfile.close(); do{ Options: clrscr(); gotoxy(1,2); cout<< "Options\n\n"; cout<< "1. Text Color\n"; cout<< "2. Reset Components\n"; cout<< "3. Customization\n"; cout<< "4. Set Autosave\n"; cout<< "5. Return to Main Menu\n"; cout<< "Selection: "; cin>> Menu2; while ((Menu2 != "1") && (Menu2 != "2") && (Menu2 != "3") && (Menu2 != "4") && (Menu2 != "5")) { cout<< "\aSelection: "; cin>> Menu2; } clrscr(); gotoxy(1,2); if (Menu2 == "1") { Output = "Text Color Accessed"; Logfile(Output); cout<< "Text Color\n\n"; cout<< "1. Default\n"; cout<< "2. Blue\n"; cout<< "3. Green\n"; cout<< "4. Cyan\n"; cout<< "5. Red\n"; cout<< "6. Purple\n"; cout<< "7. Brown\n"; cout<< "8. Yellow\n"; cout<< "9. White\n"; cout<< "10. Random\n"; cout<< "Selection: "; cin>> Color; while ((Color < 1) || (Color > 10)) { cout<< "\aSelection: "; cin>> Color; } Text(Color); ofstream Incfg("Horizon\\Data\\Horizon.cfg"); Incfg<< Color; Incfg.close(); goto Options; } // Text Color else if (Menu2 == "2") { string Clear1; Output = "Remove Components Accessed"; Logfile(Output); do{ clrscr(); gotoxy(1,2); cout<< "Remove Components\n\n"; cout<< "1. Horizon.cfg\n"; cout<< "2. Character.hcs\n"; cout<< "3. Time.log\n"; cout<< "4. Custom.bin\n"; cout<< "5. All Components\n"; cout<< "6. Return to Options Menu\n"; cout<< "Selection: "; cin>> Clear1; while ((Clear1 != "1") && (Clear1 != "2") && (Clear1 != "3") && (Clear1 != "4") && (Clear1 != "5") && (Clear1 != "6")) { cout<< "\aSelection: "; cin>> Clear1; } clrscr(); gotoxy(1,2); if (Clear1 == "1") { cout<< "Clearing."; remove("Horizon\\Data\\Horizon.cfg"); cout<< "..complete.\n\n"; cout<< "Removed: Horizon.cfg\n"; textcolor(LIGHTGRAY); Pause(); } // Horizon.cfg else if (Clear1 == "2") { cout<< "Clearing."; remove("Horizon\\Character\\Character.hcs"); cout<< "..complete.\n\n"; cout<< "Removed: Character.hcs\n"; Pause(); } // Character.hcs else if (Clear1 == "3") { cout<< "Clearing."; remove("Horizon\\Logs\\Time.log"); cout<< "..complete.\n\n"; cout<< "Removed: Time.log\n"; Pause(); } // Time.log else if (Clear1 == "4") { cout<< "Clearing."; remove("Horizon\\Custom\\Custom.bin"); cout<< "..complete.\n\n"; cout<< "Removed: Custom.bin\n"; Pause(); } // Custom.bin else if (Clear1 == "5") { cout<< "Clearing"; remove("Horizon\\Data\\Horizon.cfg"); cout<< "."; remove("Horizon\\Character\\Character.hcs"); cout<< "."; remove("Horizon\\Logs\\Time.log"); remove("Log.txt"); remove("Horizon\\Custom\\Custom.bin"); cout<< "."; cout<< "complete.\n\n"; cout<< "Removed: Horizon.cfg, Character.hcs, Time.log, Custom.bin\n"; Pause(); textcolor(LIGHTGRAY); Output = "Clear All Components"; Logfile(Output); } // All 4 }while (Clear1 != "6"); // Continue to run loop } // Clear Components else if (Menu2 == "3") { string Create; do{ clrscr(); gotoxy(1,2); cout<< "Customization\n\n"; cout<< "1. Create Weapon\n"; cout<< "2. Load " << CustomName <> Create; while ((Create != "1") && (Create != "2") && (Create != "3") && (Create != "4")) { cout<< "\aSelection: "; cin>> Create; } if ((Create == "2") && (CustomName == "None")) { cout<< "Cannot load, no weapon has been saved.\n"; Pause(); } // Cannot load (no file) clrscr(); gotoxy(1,2); if (Create == "1") { Output = "Weapon Creation Accessed"; Logfile(Output); cout<< "Weapon Creation\n\n"; cout<< "Name (no spaces): "; cin>> CustomName; while ((CustomName == "None") || (CustomName == "Dagger") || (CustomName == "Sword") || (CustomName == "Mace") || (CustomName == "Axe") || (CustomName == "Greatsword") || (CustomName == "Bow") || (CustomName == "Crossbow") || (CustomName == "Quickblade") || (CustomName == "Witherblade") || (CustomName == "Truestrike") || (CustomName == "Darkslayer") || (CustomName == "Risingsun") || (CustomName == "Curephase-w") || (CustomName == "Vampirous") || (CustomName == "Frostweaver") || (CustomName == "Destructor") || (CustomName == "Razoredge") || (CustomName == "Lehoma") || (CustomName.length() > 15)) { if (CustomName.length() > 15) cout<< "Maximum 15 characters: "; else cout<< "\aReserved name, re-enter: "; cin>> CustomName; } cout<< "Cost: "; cin>> CustomGP; cout<< "Attack bonus: "; cin>> CustomAR; cout<< "Two handed? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) Custom = 2; else Custom = 1; clrscr(); gotoxy(1,2); cout<< "Weapon Creation\n\n"; cout<< "Name: " << CustomName << " (" << CustomGP << "gp)\n"; if (CustomAR >= 0) cout<< "AR: +" << CustomAR <> Check; Checktrap(Check); if ((Check == "NO") || (Check == "No") || (Check == "no") || (Check == "N") || (Check == "n")) { CustomName = "None"; goto Options; } // Don't save Output = ("Save " + CustomName); Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Saving."; ofstream Weaponfile("Horizon\\Custom\\Custom.bin"); Weaponfile<< CustomName <> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = ("Load " + CustomName); Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Loading " << CustomName << "."; ifstream Weaponfile("Horizon\\Custom\\Custom.bin"); Weaponfile>> CustomName; Weaponfile>> CustomGP; Weaponfile>> CustomAR; Weaponfile>> Custom; Weaponfile.close(); cout<< "..complete.\n"; Pause(); } } // Load else if (Create == "3") { cout<< "About to reset Custom.bin, are you sure? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { Output = "Reset Custom.bin"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Resetting Custom.bin."; remove("Horizon\\Custom\\Custom.bin"); cout<< "..complete.\n"; CustomName = "None"; Pause(); } // Clear Custom.bin } // Reset Custom.bin }while (Create != "4"); goto Options; } // Customize if (Menu2 == "4") { Output = "Set Autosave Accessed"; Logfile(Output); cout<< "Set Autosave\n\n"; cout<< "Enter Autosave (default 10): "; cin>> Autosave; while (Autosave < 0) { cout<< "\aEnter Autosave (default 10): "; cin>> Autosave; } clrscr(); gotoxy(1,2); if (Autosave != 0) { if (Autosave == 1) cout<< "Character will be autosaved every " << Autosave << " Day.\n"; if (Autosave > 1) cout<< "Character will be autosaved every " << Autosave << " Days.\n"; } else if (Autosave == 0) { cout<< "Character will only be saved on exiting the program, not by\n"; cout<< "autosave.\n"; } ofstream AutosaveSet("Log.txt", ios::app); AutosaveSet<< "Autosave Set: " << Autosave <= 90000) Gold = 90000; if (XP >= NextLvl) { Levelup = "YES"; Level++; ofstream LogLevelUp("Log.txt", ios::app); LogLevelUp<< Name << " reaches Level " << Level << "\n"; LogLevelUp.close(); cout<< "You got a Level Up!\n"; cout<< "Day " << Day << ": " << Name << " reaches Level " << Level << "!\n"; int OldHP = TotalHP; HP = ((Level*5) + 10 + (Strength/10)); TotalHP = HP; Pause(); cout<< "Gained " << (HP - OldHP) << " HP.\n"; Set(); if ((Strength < 900) && (Dexterity < 900) && (Intelligence < 900)) { cout<< "Statistic Increase\n\n"; cout<< "Place 1 Point into...\n"; cout<< "1. Strength (current: " << Strength << ")\n"; cout<< "2. Dexterity (current: " << Dexterity << ")\n"; cout<< "3. Intelligence (current: " << Intelligence << ")\n"; cout<< "Selection: "; cin>> Choice; while ((Choice != "1") && (Choice != "2") && (Choice != "3")) { cout<< "\aSelection: "; cin>> Choice; } if (Choice == "1") { Strength++; cout<< "Strength raised to " << Strength << ".\n"; } // Strength else if (Choice == "2") { Dexterity++; cout<< "Dexterity raised to " << Dexterity << ".\n"; } // Dexterity else if (Choice == "3") { Intelligence++; cout<< "Intelligence raised to " << Intelligence << ".\n"; } // Intelligence Set(); } // Only if all below 900 if ((Wilderness <= 100) && (Barter <= 100)) { cout<< "Skill Increase\n\n"; cout<< "Place 1 Point into...\n"; cout<< "1. Wilderness (current: " << Wilderness << ")\n"; cout<< "2. Barter (current: " << Barter << ")\n"; cout<< "Selection: "; cin>> Choice; while ((Choice != "1") && (Choice != "2")) { cout<< "\aSelection: "; cin>> Choice; } if (Choice == "1") { Wilderness++; cout<< "Wilderness raised to " << Wilderness << ".\n"; } // Wilderness else if (Choice == "2") { Barter++; cout<< "Barter raised to " << Barter << ".\n"; } // Barter Set(); } // Only if both below 100 } // Levelup if (Strength >= 900) Strength = 900; if (Dexterity >= 900) Dexterity = 900; if (Intelligence >= 900) Intelligence = 900; if (Wilderness >= 100) Wilderness = 100; if (Barter >= 100) Barter = 100; Attack = (Strength + WeaponAR); Defense = (Dexterity + ShieldDR + ArmorDR); if ((HP == TotalHP) && (Levelup == "NO")) HP = ((Level*5) + 10 + (Strength/10)); if (Levelup == "YES") { HP = ((Level*5) + 10+ (Strength/10)); TotalHP = HP; } // Level up HP adjust NextLvl = ((Level*1000) + 500); if (Level >= 100) NextLvl = (NextLvl + 1000); Power = (Strength+Dexterity+Intelligence+TotalHP+Wilderness+Barter+(Level*2)+Attack); if ((Weapon == "Bow") || (Weapon == "Crossbow") || (Weapon == "Spear") || (Weapon == "Greatsword") || ((Custom == 2) && (Weapon == CustomName))) { Shield = "None"; Defense = (Defense - ShieldDR); ShieldDR = 0; } // No shield if (Weapon == "Bow") Defense = (Defense + 20); if (Weapon == "Crossbow") Defense = (Defense + 15); if (Weapon == "Axe") Defense = (Defense - 5); if (Weapon == "Spear") Defense = (Defense + 5); if (Armor == "Full") Attack = (Attack - 5); if (Shield == "Tower") Attack = (Attack - 5); do{ clrscr(); gotoxy(1,2); cout<< Name << " (Power: " << Power << ")\n"; cout<< "Level " << Level <> Action; if (Action == "Healme") { Output = "Healme Code Accessed"; Logfile(Output); HP = TotalHP; } if (Action == "Rations50") { Output = "Rations50 Code Accessed"; Logfile(Output); Rations = 50; } if (Action == "2") { if (Two == "Healing") { HP = TotalHP; Two = "Empty"; } } // Use slot 2 else if (Action == "3") { if (Three == "Healing") { HP = TotalHP; Three = "Empty"; } } // Use slot 3 else if (Action == "4") { if (Four == "Healing") { HP = TotalHP; Four = "Empty"; } } // Use slot 4 else if (Action == "5") { if (Five == "Healing") { HP = TotalHP; Five = "Empty"; } } // Use slot 5 }while ((Action != "Return") && (Action != "RETURN") && (Action != "return")); clrscr(); } //Inventory-----------------------------------------------------------------= void Town(string Name, int &Rations, int Barter, long &Gold, string &Weapon, string &Shield, string &Armor, int &WeaponAR, int &ShieldDR, int &ArmorDR, long &Defense, long &Attack, string &Two, string &Three, string &Four, string &Five, string &Shielduse, int &Day, long &XP, int &Strength, int &Dexterity, int &Intelligence) { string Output; Output = "Enter Town"; Logfile(Output); string Action = "1", Buy, CustomName = "Dagger", Check; const string Townname = "Misthaven"; int Discount = (Barter/5), Custom, TBuy, DayTrain, XPEarn; if (Discount > 10) Discount = 10; if (Shield == "Syrian") Discount = (Discount + 10); if (Shield == "Yu-lang") Discount = (Discount + 15); cout<< "Welcome to " << Townname << ", " << Name << ", we hope you enjoy your stay.\n"; Set(); do{ Maintown: clrscr(); gotoxy(1,2); cout<< Townname <> Action; while ((Action != "1") && (Action != "2") && (Action != "3") && (Action != "4") && (Action != "5")) { cout<< "\aSelection: "; cin>> Action; } clrscr(); gotoxy(1,2); if (Action == "1") { Output = "Weapons Accessed"; Logfile(Output); int CustomAR = 5, SwordAR = 10+random(10), MaceAR = 15+random(10), AxeAR = 50+random(10), GreatswordAR = 80+random(10), SpearAR = 25+random(10), BowAR = 20+random(10), CrossbowAR = 30+random(10), CustomGP = 5, SwordGP, MaceGP, AxeGP, GreatswordGP, SpearGP, BowGP, CrossbowGP; ifstream Weaponfile("Horizon\\Custom\\Custom.bin", ios::nocreate); Weaponfile>> CustomName; Weaponfile>> CustomGP; Weaponfile>> CustomAR; Weaponfile>> Custom; Weaponfile.close(); CustomAR = ((CustomAR)+random(10)); CustomGP = (CustomGP-Discount); SwordGP = (10-Discount); MaceGP = (20-Discount); AxeGP = (30-Discount); GreatswordGP = (85-Discount); SpearGP = (50-Discount); BowGP = (75-Discount); CrossbowGP = (75-Discount); if (CustomGP <= 0) CustomGP = 1; if (SwordGP <= 0) SwordGP = 1; if (MaceGP <= 0) MaceGP = 1; if (AxeGP <= 0) AxeGP = 1; if (GreatswordGP <= 0) GreatswordGP = 1; if (SpearGP <= 0) SpearGP = 1; if (BowGP <= 0) BowGP = 1; if (CrossbowGP <= 0) CrossbowGP = 1; do{ clrscr(); gotoxy(1,2); cout<< Townname << " (Weapons)\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. " << CustomGP << "gp / " << CustomName << " / +" << CustomAR << "AR\n"; cout<< "2. " << SwordGP << "gp / Sword / +" << SwordAR << "AR\n"; cout<< "3. " << MaceGP << "gp / Mace / +" << MaceAR << "AR\n"; cout<< "4. " << AxeGP << "gp / Axe / +" << AxeAR << "AR, -5DR\n"; cout<< "5. " << GreatswordGP << "gp / Greatsword / +" << GreatswordAR << "AR\n"; cout<< "6. " << SpearGP << "gp / Spear / +" << SpearAR << "AR, +5DR\n"; cout<< "7. " << BowGP << "gp / Bow / +" << BowAR << "AR, +20DR\n"; cout<< "8. " << CrossbowGP << "gp / Crossbow / +" << CrossbowAR << "AR, +15DR\n"; cout<< "9. Weapon Information\n"; cout<< "10. Return to Main Town\n"; cout<< "Selection: "; cin>> Buy; while ((Buy != "1") && (Buy != "2") && (Buy != "3") && (Buy != "4") && (Buy != "5") && (Buy != "6") && (Buy != "7") && (Buy != "8") && (Buy != "9") && (Buy != "10")) { cout<< "\aSelection: "; cin>> Buy; } if ((Buy == "1") && (Gold >= CustomGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-CustomGP); Weapon = CustomName; WeaponAR = CustomAR; if (Custom == 1) Shielduse = "YES"; else if (Custom == 2) Shielduse = "NO"; cout<< "Purchased " << CustomName << "."; } // Dagger or Custom else if ((Buy == "2") && (Gold >= SwordGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-SwordGP); Weapon = "Sword"; WeaponAR = SwordAR; Shielduse = "YES"; cout<< "Purchased Sword."; } // Sword else if ((Buy == "3") && (Gold >= MaceGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-MaceGP); Weapon = "Mace"; WeaponAR = MaceAR; Shielduse = "YES"; cout<< "Purchased Mace."; } // Mace else if ((Buy == "4") && (Gold >= AxeGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-AxeGP); Weapon = "Axe"; WeaponAR = AxeAR; Defense = (Defense - 5); Shielduse = "YES"; cout<< "Purchased Axe."; } // Axe else if ((Buy == "5") && (Gold >= GreatswordGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-GreatswordGP); Weapon = "Greatsword"; WeaponAR = GreatswordAR; Shielduse = "NO"; cout<< "Purchased Greatsword."; } // Greatsword else if ((Buy == "6") && (Gold >= SpearGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-SpearGP); Weapon = "Spear"; WeaponAR = SpearAR; Defense = (Defense + 5); Shielduse = "NO"; cout<< "Purchased Spear."; } // Spear else if ((Buy == "7") && (Gold >= BowGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-BowGP); Weapon = "Bow"; WeaponAR = BowAR; Defense = (Defense + 20); Shielduse = "NO"; cout<< "Purchased Bow."; } // Bow else if ((Buy == "8") && (Gold >= CrossbowGP)) { if (Weapon == "Quickblade") Dexterity = (Dexterity - 5); Attack = (Attack - WeaponAR); Gold = (Gold-CrossbowGP); Weapon = "Crossbow"; WeaponAR = CrossbowAR; Defense = (Defense + 15); Shielduse = "NO"; cout<< "Purchased Crossbow."; } // Crossbow if (Buy == "9") { Output = "Weapon Information Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Weapon Information\n\n"; cout<< "Dagger----: This simple weapon is quite cheap but is not very\n"; cout<< " powerful or useful in combat.\n"; cout<< "Sword-----: A standard weapon, the Sword is a fine edged blade\n"; cout<< " that works well against all creatures.\n"; cout<< "Mace------: Heavier than the Sword, the Mace is a powerful weapon\n"; cout<< " against many creatures. Although it is bulky, the large\n"; cout<< " head makes it relatively easy to strike foes.\n"; cout<< "Axe-------: This heavy weapon is rather slow and hard to parry with,\n"; cout<< " and so it decreases defense. However, it has huge attacking\n"; cout<< " power, and is much feared for the force of its chops.\n"; cout<< "Greatsword: A massive two handed blade, the Greatsword is able to split\n"; cout<< " foes in half. Although it is very powerful, without a Shield,\n"; cout<< " a Greatsword wielding adventurer may not last very long.\n"; cout<< "Spear-----: With a long wooden shaft, the Spear can keep most\n"; cout<< " adventurers at a safe distance from their foe, effectively\n"; cout<< " increasing defense. If in the hands of a skill user, the\n"; cout<< " Spear can be a deadly weapon.\n"; cout<< "Bow-------: The Bow is a favored weapon of those who dare not enter close\n"; cout<< " combat. The range at which it can be fired keeps the wielder\n"; cout<< " out of harms way, while at the same time inflicting grievous\n"; cout<< " wounds.\n"; Set(); cout<< "Weapon Information (continued)\n\n"; cout<< "Crossbow: While the deadlier bolts do very good damage, the Crossbow\n"; cout<< " is unwieldy, and thus does not give as great a defensive\n"; cout<< " bonus as the Bow.\n"; } // Weapon Information if (Buy != "10") Pause(); }while (Buy != "10"); goto Maintown; } // Weapons else if (Action == "2") { Output = "Armor Accessed"; Logfile(Output); int LeatherDR = 10+random(10), ChainDR = 50+random(10), FullDR = 100+random(10), LeatherGP, ChainGP, FullGP; LeatherGP = (10-Discount); ChainGP = (50-Discount); FullGP = (150-Discount); if (LeatherGP <= 0) LeatherGP = 1; if (ChainGP <= 0) ChainGP = 1; if (FullGP <= 0) FullGP = 1; do{ clrscr(); gotoxy(1,2); cout<< Townname << " (Armor)\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. " << LeatherGP << "gp / Leather Armor / +" << LeatherDR << "DR\n"; cout<< "2. " << ChainGP << "gp / Chain Mail / +" << ChainDR << "DR\n"; cout<< "3. " << FullGP << "gp / Full Plate Mail / +" << FullDR << "DR, -5AR\n"; cout<< "4. Armor Information\n"; cout<< "5. Return to Main Town\n"; cout<< "Selection: "; cin>> Buy; while ((Buy != "1") && (Buy != "2") && (Buy != "3") && (Buy != "4") && (Buy != "5")) { cout<< "\aSelection: "; cin>> Buy; } if ((Buy == "1") && (Gold >= LeatherGP)) { Defense = (Defense - ArmorDR); Gold = (Gold-LeatherGP); Armor = "Leather"; ArmorDR = LeatherDR; cout<< "Purchased Leather Armor."; } // Leather else if ((Buy == "2") && (Gold >= ChainGP)) { Defense = (Defense - ArmorDR); Gold = (Gold-ChainGP); Armor = "Chain"; ArmorDR = ChainDR; cout<< "Purchased Chain Mail."; } // Chain else if ((Buy == "3") && (Gold >= FullGP)) { Defense = (Defense - ArmorDR); Gold = (Gold-FullGP); Armor = "Full"; ArmorDR = FullDR; Attack = (Attack - 5); cout<< "Purchased Full Plate Mail."; } // Full if (Buy == "4") { Output = "Armor Information Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Armor Information\n\n"; cout<< "Leather Armor--: This Armor has a soft padded central area, with oil\n"; cout<< " hardened shoulders and back plates. Provides excellent\n"; cout<< " freedom of arms.\n"; cout<< "Chain Mail-----: Thin rings made of strong iron are woven over a heavy\n"; cout<< " underpadding that helps prevent chaffing. Chain Mail is\n"; cout<< " quite heavy, as it has extra layers over vital areas.\n"; cout<< "Full Plate Mail: The best non-magical protection that can be purchased,\n"; cout<< " Full Plate Mail is well worth the price. The angled\n"; cout<< " help deflect blows, while the overcoat of solid steel\n"; cout<< " is excellent against all weapons. The suit is very heavy,\n"; cout<< " and so slows the attacks of a character wearing this Armor.\n"; } // Armor Information if (Buy != "5") Pause(); }while (Buy != "5"); goto Maintown; } // Armor else if (Action == "3") { Output = "Shields Accessed"; Logfile(Output); int WoodDR = 5+random(10), MetalDR = 20+random(10), TowerDR = 30+random(10), WoodGP, MetalGP, TowerGP; WoodGP = (5-Discount); MetalGP = (20-Discount); TowerGP = (75-Discount); if (WoodGP <= 0) WoodGP = 1; if (MetalGP <= 0) MetalGP = 1; if (TowerGP <= 0) TowerGP = 1; do{ clrscr(); gotoxy(1,2); cout<< Townname << " (Shields)\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. " << WoodGP << "gp / Wooden / +" << WoodDR << "DR\n"; cout<< "2. " << MetalGP << "gp / Metal / +" << MetalDR << "DR\n"; cout<< "3. " << TowerGP << "gp / Tower / +" << TowerDR << "DR, -5AR\n"; cout<< "4. Shield Information\n"; cout<< "5. Return to Main Town\n"; if (Shielduse == "NO") { cout<> Buy; while ((Buy != "1") && (Buy != "2") && (Buy != "3") && (Buy != "4") && (Buy != "5")) { cout<< "\aSelection: "; cin>> Buy; } if ((Buy == "1") && (Gold >= WoodGP)) { Defense = (Defense - ShieldDR); Gold = (Gold-WoodGP); Shield = "Wooden"; ShieldDR = WoodDR; cout<< "Purchased Wooden Shield."; } // Wooden else if ((Buy == "2") && (Gold >= MetalGP)) { Defense = (Defense - ShieldDR); Gold = (Gold-MetalGP); Shield = "Metal"; ShieldDR = MetalDR; cout<< "Purchased Metal Shield."; } // Metal else if ((Buy == "3") && (Gold >= TowerGP)) { Defense = (Defense - ShieldDR); Gold = (Gold-TowerGP); Shield = "Tower"; ShieldDR = TowerDR; cout<< "Purchased Tower Shield."; } // Tower if (Buy == "4") { Output = "Shield Information Accessed"; Logfile(Output); clrscr(); gotoxy(1,2); cout<< "Shield Information\n\n"; cout<< "Wooden Shield: This is the cheapest Shield available. The face is\n"; cout<< " made of hardened oak, with two leather straps on the\n"; cout<< " back to hold.\n"; cout<< "Metal Shield-: A slightly stronger version of the Wooden Shield, the\n"; cout<< " face is covered in a manageable sheet of iron, making\n"; cout<< " it quite resistant to damage.\n"; cout<< "Tower Shield-: This is the heaviest and most powerful Shield. Its\n"; cout<< " massive size grants excellent defense, but impairs\n"; cout<< " attacks slightly because of its bulky shape.\n"; } // Shield Information if (Buy != "5") Pause(); }while (Buy != "5"); goto Maintown; } // Shields else if (Action == "4") { int HealingGP, AlchemistGP; HealingGP = (20 - Discount); AlchemistGP = (1000 - Discount); if (HealingGP <= 0) HealingGP = 1; if (AlchemistGP <= 100) AlchemistGP = 100; Output = "Other Accessed"; Logfile(Output); do{ clrscr(); gotoxy(1,2); cout<< Townname << " (Other)\n"; cout<< "Gold: " << Gold << "gp\n\n"; cout<< "1. 1gp / Ration / Eat one every Day\n"; cout<< "2. " << HealingGP << "gp / Healing Potion / Restore all HP\n"; cout<< "3. " << AlchemistGP << "gp / Alchemist Potion / Increase stats\n"; cout<< "4. Varies / Training / Bonus XP\n"; cout<< "5. Other Information\n"; cout<< "6. Return to Main Town\n"; cout<< "Selection: "; cin>> Buy; while ((Buy != "1") && (Buy != "2") && (Buy != "3") && (Buy != "4") && (Buy != "5") && (Buy != "6")) { cout<< "\aSelection: "; cin>> Buy; } if (Buy == "5") { clrscr(); gotoxy(1,2); cout<< "Other Information\n\n"; cout<< "Ration----------: A character must eat a single Ration every Day\n"; cout<< " or they will starve to death.\n"; cout<< "Healing Potion--: When used through the Inventory, all of the\n"; cout<< " character's HP are recovered to full.\n"; cout<< "Alchemist Potion: Once purchased the Alchemist Potion is\n"; cout<< " automatically used. It has a chance to increase\n"; cout<< " either Strength, Dexterity, or Intelligence by +1\n"; cout<< " point permanently. However, their is also a chance\n"; cout<< " that the potion will do nothing at all.\n"; cout<< "Training--------: You can pay upwards of 50gp to get Training. Based\n"; cout<< " on the amount of gold payed, the time and XP earned\n"; cout<< " will vary. No more than 1000XP can be earned from a\n"; cout<< " single Training session. Less than 50gp can be given,\n"; cout<< " but it is unlikely that a trainer will accept such a\n"; cout<< " small amount.\n"; } // Other Information if ((Buy == "1") && (Gold >= 1)) { Rations++; if (Rations > 50) { Rations--; cout<< "Cannot carry any more rations."; } else if (Rations <= 50) { Gold = (Gold-1); cout<< "Purchased Ration."; } } // Ration if (Buy == "4") { cout<< "Spend how much gold on training? "; cin>> TBuy; if (TBuy <= 0) goto NoTrain; if ((Gold < TBuy) || ((TBuy > 0) && (TBuy <= 50))) { if (Gold < TBuy) cout<< "You do not that much gold.\n"; if (((TBuy > 0) && (TBuy <= 50)) && (Gold > TBuy)) { cout<< "No trainers will work for that measly fee.\n"; cout<< "But the donation of " << TBuy << "gp is gladly accepted.\n"; Gold = (Gold - TBuy); } goto NoTrain; } // Not enough gold clrscr(); gotoxy(1,2); DayTrain = ((TBuy / 75) + (1+random(2))); if (DayTrain <= 0) DayTrain = 1; cout<< "Spending " << TBuy << "gp on Training.\n"; if (DayTrain > 1) cout<< "You will be training for " << DayTrain << " Days.\n"; if (DayTrain == 1) cout<< "You will be training for " << DayTrain << " Day.\n"; cout<< "All food and shelter is provided.\n"; Pause(); cout<< "Proceed? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "Y") || (Check == "y") || (Check == "yes")) { clrscr(); gotoxy(1,2); Day = (Day + DayTrain); XPEarn = ((TBuy / 5) + (10+random(20))); if (XPEarn <= 10) XPEarn = 10; if (XPEarn >= 1000) XPEarn = 1000; Gold = (Gold - TBuy); if (DayTrain > 1) cout<< "Finally, after " << DayTrain << " Days you complete your training.\n"; if (DayTrain == 1) cout<< "Finally, after " << DayTrain << " Day you complete your training.\n"; cout<< "You earn " << XPEarn << "XP from the new knowledge.\n"; XP = (XP + XPEarn); ofstream LogTrain("Log.txt", ios::app); LogTrain<< "Trained for " << DayTrain << " Day(s)\n"; LogTrain<< "XP: " << XPEarn << " (Training)\n"; LogTrain.close(); } // Yes NoTrain: } // Training if ((Buy == "3") && (Gold >= 1000)) { cout<< "Are you sure? "; cin>> Check; Checktrap(Check); if ((Check == "YES") || (Check == "Yes") || (Check == "yes") || (Check == "Y") || (Check == "y")) { cout<< "Purchased Alchemist Potion.\n"; Gold = (Gold-AlchemistGP); Set(); cout<< Name << " used an Alchemist Potion..."; Pause(); int Effects = 1+random(5); if ((Effects == 1) || (Effects == 2)) // +1 Str { cout<< "Strength +1 permanently!\n"; Strength = (Strength + 1); } else if (Effects == 3) // +1 Dex { cout<< "Dexterity +1 permanently!\n"; Dexterity = (Dexterity + 1); } else if (Effects == 4) // +1 Int { cout<< "Intelligence +1 permanently!\n"; Intelligence = (Intelligence + 1); } else if (Effects == 5) // Nothing cout<< "Faulty! Nothing happens!\n"; Output = "Bought an Alchemist Potion."; Logfile(Output); } // Yes else cout<< "You decide not to spend the 1000gp on the Alchemist Potion.\n"; } // Alchemist Potion string Temp = "NO"; if ((Buy == "2") && (Gold >= 20)) { if (Two == "Empty") { Two = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three == "Empty") && (Temp == "NO")) { Three = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three != "Empty") && (Four == "Empty") && (Temp == "NO")) { Four = "Healing"; Temp = "YES"; } else if ((Two != "Empty") && (Three != "Empty") && (Four != "Empty") && (Five == "Empty") && (Temp == "NO")) { Five = "Healing"; Temp = "YES"; } if (Temp == "YES") { Gold = (Gold-HealingGP); cout<< "Purchased Healing Potion."; } } // Healing if (Buy != "6") Pause(); }while (Buy != "6"); goto Maintown; } // Other if (Action != "5") Pause(); if (Action == "5") { Output = "Leave Town"; Logfile(Output); cout<< "We hope you enjoyed your time here " << Name << "!\n"; Pause(); } }while (Action != "5"); clrscr(); gotoxy(1,2); } //Town----------------------------------------------------------------------= //**************************************************************************= // END: Freeware Programmed by Carlo. //**************************************************************************=