赞 | 0 |
VIP | 6 |
好人卡 | 0 |
积分 | 1 |
经验 | 1383 |
最后登录 | 2016-2-5 |
在线时间 | 38 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 38 小时
- 注册时间
- 2009-11-30
- 帖子
- 71
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
帮忙把这个窗口改成半透明的
1. #==============================================================================
2. # Sample master list for crafting script
3. # written by Deke
4. #============================================================================================
5. # 简介:
6. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
7. # 物品方法。
8. #
9. # 使用方法:
10. # 1、召唤界面:使用脚本$scene = Scene_Craft.new
11. #
12. # 2、学习合成:$game_party.learn_recipe(合成项目)
13. #
14. # 3、合成定义:
15. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
16. # 直接写在这里就可以,另一种是在学习之前现场定义。
17. #
18. # 4、举例
19. # 4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[2])
20. # 注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
21. #
22. # 4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,
23. # 脚本:
24. # 材料 = [$game_variables[1],$game_variables[2]] #——材料编号是变量1、2的编号
25. # 材料种类 = [0,0] #——材料是物品
26. # 材料数量 = [$game_variables[3],$game_variables[4]] #——需要材料数量是变量3、4的编号
27. # 成品 = $game_variables[5] #——获得结果编号是5
28. # 成品种类 = 1 #——成品是防具类
29. # $game_party.learn_recipe(Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类))
30. #===========================================================================================
31. class Game_Temp
32. attr_reader :recipe_list
33. alias crafting_temp_initialize initialize
34. def initialize
35. crafting_temp_initialize
36. @recipe_list=[]
37. get_recipe_list
38. end
39. def get_recipe_list
40. ##########################################################################
41. # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
42. ##########################################################################
43. 材料 = [1, 2] # 需要材料的数据库编号
44. 材料种类 = [0, 0] # 需要材料的种类,0是普通物品,1是防具,2是武器
45. 材料数量 = [2, 1] # 需要材料的数量
46. 成品 = 3 # 获得物品编号
47. 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
48. @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
49.
50. ##########################################################################
51. # 1 号合成物品设定 (武器铜剑、铁剑、钢剑各1 = 密切斯特剑)
52. ##########################################################################
53. 材料 = [1, 2, 3] # 需要材料的数据库编号
54. 材料种类 = [2, 2, 2] # 需要材料的种类,0是普通物品,1是防具,2是武器
55. 材料数量 = [3, 2, 1] # 需要材料的数量
56. 成品 = 4 # 获得物品编号
57. 成品种类 = 2 # 获得物品种类,0是普通物品,1是防具,2是武器
58. @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
59.
60. ##########################################################################
61. # 2 号合成物品设定 (物品力量之石×2 + 防具钢盾×1 = 密切斯特盾)
62. ##########################################################################
63. 材料 = [13, 3] # 需要材料的数据库编号
64. 材料种类 = [0, 1] # 需要材料的种类,0是普通物品,1是防具,2是武器
65. 材料数量 = [2, 1] # 需要材料的数量
66. 成品 = 4 # 获得物品编号
67. 成品种类 = 1 # 获得物品种类,0是普通物品,1是防具,2是武器
68. @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
69.
70. ##########################################################################
71. # 2 号合成物品设定 (金疮药×2 + 仙狐涎×1 = 大粒丸)
72. ##########################################################################
73. 材料 = [1, 2] # 需要材料的数据库编号
74. 材料种类 = [0, 0] # 需要材料的种类,0是普通物品,1是防具,2是武器
75. 材料数量 = [2, 1] # 需要材料的数量
76. 成品 = 3 # 获得物品编号
77. 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
78. @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
79.
80. end # of get_recipe_list method
81. end # of updates to Game_Temp Class
82.
83. #================================
84. # CRAFTING PROGRAM
85. #----------------------------------------------------------------
86. #-written by Deke
87. #-yes_no window code created by Phsylomortis
88. #----------------------------------------------------------------
89. #================================
90.
91. #updates to Game_Party class
92.
93. class Game_Party
94.
95. attr_accessor :recipes
96.
97. alias crafting_party_initialize initialize
98.
99. def initialize
100. crafting_party_initialize
101. @recipes=[]
102. end
103.
104. #----------------------------------------------------------------------
105. def know?(recipe, version = 1)
106. unless recipe.is_a?(Game_Recipe)
107. recipe = get_recipe_from_master_list(recipe, version)
108. end
109. return $game_party.recipes.include?(recipe)
110. end
111.
112. #----------------------------------------------------------------------
113. def learn_recipe(recipe , version = 1)
114. unless recipe.is_a?(Game_Recipe)
115. recipe = get_recipe_from_master_list(recipe, version)
116. end
117. if recipe.is_a?(Game_Recipe)
118. unless know?(recipe)
119. @recipes.push(recipe)
120. end
121. end
122. end
123.
124. #----------------------------------------------------------------------
125. def forget_recipe(recipe , version = 1)
126. if !recipe.is_a?(Game_Recipe)
127. recipe = get_recipe_from_master_list(recipe, version)
128. end
129. if recipe.is_a?(Game_Recipe)
130. for i in [email protected]
131. if recipe == @recipes
132. index = i
133. break
134. end
135. end
136. if index != nil
137. @recipes.delete(@recipes[index])
138. end
139. end
140. end
141.
142. #----------------------------------------------------------------------
143. def get_recipe_from_master_list(item, version)
144. index = nil
145. for i in 0...$game_temp.recipe_list.size
146. if item[0] == $game_temp.recipe_list.result and item[1] ==$game_temp.recipe_list.result_type
147. version -= 1
148. if version == 0
149. index = i
150. break
151. end
152. end
153. end
154. if index.is_a?(Integer)
155. return ($game_temp.recipe_list[index])
156. else
157. return false
158. end
159. end
160.
161. end # of Game_Party updates
162.
163. #================================
164. class Game_Recipe
165.
166. attr_reader :ingredients
167. attr_reader :quantities
168. attr_reader :result
169. attr_reader :result_type
170. attr_reader :ingredient_types
171.
172. #----------------------------------------------------------------------
173. def initialize( ingredients, ingredient_types, quantities, result, result_type)
174. @ingredients = ingredients
175. @ingredient_types = ingredient_types
176. @quantities = quantities
177. @result = result
178. @result_type = result_type
179. end
180.
181. #----------------------------------------------------------------------
182. def name
183. case @result_type
184. when 0
185. name = $data_items[@result].name
186. when 1
187. name = $data_armors[@result].name
188. when 2
189. name = $data_weapons[@result].name
190. end
191. return name
192. end
193.
194. #----------------------------------------------------------------------
195. def have
196. have_all = true
197. for i in [email protected]
198. case @ingredient_types
199. when 0
200. if $game_party.item_number(@ingredients) < @quantities
201. have_all=false
202. end
203. when 1
204. if $game_party.armor_number(@ingredients) < @quantities
205. have_all=false
206. end
207. when 2
208. if $game_party.weapon_number(@ingredients) < @quantities
209. have_all=false
210. end
211. end
212. end
213. return have_all
214. end
215.
216. #----------------------------------------------------------------------
217. def decrement
218. for i in [email protected]
219. case @ingredient_types
220. when 0
221. $game_party.lose_item(@ingredients, @quantities)
222. when 1
223. $game_party.lose_armor(@ingredients, @quantities)
224. when 2
225. $game_party.lose_weapon(@ingredients, @quantities)
226. end
227. end
228. end
229.
230. #----------------------------------------------------------------------
231. def make
232. if have
233. case @result_type
234. when 0
235. $game_party.gain_item(@result, 1)
236. when 1
237. $game_party.gain_armor(@result, 1)
238. when 2
239. $game_party.gain_weapon(@result, 1)
240. end
241. decrement
242. end
243. end
244.
245. #----------------------------------------------------------------------
246. def == (recipe)
247. if recipe.is_a?(Game_Recipe)
248. equal = true
249. if recipe.ingredients != self.ingredients
250. equal = false
251. end
252. if recipe.ingredient_types != self.ingredient_types
253. equal = false
254. end
255. if recipe.quantities != self.quantities
256. equal = false
257. end
258. if recipe.result != self.result
259. equal=false
260. end
261. if recipe.result_type != self.result_type
262. equal = false
263. end
264. else
265. equal = false
266. end
267. return equal
268. end
269.
270. end # of Game_Recipe class
271.
272. #===================================
273.
274. class Window_Craft < Window_Selectable
275.
276. #--------------------------------------------------------------------------
277. def initialize
278. super(0, 64, 240, 416 - 32 + 16 - 15)
279. @column_max = 1
280. refresh
281. self.index = 0
282. end
283.
284. #--------------------------------------------------------------------------
285. def recipe
286. return @data[self.index]
287. end
288. ############################################################################
289. def item
290. case @types[self.index]
291. when 0
292. return $data_items[@ingredients]
293. when 1
294. return $data_armors[@ingredients]
295. when 2
296. return $data_weapons[@ingredients]
297. end
298. end
299. ############################################################################
300.
301. #--------------------------------------------------------------------------
302. def refresh
303. if self.contents != nil
304. self.contents.dispose
305. self.contents = nil
306. end
307. @data = []
308. for i in 0...$game_party.recipes.size
309. @data.push($game_party.recipes)
310. end
311. @item_max = @data.size
312. if @item_max > 0
313. self.contents = Bitmap.new(width - 32, row_max * 32)
314. self.contents.font.name = "黑体" # = "黑体"
315. self.contents.font.size = 18 # = 18
316. for i in 0...@item_max
317. draw_item(i)
318. end
319. end
320. end
321.
322. #--------------------------------------------------------------------------
323. def draw_item(index)
324. recipe = @data[index]
325. self.contents.font.color = recipe.have ? normal_color : disabled_color
326. x = 16
327. y = index * 32
328. self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
329. end
330.
331. #--------------------------------------------------------------------------
332. def update_help
333. current_recipe = recipe
334. if current_recipe.is_a?(Game_Recipe)
335. case current_recipe.result_type
336. when 0
337. description = $data_items[current_recipe.result].description
338. when 1
339. description = $data_armors[current_recipe.result].description
340. when 2
341. description = $data_weapons[current_recipe.result].description
342. end
343. else
344. description = ""
345. end
346. @help_window.set_text(description)
347. @help_window.update
348. end
349.
350. end # of Window_Craft
351.
352. #=======================================
353. class Window_CraftResult < Window_Base
354.
355. #--------------------------------------------------------------------------
356. def initialize
357. super(240, 64, 400, 184)
358. self.contents = Bitmap.new(width - 32, height - 32)
359. self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
360. self.contents.font.size = 18 # = 20
361. @result = nil
362. @type = nil
363. end
364.
365. #--------------------------------------------------------------------------
366. def refresh
367. self.contents.clear
368. case @type
369. when 0
370. item = $data_items[@result]
371. if item.recover_hp_rate > item.recover_hp
372. hp_string = "HP回复率:"
373. hp_stat = item.recover_hp_rate
374. else
375. hp_string = "HP回复量:"
376. hp_stat = item.recover_hp
377. end
378. if item.recover_sp_rate > item.recover_sp
379. sp_string = "SP回复率:"
380. sp_stat = item.recover_sp_rate
381. else
382. sp_string = "SP回复量:"
383. sp_stat = item.recover_sp
384. end
385. @strings = [hp_string, sp_string, "物理防御:" , "仙法防御:", "命中率:", "分散度:"]
386. @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
387. $game_party.item_number(@result)]
388. @bitmap = RPG::Cache.icon(item.icon_name)
389. when 1
390. item = $data_armors[@result]
391. @strings = ["物理防御:", "仙法防御:", "回避修正:", "力量增加:", "灵巧增加:",
392. "速度增加:", "仙攻增加:"]
393. @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
394. item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
395. @bitmap = RPG::Cache.icon(item.icon_name)
396. when 2
397. item = $data_weapons[@result]
398. @strings =["攻击力:", "物理防御:", "仙法防御:", "力量增加:", "灵巧增加:",
399. "速度增加:", "仙攻增加:"]
400. @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
401. item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
402. @bitmap = RPG::Cache.icon(item.icon_name)
403. end
404. for i in [email protected]
405. x = i%2 * 184
406. y = i /2 *28 +32
407. self.contents.font.color = normal_color
408. self.contents.draw_text(x,y,100, 28,@strings)
409. self.contents.font.color = system_color
410. self.contents.draw_text(x + 110, y, 45, 28, @stats.to_s)
411. end
412. self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
413. self.contents.font.color= normal_color
414. self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
415. self.contents.font.color = system_color
416. count = @stats[@stats.size - 1].to_s
417. self.contents.draw_text(294, 0, 45, 28, count )
418. end
419.
420. #----------------------------------------------------------------------
421. def set_result(result , type)
422. @result = result
423. @type = type
424. refresh
425. end
426.
427. end #of Window_CraftResult
428.
429. #=======================================
430. class Window_CraftIngredients < Window_Base
431.
432. #--------------------------------------------------------------------------
433. def initialize
434. super(240, 248, 400, 232 - 32 + 16 - 15)
435. self.contents = Bitmap.new(width - 32, height - 32)
436. self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
437. self.contents.font.size = 18 # = 20
438. @ingredients = []
439. @types = []
440. @quantities = []
441. @item = nil
442. @count = 0
443. end
444.
445. #--------------------------------------------------------------------------
446. def refresh
447. self.contents.clear
448. for i in [email protected]
449. case @types
450. when 0
451. @item = $data_items[@ingredients]
452. @count = $game_party.item_number(@ingredients)
453. when 1
454. @item = $data_armors[@ingredients]
455. @count = $game_party.armor_number(@ingredients)
456. when 2
457. @item = $data_weapons[@ingredients]
458. @count = $game_party.weapon_number(@ingredients)
459. end
460. y = i *26
461. self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
462. self.contents.font.color = @count >= @quantities ? normal_color : disabled_color
463. self.contents.draw_text(30, y, 280, 28, @item.name)
464. self.contents.draw_text(300, y, 45, 28, @quantities.to_s)
465. self.contents.font.color = system_color
466. self.contents.draw_text(245, y, 45, 28, @count.to_s )
467. end
468. end
469. #--------------------------------------------------------------------------
470. def set_ingredients(ingredients , types, quantities)
471. @ingredients = ingredients
472. @types = types
473. @quantities = quantities
474. refresh
475. end
476.
477. end # of Window_CraftIngredients
478.
479. #======================================
480. class Scene_Craft
481.
482. #--------------------------------------------------------------------------
483. def initialize(craft_index=0)
484. @craft_index=craft_index
485. end
486.
487. #--------------------------------------------------------------------------
488. def main
489. @craft_window = Window_Craft.new
490. @craft_window.index=@craft_index
491. @confirm_window = Window_Base.new(120, 188, 400, 64)
492. @confirm_window.contents = Bitmap.new(368, 32)
493. @confirm_window.contents.font.name = "黑体"
494. @confirm_window.contents.font.size = 20
495. @help_window = Window_Help.new
496. @craft_window.help_window = @help_window
497. @result_window=Window_CraftResult.new
498. @ingredients_window=Window_CraftIngredients.new
499. @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
500. @confirm_window.visible = false
501. @confirm_window.z = 1500
502. @yes_no_window.visible = false
503. @yes_no_window.active = false
504. @yes_no_window.index = 1
505. @yes_no_window.x = 270
506. @yes_no_window.y = 252
507. @yes_no_window.z = 1500
508. @label_window = Window_Base.new(450,200,190,52)
509. @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
510. @label_window.contents.font.size=20
511. @label_window.contents.font.color = @label_window.normal_color
512. @label_window.contents.font.name = "黑体"
513. @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, " 现有 需要")
514. Graphics.transition
515. loop do
516. Graphics.update
517. Input.update
518. update
519. if $scene != self
520. break
521. end
522. end
523. Graphics.freeze
524. @help_window.dispose
525. @craft_window.dispose
526. @result_window.dispose
527. @ingredients_window.dispose
528. @confirm_window.dispose
529. @yes_no_window.dispose
530. @label_window.dispose
531. end
532.
533. #--------------------------------------------------------------------------
534. def update
535. @craft_window.update
536. @ingredients_window.update
537. if $game_party.recipes.size > 0
538. @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
539. @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
540. @craft_window.recipe.ingredient_types,
541. @craft_window.recipe.quantities)
542. end
543. if @craft_window.active
544. update_craft
545. return
546. end
547. if @yes_no_window.active
548. confirm_update
549. return
550. end
551. end
552.
553. #--------------------------------------------------------------------------
554. def update_craft
555. if Input.trigger?(Input::B)
556. $game_system.se_play($data_system.cancel_se)
557. $scene = Scene_Menu.new(3)
558. return
559. end
560. if Input.trigger?(Input::C) and $game_party.recipes.size != 0
561. @recipe = @craft_window.recipe
562. if @recipe.have
563. @yes_no_window.active = true
564. @craft_window.active = false
565. else
566. $game_system.se_play($data_system.buzzer_se)
567. return
568. end
569. end
570. end
571.
572. #--------------------------------------------------------------------------
573. def confirm_update
574. @craft_index = @craft_window.index
575. @confirm_window.visible = true
576. @confirm_window.z = 1500
577. @yes_no_window.visible = true
578. @yes_no_window.active = true
579. @yes_no_window.z = 1500
580. @yes_no_window.update
581. string = "合成 " + @recipe.name + "?"
582. cw = @confirm_window.contents.text_size(string).width
583. center = @confirm_window.contents.width/2 - cw /2
584. unless @drawn
585. @confirm_window.contents.draw_text(center, 0, cw, 30, string)
586. @drawn = true
587. end
588. if Input.trigger?(Input::C)
589. if @yes_no_window.index == 0
590. $game_system.se_play($data_system.decision_se)
591. @recipe.make
592. $game_system.se_play($data_system.save_se)
593. $scene=Scene_Craft.new(@craft_index)
594. else
595. $game_system.se_play($data_system.cancel_se)
596. $scene=Scene_Craft.new(@craft_index)
597. end
598. end
599. if Input.trigger?(Input::B)
600. $game_system.se_play($data_system.cancel_se)
601. $scene=Scene_Craft.new(@craft_index)
602. end
603. end
604.
605. end # of Scene_Craft
606.
607. #==============================================================================
608. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
609. #============================================================================== |
|