Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.68 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://alu5.e3zgnuujtg.qjtv.e.s48.ru.wbprx.com/DaimoniousTailsGames
  34. # All my other scripts and projects can be found here: http://w3xiozu5c6nbp3xiub.afzvljsa.qjtv.e.s48.ru.wbprx.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 = false
  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 = 1
  45. #Quest log offsets
  46. QUEST_LOG_OFFSET_X = -30
  47. QUEST_LOG_OFFSET_Y = 150
  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 => "Necesito agua!",
  87. :level => 1,
  88. :abandonable => true,
  89. :ask_accept => true,
  90. :force_turnin => true,}
  91. DESCRIPTIONS[:questid001] = {
  92. :qgiver_name => "Esta mujer",
  93. :location => "Este lugar",
  94. :desc => " Me muero de sed, puedes traerme un
  95. poco de agua del Mercader?" }
  96. OBJECTIVES[:questid001] = {
  97. :obj1 => ["Llevarle una botella de agua",1], }
  98. REWARDS[:questid001] = {
  99. :gold => 5,
  100. :exp => 10,
  101. :scale_exp => 5,
  102. :items => [[:item,1,2]], }
  103.  
  104. DETAILS[:questid002] = {
  105. :name => "Libro de Altair",
  106. :level => 1,
  107. :force_accept => true,
  108. :force_turnin => true,}
  109. DESCRIPTIONS[:questid002] = {
  110. :qgiver_name => "Altair",
  111. :location => "Casa de Altair",
  112. :desc => " Deje caer por
  113. accidente un libro de gran valor ! Sin este libro
  114. no podremos hacer nada para detener al
  115. Señor del Mal....(Consigue el Libro de Altair)" }
  116. OBJECTIVES[:questid002] = {
  117. :libro_altair => ["La Historia de Arssen por Wilmot",1] }
  118. REWARDS[:questid002] = {
  119. :gold => 5,
  120. :exp => 10,
  121. :scale_exp => 5,
  122. :items => [[:item,1,2]], }
  123.  
  124. #Main Quest 3
  125. DETAILS[:questid003] = {
  126. :name => "I need water!",
  127. :level => 1,
  128. :abandonable => true,
  129. :ask_accept => true,
  130. :force_turnin => true,}
  131. DESCRIPTIONS[:questid003] = {
  132. :qgiver_name => "This Lady",
  133. :location => "This Place",
  134. :desc => " I'm thirsty, can you get me some water from the merchant?" }
  135. OBJECTIVES[:questid003] = {
  136. :obj1 => ["Get a canteen of water",1], }
  137. REWARDS[:questid003] = {
  138. :gold => 5,
  139. :exp => 10,
  140. :scale_exp => 5,
  141. :items => [[:item,1,2]], }
  142.  
  143. #Side Quest
  144. DETAILS[:sidequest001] = {
  145. :name => "Fibers for M'Lana",
  146. :level => 3,}
  147. DESCRIPTIONS[:sidequest001] = {
  148. :qgiver_name => "M'Lana Lee",
  149. :location => "Class Town",
  150. :desc => " You're not sure what M'Lana
  151. wants with the plant fibres, but at
  152. least she's isn't telling you to
  153. leave anymore. Better do as she
  154. says and collect them from beasts
  155. around the Forest Camp." }
  156. OBJECTIVES[:sidequest001] = {
  157. :obj1 => ["Collect 10 plant fibres",10] }
  158. REWARDS[:sidequest001] = {
  159. :gold => 20,
  160. :exp => 25,
  161. :items => [[:armor,89,1]], }
  162.  
  163. end
  164.  
  165. class Game_Quests
  166. attr_accessor :reset_hash
  167. def initialize
  168. @quests = {}
  169. QUEST::DETAILS.each do |id, quest|
  170. @quests[id] = Quest.new(id,quest)
  171. end
  172. @reset_hash = {}
  173. @quests.each_value do |quest|
  174. @reset_hash[quest.id] = {}
  175. @reset_hash[quest.id][:accepted] = false
  176. @reset_hash[quest.id][:turnedin] = false
  177. quest.objectives.each do |id, obj|
  178. @reset_hash[quest.id][id] = obj
  179. end
  180. end
  181. end
  182. def [](quest_id)
  183. return msgbox("No Quest with id " + quest_id.to_s) if @quests[quest_id].nil?
  184. @quests[quest_id]
  185. end
  186. def []=(quest_id, val)
  187. @quests[quest_id] = val
  188. end
  189. def quests
  190. @quests
  191. end
  192. def no_quests?
  193. @quests.each do |id, quest|
  194. return false if quest.accepted? && !quest.turned_in
  195. end
  196. return true
  197. end
  198. def tracking?
  199. $game_party.tracking
  200. end
  201. def track_quest(id)
  202. return if $game_party.tracking.include?(id)
  203. $game_party.tracking.push(id)
  204. if $game_party.tracking.size > $questlogmaxdisplay
  205. $game_party.tracking.reverse!.pop
  206. $game_party.tracking.reverse!
  207. end
  208. end
  209. def untrack_quest(id)
  210. return unless $game_party.tracking.include?(id)
  211. $game_party.tracking.delete(id)
  212. $game_party.tracking.compact!
  213. end
  214. end
  215.  
  216. class Quest
  217. attr_accessor :name
  218. attr_accessor :level
  219. attr_accessor :id
  220. attr_accessor :desc
  221. attr_accessor :objectives
  222. attr_accessor :turned_in
  223. attr_accessor :difficulty
  224. attr_accessor :qgiver_name
  225. attr_accessor :location
  226. attr_accessor :auto_complete
  227. attr_accessor :abandonable
  228. attr_accessor :force_accept
  229. attr_accessor :force_turnin
  230. def initialize(id,quest_hash)
  231. @id = id
  232. @level = 0
  233. @difficulty = 0
  234. @name = "No Quest Name"
  235. @desc = ""
  236. @qgiver_name = 0
  237. @location = 0
  238. @auto_complete = false
  239. @abandonable = true
  240. @need_popup = false
  241. @force_turnin = false
  242. @force_accept = false
  243. @name = quest_hash[:name] if quest_hash[:name]
  244. @level = quest_hash[:level] if quest_hash[:level]
  245. @force_accept = quest_hash[:force_accept] if quest_hash[:force_accept]
  246. @force_turnin = quest_hash[:force_turnin] if quest_hash[:force_turnin]
  247. @difficulty = quest_hash[:difficulty] if quest_hash[:difficulty]
  248. @auto_complete = quest_hash[:auto_complete] if quest_hash[:auto_complete]
  249. @abandonable = quest_hash[:abandonable] if !quest_hash[:abandonable].nil?
  250. @desc = QUEST::DESCRIPTIONS[id][:desc] if QUEST::DESCRIPTIONS[id][:desc]
  251. @qgiver_name = QUEST::DESCRIPTIONS[id][:qgiver_name] if QUEST::DESCRIPTIONS[id][:qgiver_name]
  252. @location = QUEST::DESCRIPTIONS[id][:location] if QUEST::DESCRIPTIONS[id][:location]
  253. @objectives = {}
  254. if QUEST::OBJECTIVES[id]
  255. QUEST::OBJECTIVES[id].each do |id, obj|
  256. @objectives[id] = Objective.new(id, obj)
  257. end
  258. else
  259. msgbox("Quest " + id.to_s + " has no objectives.")
  260. end
  261. @reward_gold = 0
  262. @reward_exp = 0
  263. @scale_exp = 0
  264. @reward_items = []
  265. begin
  266. if QUEST::REWARDS[id][:gold]
  267. @reward_gold = QUEST::REWARDS[id][:gold]
  268. end
  269. if QUEST::REWARDS[id][:exp]
  270. @reward_exp = QUEST::REWARDS[id][:exp]
  271. @scale_exp = QUEST::REWARDS[id][:scale_exp] if QUEST::REWARDS[id][:scale_exp]
  272. end
  273. if QUEST::REWARDS[id][:items]
  274. @reward_items = QUEST::REWARDS[id][:items]
  275. end
  276. rescue
  277. msgbox(id.to_s + " has no defined REWARDS. This is not optional.")
  278. end
  279. end
  280. def accept
  281. reset
  282. $game_party.quests[id][:accepted] = true
  283. track_quest
  284. $game_map.need_refresh = true
  285. Audio.se_play("Audio/SE/Book2")
  286. end
  287. def abandon
  288. reset
  289. $game_party.quests[id][:accepted] = false
  290. end
  291. def fail
  292. Audio.me_play("Audio/ME/Gag")
  293. abandon
  294. end
  295. def accepted?
  296. $game_party.quests[id][:accepted]
  297. end
  298. def accepted
  299. accepted?
  300. end
  301. def completed?
  302. @objectives.each do |id, obj|
  303. return false if !$game_party.quests[@id][id].completed?
  304. end
  305. return true
  306. end
  307. def force_done
  308. $game_party.quests[id][:accepted] = true
  309. @objectives.each do |id, obj|
  310. $game_party.quests[@id][id].current = obj.max
  311. end
  312. turnin
  313. end
  314. def reset
  315. $game_party.quests[id][:accepted] = false
  316. @objectives.each do |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(["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 + ' completa!'])
  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. def initialize(id, obj)
  400. @name = obj[0]
  401. @current = 0
  402. @max = obj[1]
  403. end
  404. def completed?
  405. @current >= @max
  406. end
  407. end
  408.  
  409. module DataManager
  410. class << self
  411. alias quest_cgo load_database
  412. alias quest_sng setup_new_game
  413. end
  414. def self.load_database
  415. quest_cgo
  416. $game_quests = Game_Quests.new
  417. end
  418. def self.setup_new_game
  419. $game_quests = Game_Quests.new
  420. quest_sng
  421. end
  422. end
  423.  
  424. class Scene_Quest < Scene_MenuBase
  425. def initialize
  426. super
  427. @help_window = Window_Help.new(1)
  428. @help_window.set_text("Misiones")
  429. @list_window = Window_SceneList.new
  430. @list_window.set_handler(:cancel, method(:list_cancel))
  431. @list_window.set_handler(:ok, method(:list_ok))
  432. @list_window.refresh
  433. @list_window.activate
  434. @list_window.select(0)
  435. @detail_window = Window_SceneDetail.new
  436. @command_window = Window_QuestTrack.new
  437. @command_window.x = Graphics.width / 2 - @command_window.width / 2
  438. @command_window.y = Graphics.height / 2 - @command_window.height / 2
  439. @command_window.set_handler(:track, method(:track))
  440. @command_window.set_handler(:untrack, method(:untrack))
  441. @command_window.set_handler(:abandon, method(:abandon))
  442. @command_window.set_handler(:cancel, method(:command_cancel))
  443. end
  444. def update
  445. super
  446. @detail_window.quest = @list_window.current_item
  447. end
  448. def list_cancel
  449. SceneManager.return
  450. end
  451. def list_ok
  452. @command_window.quest(@list_window.current_item)
  453. @command_window.refresh
  454. @command_window.select(0)
  455. @command_window.activate
  456. @command_window.open
  457. end
  458. def track
  459. $game_quests.track_quest(@list_window.current_item.id)
  460. command_cancel
  461. end
  462. def untrack
  463. $game_quests.untrack_quest(@list_window.current_item.id)
  464. command_cancel
  465. end
  466. def abandon
  467. @list_window.current_item.abandon
  468. command_cancel
  469. end
  470. def command_cancel
  471. @command_window.close
  472. @list_window.refresh
  473. @list_window.activate
  474. list_cancel if $game_quests.no_quests?
  475. end
  476. end
  477.  
  478. class Window_SceneList < Window_ItemList
  479. def initialize
  480. super(0,48,Graphics.width/5*2,Graphics.height-48)
  481. end
  482. def make_item_list
  483. @data = []
  484. $game_quests.quests.each do |id, quest|
  485. @data.push(quest) if quest.accepted? && !quest.turned_in?
  486. end
  487. @data.push(nil) if @data.empty?
  488. end
  489. def draw_item(index)
  490. contents.font.size = 18
  491. item = @data[index]
  492. if item
  493. rect = item_rect(index)
  494. rect.width -= 4
  495. if $game_quests.tracking?.include?(item.id)
  496. text = "*" + item.name
  497. else
  498. text = item.name
  499. end
  500. draw_text(rect, text)
  501. draw_text(rect, "Lv" + item.level.to_s,2) if item.level > 0
  502. end
  503. end
  504. def col_max; 1; end
  505. def current_item
  506. @data[@index]
  507. end
  508. def current_item_enabled?
  509. true
  510. end
  511. end
  512.  
  513. class Window_SceneDetail < Window_Base
  514. def initialize
  515. super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*2,Graphics.height-48)
  516. end
  517. def quest=(quest)
  518. return if @quest == quest
  519. @quest = quest
  520. refresh
  521. end
  522. def refresh
  523. contents.clear
  524. return unless @quest
  525. contents.font.size = 18
  526. change_color(system_color)
  527. draw_text(0,0,contents.width,line_height,@quest.qgiver_name) if @quest.qgiver_name != 0
  528. draw_text(0,0,contents.width,line_height,@quest.location,2) if @quest.location != 0
  529. change_color(normal_color)
  530. @quest.qgiver_name != 0 || @quest.location != 0 ? yy = line_height : yy = 0
  531. draw_text_ex(0,yy,@quest.desc)
  532. change_color(system_color)
  533. draw_text(0,line_height*7,contents.width,24,"Objectivos:")
  534. change_color(normal_color)
  535. yy = line_height * 8
  536. @quest.objectives.each do |id, obj|
  537. draw_objective(yy, obj)
  538. yy += 24
  539. end
  540. change_color(system_color)
  541. draw_text(0,yy,contents.width,line_height,"Recompensas:")
  542. yy += line_height
  543. if @quest.reward_exp > 0
  544. draw_text(6,yy,contents.width/2,line_height,"XP: ")
  545. change_color(normal_color)
  546. draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  547. yy += line_height
  548. end
  549. if @quest.reward_gold > 0
  550. change_color(normal_color)
  551. draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  552. cx = text_size(@quest.reward_gold).width
  553. change_color(system_color)
  554. draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  555. end
  556. yy += line_height
  557. change_color(normal_color)
  558. @quest.reward_items.each do |array|
  559. item = $data_items[array[1]] if array[0] == :item
  560. item = $data_weapons[array[1]] if array[0] == :weapon
  561. item = $data_armors[array[1]] if array[0] == :armor
  562. draw_item_name(item, 6, yy, true, contents.width)
  563. if array[2] > 1
  564. draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  565. end
  566. yy += line_height
  567. end
  568. if @quest.difficulty != 0
  569. text = "Dificultad: " + @quest.difficulty
  570. draw_text(0,contents.height-line_height,contents.width,line_height,text,2)
  571. end
  572. end
  573. def draw_objective(yy, obj)
  574. draw_text(6,yy,contents.width,24,obj.name)
  575. draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  576. end
  577. def reset_font_settings
  578. change_color(normal_color)
  579. contents.font.bold = Font.default_bold
  580. contents.font.italic = Font.default_italic
  581. end
  582. end
  583.  
  584. class Window_QuestTrack < Window_Command
  585. def initialize
  586. super(0,0)
  587. self.openness = 0
  588. end
  589. def quest(quest)
  590. @quest = quest
  591. end
  592. def make_command_list
  593. return unless @quest
  594. if !$game_quests.tracking?.include?(@quest.id)
  595. add_command("Marcar Mision", :track)
  596. else
  597. add_command("Desmarcar Mision", :untrack)
  598. end
  599. add_command("Abandonar Mision", :abandon, @quest.can_abandon?)
  600. end
  601. def window_height
  602. fitting_height(2)
  603. end
  604. end
  605.  
  606. class Window_MenuCommand
  607. alias quest_aoc add_original_commands
  608. def add_original_commands
  609. quest_aoc
  610. add_command("Misiones", :quest, !$game_quests.no_quests?)
  611. end
  612. end
  613.  
  614. class Scene_Menu
  615. alias quest_ccw create_command_window
  616. def create_command_window
  617. quest_ccw
  618. @command_window.set_handler(:quest, method(:scene_quest))
  619. end
  620. def scene_quest
  621. SceneManager.call(Scene_Quest)
  622. end
  623. end
  624.  
  625. class Scene_Map
  626. alias quest_start start
  627. alias quest_update update
  628. def start
  629. quest_start
  630. @quest_log = Window_QuestLog.new
  631. @quest_confirm = Window_QuestConfirm.new
  632. @quest_confirm.set_handler(:accept, method(:confirm_accept))
  633. @quest_confirm.set_handler(:decline, method(:confirm_cancel))
  634. @quest_confirm.set_handler(:cancel, method(:confirm_cancel))
  635. @quest_turnin = Window_QuestTurnin.new
  636. @quest_turnin.set_handler(:accept, method(:turnin_accept))
  637. @quest_turnin.set_handler(:decline, method(:confirm_cancel))
  638. @quest_turnin.set_handler(:cancel, method(:confirm_cancel))
  639. @quest_apply = Window_QuestApply.new(@quest_confirm,@quest_turnin)
  640. end
  641. def update(*args)
  642. @quest_log = Window_QuestLog.new if @quest_log.disposed?
  643. quest_update(*args)
  644. end
  645. def show_quest(id, turnin = false)
  646. @quest_apply.show($game_quests[id],turnin)
  647. end
  648. def accepting?
  649. @quest_confirm.active || @quest_turnin.active
  650. end
  651. def confirm_accept
  652. @quest_apply.accept
  653. @quest_apply.hide
  654. end
  655. def confirm_cancel
  656. @quest_apply.hide
  657. end
  658. def turnin_accept
  659. @quest_apply.turnin
  660. @quest_apply.hide
  661. end
  662. def update_call_menu
  663. if $game_system.menu_disabled || $game_map.interpreter.running? || accepting?
  664. @menu_calling = false
  665. else
  666. @menu_calling ||= Input.trigger?(:B)
  667. call_menu if @menu_calling && !$game_player.moving?
  668. end
  669. end
  670. end
  671.  
  672. class Scene_Base
  673. def accepting?
  674. false
  675. end
  676. end
  677.  
  678. class Window_QuestLog < Window_Base
  679. def initialize
  680. super(Graphics.width/5*3,0,Graphics.width/5*2,Graphics.height)
  681. self.x = 0 if QUEST_LOG_POSITION == 1
  682. self.x += QUEST_LOG_OFFSET_X
  683. self.y += QUEST_LOG_OFFSET_Y
  684. self.opacity = 0
  685. self.contents.font.size = 18
  686. end
  687. def update
  688. super
  689. return unless Graphics.frame_count % 20 == 0
  690. self.visible = !$game_quests.no_quests?
  691. self.visible = $game_quests.tracking?.size > 0
  692. self.visible = $questlogvisibility
  693. return unless self.visible
  694. contents.clear
  695. change_color(crisis_color)
  696. draw_text(0,0,contents.width,18,"Misiones:",1)
  697. yy = 18;iter = 0
  698. $game_quests.tracking?.each do |id|
  699. quest = $game_quests[id]
  700. next unless quest.accepted? && !quest.turned_in
  701. change_color(system_color)
  702. draw_text(6,yy,contents.width-6,18,quest.name)
  703. change_color(normal_color)
  704. yy += 18
  705. quest.objectives.each do |obj_id, obj|
  706. draw_objective(yy, $game_party.quests[id][obj_id])
  707. yy += 18
  708. end
  709. iter += 1
  710. end
  711. end
  712. def draw_objective(yy, obj)
  713. draw_text(0,yy,contents.width-24,18,obj.name)
  714. draw_text(0,yy,contents.width,18,obj.current.to_s+"/"+obj.max.to_s,2)
  715. end
  716. end
  717.  
  718. class Window_QuestApply < Window_Base
  719. def initialize(confirm_window, turnin_window)
  720. super(Graphics.width/8,Graphics.width/8,Graphics.width/5*3,Graphics.height-Graphics.width/8*2)
  721. self.openness = 0
  722. @confirm_window = confirm_window
  723. @turnin_window = turnin_window
  724. self.contents.font.size = 18
  725. end
  726. def refresh
  727. return unless @quest
  728. contents.clear
  729. change_color(system_color)
  730. yy = 0
  731. if @quest.qgiver_name != 0
  732. draw_text(0,0,contents.width/2,line_height,@quest.qgiver_name)
  733. yy = line_height
  734. end
  735. if @quest.location != 0
  736. draw_text(contents.width/2,0,contents.width/2,line_height,@quest.location,2)
  737. yy = line_height
  738. end
  739. change_color(crisis_color)
  740. draw_text(0,yy,contents.width,line_height,"Lvl: " + @quest.level.to_s) if @quest.level > 0
  741. draw_text(0,yy,contents.width,line_height,@quest.name,1)
  742. draw_text(0,yy,contents.width,line_height,@quest.difficulty,2) if @quest.difficulty != 0
  743. change_color(normal_color)
  744. draw_text_ex(0,line_height+yy,@quest.desc)
  745. change_color(system_color)
  746. draw_text(0,line_height*8,contents.width,line_height,"Objectivos:")
  747. change_color(normal_color)
  748. yy = line_height * 9
  749. @quest.objectives.each do |obj_id, obj|
  750. draw_objective(yy, $game_party.quests[@quest.id][obj_id])
  751. yy += line_height
  752. end
  753. change_color(system_color)
  754. draw_text(0,yy,contents.width,line_height,"Recompensas:")
  755. yy += line_height
  756. if @quest.reward_exp > 0
  757. draw_text(6,yy,contents.width/2,line_height,"XP: ")
  758. change_color(normal_color)
  759. draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  760. yy += line_height
  761. end
  762. if @quest.reward_gold > 0
  763. change_color(normal_color)
  764. draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  765. cx = text_size(@quest.reward_gold).width
  766. change_color(system_color)
  767. draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  768. end
  769. yy += line_height
  770. change_color(normal_color)
  771. @quest.reward_items.each do |array|
  772. item = $data_items[array[1]] if array[0] == :item
  773. item = $data_weapons[array[1]] if array[0] == :weapon
  774. item = $data_armors[array[1]] if array[0] == :armor
  775. draw_item_name(item, 6, yy, true, contents.width)
  776. if array[2] > 1
  777. draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  778. end
  779. yy += line_height
  780. end
  781. end
  782. def reset_font_settings
  783. change_color(normal_color)
  784. contents.font.bold = Font.default_bold
  785. contents.font.italic = Font.default_italic
  786. end
  787. def line_height
  788. 18
  789. end
  790. def draw_objective(yy, obj)
  791. draw_text(6,yy,contents.width,24,obj.name)
  792. draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  793. end
  794. def show(quest,turnin)
  795. @quest = quest
  796. return if @quest.turned_in
  797. refresh
  798. open
  799. @confirm_window.quest(@quest)
  800. @confirm_window.open if !turnin
  801. if turnin
  802. @turnin_window.quest(@quest)
  803. @turnin_window.open
  804. end
  805. end
  806. def hide
  807. close
  808. @confirm_window.close
  809. @turnin_window.close
  810. end
  811. def accept
  812. @quest.accept
  813. end
  814. def turnin
  815. @quest.turnin
  816. end
  817. end
  818.  
  819. class Window_QuestConfirm < Window_HorzCommand
  820. def initialize
  821. super(Graphics.width/8,Graphics.width/8+Graphics.height-Graphics.width/8*2)
  822. self.openness = 0
  823. self.active = false
  824. @enabled = true
  825. refresh
  826. end
  827. def window_width
  828. Graphics.width/5*2
  829. end
  830. def window_height
  831. 48
  832. end
  833. def make_command_list
  834. add_command("Acceptar",:accept)
  835. add_command("Declinar",:decline, @enabled)
  836. end
  837. def item_width
  838. width / 2 - padding * 2
  839. end
  840. def open
  841. super
  842. activate
  843. select(0)
  844. end
  845. def quest(quest)
  846. @quest = quest
  847. @enabled = !@quest.force_accept
  848. refresh
  849. end
  850. def cancel_enabled?
  851. super && @enabled
  852. end
  853. end
  854.  
  855. class Window_QuestTurnin < Window_QuestConfirm
  856. def quest(quest)
  857. @quest = quest
  858. @enabled = !@quest.force_turnin
  859. refresh
  860. end
  861. def make_command_list
  862. return unless @quest
  863. add_command("Completar",:accept,@quest.completed? && !@quest.turned_in)
  864. add_command("Cancelar",:decline, @enabled)
  865. end
  866. end
  867.  
  868. class Game_Party
  869. attr_accessor :quests
  870. attr_accessor :tracking
  871. alias quests_init initialize
  872. def initialize(*args)
  873. quests_init(*args)
  874. @quests = $game_quests.reset_hash unless $game_quests.nil?
  875. @tracking = []
  876. end
  877. end
  878.  
  879. class Game_Player
  880. alias quest_update update
  881. def update
  882. return if SceneManager.scene.accepting?
  883. quest_update
  884. end
  885. end
  886.  
  887. class Game_Event
  888. def obj(quest, objective)
  889. $game_quests[quest].objective(objective).current
  890. end
  891. end
  892.  
  893. class Game_Interpreter
  894. def accept_quest(quest)
  895. $game_quests[quest].accept
  896. end
  897. def ask_accept(quest)
  898. return unless SceneManager.scene.is_a?(Scene_Map)
  899. SceneManager.scene.show_quest(quest)
  900. Fiber.yield while SceneManager.scene.accepting?
  901. end
  902. def abandon_quest(quest)
  903. $game_quests[quest].abandon
  904. end
  905. def fail_quest(quest)
  906. $game_quests[quest].fail
  907. end
  908. def turnin_quest(quest)
  909. $game_quests[quest].turnin
  910. end
  911. def ask_turnin(quest)
  912. return unless SceneManager.scene.is_a?(Scene_Map)
  913. SceneManager.scene.show_quest(quest,true)
  914. Fiber.yield while SceneManager.scene.accepting?
  915. end
  916. def adv_obj(quest, objective, value)
  917. $game_quests[quest].adv_obj(objective, value)
  918. end
  919. def set_obj(quest, objective, value)
  920. $game_quests[quest].set_obj(objective, value)
  921. end
  922. def obj(quest, objective)
  923. $game_quests[quest].objective(objective).current
  924. end
  925. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement