Advertisement
Guest User

Script For Forum

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