Project1

标题: 想做口袋妖怪但不会做战斗换人系统 [打印本页]

作者: ckn88020253    时间: 2015-8-15 22:09
标题: 想做口袋妖怪但不会做战斗换人系统
有大神能分享一个战斗换人系统吗,仿口袋妖怪的那种。
附件是我之前在本站找的,但是在XP数据库里的队伍里面添加事件,XXX队友加入,战斗结束后队友并没有加入。不用脚本前是可以的。
另求一个做口袋的群,我是新人。拉我进去学习!!
作者: 亡灵史莱姆    时间: 2015-8-16 15:13
是这个吗?人物仓库脚本
  1. #==============================================================================
  2. # ■ chaochao的人物仓库ver1.02正式版
  3. # 修改了Game_Party
  4. # 功能:
  5. # 用来存放角色的仓库……
  6. # 召唤画面用$scene = Chaochao_Scene_Party.new
  7. # 其它使用说明在代码里已经备注。
  8. #------------------------------------------------------------------------------
  9. # 作者:chaochao
  10. # [url]http://zhuchao.go1.icpcn.com[/url]
  11. #==============================================================================
  12. class Chaochao_Window_PartyLeft < Window_Selectable
  13.   def initialize
  14.     super(0, 0, 320, 224)
  15.     self.contents = Bitmap.new(width - 32, height - 32)
  16.     self.index = 0
  17.     refresh
  18.   end
  19.   def actor
  20.     return @actors[self.index]
  21.   end
  22.   def refresh
  23.     if self.contents != nil
  24.       self.contents.dispose
  25.       self.contents = nil
  26.     end
  27.     @actors = []
  28.     for i in 0...$game_party.actors.size
  29.       @actors.push($game_party.actors[i])
  30.     end

  31.     @item_max = 4
  32.     if @item_max > 0
  33.       self.contents = Bitmap.new(width - 32, (row_max+1) * 32)
  34.       for i in 0...@item_max
  35.         draw_item(i)
  36.       end
  37.     end
  38.   end
  39.   def draw_item(index)
  40.     if @actors[index] != nil
  41.       actor = @actors[index]
  42.       text = @actors[index].name
  43.       lv = @actors[index].level.to_s + " "
  44.       if $game_party.chaochao.include?(actor.id) or $game_party.actors.size <= 1
  45.         self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色
  46.       else
  47.         self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色
  48.       end
  49.       self.contents.draw_text(4, index * 32 + 32, 288, 32, text)
  50.       self.contents.font.color = normal_color
  51.       self.contents.font.size = 16
  52.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  "Level:   ", 2)
  53.       colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
  54.       colory = [255.0000 / 60 * @actors[index].level,255].min
  55.       self.contents.font.color = Color.new(colorx, colory, 0)
  56.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  lv, 2)
  57.       self.contents.font.color = normal_color
  58.       self.contents.font.size = 22
  59.     else
  60.       self.contents.draw_text(4, index * 32 + 32, 288, 32,  "没有人物!")
  61.     end
  62.   end
  63.   def update_cursor_rect
  64.     if [url=home.php?mod=space&uid=370741]@Index[/url] < 0
  65.       self.cursor_rect.empty
  66.       return
  67.     end
  68.     row = @index / @column_max
  69.     if row < self.top_row
  70.       self.top_row = row
  71.     end
  72.     if row > self.top_row + (self.page_row_max - 1)
  73.       self.top_row = row - (self.page_row_max - 1)
  74.     end
  75.     cursor_width = self.width / @column_max - 32
  76.     x = @index % @column_max * (cursor_width + 32)
  77.     y = @index / @column_max * 32 - self.oy + 32
  78.     self.cursor_rect.set(x, y, cursor_width, 32)
  79.   end
  80.   def item_max
  81.     return @item_max
  82.   end
  83.   def actor?(index)
  84.     return @actors[index] == nil ? false : true
  85.   end
  86.   def set_index(x)
  87.     @index = x
  88.   end
  89. end

  90. #------------------------------------------------------------------------------

  91. class Chaochao_Window_PartyRight < Window_Selectable
  92.   def initialize
  93.     super(320, 0, 320, 224)
  94.     self.contents = Bitmap.new(width - 32, height - 32)
  95.     self.index = -1
  96.     refresh
  97.   end
  98.   def actor
  99.     return @actors[self.index]
  100.   end
  101.   def refresh
  102.     if self.contents != nil
  103.       self.contents.dispose
  104.       self.contents = nil
  105.     end
  106.     @actors = []
  107.     for i in 0...$game_party.actors2.size
  108.       @actors.push($game_party.actors2[i])
  109.     end

  110.     @item_max = $game_party.actors2.size
  111.     if @item_max > 0
  112.       self.contents = Bitmap.new(width - 32, row_max * 32)
  113.       for i in 0...@item_max
  114.         draw_item(i)
  115.       end
  116.     elsif @item_max == 0

  117.     end
  118.   end
  119.   def draw_item(index)
  120.     actor = @actors[index]
  121.     text = @actors[index].name
  122.     lv = @actors[index].level.to_s + " "
  123.     if $game_party.chaochao2.include?(actor.id) or $game_party.actors.size >= 4
  124.         self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色
  125.       else
  126.         self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色
  127.       end
  128.     self.contents.draw_text(4, index * 32, 288, 32, text)
  129.     self.contents.font.color = normal_color
  130.     self.contents.font.size = 16
  131.     self.contents.draw_text(4, index * 32 + 4, 288, 32,  "Level:   ", 2)
  132.     colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
  133.     colory = [255.0000 / 60 * @actors[index].level,255].min
  134.     self.contents.font.color = Color.new(colorx, colory, 0)
  135.     self.contents.draw_text(4, index * 32 + 4, 288, 32,  lv, 2)
  136.     self.contents.font.color = normal_color
  137.     self.contents.font.size = 22
  138.   end
  139.   def update_cursor_rect
  140.     if @index < 0
  141.       self.cursor_rect.empty
  142.       return
  143.     end
  144.     row = @index / @column_max
  145.     if row < self.top_row
  146.       self.top_row = row
  147.     end
  148.     if row > self.top_row + (self.page_row_max - 1)
  149.       self.top_row = row - (self.page_row_max - 1)
  150.     end
  151.     cursor_width = self.width / @column_max - 32
  152.     x = @index % @column_max * (cursor_width + 32)
  153.     y = @index / @column_max * 32 - self.oy
  154.     self.cursor_rect.set(x, y, cursor_width, 32)
  155.   end
  156.   def item_max
  157.     return @item_max
  158.   end
  159.   def actor?(index)
  160.     return @actors[index] == nil ? false : true
  161.   end
  162.   def set_index(x)
  163.     @index = x
  164.   end
  165. end

  166. #------------------------------------------------------------------------------

  167. class Chaochao_Window_PartyData < Window_Base

  168.   def initialize
  169.     super(0, 224, 640, 256)
  170.     self.contents = Bitmap.new(width - 32, height - 32)
  171.     [url=home.php?mod=space&uid=95897]@actor[/url] = nil
  172.   end

  173.   def set_actor(actor)
  174.     self.contents.clear
  175.     draw_actor_name(actor, 4, 0)
  176.     draw_actor_state(actor, 140, 0)
  177.     draw_actor_hp(actor, 284, 0)
  178.     draw_actor_sp(actor, 460, 0)
  179.     @actor = actor
  180.     self.visible = true
  181.   end
  182.   def clear
  183.     self.contents.clear
  184.   end
  185. end

  186. #------------------------------------------------------------------------------

  187. class Game_Party
  188.   attr_reader   :actors2
  189.   attr_reader   :chaochao#不能从队伍向备用角色移动的角色ID
  190.   attr_reader   :chaochao2#不能从备用角色向队伍移动的角色ID
  191.   def initialize
  192.     @actors = []
  193.     [url=home.php?mod=space&uid=236945]@gold[/url] = 0
  194.     @steps = 0
  195.     @items = {}
  196.     @weapons = {}
  197.     @armors = {}
  198.     @actors2 = []
  199.     [url=home.php?mod=space&uid=9543]@chaochao[/url] = []
  200.     @chaochao2 = []
  201.   end
  202.   def add_actor(actor_id,type=1)#type为1是向队伍中添加,为2则相反。
  203.     case type
  204.     when 1
  205.       if $game_actors[actor_id] != nil
  206.         actor = $game_actors[actor_id]
  207.         #如果队伍没有满和队伍中没有此角色
  208.         if @actors.size < 4 and not @actors.include?(actor) and not @actors2.include?(actor)
  209.           @actors.push(actor)
  210.           $game_player.refresh
  211.         end
  212.       end
  213.     when 2
  214.       if $game_actors[actor_id] != nil
  215.         actor = $game_actors[actor_id]
  216.         #如果角色不在队伍中和不在备用角色队伍中的情况下
  217.         #向备用角色中添加角色
  218.         if not @actors.include?(actor) and not @actors2.include?(actor)
  219.           @actors2.push(actor)
  220.           $game_player.refresh
  221.         end
  222.       end
  223.     end
  224.   end

  225.   def huanren(index,type=1)#type为1是从备用角色向队伍中移动,为2则相反。
  226.     actor = $game_actors[index]
  227.     case type
  228.     when 1
  229.       if @actors.size < 4 and @actors2.include?(actor) and not @chaochao2.include?(index) and not @actors.include?(actor)
  230.         @actors.push(actor)
  231.         @actors2.delete(actor)
  232.         $game_system.se_play($data_system.decision_se)
  233.         $game_player.refresh
  234.       end
  235.     when 2
  236.       if @actors.include?(actor) and not @chaochao.include?(index) and not @actors2.include?(actor)
  237.         @actors2.push(actor)
  238.         @actors.delete(actor)
  239.         $game_system.se_play($data_system.decision_se)
  240.         $game_player.refresh
  241.       end
  242.     end
  243.   end

  244.   #type1,1是操作队伍中的角色能否向备用队伍移动,2则相反。
  245.   #type2,1是添加不能移动的,2是删除不能移动的。
  246.   def yidong(actor_id,type1,type2=1)
  247.     case type2
  248.     when 1
  249.       case type1
  250.       when 1
  251.         @chaochao.push(actor_id)
  252.       when 2
  253.         @chaochao2.push(actor_id)
  254.       end
  255.     when 2
  256.       case type1
  257.       when 1
  258.         @chaochao.delete(actor_id)
  259.       when 2
  260.         @chaochao2.delete(actor_id)
  261.       end
  262.     end
  263.   end

  264.   #type,1从队伍中离开,2从备用角色中离开,3从队伍和备用角色中离开。
  265.   def remove_actor(actor_id,type=1)
  266.     actor = $game_actors[actor_id]
  267.     case type
  268.     when 1
  269.       @actors.delete(actor)
  270.       $game_player.refresh
  271.     when 2
  272.       @actors2.delete(actor)
  273.       $game_player.refresh
  274.     when 3
  275.       @actors.delete(actor)
  276.       @actors2.delete(actor)
  277.       $game_player.refresh
  278.     end
  279.   end

  280.   def refresh
  281.     new_actors = []
  282.     new_actors2 = []
  283.     for i in [email][email protected][/email]
  284.       if $data_actors[@actors[i].id] != nil
  285.         new_actors.push($game_actors[@actors[i].id])
  286.       end
  287.     end
  288.     @actors = new_actors
  289.     for i in [email][email protected][/email]
  290.       if $data_actors[@actors2[i].id] != nil
  291.         new_actors2.push($game_actors[@actors2[i].id])
  292.       end
  293.     end
  294.     @actors2 = new_actors2
  295.   end
  296. end

  297. #------------------------------------------------------------------------------

  298. class Chaochao_Scene_Party
  299.   def main
  300.     @left_temp_command = 0
  301.     @right_temp_command = 0
  302.     [url=home.php?mod=space&uid=263426]@temp[/url] = 0
  303.     @left_window = Chaochao_Window_PartyLeft.new
  304.     @left_window.active = true
  305.     @right_window = Chaochao_Window_PartyRight.new
  306.     @right_window.active = false
  307.     @data_window = Chaochao_Window_PartyData.new
  308.     update_data
  309.     Graphics.transition
  310.     loop do
  311.       Graphics.update
  312.       Input.update
  313.       update
  314.       if $scene != self
  315.         break
  316.       end
  317.     end
  318.     Graphics.freeze
  319.     @left_window.dispose
  320.     @right_window.dispose
  321.     @data_window.dispose
  322.   end

  323.   def update
  324.     @left_window.update
  325.     @right_window.update
  326.     @data_window.update
  327.     update_command
  328.     update_data
  329.   end

  330.   def update_command
  331.     if Input.trigger?(Input::B)
  332.       $game_system.se_play($data_system.cancel_se)
  333.       #画面切换
  334.       $scene = Scene_Map.new
  335.       return
  336.     end
  337.     if @left_window.active
  338.       update_left
  339.       return
  340.     end
  341.     if @right_window.active
  342.       update_right
  343.       return
  344.     end
  345.   end

  346.   def update_left
  347.     if Input.trigger?(Input::RIGHT)
  348.       if @right_window.item_max > 0
  349.         @left_temp_command = @left_window.index
  350.         @left_window.set_index(-1)
  351.         $game_system.se_play($data_system.cursor_se)
  352.         @left_window.active = false
  353.         @right_window.active = true
  354.         @left_window.refresh
  355.         @right_window.refresh
  356.         @right_window.set_index(@right_temp_command)
  357.         return
  358.       else
  359.         $game_system.se_play($data_system.buzzer_se)
  360.         return
  361.       end
  362.     end
  363.     if Input.trigger?(Input::C)
  364.       if @left_window.active and @left_window.actor?(@left_window.index) and $game_party.actors.size > 1 and not $game_party.chaochao.include?($game_party.actors[@left_window.index].id)
  365.         $game_party.huanren($game_party.actors[@left_window.index].id,2)#type为1是从备用角色向队伍中移动,为2则相反。
  366.         @left_window.refresh
  367.         @right_window.refresh
  368.       else
  369.         $game_system.se_play($data_system.buzzer_se)
  370.       end
  371.     end
  372.     return
  373.   end

  374.   def update_right
  375.     if Input.trigger?(Input::LEFT)
  376.       if @left_window.item_max > 0
  377.         @right_temp_command = @right_window.index
  378.         @right_window.set_index(-1)
  379.         $game_system.se_play($data_system.cursor_se)
  380.         @left_window.active = true
  381.         @right_window.active = false
  382.         @left_window.refresh
  383.         @right_window.refresh
  384.         @left_window.set_index(@left_temp_command)
  385.         return
  386.       else
  387.         $game_system.se_play($data_system.buzzer_se)
  388.         return
  389.       end
  390.     end
  391.     if Input.trigger?(Input::C)
  392.       if $game_party.actors.size >= 4
  393.         $game_system.se_play($data_system.buzzer_se)
  394.         return
  395.       end
  396.       if @right_window.active and @right_window.actor?(@right_window.index) and not $game_party.chaochao2.include?($game_party.actors2[@right_window.index].id)
  397.         $game_party.huanren($game_party.actors2[@right_window.index].id,1)#type为1是从备用角色向队伍中移动,为2则相反。
  398.         if $game_party.actors2.size == 0
  399.           @right_temp_command = @right_window.index
  400.           @right_window.set_index(-1)
  401.           $game_system.se_play($data_system.cursor_se)
  402.           @left_window.active = true
  403.           @right_window.active = false
  404.           @left_window.refresh
  405.           @right_window.refresh
  406.           @left_window.set_index(@left_temp_command)
  407.         end
  408.         if @right_window.index > 0
  409.           @right_window.set_index(@right_window.index-1)
  410.         end
  411.         @left_window.refresh
  412.         @right_window.refresh
  413.       else
  414.         $game_system.se_play($data_system.buzzer_se)
  415.       end
  416.     end
  417.     return
  418.   end

  419.   def update_data
  420.     if @left_window.active
  421.       if $game_party.actors[@left_window.index] != nil
  422.         @data_window.set_actor($game_party.actors[@left_window.index])
  423.       else
  424.         @data_window.clear
  425.       end
  426.       return
  427.     end
  428.     if @right_window.active
  429.       if $game_party.actors2[@right_window.index] != nil
  430.         @data_window.set_actor($game_party.actors2[@right_window.index])
  431.       else
  432.         @data_window.clear
  433.       end
  434.       return
  435.     end
  436.   end
  437. end
复制代码

作者: 亡灵史莱姆    时间: 2015-8-16 15:25
对了,似乎在rm图书馆里看到过口袋妖怪范例的(或者是天干宝典??),貌似在14楼
算了,你还是去找找看吧,天干宝典图书馆里也有……
作者: 邪月长啸    时间: 2015-8-16 19:41
亡灵史莱姆 发表于 2015-8-16 15:25
对了,似乎在rm图书馆里看到过口袋妖怪范例的(或者是天干宝典??),貌似在14楼
算了,你还是去找找看吧 ...

14楼?好像是我?

给楼主链接吧
http://pan.baidu.com/s/1mgJ2wdE# ... 2583%25E4%25BE%258B




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1