leonsandcastle

Cupid Main file

Apr 21st, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 40.78 KB | None | 0 0
  1.  
  2. #!/usr/bin/env ruby
  3. #Initialize all Classes
  4. #To start, we will create the classes for in game characters we can interact with
  5. require 'vector2d'
  6. class Sentient
  7.   attr_accessor :my_name, :type, :stride, :x_pos, :y_pos, :region_name, :health_max
  8.   attr_accessor :health_cur, :attack, :exp_gain
  9.   def initialize(type, my_name)
  10.      
  11.   end
  12. end
  13.  
  14. #Class for player
  15. class Human
  16.   attr_accessor :my_name, :type, :location, :x_pos, :y_pos, :stride
  17.   attr_accessor :fatigue, :level, :cur_exp, :exp_to_next_lvl, :stats, :inventory, :journal
  18.   def initialize
  19.     @stats = Stats.new
  20.     @inventory = Inventory.new
  21.     @journal = Journal.new
  22.   end
  23. end
  24.  
  25. class Stats
  26.     attr_accessor :strength, :defense, :agility, :vitality, :stamina, :health_max, :health_cur, :attack
  27.     def initialize
  28.       @health_cur = health_cur
  29.     end
  30.   end
  31.  
  32. ## End for entities
  33. #--- Establish Scenes
  34. class Scenes
  35.   attr_accessor :scene_name, :region_name, :enemy_types, :size_total, :size_water, :size_land, :depth_water
  36.   attr_accessor :height_land, :offset_land, :terrain, :description, :seed, :weather, :climate
  37.   def initialize
  38. end
  39. end
  40.  
  41.  
  42. #--- Eastablish BattleScene
  43. class BattleScene
  44.   attr_accessor :number_enemies, :turn, :enemy_type, :enemy_health_max, :enemy_health_cur, :enemy_attack, :exp_gain
  45. end
  46.  
  47. #--- Establish current scene
  48. class Current_Scene < Scenes
  49.   attr_accessor :current1_scene, :region_name, :x_pos, :y_pos, :object
  50.   def initialize
  51.   end
  52.   def object
  53.     @object = Obj.new
  54.   end
  55. end
  56.  
  57. #--- Establish Inventory
  58. ### Inventory
  59. class Inventory
  60.   attr_accessor :name, :quantity, :qualifier, :id, :exp_set
  61.   def initialize
  62.     @qualifier = Items.new
  63.   end
  64. end
  65.  
  66.  
  67.  
  68. #--- Establish In Game Interactables
  69. ### Items
  70. class Items
  71.   attr_accessor :item_name, :attack_bonus, :health_bonus, :health_gain, :fatigue_sub, :weight, :identified
  72. end
  73.  
  74. #--- Declare Scenes
  75. #361 Total Scenes for the world
  76. # for climate
  77. # 1 - desert, 2 - rainforest, 3 - tundra, 4 - ice land, 5 - temperate
  78. #for weather
  79. # 1 - rain, 2 - snow, 3 - thunderstorm, 4 - blizzard, 5 - windy, 6 - cloudy, 7 - sunny, 8 - raining fire
  80. Scene1 = Scenes.new
  81. Scene1.scene_name = "Scene: 1"
  82. Scene1.region_name = "Northern Sea of Monsters"
  83. Scene1.enemy_types = "Sea Dragon"
  84. Scene1.seed = 5
  85. Scene1.size_total = 267 * 267
  86. Scene1.size_water = 267 * 267
  87. Scene1.size_land = 0
  88. Scene1.depth_water = 167
  89. Scene1.height_land = 0
  90. Scene1.offset_land = 0
  91. Scene1.terrain = "Sea"
  92. Scene1.description = "To the East, West and North is more sea. To the South you see land."
  93. Scene1.climate = 4
  94. Scene1.weather = 7
  95.  
  96. Scene2 = Scenes.new
  97. Scene2.scene_name = "Scene: 2"
  98. Scene2.region_name = "Northern Sea of Monsters"
  99. Scene2.enemy_types = "Sea Farie Dragons"
  100. Scene2.seed = 7
  101. Scene2.size_total = 267 * 267
  102. Scene2.size_water = 267 * 267
  103. Scene2.size_land = 0
  104. Scene2.depth_water = 180
  105. Scene2.height_land = 0
  106. Scene2.offset_land = 0
  107. Scene2.terrain = "Sea"
  108. Scene2.description = "To the West and North is more sea. To the South you see a bay, to the East you see land."
  109. Scene2.climate = 4
  110. Scene2.weather = 7
  111.  
  112. Scene3 = Scenes.new
  113. Scene3.scene_name = "Scene: 3"
  114. Scene3.region_name = "Northern Sea of Monsters | The Chase Penensula"
  115. Scene3.enemy_types = "Razor Sea Dragons"
  116. Scene3.seed = 3
  117. Scene3.size_total = 267 * 267
  118. Scene3.size_water = 267 * 187
  119. Scene3.size_land = 216 * 120
  120. Scene3.height_land = 1.5
  121. Scene3.offset_land = 187
  122. Scene3.depth_water = 90
  123. Scene3.terrain = "Sea | Beech"
  124. Scene3.description = "To the south, there is a beech. To the North, East and West are endless Seas. The beech looks ominous..."
  125. Scene3.climate = 3
  126. Scene3.weather = 7
  127.  
  128. #Define Journal/History
  129. class Journal
  130.   attr_accessor :page
  131.   def initialize
  132.     @page = []
  133.   end
  134. end
  135.  
  136.  
  137.  
  138.  
  139.  
  140. #--- Declare World Objects
  141. #--- Declare all world sentients
  142. Player = Human.new()
  143. Player.stride = 50
  144. Player.x_pos = 267/2
  145. Player.y_pos = 267/2
  146. Player.fatigue = 0
  147. Player.level = 0
  148. Player.cur_exp = 0
  149. Player.exp_to_next_lvl = 50
  150. Player.location = 1
  151. Player.inventory.name = []
  152. Player.inventory.qualifier = []
  153. 1000.times {Player.inventory.name << 0}
  154. count = 1
  155. 11.times do
  156.   Player.inventory.name[count] = 5
  157.   count += 1
  158. end
  159. #Set names of Inventory ids.
  160. Player.inventory.qualifier[1] = "Observation"
  161. Player.inventory.qualifier[2] = "Melee Combat"
  162. Player.inventory.qualifier[3] = "Defense"
  163. Player.inventory.qualifier[4] = "Crafting"
  164. Player.inventory.qualifier[5] = "Smithing"
  165. Player.inventory.qualifier[6] = "Alchemy"
  166. Player.inventory.qualifier[7] = "Communication"
  167. Player.inventory.qualifier[8] = "Magic"
  168. Player.inventory.qualifier[9] = "Ranged Combat"
  169. Player.inventory.qualifier[10] = "Spirituality"
  170. Player.inventory.qualifier[11] = "Unarmed Combat"
  171. #12 Obs exp, 13 Melee exp, 14 Def exp, 15 Craft exp, 16 Smit exp, 17 Alch exp, 18 com exp, 19 mag exp, 20, rang exp, 21 spirit exp, 22 unarm exp
  172. Player.inventory.qualifier[23] = "Look Around"
  173. Player.inventory.qualifier[24] = "Peer Into Soul"
  174. Player.inventory.qualifier[25] = "Read Thoughts"
  175. Player.inventory.qualifier[26] = "X-Ray Vision"
  176. Player.inventory.qualifier[27] = "Under Water Vision"
  177. Player.inventory.qualifier[28] = "Eagle Eyes"
  178. Player.inventory.qualifier[29] = "Star Charting"
  179. Player.inventory.qualifier[30] = "Fire-Eyes"
  180. Player.inventory.qualifier[31] = "Identify Objects"
  181. Player.inventory.qualifier[32] = "Observe a Sentient"
  182. Player.inventory.qualifier[33] = "Thrust"
  183. Player.inventory.qualifier[34] = "Slice"
  184. Player.inventory.qualifier[35] = "Smash"
  185. Player.inventory.qualifier[36] = "Hack"
  186. Player.inventory.qualifier[37] = "Jabb"
  187. Player.inventory.qualifier[38] = "Trapping"
  188. Player.inventory.qualifier[39] = "Naptha"
  189. Player.inventory.qualifier[40] = "Shield Attack"
  190. Player.inventory.qualifier[41] = "Chakra Attack"
  191. Player.inventory.qualifier[42] = "Place Holder"
  192.  
  193. Player.inventory.qualifier[200] = "Health Potion"
  194. Player.inventory.qualifier[201] = "Dragon Steak"
  195. Player.inventory.qualifier[202] = "White Fish"
  196.  
  197. def op_item(id, val)
  198. if id < 200
  199.   puts "Error: id is not an item."
  200. elsif id > 600
  201.   puts "Error: id is to large for an item."
  202. elsif Player.inventory.name[id.to_i] + val < 0
  203.   Player.inventory.name[id.to_i] = 0; return
  204. elsif Player.inventory.name[id.to_i] + val > 32
  205.   Player.inventory.name[id.to_i] = 32; return
  206. end
  207. Player.inventory.name[id.to_i] += val
  208. end
  209.  
  210. def skill_disp(id)
  211.   if id < 1
  212.     puts "Error: id is not a skill tree."
  213.   elsif id > 11
  214.     puts "Error: id is too high for a skill tree."
  215.   else
  216.     puts "#{id} - #{Player.inventory.qualifier[id]} level #{Player.inventory.name[id]}"
  217.   end
  218. end
  219.  
  220. def skillexp(id,val)
  221.   if id < 12
  222.     puts "Error: id is to low for a skill experience."
  223.   elsif id > 22
  224.     puts "Error: id is to high for a skill experience."
  225.   else
  226.     Player.inventory.name[id] += val; return
  227.     end
  228.    
  229.    
  230.   end
  231.  
  232.  
  233. Player.stats.agility = 10
  234. Player.stats.strength = 25
  235. Player.stats.attack = Player.stats.strength / 5
  236. Player.stats.stamina = 10
  237. Player.stats.vitality = (Player.stats.strength + Player.stats.stamina) * Player.stats.agility
  238. Player.stats.health_max = 50
  239. Player.stats.health_cur = 50
  240. Player.journal.page[1] = "\n Page 1:\n"
  241. count = 1
  242. 360.times do
  243.   count += 1
  244.   Player.journal.page[count] = "\n Page #{count}:\n"
  245. end
  246. Player.journal.page[361] = "\n Page 361:\n Skills Log\n"
  247. Player.journal.page[362] = "\n Page 362:\n Observation Skill Tree\n Description: Observation is key to knowing the world around you.\n The higher the level of Observation the greater skills can be utilized.\n"
  248. Player.journal.page[362] += "Specials:\n 1- Look Around\n * Unlocks at level 5 Observation.\n -(5-10) See the surroundings.\n -(11-20) See enemies without locations.\n -(21-30) Know enemy locations.\n -(31-40) Know locations of objects, -(41+) Know everything there is for your line of sight.\n 2- Peer Into Soul\n * unlocks at Observation level 21\n -50% chance of seeing intentions of a Sentient.\n 3- Read Thoughts\n * Unleashes the psychic within you. Unlocks at level 10.\n - x% chance of knowing the thoughts of a Sentient.\n 4- X-Ray Vision\n * Unlocks at Spirituality 10 and Observation 10.\n - x% chance of seeing through objects.\n 5- Underwater Vision\n * Unlocks at Observation 5.\n - 25% chance of finding objects while under water.\n 6- Eagle Eyes\n * Allows you to see into the surrounding locations/scenes without having to be there. Unlocks at Observation 41.\n 7- Star Charting\n * Allows you to learn the locations in the world based on the stars in the sky.\n 8- Fire-Eyes\n * unlocks at Observation 10 and after consuming a dragon brain.\n - (Observation * 1.5) + attack.\n 9- Identify Objects\n * 1% chance per Observation of identifying mysterious objects, consumption is 100% successful otherwise. Ulocks at Observation 5.\n 10- Observe a Sentient\n * Allows you to see greater detail of other beings.\n - 0-50 see what they look like. 51-99 see what they are doing."
  249. Player.journal.page[363] = "\n Page 363:\n Melee Combat Tree\n Description: Melee is improtant for combat with a weapon.\n The higher the level of your Melee Combat the more proficiency with a melee weapon you become.\n"
  250. Player.journal.page[363] += "Specials:\n 1- Thrust\n * Requires a sword or hammer. Unlocks at Melee Combat 10.\n - (melee_combat * (attack + buffer_atk) + thrust) / fatigue.\n 2- Slice\n * Requires a sword or knife. Unlocks at level 5.\n - (melee_combat * (attack + buffer_atk) + Slice_level) / (fatigue - agility).\n 3- Smash\n * Requires a hammer or sword. Unlocks at level 20.\n - (melee_combat * (attack * buffer_atk) - (fatigue - agility)) * (1+(Smash / 100)).\n 4- Hack\n * Unlocks at Melee Combat 30.\n - (levelm * (attack * buffer_atk * strength) - fatigue - agility)\n 5- Jabb\n * Unlocks at Melee Combat 25.\n - (melee_combat * (attack + buffer_atk * agility) - (fatigue - agility)).\n 6- Trapping\n * Unlocks at Melee Combat 15.\n - (agility + melee_combat) * (buffer_def).\n 7- Naptha\n * Unlocks with Fire-Eyes special.\n - (melee_combat * (buffer_atk + attack) * (agility * observation)) - fatigue\n 8- Shield Attack\n * Requires a shield. Unlocks at Melee Combat 7.\n - (melee combat + buffer_atk) * (attack - fatigue)\n 9- Chakra Attack\n * Requires Spirituality 10. Talismen or Runes boost effectiveness.\n - (melee_combat * spirituality) + (buffer_atk - fatigue)\n 10- What do you think should be here?"
  251.  
  252. def journal_load(val)
  253.   line_num = 0
  254.   Player.journal.page = Marshal.load File.read("#{val}.txt")
  255.   end
  256.  
  257.  
  258. def journal_save(val)
  259.   File.open("#{val}.txt", 'w') {|f| f.write(Marshal.dump(Player.journal.page))}
  260.   end
  261. Lakmi = Sentient.new('Demi-God Human', 'Lakmi')
  262. Lakmi.my_name = 'Lakmi'
  263. Lakmi.type = 'Human Demi-God'
  264. Lakmi.stride = 90
  265.  
  266. Sea_Dragon = Sentient.new('Sea Dragon', 'Enemy')
  267. Sea_Dragon.my_name = 'Enemy'
  268. Sea_Dragon.type = 'Sea Dragon'
  269. Sea_Dragon.stride = 70
  270. Sea_Dragon.region_name = 'Northern Sea of Monsters'
  271. Sea_Dragon.health_max = 25
  272. Sea_Dragon.health_cur = 25
  273. Sea_Dragon.attack = 4
  274. Sea_Dragon.exp_gain = 20
  275.  
  276. Sea_Farie_Dragon = Sentient.new('Sea Farie Dragon', 'Enemy')
  277. Sea_Farie_Dragon.my_name = 'Enemy'
  278. Sea_Farie_Dragon.type = 'Sea Farie Dragon'
  279. Sea_Farie_Dragon.stride = 10
  280. Sea_Farie_Dragon.region_name = 'Northern Sea of Monsters'
  281. Sea_Farie_Dragon.health_max = 15
  282. Sea_Farie_Dragon.health_cur = 15
  283. Sea_Farie_Dragon.attack = 3
  284. Sea_Farie_Dragon.exp_gain = 15
  285.  
  286. Razor_Sea_Dragon = Sentient.new('Razor Sea Dragon', 'Enemy')
  287. Razor_Sea_Dragon.my_name = 'Enemy'
  288. Razor_Sea_Dragon.type = 'Razor Sea Dragon'
  289. Razor_Sea_Dragon.stride = 20
  290. Razor_Sea_Dragon.region_name = 'Northern Sea of Monsters | Chase Penensula'
  291. Razor_Sea_Dragon.health_max = 30
  292. Razor_Sea_Dragon.health_cur = 30
  293. Razor_Sea_Dragon.attack = 7
  294. Razor_Sea_Dragon.exp_gain = 30
  295.  
  296. #--- Declare items
  297.  
  298. Potion = Items.new
  299. Potion.health_gain = 10
  300. Potion.attack_bonus = 5
  301. Potion.item_name = "Health Potion"
  302. Potion.weight = 1
  303.  
  304. Dragon_Steak = Items.new
  305. Dragon_Steak.fatigue_sub = 5
  306. Dragon_Steak.health_bonus = 10
  307. Dragon_Steak.item_name = "Dragon Steak"
  308. Dragon_Steak.weight = 1.5
  309.  
  310. White_Fish = Items.new
  311. White_Fish.fatigue_sub = 30
  312. White_Fish.health_gain = 5
  313. White_Fish.item_name = "White Fish"
  314. White_Fish.weight = 0.5
  315. White_Fish.identified = false
  316.  
  317. #File methods
  318. Load_Player = Array.new
  319. load_pl = false
  320. line_num = 0
  321.  
  322. #Methods for file function
  323.  
  324. def new_game(saver)
  325.   File.open("#{saver}-inv.txt", 'w') {|f| f.write(Marshal.dump(Player.inventory.name))}
  326.   File.open("#{saver}","a") do |line|
  327.     write_to = open(Player.my_name, 'w')
  328.   write_to.write(Player.my_name)
  329.           write_to.write("\n")
  330.           write_to.write(Player.type)
  331.           write_to.write("\n")
  332.           write_to.write(Player.location)
  333.           write_to.write("\n")
  334.           write_to.write(Player.x_pos)
  335.          write_to.write("\n")
  336.          write_to.write(Player.y_pos)
  337.           write_to.write("\n")
  338.          write_to.write(Player.exp_to_next_lvl)
  339.          write_to.write("\n")
  340.           write_to.write(Player.cur_exp)
  341.           write_to.write("\n")
  342.           write_to.write(Player.fatigue)
  343.           write_to.write("\n")
  344.           write_to.write(Player.stats.agility)
  345.           write_to.write("\n")
  346.           write_to.write(Player.stats.attack)
  347.           write_to.write("\n")
  348.           write_to.write(Player.stats.defense)
  349.           write_to.write("\n")
  350.           write_to.write(Player.stats.health_cur)
  351.           write_to.write("\n")
  352.           write_to.write(Player.stats.health_max)
  353.           write_to.write("\n")
  354.           write_to.write(Player.stats.vitality)
  355.           write_to.write("\n")
  356.           write_to.write(Player.level)
  357.           write_to.write("\n")
  358.   end
  359. end
  360.  
  361. def load_game(opener)
  362.   line_num = 0
  363.   Player.inventory.name = Marshal.load File.read("#{opener}-inv.txt")
  364.   File.open("#{opener}").each do |line|
  365.     line_num += 1
  366.     Load_Player[line_num] = line.chomp
  367.   end
  368.   Player.my_name = Load_Player[1]
  369.   Player.type = Load_Player[2]
  370.   Player.location = Load_Player[3].to_i
  371.   Player.x_pos = Load_Player[4].to_i
  372.   Player.y_pos = Load_Player[5].to_i
  373.   Player.exp_to_next_lvl = Load_Player[6].to_i
  374.   Player.cur_exp = Load_Player[7].to_i
  375.   Player.fatigue = Load_Player[8].to_i
  376.   Player.stats.agility = Load_Player[9].to_i
  377.   Player.stats.attack = Load_Player[10].to_i
  378.   Player.stats.defense = Load_Player[11].to_i
  379.   Player.stats.health_cur = Load_Player[12].to_i
  380.   Player.stats.health_max = Load_Player[13].to_i
  381.   Player.stats.vitality = Load_Player[14].to_i
  382.   Player.level = Load_Player[15].to_i
  383.   puts "#{Player.my_name}, we have been waiting for you..."
  384. end
  385.  
  386. #--- Menu
  387. puts "Hello, I am #{Lakmi.my_name}, a #{Lakmi.type}."
  388. # Get Player Name
  389. puts "What is your name adventurer?"
  390. Player.my_name = gets.chomp
  391. if File.exists?("#{Player.my_name}")
  392.   load_game(Player.my_name)
  393.   journal_load("Journal-#{Player.my_name}")
  394. else
  395.    puts "#{Player.my_name}, where do you hail from?"
  396.   Player.type = gets.chomp
  397.   new_game(Player.my_name)
  398.  
  399.            puts "It must be lonely coming all the way from #{Player.type} to Velsaron..."
  400.  puts "Here, take this... The planet of Velsaron is so dastardly... These clothes will keep you warm..."
  401.  puts "Starter Clothing added to inventory!"
  402. end
  403.  
  404. #check to see if that human already has a file saved.  
  405.  
  406.  
  407. sleep 4
  408. system("cls")
  409.  
  410. #Game
  411. Scene = Player.location
  412. end_game = false
  413. input1 = ""
  414. Right_Now = Current_Scene.new
  415. options = ""
  416. battle_end = false
  417. item_find = 0
  418. item_select = ""
  419. item_find_ident = ""
  420. Battle = BattleScene.new
  421. new_place = true
  422. terrain_mult = 0
  423. sleep_on = false
  424. ### set up inventory
  425. total_value = 0
  426.  
  427.  
  428. while end_game == false
  429.  
  430.  
  431.       if Player.location == 1 && new_place == true
  432.      Right_Now.current1_scene = "#{Player.location} Scene"
  433.      Right_Now.region_name = Scene1.region_name
  434.       Right_Now.seed = rand(Scene1.seed)
  435.       Right_Now.enemy_types = Scene1.enemy_types
  436.       Sea_Dragon.x_pos = rand(267)
  437.       Sea_Dragon.y_pos = rand(267)
  438.       Right_Now.x_pos = Sea_Dragon.x_pos
  439.       Right_Now.y_pos = Sea_Dragon.y_pos
  440.       Right_Now.description = Scene1.description
  441.       Right_Now.depth_water = Scene1.depth_water
  442.       Right_Now.climate = Scene1.climate
  443.       Right_Now.weather = Scene1.weather
  444.       terrain_mult = 0.56
  445.       new_place = false
  446.     end
  447.     if Player.location == 2 && new_place == true
  448.       Right_Now.current1_scene = "#{Player.location} Scene"
  449.       Right_Now.region_name = Scene2.region_name
  450.       Right_Now.seed = rand(Scene2.seed)
  451.       Right_Now.enemy_types = Scene2.enemy_types
  452.       Sea_Farie_Dragon.x_pos = rand(267)
  453.       Sea_Farie_Dragon.y_pos = rand(267)
  454.       Right_Now.x_pos = Sea_Farie_Dragon.x_pos
  455.       Right_Now.y_pos = Sea_Farie_Dragon.y_pos
  456.       Right_Now.description = Scene2.description
  457.       Right_Now.depth_water = Scene2.depth_water
  458.       Right_Now.climate = Scene2.climate
  459.       Right_Now.weather = Scene2.weather
  460.       new_place = false
  461.       terrain_mult = 0.56
  462.     end
  463.     if Player.location == 3 && new_place == true
  464.       Right_Now.current1_scene = "#{Player.location} Scene"
  465.       Right_Now.region_name = Scene3.region_name
  466.       Right_Now.seed = rand(Scene3.seed)
  467.       Right_Now.enemy_types = Scene2.enemy_types
  468.       Razor_Dragon.x_pos = rand(267)
  469.       Razor_Dragon.y_pos = rand(267)
  470.       Right_Now.x_pos = Razor_Dragon.x_pos
  471.       Right_Now.y_pos = Razor_Dragon.y_pos
  472.       Right_Now.descriptiong = Scene3.description
  473.       Right_Now.depth_water = Scene3.depth_water
  474.       Right_Now.climate = Scene2.climate
  475.       Right_Now.weather = Scene2.weather
  476.         #code
  477.     end
  478.    
  479.       display = ""
  480.       puts Right_Now.current1_scene
  481.       display = "(1)-Identify Region, (2)-Move in direction, (3)-Interact with Environment, (4)-Look Around, (5)-Self"
  482.       puts display
  483.       input1 = gets.chomp
  484.       system("cls")
  485.         case input1
  486.         when ""
  487.           puts "#{Lakmi.my_name}: 'Remember, you can exit the game anytime by typing the word Exit.'"
  488.           end_game = false
  489.        
  490.        when "1"
  491.         puts Right_Now.region_name
  492.         end_game = false
  493.      
  494.        when "2"
  495.       puts "Which direction do you wish to move in?"
  496.       puts "(E)ast, (W)est, North, South, Down, Up?"
  497.       move_amt = 0
  498.       direction = gets.chomp
  499.        case direction
  500.         when "E"
  501.           if Player.y_pos == Right_Now.y_pos && Player.x_pos - Player.stride == Right_Now.x_pos
  502.             puts "An enemy is in the way."
  503.           else
  504.             move_amt =  (Player.stride - (Player.fatigue - (Player.stats.agility * 1.5)))
  505.             Player.x_pos += move_amt.abs
  506.           end
  507.           if Player.x_pos >= 267
  508.             Player.location += 1
  509.             Player.x_pos = 0
  510.             new_place = true
  511.           end
  512.         when "W"
  513.           if Player.x_pos - Player.stride == Right_Now.x_pos && Player.y_pos == Right_Now.y_pos
  514.            puts "An enemy is in the way."
  515.           else
  516.             move_amt = (Player.stride - (Player.fatigue - (Player.stats.agility * 1.5)))
  517.             Player.x_pos -= move_amt.abs
  518.           end
  519.           if Player.x_pos << 0
  520.             Player.location -= 1
  521.             Player.x_pos = 266
  522.             new_place = true
  523.           end
  524.          
  525.          
  526.          
  527.         end  
  528.         when "Exit"
  529.         end_game = true
  530.         puts "Game Over"
  531.      
  532.     when "3"
  533.       options = ""
  534.        if Right_Now.seed > 0
  535.          options += "X-Battle #{Right_Now.enemy_types}"
  536.        end
  537.        if Right_Now.depth_water > 0
  538.         options += " Y-Dive to #{Right_Now.depth_water} below the surface"
  539.        end
  540.        if Right_Now.seed > 0
  541.          options += " M-Move to #{Right_Now.enemy_types}"
  542.        end
  543.        
  544.       puts options
  545.       interaction_input = gets.chomp.upcase
  546.      
  547.       when "4"
  548.         puts Right_Now.description
  549.         puts "There are #{Right_Now.seed} number of #{Right_Now.enemy_types}." if Player.inventory.name[11] >= 11
  550.         puts "They seem to be at coordinates, #{Right_Now.x_pos}, #{Right_Now.y_pos}" if Player.inventory[11] >= 21
  551.         #increase EXP for observation skill tree
  552.         skillexp(12,20)
  553.         Player.journal.page[361] += "\n#{Player.my_name} feels his eyes improving... but a factor of #{Player.inventory.name[1]}"
  554.         puts "Journal log added."
  555.          
  556.       when "5"
  557.         puts "You examine yourself..."
  558.         puts "Your heatlh is at #{Player.stats.health_cur}."
  559.         puts "Your attack strength is at #{Player.stats.attack}."
  560.         puts "Your fatigue level is at #{Player.fatigue}."
  561.         puts "(C)heck inventory, (S)tats, Sa(V)e, (T)he Journal, S(K)ill Tree"
  562.         self_input = gets.chomp.upcase
  563.         end
  564.        
  565.         case self_input
  566.        
  567.         when "K"
  568.         puts "You have some nice skills...."
  569.         count = 0
  570.         11.times do
  571.         count += 1
  572.         skill_disp(count)
  573.       end
  574.         puts "Enter a correspoding number to view the tree of Specials."
  575.         skill_choic = gets.chomp
  576.         self_input = ""
  577.         case skill_choic
  578.          
  579.         when "1"
  580.          
  581.           puts "#{Player.inventory.qualifier[23]} level #{Player.inventory.name[23]}" if Player.inventory.name[1] >= 5
  582.           puts "#{Player.inventory.qualifier[24]} level #{Player.inventory.name[24]}" if Player.inventory.name[1] >= 21
  583.           puts "#{Player.inventory.qualifier[25]} level #{Player.inventory.name[25]}"
  584.           puts "#{Player.inventory.qualifier[26]} level #{Player.inventory.name[26]}"
  585.           puts "#{Player.inventory.qualifier[27]} level #{Player.inventory.name[27]}"
  586.           puts "#{Player.inventory.qualifier[28]} level #{Player.inventory.name[28]}" if Player.inventory.name[1] >= 41
  587.           puts "#{Player.inventory.qualifier[29]} level #{Player.inventory.name[29]}"
  588.           puts "#{Player.inventory.qualifier[30]} level #{Player.inventory.name[30]}" if Player.inventory.name[1] >= 10
  589.           puts "#{Player.inventory.qualifier[31]} level #{Player.inventory.name[31]}"
  590.           puts "#{Player.inventory.qualifier[32]} level #{Player.inventory.name[32]}"
  591.          
  592.         end
  593.         when "T"
  594.           puts "You search yourself and try to locate your journal..."
  595.           if File.exists?("Journal-#{Player.my_name}")
  596.             journal_load("Journal-#{Player.my_name}")
  597.           end
  598.           puts "You pull out your Journal..."
  599.           puts "Pages 2-361 are scene logs. Page 1 is your inventory log. Page 361 is your Skills log.\n Pages 362-373 are Skill Tree Specific."
  600.           puts "What page do you wish to read?"
  601.           self_input = ""
  602.           p_sel = 0
  603.           until self_input == "C" do
  604.            
  605.           self_input = gets.chomp
  606.          
  607.           case self_input
  608.            
  609.           when "F"
  610.             p_sel += 1
  611.           when "B"
  612.             p_sel -= 1
  613.           when "C"
  614.             self_input = ""
  615.           break
  616.         else
  617.           p_sel = self_input.to_i
  618.          
  619.         end
  620.           puts Player.journal.page[p_sel.to_i]
  621.           puts "Page (F)orward | Page (B)ackwards | (C)lose Journal  ?"
  622.           self_input = ""
  623.         end
  624.          
  625.        
  626.         when "C"
  627.           cur_inventory = ""
  628.           count = 0
  629.           puts "Your inventory:"
  630.               cur_inventory += "#{Player.inventory.name[200]} Health Potion " if Player.inventory.name[200] >= 1
  631.               cur_inventory += "#{Player.inventory.name[201]} Dragon Steak " if Player.inventory.name[201] >= 1
  632.               cur_inventory += "#{Player.inventory.name[202]} " if Player.inventory.name[202] >= 1
  633.               cur_inventory += "#{White_Fish.item_name} " if Player.inventory.name[202] >= 1 && White_Fish.identified == true
  634.               cur_inventory += "Unknown Item " if Player.inventory.name[202] >= 1 && White_Fish.identified == false
  635.              
  636.           puts cur_inventory
  637.           puts "Enter the item you wish to use... Leave blank for none."
  638.           puts "Type I-(Item Name) to inspect the item..."
  639.           puts "Type ID to identify unknown items."
  640.           inv_sel = gets.chomp
  641.           self_input = ""
  642.          
  643.           case inv_sel
  644.             ###Inspect item
  645.           when "ID"
  646.             puts "You begin to inspect the unknown items..."
  647.             until White_Fish.identified == true || Player.inventory.name[1] >= 100            
  648.             if Player.inventory.name[202] >= 1 && White_Fish.identified == false
  649.               ident = 0
  650.               ident = rand(100)
  651.               if ident <= (Player.inventory.name[25] + 25)
  652.                 White_Fish.identified = true
  653.                 puts "You identify one object as a White Fish."
  654.                 Player.inventory.name[12] += 20
  655.                 Player.journal.page[361] += "White Fish identified! Observation EXP increased 20 points!\n"
  656.               else
  657.                 Player.inventory.name[12] += 10
  658.                 Player.journal.page[361] += "Identification of item failed. Observation EXP increased 10 points.\n"
  659.               end
  660.              
  661.             end
  662.           end
  663.          
  664.            
  665.            
  666.           when "I-Health Potion"
  667.             puts "Health Potion:"
  668.             if Player.inventory.name[200] > 0
  669.               puts "Adds, #{Potion.health_gain} points of health."
  670.               puts "Adds, #{Potion.attack_bonus} points to attack."
  671.               puts "Weighs, #{Potion.weight} kilogram."
  672.             else
  673.               puts "You don't have any Health Potions."
  674.             end
  675.            
  676.           when "I-Dragon Steak"
  677.             puts "Dragon Steak:"
  678.             if Player.inventory.name[201] > 0
  679.               puts "Removes, #{Dragon_Steak.fatigue_sub} points of fatigue."
  680.               puts "Adds, #{Dragon_Steak.health_bonus} points of health."
  681.               puts "Weighs, #{Dragon_Steak.weight} kilograms."
  682.             else
  683.               puts "You don't have any Dragon Steaks."
  684.             end
  685.            
  686.             when "I-White Fish"
  687.             puts "White Fish" if White_Fish.identified == true
  688.             puts "Unknown Item" if White_Fish.identified == false
  689.             if Player.inventory.name[202] >= 1 && White_Fish.identified == true
  690.               puts "Adds, #{White_Fish.health_gain} points of health."
  691.               puts "Removes, #{White_Fish.fatigue_sub} points of Fatigue."
  692.               puts "Weighs, #{White_Fish.weight} kilograms."
  693.             elsif Player.inventory.name[202] >= 1 && White_Fish.identified == false
  694.               puts "You don't know what this does yet..."
  695.             elsif Player.inventory.name[202] <= 0
  696.               puts "You don't have any of those."
  697.             end
  698.            
  699.            ###Use Item
  700.              when "White Fish"
  701.             if Player.inventory.name[202] > 0
  702.                 Player.stats.health_cur += White_Fish.health_gain
  703.                 Player.fatigue -= White_Fish.fatigue_sub
  704.                 if Player.fatigue < 0
  705.                   Player.fatigue = 0
  706.                 end
  707.                
  708.                 if Player.health_cur > Player.stats.health_max
  709.                   Player.stats.health_cur = Player.stats.health_max
  710.                 end
  711.                 puts "White Fish identified!" if White_Fish.identified == false
  712.                 White_Fish.identified = true
  713.                 puts "Your health is now at #{Player.stats.health_cur}!"
  714.                 puts "Your attack is now at #{Player.stats.attack}!"
  715.               else
  716.                 puts "You don't have any of those."
  717.             end
  718.            
  719.            
  720.           when "Health Potion"
  721.             if Player.inventory.name[200] > 0      
  722.           Player.stats.health_cur += Potion.health_gain
  723.           Player.stats.attack += Potion.attack_bonus
  724.           if Player.stats.health_cur > Player.stats.health_max
  725.             Player.stats.health_cur = Player.stats.health_max
  726.           end
  727.           puts "Your health is now at, #{Player.stats.health_cur}!"
  728.           puts "Your attack is now at, #{Player.stats.attack}!"
  729.         else
  730.           puts "You have no #{Player.inventory.qualifier[200]}s."
  731.         end
  732.          
  733.          
  734.         when "Dragon Steak"
  735.           if Player.inventory.name[201] > 0
  736.          
  737.           Player.fatigue -= Dragon_Steak.fatigue_sub
  738.           if Player.fatigue < 0.0
  739.             Player.fatigue = 0.0
  740.           end
  741.           puts "Your fatigue level is now at, #{Player.fatigue}!"
  742.         else
  743.           puts "You have no #{Player.inventory.qualifier[201]}s."
  744.         end
  745.         end
  746.        
  747.         when "S"
  748.           puts "Your current Level is #{Player.level}, your current Experience is at #{Player.cur_exp}."
  749.           puts "Experience required to next Level is, #{Player.exp_to_next_lvl}."
  750.           puts "Your location is (X,Y); #{Player.x_pos}, #{Player.y_pos}"
  751.           self_input =""
  752.          
  753.         when "V"
  754.           new_game(Player.my_name)
  755.           journal_save("Journal-#{Player.my_name}")
  756.           puts "Saved your information!"
  757.           self_input = ""
  758.           end
  759.         #situation for environment interaction
  760.         case interaction_input
  761.          
  762.         when "M"
  763.           move_amt = Player.x_pos + 0.5 * ((Player.stride-Player.fatigue) + Player.stats.agility) * 1
  764.           move_ang = 0
  765.           move_ang = (Player.x_pos - Right_Now.x_pos) / (Player.y_pos - Right_Now.x_pos)
  766.           Player.x_pos = move_amt + (0.5 * move_ang * move_ang)
  767.           Player.y_pos = move_amt + (0.5 * move_ang * move_ang)
  768.           puts "You have moved towards the #{Right_Now.enemy_types}."
  769.           puts Player.x_pos
  770.           puts Player.y_pos
  771.           puts Right_Now.x_pos
  772.           puts Right_Now.y_pos
  773.          
  774.           when "X"
  775.          
  776.           Battle.number_enemies = Right_Now.seed
  777.           Battle.enemy_type = Right_Now.enemy_types
  778.           Battle.turn = 0
  779.            if Battle.number_enemies > 0
  780.             battle_end = false
  781.           else
  782.             battle_end = true
  783.             end
  784.          
  785.            if Player.location == 1
  786.             Battle.enemy_health_max = Sea_Dragon.health_max
  787.             Battle.enemy_attack = Sea_Dragon.attack
  788.             Battle.enemy_health_cur = Sea_Dragon.health_cur
  789.             Battle.exp_gain = Sea_Dragon.exp_gain
  790.           end
  791.            if Player.location == 2
  792.              Battle.enemy_health_max = Sea_Farie_Dragon.health_max
  793.              Battle.enemy_attack = Sea_Farie_Dragon.attack
  794.              Battle.enemy_health_cur = Sea_Farie_Dragon.health_cur
  795.              Battle.exp_gain = Sea_Farie_Dragon.exp_gain
  796.            end
  797.            Player.journal.page[Player.location + 1] = "Page 2:\n #{Right_Now.current1_scene};\n #{Player.my_name} had an encounter with #{Battle.enemy_type} at #{Time.now}, #{Player.x_pos}, #{Player.y_pos}." if Player.journal.page[1] == ""
  798.            Player.journal.page[Player.location + 1] += "\n #{Player.my_name} had an encounter with #{Battle.enemy_type} at #{Time.now}, #{Player.x_pos}, #{Player.y_pos}." if Player.journal.page[1] != ""
  799.             puts "Journal Entry added."
  800.            
  801.           while battle_end == false
  802.             attack_cur = 0
  803.                        
  804.             puts "#{Battle.number_enemies} #{Battle.enemy_type}"
  805.             puts "You have, #{Player.stats.health_cur} of #{Player.stats.health_max} health points."
  806.             puts "The enemy has #{Battle.enemy_health_cur} of #{Battle.enemy_health_max} health points."
  807.             puts "(A) Attack; (R) Run."
  808.             battle_choice = gets.chomp
  809.            
  810.             case battle_choice
  811.              when "A"
  812.                if Right_Now.seed > 0              
  813.               attack_cur = rand(Player.stats.attack) + 0.5
  814.               Player.journal.page[Player.location + 1] += "\n #{Player.my_name} felt very strong and able to defeat the enemy #{Battle.enemy_type} inflicting #{Player.stats.attack / attack_cur} of his full attack on the enemy!"
  815.               Player.journal.page[Player.location + 1] += "\n There was a sound of bone breaking from the enemy!" if (Player.stats.attack / attack_cur) >= 6
  816.               Player.journal.page[Player.location + 1] += "\n There was little effort to harm the enemy in #{Player.my_name}'s attempt!" if (Player.stats.attack / attack_cur) <= 5
  817.               Battle.enemy_health_cur -= attack_cur
  818.               puts "You inflict #{attack_cur} of damage on #{Battle.enemy_type}"
  819.               attack_cur = rand(Battle.enemy_attack) + 0.5
  820.               Player.journal.page[Player.location + 1] += "\n #{Player.my_name} felt freight from the pressence of the enemy #{Battle.enemy_type} as he took #{attack_cur} damage!" if (Battle.enemy_health_cur / Battle.enemy_health_max) >= 0.5
  821.               Player.journal.page[Player.location + 1] += "\n #{Player.my_name} had no fears when recieving #{attack_cur} damage." if Battle.enemy_health_cur / Battle.enemy_health_max <= 0.4
  822.               Player.stats.health_cur -= attack_cur
  823.               puts "#{Battle.enemy_type} inflicts #{attack_cur} of damage on you."
  824.               Player.fatigue += 0.5
  825.             else
  826.             puts "There are no enemies to fight..."
  827.             battle_end = true
  828.           end
  829.              
  830.            
  831.              when "R"
  832.                battle_end = true
  833.                 interaction_input = ""
  834.                puts "You have ran away."
  835.                battle_choice = ""
  836.              end
  837.            
  838.              if Battle.enemy_health_cur <= 0
  839.                battle_end = true
  840.                puts "The battle is over..."
  841.                interaction_input = ""
  842.                battle_choice = ""
  843.                Player.journal.page[Player.location + 1] += "\n #{Player.my_name} defeated the enemy #{Battle.enemy_type} at #{Time.now}!"
  844.                Player.cur_exp += Battle.exp_gain
  845.                puts "You gained, #{Battle.exp_gain} experience points."
  846.                item_find = rand(10)
  847.                Right_Now.seed -= 1
  848.                Player.journal.page[Player.location + 1] += "\n Thus clearing #{Right_Now.current1_scene}." if Right_Now.seed == 0
  849.                puts "There are #{Right_Now.seed} enemy #{Battle.enemy_type} left."
  850.                if item_find >= 5
  851.                  puts "You found a #{Dragon_Steak.item_name}!"
  852.                 op_item(201,1)
  853.                 puts "#{Dragon_Steak.item_name} added to inventory."
  854.                 Player.journal.page[1] += "\n Inventory Log;\n Dragon Steak added to inventory! \n Dragon Steak now at #{Player.inventory.name[201]}!"
  855.                end
  856.                puts "Journal entry logged."
  857.              end
  858.              if Player.stats.health_cur == 0
  859.                end_game = true
  860.                  battle_end = true
  861.                  puts "You have died to #{Battle.enemy_type}"
  862.                  interaction_input = ""
  863.                  battle_choice = ""
  864.                end
  865.            end
  866.        
  867.           when "Y"
  868.             interaction_input = ""
  869.             puts "You dive to the bottom of the sea at #{Right_Now.depth_water} kilometers."
  870.             puts "You find..."
  871.             breath = 100
  872.             find_suc = 1000
  873.             until breath == 0 or find_suc <= Player.inventory.name[25] do          
  874.             item_find = rand(3)
  875.             find_suc = rand(99)
  876.             number_found = rand(4) + 1
  877.             if item_find > 2 && find_suc <= Player.inventory.name[25]
  878.               puts "#{number_found} Health Potions!"
  879.               item_find_indent = "Health Potion"
  880.               if Player.inventory.name[200] >= 32
  881.              puts "You have max #{item_find_ident}."
  882.             else
  883.               op_item(200,number_found)
  884.               puts "#{item_find_ident} added to inventory."
  885.               Player.journal.page[1] = "Page:1" if Player.journal.page[1] == ""
  886.               Player.journal.page[1] += "\n #{Player.my_name} found #{number_found} #{item_find_ident} at #{Right_Now.depth_water} below the surface. #{Time.now}"
  887.             end
  888.               else
  889.               puts "#{Lakmi.my_name}: You know, with some improvement on your Observation Skill you could find some nice things."
  890.             end
  891.               if item_find < 2 && find_suc <= Player.inventory.name[25]
  892.                 puts "#{number_found} White Fish!"
  893.                 item_find_ident = "White Fish"
  894.                 if Player.inventory.name[202] >= 32
  895.              puts "You have max #{item_find_ident}."
  896.             else
  897.               op_item(202,number_found)
  898.               puts "#{item_find_ident} added to inventory."
  899.               Player.journal.page[1] = "Page:1" if Player.journal.page[1] == ""
  900.               Player.journal.page[1] += "\n #{Player.my_name} found #{number_found} #{item_find_ident} at #{Right_Now.depth_water} below the surface. #{Time.now}"
  901.             end
  902.             else
  903.               puts "#{Lakmi.my_name}: You know, with some improvement on your Observation Skill you could find some nice things."
  904.              
  905.             end
  906.             Player.inventory.name[12] += 10
  907.             breath -= 10
  908.           end
  909.            
  910.            
  911.            end
  912.         ###Allocate Fatigue to Human
  913.         Player.fatigue += (Player.stats.stamina / (Player.stats.attack - 10)) * terrain_mult
  914.         Player.fatigue = Player.fatigue.abs
  915.         ###Put system in sleep for 15 seconds
  916.         if sleep_on == true
  917.             sleep 10
  918.         end
  919.        
  920.         ### Clear the screen and check to see if the Human has leveled up
  921.        
  922.         level_up = false
  923.         if Player.cur_exp >= Player.exp_to_next_lvl
  924.           level_up = true
  925.         end
  926.        
  927.         if level_up == true
  928.           Player.level += 1
  929.           Player.exp_to_next_lvl *= 2
  930.           puts "Congratulations!"
  931.           sleep 1
  932.           puts "You have leveled up to Level: #{Player.level}"
  933.           next_lvl = Player.exp_to_next_lvl - Player.cur_exp
  934.           puts "You only need, #{next_lvl} more Experience!"
  935.         end
  936.        
  937.         if Player.inventory.name[12] >= (100 +(Player.inventory.name[1] * 2))
  938.       Player.inventory.name[12] = 0 if Player.inventory.name[1] < 99
  939.       Player.inventory.name[1] += 1 if Player.inventory.name[1] < 99
  940.       puts "Observation is now level #{Player.inventory.name[1]}!" if Player.inventory.name[1] < 99
  941.       Player.inventory.name[150] += Player.inventory.name[1]
  942.      
  943.      
  944.       until Player.inventory.name[150] == 0 do
  945.       puts "#{Player.inventory.qualifier[23]} level #{Player.inventory.name[23]}" if Player.inventory.name[1] >= 5
  946.           puts "#{Player.inventory.qualifier[24]} level #{Player.inventory.name[24]}" if Player.inventory.name[1] >= 21
  947.           puts "#{Player.inventory.qualifier[25]} level #{Player.inventory.name[25]}"
  948.           puts "#{Player.inventory.qualifier[26]} level #{Player.inventory.name[26]}"
  949.           puts "#{Player.inventory.qualifier[27]} level #{Player.inventory.name[27]}"
  950.           puts "#{Player.inventory.qualifier[28]} level #{Player.inventory.name[28]}" if Player.inventory.name[1] >= 41
  951.           puts "#{Player.inventory.qualifier[29]} level #{Player.inventory.name[29]}"
  952.           puts "#{Player.inventory.qualifier[30]} level #{Player.inventory.name[30]}" if Player.inventory.name[1] >= 10
  953.           puts "#{Player.inventory.qualifier[31]} level #{Player.inventory.name[31]}"
  954.           puts "#{Player.inventory.qualifier[32]} level #{Player.inventory.name[32]}"
  955.       skill_choice1 = gets.chomp
  956.       skill_choice1 = skill_choice1.to_i
  957.      
  958.       case skill_choice1
  959.        
  960.       when 1
  961.         Player.inventory.name[21] += 1
  962.         puts "Look Around increased!"
  963.         Player.inventory.name[150] -= 1
  964.        
  965.       when 2
  966.         if Player.inventory.name[1] >= 21
  967.          Player.inventory.name[22] += 1
  968.           puts "Peer Into Soul increased!"
  969.           Player.inventory.name[150] -= 1
  970.         end
  971.        
  972.       when 3
  973.         Player.inventory.name[23] += 1
  974.         puts "Read Thoughts increased!"
  975.         Player.inventory.name[150] -= 1
  976.        
  977.       when 4
  978.         Player.inventory.name[24] += 1
  979.         puts "X-Ray Vision increased!"
  980.         Player.inventory.name[150] -= 1
  981.        
  982.       when 5
  983.         Player.inventory.name[25] += 1
  984.         puts "Underwater Vision increased!"
  985.         Player.inventory.name[150] -= 1
  986.        
  987.       when 6
  988.         if Player.inventory.name[1] >= 41
  989.           Plater.inventory.name[26] += 1
  990.           puts "Eagle Eyes increased!"
  991.           Player.inventory.name[150] -= 1
  992.             #code
  993.         end
  994.        
  995.       when 7
  996.         Player.inventory.name[27] += 1
  997.         puts "Star Charting increased!"
  998.         Player.inventory.name[150] -= 1
  999.        
  1000.       when 8
  1001.         if PLayer.inventory.name[1] >= 10
  1002.           Player.inventory.name[28] += 1
  1003.           puts "Fire-Eyes increased!"
  1004.           Player.inventory.name[150] -= 1
  1005.             #code
  1006.         end
  1007.        
  1008.       when 9
  1009.         Player.inventory.name[29] += 1
  1010.         puts "Identify Object increased!"
  1011.         Player.inventory.name[150] -= 1
  1012.        
  1013.       when 10
  1014.         Player.inventory.name[30] += 1
  1015.         puts "Observe Sentient increased!"
  1016.         Player.inventory.name[150] -= 1
  1017.       end
  1018.        
  1019.       end
  1020.     end
  1021.        
  1022.         ###change weather
  1023.         ###update Journal file
  1024.         journal_save("Journal-#{Player.my_name}")
  1025.         ###Move the entities around.
  1026.           end
Advertisement
Add Comment
Please, Sign In to add comment