Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.66 KB | None | 0 0
  1. #encoding:utf-8
  2. #=============================================================================
  3. #-----------RMVA加点系统正常向-v1.03---By:救世小树--------转载请注明出处-------
  4. #=============================================================================
  5.  
  6. module Point_Tree
  7.  
  8. POINT_KIND = 6 #设定加点种类
  9. LEVEL_UP_POINT = 3 #每升一级自由属性点增加数
  10. RESET_ITEM = 29 #洗点水编号
  11.  
  12. #$game_actors[n].point[0]+=x
  13. #n为角色ID,x为增加的未分配点数
  14.  
  15. STR_POINT = ["生命","精神","力量","耐力","敏捷","抗性"]
  16.  
  17. #分别对应增加 [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  18. POINT_ADD_PARAM = [
  19. [1 , 0, 0, 0, 0, 0, 0, 0], #体力
  20. [0 , 1, 0, 0, 0, 0, 0, 0], #精神
  21. [0 , 0, 1, 0, 1, 0, 0, 0], #力量
  22. [0 , 0, 0, 1, 0, 1, 0, 0], #耐力
  23. [0 , 0, 0, 0, 0, 0, 1, 0], #灵活
  24. [0 , 0, 0, 0, 0, 0, 0, 1], #韧性
  25.  
  26. [0,0,0,0,0,0,0,0]]
  27. #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
  28.  
  29. #分别对应增加 [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  30. POINT_ADD_XPARAM = [
  31. [0 , 0, 0, 0, 0, 0, 0, 5, 0, 0], #体力
  32. [0 , 0, 0, 0, 0, 0, 0, 0, 5, 0], #精神
  33. [0 , 0, 5, 0, 0, 0, 0, 0, 0, 0], #力量
  34. [0 , 0, 0, 0, 0, 0, 0, 0, 0, 5], #耐力
  35. [0 , 5, 0, 0, 0, 0, 0, 0, 0, 0], #灵活
  36. [5 , 0, 0, 0, 0, 0, 0, 0, 0, 0], #韧性
  37.  
  38. [0,0,0,0,0,0,0,0,0,0]]
  39. #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
  40.  
  41. #各种名称
  42.  
  43. ADDPOINT = "加點" #菜单中选项
  44. POINT_NAME = "Ap" #未分配点数
  45.  
  46. XARAM_NAME = ["命中率","迴避率","爆擊率","必杀闪避","魔法闪避","魔法反射","物理反击","HP再生","Mp再生","Tp再生"]
  47.  
  48.  
  49. def temp_all
  50. r = 0
  51. for i in 0 .. POINT_KIND-1
  52. r+=$temp_point[i]
  53. end
  54. return r
  55. end
  56.  
  57. def reset(actor_id)
  58. for i in 1..6
  59. $game_actors[actor_id].point[0] += $game_actors[actor_id].point[i]
  60. $game_actors[actor_id].point[i] =0
  61. end
  62. end
  63.  
  64. end
  65.  
  66. $temp_point = []
  67. for i in 0 .. Point_Tree::POINT_KIND-1
  68. $temp_point.push(0)
  69. end
  70.  
  71. class Game_Actor < Game_Battler
  72. include Point_Tree
  73. attr_accessor :point
  74.  
  75. alias setup_tre setup
  76. def setup(actor_id)
  77. @point = []
  78. for i in 0 .. POINT_KIND
  79. @point.push(0)
  80. end
  81. setup_tre(actor_id)
  82. end
  83.  
  84.  
  85. alias level_up_tre level_up
  86. def level_up
  87. level_up_tre
  88. @hp += mhp
  89. @mp += mmp
  90. @point[0] += LEVEL_UP_POINT
  91. end
  92.  
  93. def point_plus(param_id)
  94. r=0
  95. for i in 1 .. POINT_KIND
  96. r+=@point[i]*POINT_ADD_PARAM[i-1][param_id]
  97. end
  98. return r
  99. end
  100.  
  101. alias add_point_item_apply item_apply
  102. def item_apply(user, item)
  103. add_point_item_apply(user, item)
  104. if item.id == RESET_ITEM and item.is_a?(RPG::Item)
  105. reset(@actor_id)
  106. self.hp = [self.hp,self.mhp].min
  107. self.mp = [self.mp,self.mmp].min
  108. end
  109. end
  110.  
  111. end
  112.  
  113. class Window_Point_Command < Window_Command
  114.  
  115. include Point_Tree
  116. #--------------------------------------------------------------------------
  117. # ● 初始化指令选择位置(类方法)
  118. #--------------------------------------------------------------------------
  119. def self.init_command_position
  120. @@last_command_symbol = nil
  121. end
  122. #--------------------------------------------------------------------------
  123. # ● 初始化对象
  124. #--------------------------------------------------------------------------
  125. def initialize(actor)
  126. @status_window = nil
  127. @actor = actor
  128. super(0,0)
  129. select_last
  130. end
  131. def actor=(actor)
  132. return if @actor == actor
  133. @actor = actor
  134. refresh
  135. end
  136. def status_window=(status_window)
  137. return if @status_window == status_window
  138. @status_window = status_window
  139. end
  140. #--------------------------------------------------------------------------
  141. # ● 获取窗口的宽度
  142. #--------------------------------------------------------------------------
  143. def window_width
  144. return 160
  145. end
  146. #--------------------------------------------------------------------------
  147. # ● 获取显示行数
  148. #--------------------------------------------------------------------------
  149. def visible_line_number
  150. item_max
  151. end
  152. def get_actor_point(index)
  153. s = @actor.point[index+1].to_s
  154. return "("+s+")+"+$temp_point[index].to_s
  155. end
  156. #--------------------------------------------------------------------------
  157. # ● 生成指令列表
  158. #--------------------------------------------------------------------------
  159. def make_command_list
  160. for i in 0 .. POINT_KIND-1
  161. add_command(STR_POINT[i] + get_actor_point(i) , :point_add ,add_enabled)
  162. end
  163. add_command("确认", :point_ok)
  164. add_command("取消", :point_cancle)
  165. end
  166. #--------------------------------------------------------------------------
  167. # ● 按下确定键时的处理
  168. #--------------------------------------------------------------------------
  169. def process_ok
  170. @@last_command_symbol = current_symbol
  171. super
  172. end
  173. #--------------------------------------------------------------------------
  174. # ● 返回最后一个选项的位置
  175. #--------------------------------------------------------------------------
  176. def select_last
  177. select_symbol(@@last_command_symbol)
  178. end
  179.  
  180. def add_enabled
  181. temp_all < @actor.point[0]
  182. end
  183.  
  184. def update_help
  185. @help_window.set_text(self.index+1) if @help_window
  186. @status_window.index = self.index if @status_window
  187. end
  188. end
  189.  
  190. #帮助窗口
  191. class Window_Point_Help < Window_Base
  192. include Point_Tree
  193. def initialize(x,y,w,h)
  194. super(x, y, w, h)
  195.  
  196.  
  197. end
  198. def set_text(id)
  199. contents.clear
  200. if id <= POINT_KIND
  201. text = "\\}提升一点该属性"
  202. elsif id == POINT_KIND+1
  203. text = "\\}确认此次加点分配"
  204. elsif id == POINT_KIND+2
  205. text = "\\}取消此次加点分配"
  206. end
  207. draw_text_ex(8, 8, text)
  208. end
  209. end
  210.  
  211.  
  212. #角色状态窗口
  213. class Window_Point_Actor < Window_Base
  214. include Point_Tree
  215.  
  216.  
  217. def initialize(actor)
  218. super(160, 0, Graphics.width - 160, Graphics.height)
  219. @actor = actor
  220. @index = 0
  221. refresh
  222. end
  223. def actor=(actor)
  224. return if @actor == actor
  225. @actor = actor
  226. refresh
  227. end
  228. def index=(index)
  229. return if @index == index
  230. @index = index
  231. refresh
  232. end
  233. def line_height
  234. return 24
  235. end
  236. def refresh
  237. contents.clear
  238. contents.font.size = 24
  239. draw_actor_name(@actor, 100, 0)
  240. draw_actor_class(@actor, 240, 0)
  241. draw_actor_face(@actor, 2, 0)
  242. contents.font.size = 20
  243. draw_actor_level(@actor, 102, 24)
  244. draw_actor_point(100,48)
  245. contents.font.size = 16
  246. draw_actor_param_point(8,16 * 6)
  247. draw_actor_xparam_point(8,16 * 14)
  248. end
  249. def draw_actor_point(x,y)
  250. draw_text(x,y,200,line_height," 未分配"+POINT_NAME + ":" + @actor.point[0].to_s)
  251. draw_text(x,y+line_height,200,line_height,"此次分配"+POINT_NAME + ":" + temp_all.to_s)
  252. end
  253. def draw_actor_param_point(x,y)
  254. 8.times {|i| draw_actor_param_to_s(x,y,i)}
  255. end
  256. def draw_actor_xparam_point(x,y)
  257. 10.times {|i| draw_actor_xparam_to_s(x,y,i)}
  258. end
  259.  
  260. def draw_actor_param_to_s(x,y,param_id)
  261. a=0
  262. for i in 0 .. POINT_KIND-1
  263. a+=$temp_point[i]*POINT_ADD_PARAM[i][param_id]
  264. end
  265. s1 = Vocab::param(param_id)
  266. s2 = @actor.param(param_id).to_s
  267. s3 = (@actor.param(param_id)+a).to_s
  268. if @index < POINT_KIND
  269. if POINT_ADD_PARAM[@index][param_id]==0
  270. s4 = ""
  271. else
  272. s4 = "+" + POINT_ADD_PARAM[@index][param_id].to_s
  273. end
  274. else
  275. s4 = ""
  276. end
  277.  
  278. change_color(system_color)
  279. draw_text(x,y+16*param_id,100,line_height,s1)
  280. change_color(normal_color)
  281. s2+= " →"
  282. draw_text(x+82,y+16*param_id,120,line_height,s2,2)
  283. change_color(system_color)
  284. draw_text(x+150,y+16*param_id,100,line_height,s3,2)
  285. change_color(normal_color)
  286. contents.font.size = 14
  287. draw_text(x+266,y+16*param_id,100,line_height,s4)
  288. contents.font.size = 16
  289. end
  290. def draw_actor_xparam_to_s(x,y,xparam_id)
  291. a=0.00
  292. for i in 0 .. POINT_KIND-1
  293. a+=($temp_point[i]*POINT_ADD_XPARAM[i][xparam_id]/10000.0)
  294. end
  295. s1 = XARAM_NAME[xparam_id]
  296. s2 = sprintf("%02.2f%%",@actor.xparam(xparam_id)*100)
  297. s3 = sprintf("%02.2f%%",(@actor.xparam(xparam_id) + a)*100)
  298.  
  299. if @index < POINT_KIND
  300. if POINT_ADD_XPARAM[@index][xparam_id]==0
  301. s4=""
  302. else
  303. s4 = sprintf("+%02.2f%%",POINT_ADD_XPARAM[@index][xparam_id]/100.0)
  304. end
  305. else
  306. s4 = ""
  307. end
  308.  
  309. change_color(system_color)
  310. draw_text(x,y+16*xparam_id,100,line_height,s1)
  311. change_color(normal_color)
  312. s2+= " →"
  313. draw_text(x+82,y+16*xparam_id,120,line_height,s2,2)
  314. change_color(system_color)
  315. draw_text(x+150,y+16*xparam_id,100,line_height,s3,2)
  316. change_color(normal_color)
  317. contents.font.size = 14
  318. draw_text(x+266,y+16*xparam_id,100,line_height,s4)
  319. contents.font.size = 16
  320.  
  321.  
  322. end
  323. end
  324.  
  325. class Scene_Point < Scene_Base
  326. include Point_Tree
  327. def start
  328. super
  329. create_background
  330. @actor = $game_party.menu_actor
  331. create_command_window
  332. create_status_window
  333. create_help_window
  334. @command_window.activate
  335. end
  336. def terminate
  337. super
  338. dispose_background
  339. end
  340. def create_background
  341. @background_sprite = Sprite.new
  342. @background_sprite.bitmap = SceneManager.background_bitmap
  343. @background_sprite.color.set(16, 16, 16, 128)
  344. end
  345. def dispose_background
  346. @background_sprite.dispose
  347. end
  348.  
  349. def create_command_window
  350. @command_window = Window_Point_Command.new(@actor)
  351. @command_window.set_handler(:cancel, method(:return_scene))
  352. @command_window.set_handler(:pagedown, method(:next_actor))
  353. @command_window.set_handler(:pageup, method(:prev_actor))
  354. @command_window.set_handler(:point_add, method(:add_point))
  355. @command_window.set_handler(:point_ok, method(:add_ok))
  356. @command_window.set_handler(:point_cancle,method(:add_cancle))
  357.  
  358. end
  359. def return_scene
  360. add_cancle
  361. SceneManager.return
  362. end
  363. def create_status_window
  364. @status_window = Window_Point_Actor.new(@actor)
  365. @command_window.status_window = @status_window
  366. end
  367. def create_help_window
  368. @help_window = Window_Point_Help.new(0,@command_window.height,160,Graphics.height-@command_window.height)
  369. #(0, 216, 160, 200)
  370. @help_window.viewport = @viewport
  371. @command_window.help_window = @help_window
  372. end
  373.  
  374. def add_point
  375. if temp_all >= @actor.point[0]
  376. @command_window.activate
  377. return
  378. end
  379. $temp_point[@command_window.index] += 1
  380. @status_window.refresh
  381. @command_window.refresh
  382. @command_window.activate
  383. end
  384.  
  385.  
  386. def add_ok
  387. for i in 0 .. POINT_KIND-1
  388. @actor.point[i+1] += $temp_point[i]
  389. end
  390. @actor.point[0]-= temp_all
  391. add_cancle
  392. end
  393.  
  394. def add_cancle
  395. for i in 0 .. POINT_KIND-1
  396. $temp_point[i]=0
  397. end
  398. @status_window.refresh
  399. @command_window.refresh
  400. @command_window.activate
  401. end
  402.  
  403.  
  404. def next_actor
  405. @actor = $game_party.menu_actor_next
  406. on_actor_change
  407. end
  408. #--------------------------------------------------------------------------
  409. # ● 切换到上一个角色
  410. #--------------------------------------------------------------------------
  411. def prev_actor
  412. @actor = $game_party.menu_actor_prev
  413. on_actor_change
  414. end
  415. #--------------------------------------------------------------------------
  416. # ● 切换角色
  417. #--------------------------------------------------------------------------
  418. def on_actor_change
  419. add_cancle
  420. @status_window.actor = @actor
  421. @command_window.actor = @actor
  422. @command_window.activate
  423. end
  424.  
  425. end
  426.  
  427. class Window_MenuCommand < Window_Command
  428. alias add_original_commands_old add_original_commands
  429. def add_original_commands
  430. add_original_commands_old
  431. add_command(Point_Tree::ADDPOINT, :addpoint)
  432. end
  433. end
  434.  
  435. class Scene_Menu < Scene_MenuBase
  436. alias create_command_window_old create_command_window
  437. def create_command_window
  438. create_command_window_old
  439. @command_window.set_handler(:addpoint,method(:add_point))
  440. end
  441. def add_point
  442. @status_window.select_last
  443. @status_window.activate
  444. @status_window.set_handler(:ok, method(:on_ok))
  445. @status_window.set_handler(:cancel, method(:on_personal_cancel))
  446. end
  447. def on_ok
  448. SceneManager.call(Scene_Point)
  449. Window_Point_Command::init_command_position
  450. end
  451. end
  452.  
  453.  
  454.  
  455.  
  456.  
  457. #===============================================================
  458. #顯示在介面上
  459. #===============================================================
  460. =begin
  461. class Window_Status < Window_Selectable
  462. include Point_Tree
  463. alias draw_parameters_old draw_parameters
  464. def draw_parameters(x, y)
  465. draw_parameters_old(x,y)
  466. draw_point(x,y)
  467. end
  468. def draw_point(x,y)
  469. for i in 0..5
  470. change_color(system_color)
  471. draw_text(x+100, y+ line_height * i, 80, line_height, STR_POINT[i])
  472. change_color(normal_color)
  473. draw_text(x+180, y+ line_height * i, 36, line_height,@actor.point[i+1].to_s, 2)
  474. end
  475. end
  476.  
  477. end
  478.  
  479. class Window_Base < Window
  480. def draw_actor_param(actor, x, y, param_id)
  481. change_color(system_color)
  482. draw_text(x-30, y, 80, line_height, Vocab::param(param_id))
  483. change_color(normal_color)
  484. draw_text(x+ 50, y, 36, line_height, actor.param(param_id), 2)
  485. end
  486. end
  487. =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement