// header files #include #include #include #include #include using namespace std; //clear the screen inline void Cls() { system("cls"); } //locate a screen position for input / output inline void Locate(int x, int y) { COORD position = {x,y}; SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), position); } //character information structure class Character { private: char name[21]; char race[7]; char character_class[15]; int level, experience; int spell_level[20]; int max_mana, max_hp, magic, strength, defence, agility; int mana, hp; float magical_success_rate; float to_hit; float escape_rate; float evasion_rate; float battle_interval; int damage_estimate[2]; int damage; bool poisoned; int equipped[3]; int inventory[50]; public: void SetName(char[21]); void SetRace(char[7]); void SetCharacterClass(char[15]); void SetLevel(int); void SetExperience(int); void SetSpellLevel(int,int); void SetMaxMana(int); void SetMaxHP(int); void SetMagic(int); void SetStrength(int); void SetDefence(int); void SetAgility(int); void SetMana(int); void SetHP(int); void SetMagicalSuccessRate(float); void SetToHit(float); void SetEscapeRate(float); void SetEvasionRate(float); void SetBattleInterval(float); void SetDamageEstimate(int, int); void SetDamage(int); void SetPoisoned(bool); void SetEquipped(int, int); void SetInventory(int, int); char *GetName(); char *GetRace(); char *GetCharacterClass(); int GetLevel(); int GetExperience(); int GetSpellLevel(int); int GetMaxMana(); int GetMaxHP(); int GetMagic(); int GetStrength(); int GetDefence(); int GetAgility(); int GetMana(); int GetHP(); float GetMagicalSuccessRate(); float GetToHit(); float GetEscapeRate(); float GetEvasionRate(); float GetBattleInterval(); int GetDamageEstimate(int); int GetDamage(); bool GetPoisoned(); int GetEquipped(int); int GetInventory(int); }; //beginning of set Character member function declarations void Character::SetName(char g_name[21]) { strcpy(name, g_name); } void Character::SetRace(char g_race[7]) { strcpy(race, g_race); } void Character::SetCharacterClass(char g_character_class[15]) { strcpy(character_class, g_character_class); } void Character::SetLevel(int g_level) { level = g_level; } void Character::SetExperience(int g_experience) { experience = g_experience; } void Character::SetSpellLevel(int g_spell, int g_level) { spell_level[g_spell] = g_level; } void Character::SetMaxMana(int g_max_mana) { max_mana = g_max_mana; } void Character::SetMaxHP(int g_max_hp) { max_hp = g_max_hp; } void Character::SetMagic(int g_magic) { magic = g_magic; } void Character::SetStrength(int g_strength) { strength = g_strength; } void Character::SetDefence(int g_defence) { defence = g_defence; } void Character::SetAgility(int g_agility) { agility = g_agility; } void Character::SetMana(int g_mana) { mana = g_mana; } void Character::SetHP(int g_hp) { hp = g_hp; } void Character::SetMagicalSuccessRate(float g_magical_success_rate) { magical_success_rate = g_magical_success_rate; } void Character::SetToHit(float g_to_hit) { to_hit = g_to_hit; } void Character::SetEscapeRate(float g_escape_rate) { escape_rate = g_escape_rate; } void Character::SetEvasionRate(float g_evasion_rate) { evasion_rate = g_evasion_rate; } void Character::SetBattleInterval(float g_battle_interval) { battle_interval = g_battle_interval; } void Character::SetDamageEstimate(int estimate_num, int g_estimate_value) { damage_estimate[estimate_num] = g_estimate_value; } void Character::SetDamage(int g_damage) { // use formula here } void Character::SetPoisoned(bool g_poisoned) { poisoned = g_poisoned; } void Character::SetEquipped(int slot_num, int item_num) { equipped[slot_num] = item_num; } void Character::SetInventory(int slot_num, int amount) { inventory[slot_num] = amount; } //end of set, beginning of get Character member function declarations char *Character::GetName() { return name; } char *Character::GetRace() { return race; } char *Character::GetCharacterClass() { return character_class; } int Character::GetLevel() { return level; } int Character::GetExperience() { return experience; } int Character::GetSpellLevel(int spell) { return spell_level[spell]; } int Character::GetMaxMana() { return max_mana; } int Character::GetMaxHP() { return max_hp; } int Character::GetMagic() { return magic; } int Character::GetStrength() { return strength; } int Character::GetDefence() { return defence; } int Character::GetAgility() { return agility; } int Character::GetMana() { return mana; } int Character::GetHP() { return hp; } float Character::GetMagicalSuccessRate() { return magical_success_rate; } float Character::GetToHit() { return to_hit; } float Character::GetEscapeRate() { return escape_rate; } float Character::GetEvasionRate() { return evasion_rate; } float Character::GetBattleInterval() { return battle_interval; } int Character::GetDamageEstimate(int estimate_num) { return damage_estimate[estimate_num]; } int Character::GetDamage() { return damage; } bool Character::GetPoisoned() { return poisoned; } int Character::GetEquipped(int slot_num) { return equipped[slot_num-1]; } int Character::GetInventory(int slot_num) { return inventory[slot_num]; } //end of get Character member function declarations //the only instance of the Character Class: Character player; //Item information structure class Item { private: bool two_handed; int damage_estimate_mod[2]; int damage_taken_mod; int max_mana_mod; int max_hp_mod; int magic_mod; int strength_mod; int defence_mod; int agility_mod; float magical_success_rate_mod; float to_hit_mod; float escape_rate_mod; float evasion_rate_mod; float battle_interval_mod; public: void Item::SetStats(int, int); bool Item::GetTwoHanded(); int Item::GetDamageEstimateMod(int); int Item::GetDamageTakenMod(); int Item::GetMaxManaMod(); int Item::GetMaxHPMod(); int Item::GetMagicMod(); int Item::GetStrengthMod(); int Item::GetDefenceMod(); int Item::GetAgilityMod(); float Item::GetMagicalSuccessRateMod(); float Item::GetToHitMod(); float Item::GetEscapeRateMod(); float Item::GetEvasionRateMod(); float Item::GetBattleIntervalMod(); char *ConvertItemName(int, int, bool); }; //set the stats of an item void Item::SetStats(int item_type, int item_num) { switch(item_type) { case 1: //weapons switch(item_num) { case 1: //agile glove two_handed = false; damage_estimate_mod[0] = 3; damage_estimate_mod[1] = 5; damage_taken_mod = 0; max_mana_mod = -3; max_hp_mod = 0; magic_mod = -1; strength_mod = 0; defence_mod = 0; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 2; escape_rate_mod = 1; evasion_rate_mod = 2; battle_interval_mod = -10; break; case 2: //basher's club two_handed = false; damage_estimate_mod[0] = 3; damage_estimate_mod[1] = 9; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = -10; to_hit_mod = 10; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = -15; break; case 3: //bow of wood two_handed = false; damage_estimate_mod[0] = 2; damage_estimate_mod[1] = 3; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 6; escape_rate_mod = 6; evasion_rate_mod = 6; battle_interval_mod = -10; break; case 4: //deadly dagger two_handed = false; damage_estimate_mod[0] = 4; damage_estimate_mod[1] = 5; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = -1; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 1; escape_rate_mod = 1; evasion_rate_mod = 1; battle_interval_mod = 0; break; case 5: //dueling blade two_handed = true; damage_estimate_mod[0] = 9; damage_estimate_mod[1] = 16; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 5; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = -5; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 6: //great axe two_handed = false; damage_estimate_mod[0] = 10; damage_estimate_mod[1] = 12; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = -5; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = -2; escape_rate_mod = -3; evasion_rate_mod = -1; battle_interval_mod = 50; break; case 7: //hatchet of awe two_handed = false; damage_estimate_mod[0] = 8; damage_estimate_mod[1] = 10; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = -3; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = -2; escape_rate_mod = -2; evasion_rate_mod = -1; battle_interval_mod = 0; break; case 8: //lance of sharpness two_handed = false; damage_estimate_mod[0] = 4; damage_estimate_mod[1] = 6; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 1; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 4; escape_rate_mod = 0; evasion_rate_mod = 1; battle_interval_mod = 0; break; case 9: //magi-spike two_handed = false; damage_estimate_mod[0] = 5; damage_estimate_mod[1] = 8; damage_taken_mod = 0; max_mana_mod = 2; max_hp_mod = -2; magic_mod = 2; strength_mod = -2; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 2; to_hit_mod = -2; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 10: //mana sword two_handed = false; damage_estimate_mod[0] = 5; damage_estimate_mod[1] = 7; damage_taken_mod = 0; max_mana_mod = 5; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 11: //painspine two_handed = false; damage_estimate_mod[0] = 12; damage_estimate_mod[1] = 15; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = -3; strength_mod = -3; defence_mod = -3; agility_mod = -3; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 12: //staff of protection two_handed = false; damage_estimate_mod[0] = 2; damage_estimate_mod[1] = 5; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 3; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 5; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 13: //staff of sorcery two_handed = false; damage_estimate_mod[0] = 1; damage_estimate_mod[1] = 3; damage_taken_mod = 0; max_mana_mod = 10; max_hp_mod = 0; magic_mod = 3; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 5; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 14: //swift crest two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 2; escape_rate_mod = 2; evasion_rate_mod = 2; battle_interval_mod = -20; break; case 15: //vital scimitar two_handed = false; damage_estimate_mod[0] = 3; damage_estimate_mod[1] = 7; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 3; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; } break; case 2: //shields switch(item_num) { case 1: //agile safeguard two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -4; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = -20; break; case 2: //body shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = -1; damage_taken_mod = -8; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = -1; evasion_rate_mod = 0; escape_rate_mod = -1; evasion_rate_mod = -1; battle_interval_mod = 0; break; case 3: //buckler of aim two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -2; max_mana_mod = -2; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 1; to_hit_mod = 2; escape_rate_mod = 2; evasion_rate_mod = 2; battle_interval_mod = 0; break; case 4: //chaos shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -4; max_mana_mod = 0; max_hp_mod = 1; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 1; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 5: //circular shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -3; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 1; escape_rate_mod = 1; evasion_rate_mod = 1; battle_interval_mod = 0; break; case 6: //coat of arms two_handed = false; damage_estimate_mod[0] = 2; damage_estimate_mod[1] = 3; damage_taken_mod = -1; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 1; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 7: //gargantuan barrier two_handed = true; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -25; max_mana_mod = -100; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 8: //parrying shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -3; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 2; battle_interval_mod = 0; break; case 9: //piercing crest two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 7; damage_taken_mod = 0; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 2; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 10: //shield of casting two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -3; max_mana_mod = 3; max_hp_mod = 0; magic_mod = 0; strength_mod = -1; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 3; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 11: //shield of chance two_handed = false; damage_estimate_mod[0] = -3; damage_estimate_mod[1] = 3; damage_taken_mod = -5; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 12: //shield of the earth two_handed = false; damage_estimate_mod[0] = 1; damage_estimate_mod[1] = 0; damage_taken_mod = -7; max_mana_mod = -1; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = -1; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = -1; battle_interval_mod = 0; break; case 13: //shield of the heart two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -3; max_mana_mod = 0; max_hp_mod = 1; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 1; escape_rate_mod = 0; evasion_rate_mod = 1; battle_interval_mod = 0; break; case 14: //silver shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -5; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 15: //vigorous shield two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -5; max_mana_mod = -10; max_hp_mod = 10; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; } break; case 3: //armour switch(item_num) { case 1: //aluminim suit two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -2; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 15; battle_interval_mod = 0; break; case 2: //basher's cloak two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 2; damage_taken_mod = -3; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 3; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 3: //bashmage coat two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -6; max_mana_mod = 2; max_hp_mod = 2; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = -10; break; case 4: //battle master's mail two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -6; max_mana_mod = -2; max_hp_mod = -2; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 2; to_hit_mod = 2; escape_rate_mod = -5; evasion_rate_mod = 2; battle_interval_mod = 0; break; case 5: //chainmail two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -8; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = -1; battle_interval_mod = 0; break; case 6: //cloak of skill two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -1; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 1; strength_mod = 1; defence_mod = 1; agility_mod = 1; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 7: //coat of all trades two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 3; damage_taken_mod = -5; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 3; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 2; battle_interval_mod = -15; break; case 8: //energy mail two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -4; max_mana_mod = 2; max_hp_mod = 2; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = -1; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 9: //lead vest two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -15; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = -10; battle_interval_mod = 0; break; case 10: //mail of fate two_handed = false; damage_estimate_mod[0] = 3; damage_estimate_mod[1] = -2; damage_taken_mod = -6; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 11: //mana coat two_handed = false; damage_estimate_mod[0] = -1; damage_estimate_mod[1] = 0; damage_taken_mod = 0; max_mana_mod = 7; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 1; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 12: //nimble vest two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = -1; damage_taken_mod = -4; max_mana_mod = 0; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 2; escape_rate_mod = 1; evasion_rate_mod = 1; battle_interval_mod = 0; break; case 13: //platemail two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -12; max_mana_mod = -2; max_hp_mod = 0; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = -2; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 14: //rune cape two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -3; max_mana_mod = 1; max_hp_mod = 0; magic_mod = 1; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 1; to_hit_mod = 0; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = 0; break; case 15: //slicer plate two_handed = false; damage_estimate_mod[0] = 0; damage_estimate_mod[1] = 0; damage_taken_mod = -6; max_mana_mod = 2; max_hp_mod = 2; magic_mod = 0; strength_mod = 0; defence_mod = 0; agility_mod = 0; magical_success_rate_mod = 0; to_hit_mod = 5; escape_rate_mod = 0; evasion_rate_mod = 0; battle_interval_mod = -15; break; } break; } } //get Item member functions bool Item::GetTwoHanded() { return two_handed; } int Item::GetDamageEstimateMod(int estimate_num) { return damage_estimate_mod[estimate_num]; } int Item::GetDamageTakenMod() { return damage_taken_mod; } int Item::GetMaxManaMod() { return max_mana_mod; } int Item::GetMaxHPMod() { return max_hp_mod; } int Item::GetMagicMod() { return magic_mod; } int Item::GetStrengthMod() { return strength_mod; } int Item::GetDefenceMod() { return defence_mod; } int Item::GetAgilityMod() { return agility_mod; } float Item::GetMagicalSuccessRateMod() { return magical_success_rate_mod; } float Item::GetToHitMod() { return to_hit_mod; } float Item::GetEscapeRateMod() { return escape_rate_mod; } float Item::GetEvasionRateMod() { return evasion_rate_mod; } float Item::GetBattleIntervalMod() { return battle_interval_mod; } //returns the name of a given item number char *Item::ConvertItemName(int item_type, int item_num, bool one_item) { char temp_name[2][21]; int master_num = 3 * (item_type - 1) + item_num; //number from 1 - 45 (combines item's type & #) switch(master_num) { //beginning of weapons case 1: strcpy(temp_name[1], "Agile Glove"); strcpy(temp_name[0], "Agile Gloves"); break; case 2: strcpy(temp_name[1], "Basher's Club"); strcpy(temp_name[0], "Basher's Clubs"); break; case 3: strcpy(temp_name[1], "Bow of Wood"); strcpy(temp_name[0], "Bows of Wood"); break; case 4: strcpy(temp_name[1], "Deadly Dagger"); strcpy(temp_name[0], "Deadly Daggers"); break; case 5: strcpy(temp_name[1], "Dueling Blade"); strcpy(temp_name[0], "Dueling Blades"); break; case 6: strcpy(temp_name[1], "Great Axe"); strcpy(temp_name[0], "Great Axes"); break; case 7: strcpy(temp_name[1], "Hatchet of Awe"); strcpy(temp_name[0], "Hatchets of Awe"); break; case 8: strcpy(temp_name[1], "Lance of Sharpness"); strcpy(temp_name[0], "Lances of Sharpness"); break; case 9: strcpy(temp_name[1], "Magi-Spike"); strcpy(temp_name[0], "Magi-Spikes"); break; case 10: strcpy(temp_name[1], "Mana Sword"); strcpy(temp_name[0], "Mana Swords"); break; case 11: strcpy(temp_name[1], "Painspine"); strcpy(temp_name[0], "Painspines"); break; case 12: strcpy(temp_name[1], "Staff of Protection"); strcpy(temp_name[0], "Staves of Protection"); break; case 13: strcpy(temp_name[1], "Staff of Sorcery"); strcpy(temp_name[0], "Staves of Sorcery"); break; case 14: strcpy(temp_name[1], "Swift Crest"); strcpy(temp_name[0], "Swift Crests"); break; case 15: strcpy(temp_name[1], "Vital Scimitar"); strcpy(temp_name[0], "Vital Scimitars"); break; //end of weapons, beginning of shields case 16: strcpy(temp_name[1], "Agile Safeguard"); strcpy(temp_name[0], "Agile Safeguards"); break; case 17: strcpy(temp_name[1], "Body Shield"); strcpy(temp_name[0], "Body Shields"); break; case 18: strcpy(temp_name[1], "Buckler of Aim"); strcpy(temp_name[0], "Bucklers of Aim"); break; case 19: strcpy(temp_name[1], "Chaos Shield"); strcpy(temp_name[0], "Chaos Shields"); break; case 20: strcpy(temp_name[1], "Circular Shield"); strcpy(temp_name[0], "Circular Shields"); break; case 21: strcpy(temp_name[1], "Coat of Arms"); strcpy(temp_name[0], "Coats of Arms"); break; case 22: strcpy(temp_name[1], "Gargantuan Barrier"); strcpy(temp_name[0], "Gargantuan Barriers"); break; case 23: strcpy(temp_name[1], "Parrying Shield"); strcpy(temp_name[0], "Parrying Shields"); break; case 24: strcpy(temp_name[1], "Piercing Crest"); strcpy(temp_name[0], "Piercing Crests"); break; case 25: strcpy(temp_name[1], "Shield of Casting"); strcpy(temp_name[0], "Shields of Casting"); break; case 26: strcpy(temp_name[1], "Shield of Chance"); strcpy(temp_name[0], "Shields of Chance"); break; case 27: strcpy(temp_name[1], "Shield of the Earth"); strcpy(temp_name[0], "Shields of the Earth"); break; case 28: strcpy(temp_name[1], "Shield of the Heart"); strcpy(temp_name[0], "Shields of the Heart"); break; case 29: strcpy(temp_name[1], "Silver Shield"); strcpy(temp_name[0], "Silver Shields"); break; case 30: strcpy(temp_name[1], "Vigorous Shield"); strcpy(temp_name[0], "Vigorous Shields"); break; //end of shields, beginning of armour case 31: strcpy(temp_name[1], "Aluminum Suit"); strcpy(temp_name[0], "Aluminum Suits"); break; case 32: strcpy(temp_name[1], "Basher's Cloak"); strcpy(temp_name[0], "Basher's Cloaks"); break; case 33: strcpy(temp_name[1], "Bashmage Coat"); strcpy(temp_name[0], "Bashmage Coats"); break; case 34: strcpy(temp_name[1], "Battle Master's Mail"); strcpy(temp_name[0], "Battle Master's Mails"); break; case 35: strcpy(temp_name[1], "Chainmail"); strcpy(temp_name[0], "Chainmails"); break; case 36: strcpy(temp_name[1], "Cloak of Skill"); strcpy(temp_name[0], "Cloaks of Skill"); break; case 37: strcpy(temp_name[1], "Coat of All Trades"); strcpy(temp_name[0], "Coats of All Trades"); break; case 38: strcpy(temp_name[1], "Energy Mail"); strcpy(temp_name[0], "Energy Mails"); break; case 39: strcpy(temp_name[1], "Lead Vest"); strcpy(temp_name[0], "Lead Vests"); break; case 40: strcpy(temp_name[1], "Mail of Fate"); strcpy(temp_name[0], "Mails of Fate"); break; case 41: strcpy(temp_name[1], "Mana Coat"); strcpy(temp_name[0], "Mana Coats"); break; case 42: strcpy(temp_name[1], "Nimble Vest"); strcpy(temp_name[0], "Nimble Vests"); break; case 43: strcpy(temp_name[1], "Platemail"); strcpy(temp_name[0], "Platemails"); break; case 44: strcpy(temp_name[1], "Rune Cape"); strcpy(temp_name[0], "Rune Capes"); break; case 45: strcpy(temp_name[1], "Slicer Plate"); strcpy(temp_name[0], "Slicer Plates"); break; //end of armour, beginning of various items case 46: strcpy(temp_name[0], "Mana Flask"); strcpy(temp_name[1], "Mana Flasks"); break; case 47: strcpy(temp_name[0], "Mana Orb"); strcpy(temp_name[1], "Mana Orbs"); break; case 48: strcpy(temp_name[0], "Health Flask"); strcpy(temp_name[1], "Health Flasks"); break; case 49: strcpy(temp_name[0], "Health Orb"); strcpy(temp_name[1], "Health Orbs"); break; case 50: strcpy(temp_name[0], "Gold"); strcpy(temp_name[1], "Gold"); break; //end of various items } if (one_item) return temp_name[1]; else return temp_name[0]; } //NPC information structure struct NPC { char name[15]; char job[10]; char item[10][10]; int price[10]; char message[7][30]; }; //NPC instances: NPC Rolan; class Enemy { private: int number; char name[21]; char race[7]; char character_class[15]; int max_mana, max_hp; int mana, hp; float magical_success_rate; float to_hit; float evasion_rate; float battle_interval; int damage_estimate[2]; int item_reward[22]; int experience_reward; int damage; bool poisoned; void Attack(); void CastSpell(int); public: void SetStats(int); void SetMana(int); void SetHP(int); char *GetName(); char *GetRace(); char *GetCharacterClass(); int GetMaxMana(); int GetMaxHP(); int GetMana(); int GetHP(); float GetMagicalSuccessRate(); float GetToHit(); float GetEvasionRate(); float GetBattleInterval(); void TakeTurn(); }; //logic behind enemy attacks void Enemy::Attack() { } //logic behind enemy spellcasting void Enemy::CastSpell(int spell_num) { switch(spell_num) { case 1: //torture mana -= 10; player.SetHP(player.GetHP() - 25); cout << "The enemy casts 'torture'!"; break; case 2: //drain mana -= 25; player.SetHP(player.GetHP() - 15); hp += 15; if(hp > max_hp) hp = max_hp; cout << "The enemy casts 'drain'!"; break; case 3: //plague mana -= 35; player.SetHP((int)(player.GetHP() - 0.35 * player.GetHP())); cout << "The enemy casts 'plague'!"; break; case 4: //replenish mana -=40; mana = max_mana; cout << "The enemy casts 'replenish'!"; break; case 5: //sizzle mana -= 20; player.SetHP(player.GetHP() - 50); cout << "The enemy casts 'sizzle'!"; break; case 6: //self-destruct mana -= 20; hp = 0; player.SetHP(player.GetHP() - 100); cout << "The enemy casts 'self-destruct'!"; break; case 7: //chaos stab player.SetHP(player.GetHP() - 85); cout << "The enemy uses the 'chaos stab' attack"; break; case 8: //fireball mana -= 50; player.SetHP(player.GetHP() - 185); cout << "The enemy engulfs you in a fireball!"; break; case 9: //meditate hp += 50; mana += 50; cout << "The enemy meditates!"; break; case 10: //curse mana -= 60; player.SetHP(1); cout << "The enemy curses you!"; break; case 11: //howl to the moon mana -= 50; damage_estimate[0] = damage_estimate[0] * 2; damage_estimate[1] = damage_estimate[1] * 2; cout << "The enemy howls to the moon, increasing its physical strenght!"; break; case 12: //thunder crash mana -= 25; player.SetHP(player.GetHP() - 350); cout << "The enemy casts 'thunder crash', and hits you with lightning."; break; case 13: //poison mana -= 20; player.SetPoisoned(true); cout << "The enemy casts 'poison', and you become poisoned."; break; case 14: //heal with time hp += 50; cout << "Over time, the enemy heals itself naturally."; break; case 15: //worm feast mana -= 50; player.SetHP((int)(player.GetHP() * 0.45)); cout << "The enemy feeds you to the worms!"; break; case 16: //regenerate hp = max_hp; cout << "The enemy fully regenerates itself."; break; case 17: //dragon's breath mana -= 1000; player.SetHP(10); cout << "The enemy curses you with its breath."; break; case 18: //dragon's death mana -= 1; player.SetHP(0); cout << "The enemy blows up your face with its breath."; break; } } void Enemy::SetStats(int enemy_num) { number = enemy_num; switch(number) { case 1: strcpy(name, "Slick Snake"); strcpy(race, "Snake"); strcpy(character_class, "Fighter"); max_mana = 0; max_hp = 30; magical_success_rate = 0; to_hit = 40; evasion_rate = 0; battle_interval = 900; damage_estimate[0] = 5; damage_estimate[1] = 8; experience_reward = 3; break; case 2: strcpy(name, "Flaming Rat"); strcpy(race, "Rat"); strcpy(character_class, "Fighter"); max_mana = 0; max_hp = 23; magical_success_rate = 0; to_hit = 40; evasion_rate = 0; battle_interval = 1000; damage_estimate[0] = 10; damage_estimate[1] = 12; experience_reward = 6; break; case 3: strcpy(name, "Corrupted Follower"); strcpy(race, "Human"); strcpy(character_class, "Soldier"); max_mana = 0; max_hp = 30; magical_success_rate = 0; to_hit = 55; evasion_rate = 2; battle_interval = 980; damage_estimate[0] = 9; damage_estimate[1] = 11; experience_reward = 10; break; case 4: strcpy(name, "Painmage"); strcpy(race, "Human"); strcpy(character_class, "Elemental Mage"); max_mana = 10; max_hp = 30; magical_success_rate = 50; to_hit = 40; evasion_rate = 0; battle_interval = 1000; damage_estimate[0] = 5; damage_estimate[1] = 10; experience_reward = 14; break; case 5: strcpy(name, "Deadly Dancer"); strcpy(race, "Faerie"); strcpy(character_class, "Gladiator"); max_mana = 0; max_hp = 80; magical_success_rate = 0; to_hit = 90; evasion_rate = 10; battle_interval = 850; damage_estimate[0] = 4; damage_estimate[1] = 10; experience_reward = 20; break; case 6: strcpy(name, "Mindless Vampire"); strcpy(race, "Vampire"); strcpy(character_class, "Bounty Hunter"); max_mana = 50; max_hp = 50; magical_success_rate = 75; to_hit = 68; evasion_rate = 0; battle_interval = 1000; damage_estimate[0] = 9; damage_estimate[1] = 18; experience_reward = 27; break; case 7: strcpy(name, "Plague Lord"); strcpy(race, "Zombie"); strcpy(character_class, "Mummy"); max_mana = 70; max_hp = 37; magical_success_rate = 60; to_hit = 75; evasion_rate = 2; battle_interval = 985; damage_estimate[0] = 12; damage_estimate[1] = 24; experience_reward = 39; break; case 8: strcpy(name, "Warrior of the Sheath"); strcpy(race, "Hillfolk"); strcpy(character_class, "Warrior"); max_mana = 0; max_hp = 50; magical_success_rate = 0; to_hit = 95; evasion_rate = 0; battle_interval = 800; damage_estimate[0] = 25; damage_estimate[1] = 30; experience_reward = 65; break; case 9: strcpy(name, "Thunder Mage"); strcpy(race, "Human"); strcpy(character_class, "Elemental Mage"); max_mana = 100; max_hp = 48; magical_success_rate = 92; to_hit = 40; evasion_rate = 0; battle_interval = 820; damage_estimate[0] = 10; damage_estimate[1] = 20; experience_reward = 80; break; case 10: strcpy(name, "Rock Tunneler"); strcpy(race, "Mole"); strcpy(character_class, "Fighter"); max_mana = 20; max_hp = 130; magical_success_rate = 50; to_hit = 75; evasion_rate = 0; battle_interval = 900; damage_estimate[0] = 30; damage_estimate[1] = 40; experience_reward = 120; break; case 11: strcpy(name, "Chaos Knight"); strcpy(race, "Human"); strcpy(character_class, "Knight"); max_mana = 0; max_hp = 150; magical_success_rate = 0; to_hit = 50; evasion_rate = 0; battle_interval = 925; damage_estimate[0] = 35; damage_estimate[1] = 50; experience_reward = 165; break; case 12: strcpy(name, "Power Mage"); strcpy(race, "Human"); strcpy(character_class, "DarkMage"); max_mana = 150; max_hp = 100; magical_success_rate = 65; to_hit = 42; evasion_rate = 0; battle_interval = 875; damage_estimate[0] = 5; damage_estimate[1] = 30; experience_reward = 200; break; case 13: strcpy(name, "Shadow Being"); strcpy(race, "Hologram"); strcpy(character_class, "BloodSpirit"); max_mana = 120; max_hp = 220; magical_success_rate = 77; to_hit = 66; evasion_rate = 30; battle_interval = 800; damage_estimate[0] = 50; damage_estimate[1] = 75; experience_reward = 400; break; case 14: strcpy(name, "DarkWolf"); strcpy(race, "Werewolf"); strcpy(character_class, "Sentinel"); max_mana = 100; max_hp = 310; magical_success_rate = 100; to_hit = 80; evasion_rate = 0; battle_interval = 700; damage_estimate[0] = 50; damage_estimate[1] = 75; experience_reward = 400; break; case 15: strcpy(name, "Scurrying Iguana"); strcpy(race, "Lizard"); strcpy(character_class, "Fighter"); max_mana = 0; max_hp = 350; magical_success_rate = 0; to_hit = 84; evasion_rate = 20; battle_interval = 1000; damage_estimate[0] = 50; damage_estimate[1] = 100; experience_reward = 450; break; case 16: strcpy(name, "Eroding Dead One"); strcpy(race, "Dead Human"); strcpy(character_class, "Warrior"); max_mana = 0; max_hp = 650; magical_success_rate = 0; to_hit = 100; evasion_rate = 0; battle_interval = 800; damage_estimate[0] = 60; damage_estimate[1] = 150; experience_reward = 650; break; case 17: strcpy(name, "Mage of Invisibility"); strcpy(race, "Human"); strcpy(character_class, "Mage"); max_mana = 100; max_hp = 600; magical_success_rate = 94; to_hit = 79; evasion_rate = 15; battle_interval = 550; damage_estimate[0] = 50; damage_estimate[1] = 105; experience_reward = 800; break; case 18: strcpy(name, "Slugzard"); strcpy(race, "Slug"); strcpy(character_class, "Wizard"); max_mana = 20; max_hp = 750; magical_success_rate = 96; to_hit = 88; evasion_rate = 0; battle_interval = 580; damage_estimate[0] = 68; damage_estimate[1] = 122; experience_reward = 1000; break; case 19: strcpy(name, "Knight of Good Health"); strcpy(race, "Human"); strcpy(character_class, "Knight"); max_mana = 0; max_hp = 1000; magical_success_rate = 0; to_hit = 90; evasion_rate = 10; battle_interval = 600; damage_estimate[0] = 70; damage_estimate[1] = 130; experience_reward = 1200; break; case 20: strcpy(name, "Wraith of Pain"); strcpy(race, "Apparition"); strcpy(character_class, "Warrior"); max_mana = 120; max_hp = 1350; magical_success_rate = 80; to_hit = 80; evasion_rate = 30; battle_interval = 580; damage_estimate[0] = 80; damage_estimate[1] = 120; experience_reward = 1500; break; //bosses case 21: strcpy(name, "Beast Lord"); strcpy(race, "Beast"); strcpy(character_class, "Martial Artist"); max_mana = 0; max_hp = 80; magical_success_rate = 0; to_hit = 80; evasion_rate = 0; battle_interval = 750; damage_estimate[0] = 15; damage_estimate[1] = 20; experience_reward = 15; break; case 22: strcpy(name, "Cloaked Plaguemaster"); strcpy(race, "Zombie"); strcpy(character_class, "Insect Mage"); max_mana = 200; max_hp = 155; magical_success_rate = 65; to_hit = 83; evasion_rate = 7; battle_interval = 800; damage_estimate[0] = 25; damage_estimate[1] = 35; experience_reward = 75; case 23: strcpy(name, "Steel Juggernaut"); strcpy(race, "Machine"); strcpy(character_class, "Fighter"); max_mana = 0; max_hp = 100; magical_success_rate = 0; to_hit = 75; evasion_rate = 5; battle_interval = 1200; damage_estimate[0] = 28; damage_estimate[1] = 40; experience_reward = 675; case 24: strcpy(name, "Blue Dragon"); strcpy(race, "Dragon"); strcpy(character_class, "Warrior"); max_mana = 1000; max_hp = 4000; magical_success_rate = 50; to_hit = 99; evasion_rate = 10; battle_interval = 350; damage_estimate[0] = 150; damage_estimate[1] = 250; experience_reward = 5000; case 25: strcpy(name, "Apoco Dragon"); strcpy(race, "Greater-Dragon"); strcpy(character_class, "FlameMaster"); max_mana = 1; max_hp = 6000; magical_success_rate = 70; to_hit = 90; evasion_rate = 10; battle_interval = 350; damage_estimate[0] = 250; damage_estimate[1] = 400; experience_reward = 15000; } } void Enemy::SetMana(int g_mana) { mana = g_mana; } void Enemy::SetHP(int g_hp) { hp = g_hp; } char *Enemy::GetName() { return name; } char *Enemy::GetRace() { return race; } char *Enemy::GetCharacterClass() { return character_class; } int Enemy::GetMaxMana() { return max_mana; } int Enemy::GetMaxHP() { return max_hp; } int Enemy::GetMana() { return mana; } int Enemy::GetHP() { return hp; } float Enemy::GetMagicalSuccessRate() { return magical_success_rate; } float Enemy::GetToHit() { return to_hit; } float Enemy::GetEvasionRate() { return evasion_rate; } float Enemy::GetBattleInterval() { return battle_interval; } //logic behind enemy actions void Enemy::TakeTurn() { switch(number) { case 1: //slick snake Attack(); break; case 2: //flaming rat Attack(); break; case 3: //corrupted follower Attack(); break; case 4: //painmage if (mana == 10) CastSpell(1); //cast "torture" else Attack(); break; case 5: //deadly dancer Attack(); break; case 6: //mindless vampire if (mana >= 25) CastSpell(2); //cast "drain" else Attack(); break; case 7: //plague lord if ((mana >= 35) && ((int)(player.GetHP() * 0.3) >= 18)) CastSpell(3); //cast "plague" else Attack(); break; case 8: //warrior of the sheath Attack(); break; case 9: //thunder mage if ((mana >= 60) && (hp < 24)) CastSpell(4); //cast "replenish" else if (mana >= 20) CastSpell(5); //cast "sizzle" else Attack(); break; case 10: //rock tunneler if (hp <= 18) CastSpell(6); //cast "self-destruct" else Attack(); break; case 11: //chaos knight CastSpell(7); //use "chaos stab" break; case 12: //power mage if (hp >= 50 && mana >= 50) CastSpell(8); //cast "fireball" else CastSpell(9); //cast "meditate" break; case 13: //shadow being if ((mana >= 60) && (player.GetHP() > 1)) CastSpell(10); //cast "curse" else Attack(); break; case 14: //darkwolf if (mana >= 50) CastSpell(11); //howl to the moon else Attack(); break; case 15: //scurrying iguana Attack(); if ((evasion_rate + 5) < 100) evasion_rate += 5; break; case 16: //eroding dead one Attack(); if ((to_hit - 5) > 10) to_hit -= 5; if ((damage_estimate[0] - 5) > 10) damage_estimate[0] -= 5; if ((damage_estimate[1] - 5) > 10) damage_estimate[1] -= 5; break; case 17: //mage of invisibility if (mana >= 25) CastSpell(12); //cast "thunder crash" else Attack(); if ((evasion_rate + 5) <= 80) evasion_rate += 5; break; case 18: //slugzard if (mana == 20) CastSpell(13); //cast "poison" else Attack(); break; case 19: //night of good health Attack(); CastSpell(14); //cast "heal with time" break; case 20: //wraith of pain if ((player.GetHP() > 80) && (mana >= 60)) CastSpell(10); //cast "curse"; else Attack(); break; //bosses case 21: //beast lord Attack(); break; case 22: //cloaked plaguemaster if ((mana >= 50) && (player.GetHP() > (player.GetMaxHP() * 0.45))) CastSpell(15); //cast "worm feast" else Attack(); break; case 23: //steel juggernaut Attack(); CastSpell(16); //cast "regenerate" break; case 24: //blue dragon if (mana == 1000) CastSpell(17); //cast "dragon's breath" else Attack(); break; case 25: //apoco dragon if (mana == 1) CastSpell(18); //case "dragon's death" else Attack(); break; } } //function declarations void Story(); void CharacterMenu(); char CharacterResults(); void GameMenu(); void GameLoop(); void ShowLocationInfo(int, int, int); void ShowPlayerInfo(); void ShowInventory(); void ViewLocation(int, int, int); void MovePlayer(char); bool Battle(int); void PlayerTakeTurn(); void BattleStats(Enemy); //end of function declarations //game's entry point void main() { char choice; bool done; int count; cout << "Quest of the Flame\n\n" << "What would you like to do?\n\n"; cout << "1. New Game\n" << "2. Resume Game\n" << "3. Exit\n\n"; do { done = true; cout << flush; choice = getch(); switch(choice) { case '1': Story(); break; case '2': cout << "Not yet available\n\n"; cout << "Press any key to reset..."; cout << flush; getch(); Locate(0,8); for (count = 1; count <= 240; ++count) cout << " "; Locate(0,8); done = false; break; case '3': Cls(); break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to reset..."; cout << flush; getch(); done = false; Locate(0,8); for (count = 1; count <= 240; ++count) cout << " "; Locate(0,8); done = false; break; } } while (!done); cout << "Press any key to exit..."; cout << flush; getch(); } //displays the game's story void Story() { Cls(); cout << "Story:\n\n" << "Welcome to the land of Relourin, young warrior. You have been selected by the\n" << "King himself for this mission.\n\n" << "This land is in grave danger. Something has emerged into the depths of the\n" << "Great Volcano. Many strange things have been happening. Strange unfriendly\n" << "creatures have been roaming the countryside, looking for a fight. The local\n" << "villages have been sabotaged. There are far too many of them for us to ward\n" << "off without you. You are our only hope.\n\n" << "Leave with haste, and rid this land of evil before it's too late.\n\n" << "Press any key to continue..."; cout << flush; getch(); CharacterMenu(); Cls(); } //menu for allowing the user to select a character void CharacterMenu() { char name[21]; bool done; char result; char choice; int counter; do { Cls(); cout << "What is your name?\n"; cin.getline (name, 21); player.SetName(name); Cls(); cout << "Please choose a race for your character:\n\n"; cout << "1. Human: A strong physical race, in offence and defence.\n\n"; cout << "2. Goblin: Another physical race, with a powerful attack, but little grasp of" << "\n magic.\n\n"; cout << "3. Elf: A less physical race, with its roots in magic.\n\n"; cout << "4. Faerie: A very agile race.\n\n"; cout << "5. Dragon: The most well-rounded of all races.\n\n"; for (int count = 0; count <= 49; count++) player.SetInventory(count, 0); do { done = true; cout << flush; choice = getch(); switch(choice) { case '1': player.SetRace("Human"); player.SetMagic(10); player.SetStrength(30); player.SetDefence(30); player.SetAgility(15); player.SetInventory(19,1); //circular shield player.SetEquipped(2, 5); player.SetInventory(34,1); //chainmail player.SetEquipped(3, 5); break; case '2': player.SetRace("Goblin"); player.SetMagic(5); player.SetStrength(40); player.SetDefence(30); player.SetAgility(10); player.SetInventory(23, 1); //piercing crest player.SetEquipped(2, 9); player.SetInventory(42, 1); //platemail player.SetEquipped(3, 13); break; case '3': player.SetRace("Elf"); player.SetMagic(45); player.SetStrength(15); player.SetDefence(10); player.SetAgility(15); player.SetInventory(24, 1); //shield of casting player.SetEquipped(2, 10); player.SetInventory(40, 1); //mana coat player.SetEquipped(3, 11); break; case '4': player.SetRace("Faerie"); player.SetMagic(25); player.SetStrength(5); player.SetDefence(20); player.SetAgility(35); player.SetInventory(22, 1); //parrying shield player.SetEquipped(2, 8); player.SetInventory(30, 1); //aluminum suit player.SetEquipped(3, 1); break; case '5': player.SetRace("Dragon"); player.SetMagic(20); player.SetStrength(20); player.SetDefence(25); player.SetAgility(20); player.SetInventory(28, 1); //silver shield player.SetEquipped(2, 14); player.SetInventory(36, 1); // coat of all trades player.SetEquipped(3, 7); break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); Locate(0,13); for (int count = 1; count <= 240; ++count) cout << " "; Locate(0,13); done = false; break; } } while (!done) ; Cls(); cout << "Please choose a class for your character:\n\n"; cout << "1. Chaos Mage: A sorceror class with powerful but sometimes suicidal spells.\n\n"; cout << "2. Thief: A nimble class that attacks with agility, and steals various things.\n\n"; cout << "3. Elemental Mage: A sorceror class that can control the elements.\n\n"; cout << "4. Ninja: A strong and agile physical class that uses martial arts spells.\n\n"; cout << "5. Gladiator: Another strong physical class that uses close-range weapons.\n\n"; cout << "6. Warlord: An agile class that uses long-range weapons.\n\n"; do { done = true; cout << flush; choice = getch(); switch(choice) { case '1': player.SetCharacterClass("Chaos Mage"); player.SetMagic(player.GetMagic() + 20); player.SetStrength(player.GetStrength() + 20); player.SetDefence(player.GetDefence() + 20); player.SetAgility(player.GetAgility() + 20); player.SetInventory(9, 1); //mana sword player.SetEquipped(1, 10); break; case '2': player.SetCharacterClass("Thief"); player.SetMagic(player.GetMagic() + 20); player.SetStrength(player.GetStrength() + 15); player.SetDefence(player.GetDefence() + 15); player.SetAgility(player.GetAgility() + 30); player.SetInventory(0, 1); //agile glove player.SetEquipped(1, 1); break; case '3': player.SetCharacterClass("Elemental Mage"); player.SetMagic(player.GetMagic() + 35); player.SetStrength(player.GetStrength() + 10); player.SetDefence(player.GetDefence() + 15); player.SetAgility(player.GetAgility() + 20); player.SetInventory(8, 1); //magi-spike player.SetEquipped(1, 9); break; case '4': player.SetCharacterClass("Ninja"); player.SetMagic(player.GetMagic() + 15); player.SetStrength(player.GetStrength() + 30); player.SetDefence(player.GetDefence() + 10); player.SetAgility(player.GetAgility() + 25); player.SetInventory(13, 1); //swift crest player.SetEquipped(1, 14); break; case '5': player.SetCharacterClass("Gladiator"); player.SetMagic(player.GetMagic() + 10); player.SetStrength(player.GetStrength() + 30); player.SetDefence(player.GetDefence() + 30); player.SetAgility(player.GetAgility() + 10); player.SetInventory(4, 1); //dueling blade player.SetEquipped(1, 5); break; case '6': player.SetCharacterClass("Warlord"); player.SetMagic(player.GetMagic() + 10); player.SetStrength(player.GetStrength() + 20); player.SetDefence(player.GetDefence() + 20); player.SetAgility(player.GetAgility() + 30); player.SetInventory(2, 1); player.SetEquipped(1, 3); break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); Locate(0,14); for (int count = 1; count <= 240; ++count) cout << " "; Locate(0,14); done = false; break; } } while (!done); player.SetLevel(0); player.SetExperience(0); for (counter = 0; counter <= 19; counter++) player.SetSpellLevel(counter, 0); player.SetMaxMana(2 * player.GetMagic()); player.SetMana(player.GetMaxMana()); player.SetMaxHP(2 * player.GetDefence()); player.SetHP(player.GetMaxHP()); player.SetMagicalSuccessRate(-0.01 * (player.GetMagic() - 100) * (player.GetMagic() - 100) + 100); player.SetToHit(-0.01 * (player.GetAgility() - 100) * (player.GetAgility() - 100) + 100); player.SetEscapeRate((-0.01 * (player.GetStrength() - 100) * (player.GetStrength() - 100) + -0.01 * (player.GetAgility() - 100) * (player.GetAgility() - 100) + 200 ) / 2); player.SetEvasionRate((float)player.GetAgility() / 10.0f); player.SetBattleInterval(1000.0f - 0.85 * (float)player.GetAgility()); switch(player.GetRace()[0]) { case 'H': break; case 'G': break; case 'E': break; case 'F': break; case 'D': break; } switch(player.GetCharacterClass()[0]) { case 'C': break; case 'T': break; case 'E': break; case 'N': break; case 'G': break; case 'W': break; } result = CharacterResults(); if (result == 'n' || result == 'N') { Cls(); cout << "You may now choose again, press any key..."; cout << flush; getch(); done = false; } } while (!done); GameLoop(); } //results of character choices to be reviewed char CharacterResults() { char yn; bool done = false; Cls(); cout << "Name: " << player.GetName(); cout << "\nRace: " << player.GetRace(); cout << "\nClass: " << player.GetCharacterClass(); cout << "\n\nMagic: " << player.GetMagic(); cout << "\nStrength: " << player.GetStrength(); cout << "\nDefence: " << player.GetDefence(); cout << "\nAgility: " << player.GetAgility(); cout << "\n\nMaximum Mana: " << player.GetMaxMana(); cout << "\nMaximum HP: " << player.GetMaxHP(); cout << "\n\nMagical Success Rate: " << player.GetMagicalSuccessRate() << "%"; cout << "\nTo Hit: " << player.GetToHit() << "%"; cout << "\nEscape Rate: " << player.GetEscapeRate() << "%"; cout << "\nEvasion Rate: " << player.GetEvasionRate() << "%"; cout << "\nBattle Interval: " << player.GetBattleInterval(); cout << "\n\nWould you like to keep these stats and continue?(y/n)"; do { cout << flush; yn = getch(); if (yn != 'y' && yn != 'Y' && yn != 'n' && yn != 'N') { cout << "\n\nNot a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); Locate(0,19); for (int count = 1; count <= 320; ++count) cout << " "; Locate(53,18); } else done = true; } while (!done); return yn; } //show the buttons that correspond with character actions void GameMenu() { Cls(); cout << "General Actions:\n\n"; cout << "L: Look Around\n"; cout << "I: View Inventory\n"; cout << "C: View Character Information\n"; cout << "U: Look North\n"; cout << "J: Look South\n"; cout << "H: Look West\n"; cout << "K: Look East\n"; cout << "8: Move North\n"; cout << "5: Move South\n"; cout << "4: Move West\n"; cout << "6: Move East\n"; cout << "X: Exit Game\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); } //main game loop void GameLoop() { char choice; bool done = false; int location[3] = {1, 1, 1}; ShowLocationInfo(location[0], location[1], location[2]); do { Cls(); cout << "What would you like to do? To see a menu of commands, press M.\n"; cout << flush; choice = getch(); switch(choice) { case 'm': case 'M': GameMenu(); break; case 'l': case 'L': ShowLocationInfo(location[0], location[1], location[2]); break; case 'c': case 'C': Cls(); ShowPlayerInfo(); break; case 'i': case 'I': ShowInventory(); break; case 'x': case 'X': done = true; break; } if (player.GetHP() <= 0) done = true; }while (!done); } //show info regarding character location void ShowLocationInfo(int level, int xpos, int ypos) { Cls(); switch(level) { case 1: switch(xpos) { case 1: switch(ypos) { case 1: cout << "You are at the south-west corner of Rannigan, your hometown."; break; case 2: case 3: case 4: cout << "You are at the western shore of Rannigan, your hometown."; break; case 5: cout << "You are at the north-west corner of Rannigan, your hometown."; break; } break; case 2: switch(ypos) { case 1: cout << "You are at the southern shore of Rannigan, your hometown."; break; case 2: cout << "You are at the shop of Janur, the Mage."; break; } break; } break; } cout << "\n\nPress any key to continue..."; cout << flush; getch(); } //show your character's stats void ShowPlayerInfo() { cout << "Name: " << player.GetName(); cout << "\nRace: " << player.GetRace(); cout << "\nClass: " << player.GetCharacterClass(); cout << "\n\nMagic: " << player.GetMagic(); cout << "\nStrength: " << player.GetStrength(); cout << "\nDefence: " << player.GetDefence(); cout << "\nAgility: " << player.GetAgility(); cout << "\n\nMana: " << player.GetMana() << " / " << player.GetMaxMana(); cout << "\nHP: " << player.GetHP() << " / " << player.GetMaxHP(); cout << "\n\nMagical Success Rate: " << player.GetMagicalSuccessRate() << "%"; cout << "\nTo Hit: " << player.GetToHit() << "%"; cout << "\nEscape Rate: " << player.GetEscapeRate() << "%"; cout << "\nEvasion Rate: " << player.GetEvasionRate() << "%"; cout << "\nBattle Interval: " << player.GetBattleInterval(); cout << "\n\nLevel: " << player.GetLevel(); cout << "\nExperience: " << player.GetExperience() << " experience point"; if (player.GetExperience() != 1) cout << "s"; cout << "\nNext Level: " << (player.GetLevel() + 1) * (player.GetLevel() + 1) - player.GetExperience() << " experience point"; if (player.GetLevel() != 0) cout << "s"; cout << " to level " << player.GetLevel() + 1; cout << "\nGold: " << player.GetInventory(49) << " piece"; if (player.GetInventory(49) != 1) cout << "s"; cout << "\n\nPress any key to continue..."; cout << flush; getch(); } //show your character's inventory void ShowInventory() { Cls(); Item void_item; int master_num = 1; for (int item_type = 1; item_type <= 3; ++item_type) { for (int item_num = 1; item_num <= 15; ++item_num) { void_item.SetStats(item_type, item_num); ++master_num; cout << player.GetInventory(master_num) << " "; cout << void_item.ConvertItemName(item_type, item_num, (player.GetInventory(master_num) == 1)); } } cout << "\n\nPress any key to continue..."; cout << flush; getch(); } //show a map location void ViewLocation(int x, int y, int z) { } //move in a given direction void MovePlayer(char direction) { } //loop for a battle bool Battle(int enemy_num) { bool alive, enemy_alive = true; int interval_counter, enemy_interval_counter = 0; Item current_weapon; current_weapon.SetStats(1, player.GetEquipped(1)); Item current_shield; current_shield.SetStats(2, player.GetEquipped(2)); Item current_armour; current_armour.SetStats(3, player.GetEquipped(3)); Enemy current_enemy; current_enemy.SetHP(current_enemy.GetMaxHP()); current_enemy.SetMana(current_enemy.GetMaxMana()); while(alive && enemy_alive) { ++interval_counter; ++enemy_interval_counter; if (interval_counter >= player.GetBattleInterval()) { interval_counter -= player.GetBattleInterval(); PlayerTakeTurn(); } if (current_enemy.GetHP() > 0) { if (enemy_interval_counter >= current_enemy.GetBattleInterval()) { enemy_interval_counter -= current_enemy.GetBattleInterval(); current_enemy.TakeTurn(); } } if (player.GetHP() < 0) alive = false; if (current_enemy.GetHP() < 0) enemy_alive = false; } return alive; } //option menu for the player's turn void PlayerTakeTurn() { Cls(); char input; bool done = false; while (done == false) { cout << "What would you like to do?\n\n"; cout << "A: attack\n"; cout << "C: cast a spell\n"; cout << "E: equip items\n"; cout << "R: run away\n"; cout << "S: view stats\n\n"; cout << flush; input = getch(); switch(input) { case 'a': case 'A': done = true; Cls(); break; case 'c': case 'C': done = true; Cls(); break; case 'e': case 'E': break; case 'r': case 'R': done = true; break; case 's': case 'S': break; } } } //show the stats of the character and the enemy while in battle void BattleStats(Enemy current_enemy) { Cls(); cout << "Battle Statistics: Player Stats\n\n"; ShowPlayerInfo(); cout << "Battle Statistics: Enemy Stats\n\n"; cout << "Name: " << current_enemy.GetName(); cout << "\nRace: " << current_enemy.GetRace(); cout << "\nClass: " << current_enemy.GetCharacterClass(); cout << "\n\nMana: " << current_enemy.GetMana() << " / " << current_enemy.GetMaxMana(); cout << "\nHP: " << current_enemy.GetHP() << " / " << current_enemy.GetMaxHP(); cout << "\n\nMagical Success Rate: " << current_enemy.GetMagicalSuccessRate() << "%"; cout << "\nTo Hit: " << current_enemy.GetToHit() << "%"; cout << "\nEvasion Rate: " << current_enemy.GetEvasionRate() << "%"; cout << "\nBattle Interval: " << current_enemy.GetBattleInterval(); cout << "\n\nPress any key to continue..."; cout << flush; getch(); Cls(); }