Advertisement
Guest User

Untitled

a guest
Aug 9th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.42 KB | None | 0 0
  1. #Basic Quest System v1.2f
  2. #----------#
  3. #Features: Quests! What more can you say.
  4. #
  5. #Usage: Set up your quests and away you go!
  6. # Script calls:
  7. # accept_quest(:questid) - force quest accept
  8. # ask_accept(:questid) - open quest acceptance window
  9. # abandon_quest(:questid) - force quest abandon
  10. # turnin_quest(:questid) - force quest turnin
  11. # fail_quest(:questid) - force abandon with ME
  12. # ask_turnin(:questid) - open quest complete window
  13. #
  14. # adv_obj(:questid, :objectiveid, value) - changes obj by value
  15. # set_obj(:questid, :objectiveid, value) - sets obj to value
  16. # obj(:questid, :objectiveid) - gets obj value
  17. #
  18. # $game_quests[:questid].accepted? - true if quest is accepted
  19. # $game_quests[:questid].completed? - true if quest is completed
  20. # $game_quests[:questid].turned_in? - true if quest is turned in
  21. #
  22. # Examples:
  23. # The obj function can be used in conditional branches to check progress
  24. # of certain objectives. Example.
  25. # #Checking if :obj3 of :quest89 is greater than 3:
  26. # obj(:quest89, :obj3) > 3
  27. #
  28. #~ #----------#
  29. #-- Script by: V.M of D.T
  30. #
  31. #- Questions or comments can be:
  32. # given by email: sumptuaryspade@live.ca
  33. # provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  34. # All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  35. #
  36. #--- Free to use in any project, commercial or non-commercial, with credit given
  37. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  38.  
  39. #Visibility of quest log on map
  40. $questlogvisibility = true
  41. #Maximum # of quests displayed on the quest log overlay
  42. $questlogmaxdisplay = 5
  43. #Quest log position, 1 - top-left, 2 - top-right
  44. QUEST_LOG_POSITION = 2
  45. #Quest log offsets
  46. QUEST_LOG_OFFSET_X = 0
  47. QUEST_LOG_OFFSET_Y = 0
  48.  
  49. # Quest Format and set up!
  50.  
  51. # DETAILS[:quest_id] = {
  52. # :name => "quest name" #Quest name
  53. # :level => value #Arbitrary value (Optional)
  54. # :difficulty => "string" #Arbitrary string (Optional)
  55. # :auto_complete => true #Recieve rewards on the spot (Optional)
  56. # :abandonable => false #Set's whether quest can be abandoned (Optional)
  57. # :force_accept => true #ask_accept only allows accepting (Optional)
  58. # :force_turnin => true #ask_turnin only allows completing (Optional)
  59. # }
  60. # DESCRIPTIONS[:quest_id] = {
  61. # :qgiver_name => "string" #Quest giver name (shows in log) (Optional)
  62. # :location => "string" #Quest giver location (shows in log) (Optional)
  63. # :desc => "string" #Description of quest displayed in log (Optional)
  64. # }
  65. # OBJECTIVES[:quest_id] = { #Quest objectives, "string" is name, id is max value
  66. # :obj_id1 => ["string", id]
  67. # :obj_id2 => ["string", id],
  68. # etc...
  69. # }
  70. # REWARDS[:quest_id] = {
  71. # :gold => value #Gold recieved from quest (Optional)
  72. # :exp => value #Exp recieved from quest (Optional)
  73. # #Items recieved from quest, :type is :item, :weapon, or :armor
  74. # :scale_exp => value #Percent value to scale exp based on level vs party
  75. # :items => [[:type,id,value], ...]], (Optional)
  76. # }
  77.  
  78. module QUEST
  79. DETAILS= {}
  80. DESCRIPTIONS = {}
  81. OBJECTIVES = {}
  82. REWARDS = {}
  83.  
  84. #Main Quest 1
  85. DETAILS[:questid001] = {
  86. :name => "I need water!",
  87. :level => 1,
  88. :force_accept => true,
  89. :force_turnin => true,}
  90. DESCRIPTIONS[:questid001] = {
  91. :qgiver_name => "This Lady",
  92. :location => "This Place",
  93. :desc => " I'm thirsty, can you get me some water from the merchant?" }
  94. OBJECTIVES[:questid001] = {
  95. :obj1 => ["Get a canteen of water",1], }
  96. REWARDS[:questid001] = {
  97. :gold => 5,
  98. :exp => 10,
  99. :scale_exp => 5,
  100. :items => [[:item,1,2]], }
  101.  
  102. #Main Quest 2
  103. DETAILS[:questid002] = {
  104. :name => "First Steps: Arkineer",
  105. :level => 2,}
  106. DESCRIPTIONS[:questid002] = {
  107. :qgiver_name => "Marshal Avalan",
  108. :location => "Class Town",
  109. :desc => " An Arkineer's job is to construct
  110. as much as it is to fight. To do
  111. that, requires materials though.
  112. Head to the Forest Encampment and
  113. see what the situation is." }
  114. OBJECTIVES[:questid002] = {
  115. :obj1 => ["Head to the Forest Camp",1] }
  116. REWARDS[:questid002] = {}
  117.  
  118. #Main Quest 3
  119. DETAILS[:questid003] = {
  120. :name => "Starving bear",
  121. :abandonable => false,
  122. :force_accept => true,
  123. :force_turnin => true,}
  124. DESCRIPTIONS[:questid003] = {
  125. :qgiver_name => "Bear",
  126. :location => "Treasure island 2",
  127. :desc => "Would you help me catch some perch please!" }
  128. OBJECTIVES[:questid003] = {
  129. :obj1 => ["Perches",5], }
  130. REWARDS[:questid003] = {
  131. :gold => 100,
  132. :exp => 100, }
  133.  
  134. #Main Quest 4
  135. DETAILS[:questid004] = {
  136. :name => "Hái nấm cho Mèo",
  137. :level => 1,
  138. :abandonable => false,
  139. :auto_complete => true,
  140. :force_accept => true,
  141. :force_turnin => true,}
  142. DESCRIPTIONS[:questid004] = {
  143. :qgiver_name => "Mèo",
  144. :location => "Làng Cà Chua",
  145. :desc => "Hôm nay Mèo nấu món cá sốt nấm.
  146. Nạ đi lên đồi hái nấm cho Mèo nhá" }
  147. OBJECTIVES[:questid004] = {
  148. :obj1 => ["Hái nấm đỏ",1], }
  149. REWARDS[:questid004] = {
  150. :gold => 5,
  151. :exp => 10,}
  152.  
  153. #Main Quest 5
  154. DETAILS[:questid005] = {
  155. :name => "Bắt cá cho Mèo",
  156. :level => 1,
  157. :abandonable => false,
  158. :force_accept => true,
  159. :force_turnin => true,}
  160. DESCRIPTIONS[:questid005] = {
  161. :qgiver_name => "Mèo",
  162. :location => "Làng Cà Chua",
  163. :desc => "Hôm nay Mèo nấu món cá sốt nấm.
  164. Nạ ra biển bắt cá cho Mèo nhá" }
  165. OBJECTIVES[:questid005] = {
  166. :obj1 => ["Cá",1], }
  167. REWARDS[:questid005] = {
  168. :gold => 5,
  169. :exp => 10,}
  170.  
  171. #Side Quest
  172. DETAILS[:sidequest001] = {
  173. :name => "Fibers for M'Lana",
  174. :level => 3,}
  175. DESCRIPTIONS[:sidequest001] = {
  176. :qgiver_name => "M'Lana Lee",
  177. :location => "Class Town",
  178. :desc => " You're not sure what M'Lana
  179. wants with the plant fibres, but at
  180. least she's isn't telling you to
  181. leave anymore. Better do as she
  182. says and collect them from beasts
  183. around the Forest Camp." }
  184. OBJECTIVES[:sidequest001] = {
  185. :obj1 => ["Collect 10 plant fibres",10] }
  186. REWARDS[:sidequest001] = {
  187. :gold => 20,
  188. :exp => 25,
  189. :items => [[:armor,89,1]], }
  190.  
  191. end
  192.  
  193. class Game_Quests
  194. attr_accessor :reset_hash
  195. def initialize
  196. @quests = {}
  197. QUEST::DETAILS.each do |id, quest|
  198. @quests[id] = Quest.new(id,quest)
  199. end
  200. @reset_hash = {}
  201. @quests.each_value do |quest|
  202. @reset_hash[quest.id] = {}
  203. @reset_hash[quest.id][:accepted] = false
  204. @reset_hash[quest.id][:turnedin] = false
  205. quest.objectives.each do |id, obj|
  206. @reset_hash[quest.id][id] = obj
  207. end
  208. end
  209. end
  210. def [](quest_id)
  211. return msgbox("No Quest with id " + quest_id.to_s) if @quests[quest_id].nil?
  212. @quests[quest_id]
  213. end
  214. def []=(quest_id, val)
  215. @quests[quest_id] = val
  216. end
  217. def quests
  218. @quests
  219. end
  220. def no_quests?
  221. @quests.each do |id, quest|
  222. return false if quest.accepted? && !quest.turned_in
  223. end
  224. return true
  225. end
  226. def tracking?
  227. $game_party.tracking
  228. end
  229. def track_quest(id)
  230. return if $game_party.tracking.include?(id)
  231. $game_party.tracking.push(id)
  232. if $game_party.tracking.size > $questlogmaxdisplay
  233. $game_party.tracking.reverse!.pop
  234. $game_party.tracking.reverse!
  235. end
  236. end
  237. def untrack_quest(id)
  238. return unless $game_party.tracking.include?(id)
  239. $game_party.tracking.delete(id)
  240. $game_party.tracking.compact!
  241. end
  242. end
  243.  
  244. class Quest
  245. attr_accessor :name
  246. attr_accessor :level
  247. attr_accessor :id
  248. attr_accessor :desc
  249. attr_accessor :objectives
  250. attr_accessor :turned_in
  251. attr_accessor :difficulty
  252. attr_accessor :qgiver_name
  253. attr_accessor :location
  254. attr_accessor :auto_complete
  255. attr_accessor :abandonable
  256. attr_accessor :force_accept
  257. attr_accessor :force_turnin
  258. def initialize(id,quest_hash)
  259. @id = id
  260. @level = 0
  261. @difficulty = 0
  262. @name = "No Quest Name"
  263. @desc = ""
  264. @qgiver_name = 0
  265. @location = 0
  266. @auto_complete = false
  267. @abandonable = true
  268. @need_popup = false
  269. @force_turnin = false
  270. @force_accept = false
  271. @name = quest_hash[:name] if quest_hash[:name]
  272. @level = quest_hash[:level] if quest_hash[:level]
  273. @force_accept = quest_hash[:force_accept] if quest_hash[:force_accept]
  274. @force_turnin = quest_hash[:force_turnin] if quest_hash[:force_turnin]
  275. @difficulty = quest_hash[:difficulty] if quest_hash[:difficulty]
  276. @auto_complete = quest_hash[:auto_complete] if quest_hash[:auto_complete]
  277. @abandonable = quest_hash[:abandonable] if !quest_hash[:abandonable].nil?
  278. @desc = QUEST::DESCRIPTIONS[id][:desc] if QUEST::DESCRIPTIONS[id][:desc]
  279. @qgiver_name = QUEST::DESCRIPTIONS[id][:qgiver_name] if QUEST::DESCRIPTIONS[id][:qgiver_name]
  280. @location = QUEST::DESCRIPTIONS[id][:location] if QUEST::DESCRIPTIONS[id][:location]
  281. @objectives = {}
  282. if QUEST::OBJECTIVES[id]
  283. QUEST::OBJECTIVES[id].each do |id, obj|
  284. @objectives[id] = Objective.new(id, obj)
  285. end
  286. else
  287. msgbox("Quest " + id.to_s + " has no objectives.")
  288. end
  289. @reward_gold = 0
  290. @reward_exp = 0
  291. @scale_exp = 0
  292. @reward_items = []
  293. begin
  294. if QUEST::REWARDS[id][:gold]
  295. @reward_gold = QUEST::REWARDS[id][:gold]
  296. end
  297. if QUEST::REWARDS[id][:exp]
  298. @reward_exp = QUEST::REWARDS[id][:exp]
  299. @scale_exp = QUEST::REWARDS[id][:scale_exp] if QUEST::REWARDS[id][:scale_exp]
  300. end
  301. if QUEST::REWARDS[id][:items]
  302. @reward_items = QUEST::REWARDS[id][:items]
  303. end
  304. rescue
  305. msgbox(id.to_s + " has no defined REWARDS. This is not optional.")
  306. end
  307. end
  308. def accept
  309. reset
  310. $game_party.quests[id][:accepted] = true
  311. track_quest
  312. $game_map.need_refresh = true
  313. Audio.se_play("Audio/SE/Book2")
  314. end
  315. def abandon
  316. reset
  317. $game_party.quests[id][:accepted] = false
  318. end
  319. def fail
  320. Audio.me_play("Audio/ME/Gag")
  321. abandon
  322. end
  323. def accepted?
  324. $game_party.quests[id][:accepted]
  325. end
  326. def accepted
  327. accepted?
  328. end
  329. def completed?
  330. @objectives.each do |id, obj|
  331. return false if !$game_party.quests[@id][id].completed?
  332. end
  333. return true
  334. end
  335. def force_done
  336. $game_party.quests[id][:accepted] = true
  337. @objectives.each do |id, obj|
  338. $game_party.quests[@id][id].current = obj.max
  339. end
  340. turnin
  341. end
  342. def reset
  343. $game_party.quests[id][:accepted] = false
  344. @objectives.each do |id, obj|
  345. $game_party.quests[@id][id].current = 0
  346. end
  347. $game_party.quests[id][:turnedin] = false
  348. end
  349. def objective(id)
  350. return Objective.new(["No Objective Found",0]) if @objectives[id].nil?
  351. $game_party.quests[@id][id]
  352. end
  353. def set_obj(id, value)
  354. objective(id).current = value
  355. @need_popup = false if !completed?
  356. popup if completed? && !@need_popup
  357. turnin if completed? && @auto_complete
  358. $game_map.need_refresh = true
  359. end
  360. def adv_obj(id, value)
  361. objective(id).current += value
  362. @need_popup = false if !completed?
  363. popup if completed? && !@need_popup
  364. turnin if completed? && @auto_complete
  365. $game_map.need_refresh = true
  366. end
  367. def reward_gold
  368. @reward_gold
  369. end
  370. def reward_exp
  371. get_mod_exp.to_i
  372. end
  373. def reward_items
  374. @reward_items
  375. end
  376. def turnin
  377. $game_party.quests[id][:turnedin] = true
  378. untrack_quest
  379. $game_map.need_refresh = true
  380. $game_party.gain_gold(@reward_gold)
  381. $game_party.members.each do |actor|
  382. actor.gain_exp(@reward_exp)
  383. end
  384. @reward_items.each do |array|
  385. item = $data_items[array[1]] if array[0] == :item
  386. item = $data_weapons[array[1]] if array[0] == :weapon
  387. item = $data_armors[array[1]] if array[0] == :armor
  388. $game_party.gain_item(item, array[2])
  389. end
  390. end
  391. def track_quest
  392. $game_quests.track_quest(@id)
  393. end
  394. def untrack_quest
  395. $game_quests.untrack_quest(@id)
  396. end
  397. def can_abandon?
  398. @abandonable
  399. end
  400. def popup
  401. @need_popup = true
  402. Audio.me_play("Audio/ME/Item")
  403. if Module.const_defined?(:Popup)
  404. Popup.add([@name + ' complete!'])
  405. end
  406. end
  407. def turned_in?
  408. $game_party.quests[id][:turnedin]
  409. end
  410. def turned_in
  411. turned_in?
  412. end
  413. def active?
  414. accepted? && !completed?
  415. end
  416. def get_mod_exp
  417. pval = @scale_exp * (@level - $game_party.highest_level).to_f / 100 + 1
  418. @reward_exp * pval
  419. end
  420. end
  421.  
  422. class Objective
  423. attr_accessor :id
  424. attr_accessor :name
  425. attr_accessor :current
  426. attr_accessor :max
  427. def initialize(id, obj)
  428. @name = obj[0]
  429. @current = 0
  430. @max = obj[1]
  431. end
  432. def completed?
  433. @current >= @max
  434. end
  435. end
  436.  
  437. module DataManager
  438. class << self
  439. alias quest_cgo load_database
  440. alias quest_sng setup_new_game
  441. end
  442. def self.load_database
  443. quest_cgo
  444. $game_quests = Game_Quests.new
  445. end
  446. def self.setup_new_game
  447. $game_quests = Game_Quests.new
  448. quest_sng
  449. end
  450. end
  451.  
  452. class Scene_Quest < Scene_MenuBase
  453. def initialize
  454. super
  455. @help_window = Window_Help.new(1)
  456. @help_window.set_text("Quest Log")
  457. @list_window = Window_SceneList.new
  458. @list_window.set_handler(:cancel, method(:list_cancel))
  459. @list_window.set_handler(:ok, method(:list_ok))
  460. @list_window.refresh
  461. @list_window.activate
  462. @list_window.select(0)
  463. @detail_window = Window_SceneDetail.new
  464. @command_window = Window_QuestTrack.new
  465. @command_window.x = Graphics.width / 2 - @command_window.width / 2
  466. @command_window.y = Graphics.height / 2 - @command_window.height / 2
  467. @command_window.set_handler(:track, method(:track))
  468. @command_window.set_handler(:untrack, method(:untrack))
  469. @command_window.set_handler(:abandon, method(:abandon))
  470. @command_window.set_handler(:cancel, method(:command_cancel))
  471. end
  472. def update
  473. super
  474. @detail_window.quest = @list_window.current_item
  475. end
  476. def list_cancel
  477. SceneManager.return
  478. end
  479. def list_ok
  480. @command_window.quest(@list_window.current_item)
  481. @command_window.refresh
  482. @command_window.select(0)
  483. @command_window.activate
  484. @command_window.open
  485. end
  486. def track
  487. $game_quests.track_quest(@list_window.current_item.id)
  488. command_cancel
  489. end
  490. def untrack
  491. $game_quests.untrack_quest(@list_window.current_item.id)
  492. command_cancel
  493. end
  494. def abandon
  495. @list_window.current_item.abandon
  496. command_cancel
  497. end
  498. def command_cancel
  499. @command_window.close
  500. @list_window.refresh
  501. @list_window.activate
  502. list_cancel if $game_quests.no_quests?
  503. end
  504. end
  505.  
  506. class Window_SceneList < Window_ItemList
  507. def initialize
  508. super(0,48,Graphics.width/5*2,Graphics.height-48)
  509. end
  510. def make_item_list
  511. @data = []
  512. $game_quests.quests.each do |id, quest|
  513. @data.push(quest) if quest.accepted? && !quest.turned_in?
  514. end
  515. @data.push(nil) if @data.empty?
  516. end
  517. def draw_item(index)
  518. contents.font.size = 18
  519. item = @data[index]
  520. if item
  521. rect = item_rect(index)
  522. rect.width -= 4
  523. if $game_quests.tracking?.include?(item.id)
  524. text = "*" + item.name
  525. else
  526. text = item.name
  527. end
  528. draw_text(rect, text)
  529. draw_text(rect, "Lv" + item.level.to_s,2) if item.level > 0
  530. end
  531. end
  532. def col_max; 1; end
  533. def current_item
  534. @data[@index]
  535. end
  536. def current_item_enabled?
  537. true
  538. end
  539. end
  540.  
  541. class Window_SceneDetail < Window_Base
  542. def initialize
  543. super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*2,Graphics.height-48)
  544. end
  545. def quest=(quest)
  546. return if @quest == quest
  547. @quest = quest
  548. refresh
  549. end
  550. def refresh
  551. contents.clear
  552. return unless @quest
  553. contents.font.size = 18
  554. change_color(system_color)
  555. draw_text(0,0,contents.width,line_height,@quest.qgiver_name) if @quest.qgiver_name != 0
  556. draw_text(0,0,contents.width,line_height,@quest.location,2) if @quest.location != 0
  557. change_color(normal_color)
  558. @quest.qgiver_name != 0 || @quest.location != 0 ? yy = line_height : yy = 0
  559. draw_text_ex(0,yy,@quest.desc)
  560. change_color(system_color)
  561. draw_text(0,line_height*7,contents.width,24,"Objectives:")
  562. change_color(normal_color)
  563. yy = line_height * 8
  564. @quest.objectives.each do |id, obj|
  565. draw_objective(yy, obj)
  566. yy += 24
  567. end
  568. change_color(system_color)
  569. draw_text(0,yy,contents.width,line_height,"Rewards:")
  570. yy += line_height
  571. if @quest.reward_exp > 0
  572. draw_text(6,yy,contents.width/2,line_height,"XP: ")
  573. change_color(normal_color)
  574. draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  575. yy += line_height
  576. end
  577. if @quest.reward_gold > 0
  578. change_color(normal_color)
  579. draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  580. cx = text_size(@quest.reward_gold).width
  581. change_color(system_color)
  582. draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  583. end
  584. yy += line_height
  585. change_color(normal_color)
  586. @quest.reward_items.each do |array|
  587. item = $data_items[array[1]] if array[0] == :item
  588. item = $data_weapons[array[1]] if array[0] == :weapon
  589. item = $data_armors[array[1]] if array[0] == :armor
  590. draw_item_name(item, 6, yy, true, contents.width)
  591. if array[2] > 1
  592. draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  593. end
  594. yy += line_height
  595. end
  596. if @quest.difficulty != 0
  597. text = "Difficulty: " + @quest.difficulty
  598. draw_text(0,contents.height-line_height,contents.width,line_height,text,2)
  599. end
  600. end
  601. def draw_objective(yy, obj)
  602. draw_text(6,yy,contents.width,24,obj.name)
  603. draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  604. end
  605. def reset_font_settings
  606. change_color(normal_color)
  607. contents.font.bold = Font.default_bold
  608. contents.font.italic = Font.default_italic
  609. end
  610. end
  611.  
  612. class Window_QuestTrack < Window_Command
  613. def initialize
  614. super(0,0)
  615. self.openness = 0
  616. end
  617. def quest(quest)
  618. @quest = quest
  619. end
  620. def make_command_list
  621. return unless @quest
  622. if !$game_quests.tracking?.include?(@quest.id)
  623. add_command("Track Quest", :track)
  624. else
  625. add_command("Untrack Quest", :untrack)
  626. end
  627. add_command("Abandon Quest", :abandon, @quest.can_abandon?)
  628. end
  629. def window_height
  630. fitting_height(2)
  631. end
  632. end
  633.  
  634. class Window_MenuCommand
  635. alias quest_aoc add_original_commands
  636. def add_original_commands
  637. quest_aoc
  638. add_command("Quest Log", :quest, !$game_quests.no_quests?)
  639. end
  640. end
  641.  
  642. class Scene_Menu
  643. alias quest_ccw create_command_window
  644. def create_command_window
  645. quest_ccw
  646. @command_window.set_handler(:quest, method(:scene_quest))
  647. end
  648. def scene_quest
  649. SceneManager.call(Scene_Quest)
  650. end
  651. end
  652.  
  653. class Scene_Map
  654. alias quest_start start
  655. alias quest_update update
  656. def start
  657. quest_start
  658. @quest_log = Window_QuestLog.new
  659. @quest_confirm = Window_QuestConfirm.new
  660. @quest_confirm.set_handler(:accept, method(:confirm_accept))
  661. @quest_confirm.set_handler(:decline, method(:confirm_cancel))
  662. @quest_confirm.set_handler(:cancel, method(:confirm_cancel))
  663. @quest_turnin = Window_QuestTurnin.new
  664. @quest_turnin.set_handler(:accept, method(:turnin_accept))
  665. @quest_turnin.set_handler(:decline, method(:confirm_cancel))
  666. @quest_turnin.set_handler(:cancel, method(:confirm_cancel))
  667. @quest_apply = Window_QuestApply.new(@quest_confirm,@quest_turnin)
  668. end
  669. def update(*args)
  670. @quest_log = Window_QuestLog.new if @quest_log.disposed?
  671. quest_update(*args)
  672. end
  673. def show_quest(id, turnin = false)
  674. @quest_apply.show($game_quests[id],turnin)
  675. end
  676. def accepting?
  677. @quest_confirm.active || @quest_turnin.active
  678. end
  679. def confirm_accept
  680. @quest_apply.accept
  681. @quest_apply.hide
  682. end
  683. def confirm_cancel
  684. @quest_apply.hide
  685. end
  686. def turnin_accept
  687. @quest_apply.turnin
  688. @quest_apply.hide
  689. end
  690. def update_call_menu
  691. if $game_system.menu_disabled || $game_map.interpreter.running? || accepting?
  692. @menu_calling = false
  693. else
  694. @menu_calling ||= Input.trigger?(:B)
  695. call_menu if @menu_calling && !$game_player.moving?
  696. end
  697. end
  698. end
  699.  
  700. class Scene_Base
  701. def accepting?
  702. false
  703. end
  704. end
  705.  
  706. class Window_QuestLog < Window_Base
  707. def initialize
  708. super(Graphics.width/5*3,0,Graphics.width/5*2,Graphics.height)
  709. self.x = 0 if QUEST_LOG_POSITION == 1
  710. self.x += QUEST_LOG_OFFSET_X
  711. self.y += QUEST_LOG_OFFSET_Y
  712. self.opacity = 0
  713. self.contents.font.size = 18
  714. end
  715. def update
  716. super
  717. return unless Graphics.frame_count % 20 == 0
  718. self.visible = !$game_quests.no_quests?
  719. self.visible = $game_quests.tracking?.size > 0
  720. self.visible = $questlogvisibility
  721. return unless self.visible
  722. contents.clear
  723. change_color(crisis_color)
  724. draw_text(0,0,contents.width,18,"Quest Log:",1)
  725. yy = 18;iter = 0
  726. $game_quests.tracking?.each do |id|
  727. quest = $game_quests[id]
  728. next unless quest.accepted? && !quest.turned_in
  729. change_color(system_color)
  730. draw_text(6,yy,contents.width-6,18,quest.name)
  731. change_color(normal_color)
  732. yy += 18
  733. quest.objectives.each do |obj_id, obj|
  734. draw_objective(yy, $game_party.quests[id][obj_id])
  735. yy += 18
  736. end
  737. iter += 1
  738. end
  739. end
  740. def draw_objective(yy, obj)
  741. draw_text(0,yy,contents.width-24,18,obj.name)
  742. draw_text(0,yy,contents.width,18,obj.current.to_s+"/"+obj.max.to_s,2)
  743. end
  744. end
  745.  
  746. class Window_QuestApply < Window_Base
  747. def initialize(confirm_window, turnin_window)
  748. super(Graphics.width/8,Graphics.width/8,Graphics.width/5*3,Graphics.height-Graphics.width/8*2)
  749. self.openness = 0
  750. @confirm_window = confirm_window
  751. @turnin_window = turnin_window
  752. self.contents.font.size = 18
  753. end
  754. def refresh
  755. return unless @quest
  756. contents.clear
  757. change_color(system_color)
  758. yy = 0
  759. if @quest.qgiver_name != 0
  760. draw_text(0,0,contents.width/2,line_height,@quest.qgiver_name)
  761. yy = line_height
  762. end
  763. if @quest.location != 0
  764. draw_text(contents.width/2,0,contents.width/2,line_height,@quest.location,2)
  765. yy = line_height
  766. end
  767. change_color(crisis_color)
  768. draw_text(0,yy,contents.width,line_height,"Lvl: " + @quest.level.to_s) if @quest.level > 0
  769. draw_text(0,yy,contents.width,line_height,@quest.name,1)
  770. draw_text(0,yy,contents.width,line_height,@quest.difficulty,2) if @quest.difficulty != 0
  771. change_color(normal_color)
  772. draw_text_ex(0,line_height+yy,@quest.desc)
  773. change_color(system_color)
  774. draw_text(0,line_height*8,contents.width,line_height,"Objectives:")
  775. change_color(normal_color)
  776. yy = line_height * 9
  777. @quest.objectives.each do |obj_id, obj|
  778. draw_objective(yy, $game_party.quests[@quest.id][obj_id])
  779. yy += line_height
  780. end
  781. change_color(system_color)
  782. draw_text(0,yy,contents.width,line_height,"Rewards:")
  783. yy += line_height
  784. if @quest.reward_exp > 0
  785. draw_text(6,yy,contents.width/2,line_height,"XP: ")
  786. change_color(normal_color)
  787. draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  788. yy += line_height
  789. end
  790. if @quest.reward_gold > 0
  791. change_color(normal_color)
  792. draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  793. cx = text_size(@quest.reward_gold).width
  794. change_color(system_color)
  795. draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  796. end
  797. yy += line_height
  798. change_color(normal_color)
  799. @quest.reward_items.each do |array|
  800. item = $data_items[array[1]] if array[0] == :item
  801. item = $data_weapons[array[1]] if array[0] == :weapon
  802. item = $data_armors[array[1]] if array[0] == :armor
  803. draw_item_name(item, 6, yy, true, contents.width)
  804. if array[2] > 1
  805. draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  806. end
  807. yy += line_height
  808. end
  809. end
  810. def reset_font_settings
  811. change_color(normal_color)
  812. contents.font.bold = Font.default_bold
  813. contents.font.italic = Font.default_italic
  814. end
  815. def line_height
  816. 18
  817. end
  818. def draw_objective(yy, obj)
  819. draw_text(6,yy,contents.width,24,obj.name)
  820. draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  821. end
  822. def show(quest,turnin)
  823. @quest = quest
  824. return if @quest.turned_in
  825. refresh
  826. open
  827. @confirm_window.quest(@quest)
  828. @confirm_window.open if !turnin
  829. if turnin
  830. @turnin_window.quest(@quest)
  831. @turnin_window.open
  832. end
  833. end
  834. def hide
  835. close
  836. @confirm_window.close
  837. @turnin_window.close
  838. end
  839. def accept
  840. @quest.accept
  841. end
  842. def turnin
  843. @quest.turnin
  844. end
  845. end
  846.  
  847. class Window_QuestConfirm < Window_HorzCommand
  848. def initialize
  849. super(Graphics.width/8,Graphics.width/8+Graphics.height-Graphics.width/8*2)
  850. self.openness = 0
  851. self.active = false
  852. @enabled = true
  853. refresh
  854. end
  855. def window_width
  856. Graphics.width/5*2
  857. end
  858. def window_height
  859. 48
  860. end
  861. def make_command_list
  862. add_command("Accept",:accept)
  863. add_command("Decline",:decline, @enabled)
  864. end
  865. def item_width
  866. width / 2 - padding * 2
  867. end
  868. def open
  869. super
  870. activate
  871. select(0)
  872. end
  873. def quest(quest)
  874. @quest = quest
  875. @enabled = !@quest.force_accept
  876. refresh
  877. end
  878. def cancel_enabled?
  879. super && @enabled
  880. end
  881. end
  882.  
  883. class Window_QuestTurnin < Window_QuestConfirm
  884. def quest(quest)
  885. @quest = quest
  886. @enabled = !@quest.force_turnin
  887. refresh
  888. end
  889. def make_command_list
  890. return unless @quest
  891. add_command("Complete",:accept,@quest.completed? && !@quest.turned_in)
  892. add_command("Cancel",:decline, @enabled)
  893. end
  894. end
  895.  
  896. class Game_Party
  897. attr_accessor :quests
  898. attr_accessor :tracking
  899. alias quests_init initialize
  900. def initialize(*args)
  901. quests_init(*args)
  902. @quests = $game_quests.reset_hash unless $game_quests.nil?
  903. @tracking = []
  904. end
  905. end
  906.  
  907. class Game_Player
  908. alias quest_update update
  909. def update
  910. return if SceneManager.scene.accepting?
  911. quest_update
  912. end
  913. end
  914.  
  915. class Game_Event
  916. def obj(quest, objective)
  917. $game_quests[quest].objective(objective).current
  918. end
  919. end
  920.  
  921. class Game_Interpreter
  922. def accept_quest(quest)
  923. $game_quests[quest].accept
  924. end
  925. def ask_accept(quest)
  926. return unless SceneManager.scene.is_a?(Scene_Map)
  927. SceneManager.scene.show_quest(quest)
  928. Fiber.yield while SceneManager.scene.accepting?
  929. end
  930. def abandon_quest(quest)
  931. $game_quests[quest].abandon
  932. end
  933. def fail_quest(quest)
  934. $game_quests[quest].fail
  935. end
  936. def turnin_quest(quest)
  937. $game_quests[quest].turnin
  938. end
  939. def ask_turnin(quest)
  940. return unless SceneManager.scene.is_a?(Scene_Map)
  941. SceneManager.scene.show_quest(quest,true)
  942. Fiber.yield while SceneManager.scene.accepting?
  943. end
  944. def adv_obj(quest, objective, value)
  945. $game_quests[quest].adv_obj(objective, value)
  946. end
  947. def set_obj(quest, objective, value)
  948. $game_quests[quest].set_obj(objective, value)
  949. end
  950. def obj(quest, objective)
  951. $game_quests[quest].objective(objective).current
  952. end
  953. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement