Project1

标题: 关于图片战斗系统坐标修改 [打印本页]

作者: [email protected]    时间: 2012-6-2 14:07
标题: 关于图片战斗系统坐标修改
本帖最后由 hcm 于 2012-6-4 22:28 编辑
  1. #==============================================================================

  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息

  3. #==============================================================================

  4. module Momo_IconCommand

  5.   # 图标名称设定

  6.   ATTACK_ICON_NAME = "攻击" # 攻撃

  7.   SKILL_ICON_NAME = "法术"   # 特技

  8.   GUARD_ICON_NAME = "防御"  # 防御

  9.   ITEM_ICON_NAME = "道具"     # 物品

  10.   BAOHU_ICON_NAME = "保护"

  11.   ZHAO_ICON_NAME = "召唤"

  12.   # X坐标修正

  13.   X_PLUS = 0 - 62

  14.   # Y坐标修正

  15.   Y_PLUS = 0 - 311
  16.   # 选择时图标的动作

  17.   # 0:静止 1:放大

  18.   SELECT_TYPE = 0

  19.   # 闪烁时光芒的颜色

  20.   FLASH_COLOR = Color.new(255, 255, 255, 128)

  21.   # 闪烁时间

  22.   FLASH_DURATION = 10

  23.   # 闪烁间隔

  24.   FLASH_INTERVAL = 40

  25.   # 是否写出文字的名称

  26.   COM_NAME_DROW = false

  27.   # 文字名称是否移动

  28.   COM_NAME_MOVE = false

  29.   # 文字内容

  30.   ATTACK_NAME = "攻击"    # 攻击

  31.   SKILL_NAME = "特技"   # 特技

  32.   GUARD_NAME = "防御"     # 防御

  33.   ITEM_NAME = "物品"  # 物品

  34.   BAOHU_NAME = "保护"

  35.   ZHAO_NAME = "召唤"

  36.   # 文字颜色

  37.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)

  38.   # 文字坐标修正

  39.   COM_NAME_X_PLUS = 0

  40.   COM_NAME_Y_PLUS = 0

  41. end


  42. class Window_CommandIcon < Window_Selectable

  43.   attr_accessor :last_index

  44.   #--------------------------------------------------------------------------

  45.   # ● オブジェクト初期化

  46.   #--------------------------------------------------------------------------

  47.   def initialize(x, y, commands)

  48.     super(x, y, 32, 32)

  49.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする

  50.     self.windowskin = RPG::Cache.windowskin("")

  51.     self.z = 9999

  52.    @item_max = commands.size #项目数

  53.    @commands = commands #指令数

  54.    @column_max = 1

  55.     @index = 0

  56.     @last_index = nil

  57.     @name_sprite = nil

  58.     @sprite = []

  59.     refresh

  60.   end

  61.   def dispose

  62.     super

  63.     for sprite in @sprite

  64.       sprite.dispose unless sprite.nil?

  65.     end

  66.     @name_sprite.dispose unless @name_sprite.nil?

  67.   end

  68.   #--------------------------------------------------------------------------

  69.   # ● リフレッシュ

  70.   #--------------------------------------------------------------------------

  71.   def refresh

  72.     @name_sprite.dispose unless @name_sprite.nil?

  73.     for sprite in @sprite

  74.       sprite.dispose unless sprite.nil?

  75.     end

  76.     @name_sprite = nil

  77.     draw_com_name if Momo_IconCommand::COM_NAME_DROW

  78.     @sprite = []

  79.     for i in 0...@item_max

  80.       draw_item(i)

  81.     end

  82.   end

  83.   #--------------------------------------------------------------------------

  84.   # ● 項目の描画

  85.   #--------------------------------------------------------------------------

  86.   def draw_item(index)

  87.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])

  88.     @sprite[index].z = self.z + 1

  89.   end

  90.   def draw_com_name

  91.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)

  92.    
  93.   end

  94.   

  95.   # 更新

  96.   def update

  97.     super

  98.     icon_update

  99.     com_name_update if Momo_IconCommand::COM_NAME_DROW

  100.     if move_index?

  101.       @last_index = self.index

  102.     end

  103.   end

  104.   # アイコンの更新

  105.   def icon_update

  106.     for i in [email][email protected][/email]

  107.       @sprite[i].active = (self.index == i)

  108.       @sprite[i].x = self.x
  109.       @sprite[i].y = self.y + i*26

  110.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1

  111.       @sprite[i].visible = self.visible

  112.       @sprite[i].update

  113.     end

  114.   end

  115.   # コマンドネームの更新

  116.   def com_name_update

  117.     if move_index?

  118.       @name_sprite.name = get_com_name

  119.     end

  120.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS

  121.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS

  122.     @name_sprite.z = self.z + 1

  123.     @name_sprite.active = self.active

  124.     @name_sprite.visible = self.visible

  125.     @name_sprite.update

  126.   end

  127.   def get_com_name

  128.     make_name_set if @name_set.nil?

  129.     name = @name_set[self.index]

  130.     name = "" if name.nil?

  131.     return name

  132.   end

  133.   def make_name_set

  134.     @name_set = []

  135.     @name_set[0] = Momo_IconCommand::ATTACK_NAME

  136.     @name_set[1] = Momo_IconCommand::SKILL_NAME

  137.     @name_set[2] = Momo_IconCommand::GUARD_NAME

  138.     @name_set[3] = Momo_IconCommand::ITEM_NAME

  139.     @name_set[4] = Momo_IconCommand::BAOHU_NAME

  140.     @name_set[5] = Momo_IconCommand::ZHAO_NAME

  141.   end

  142.   def move_index?

  143.     return self.index != @last_index

  144.   end

  145.   def need_reset

  146.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW

  147.   end

  148. end


  149. # アイコン用スプライト

  150. class Sprite_Icon < Sprite

  151.   attr_accessor :active

  152.   attr_accessor :icon_name

  153.   #--------------------------------------------------------------------------

  154.   # ● オブジェクト初期化

  155.   #--------------------------------------------------------------------------

  156.   def initialize(viewport, icon_name)

  157.     super(viewport)

  158.     @icon_name = icon_name

  159.     @last_icon = @icon_name

  160.     @count = 0

  161.     self.bitmap = RPG::Cache.icon(@icon_name)

  162.     self.ox = self.bitmap.width / 2

  163.     self.oy = self.bitmap.height / 2

  164.     @active = false

  165.   end

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

  167.   # ● 解放

  168.   #--------------------------------------------------------------------------

  169.   def dispose

  170.     if self.bitmap != nil

  171.       self.bitmap.dispose

  172.     end

  173.     super

  174.   end

  175.   #--------------------------------------------------------------------------

  176.   # ● フレーム更新

  177.   #--------------------------------------------------------------------------

  178.   def update

  179.     super

  180.     if @icon_name != @last_icon

  181.       @last_icon = @icon_name

  182.       self.bitmap = RPG::Cache.icon(@icon_name)

  183.     end

  184.     if @active

  185.       @count += 1

  186.       case Momo_IconCommand::SELECT_TYPE

  187.       when 0

  188.         icon_flash

  189.       when 1

  190.         icon_zoom

  191.       end

  192.       @count = 0 if @count == 20

  193.     else

  194.       icon_reset

  195.     end

  196.   end

  197.   def icon_flash

  198.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1

  199.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)

  200.     end

  201.   end

  202.   def icon_zoom

  203.     case @count

  204.     when 1..10

  205.       zoom = 1.0 + @count / 10.0

  206.     when 11..20

  207.       zoom = 2.0 - (@count - 10) / 10.0

  208.     end

  209.     self.zoom_x = zoom

  210.     self.zoom_y = zoom

  211.   end

  212.   def icon_reset

  213.     @count = 0

  214.     self.zoom_x = 1.0

  215.     self.zoom_y = 1.0

  216.   end

  217. end


  218. # コマンドネーム用スプライト

  219. class Sprite_Comm_Name < Sprite

  220.   attr_accessor :active

  221.   attr_accessor :name

  222.   attr_accessor :need_reset

  223.   #--------------------------------------------------------------------------

  224.   # ● オブジェクト初期化

  225.   #--------------------------------------------------------------------------

  226.   def initialize(viewport, name)

  227.     super(viewport)

  228.     @name = name

  229.     @last_name = nil

  230.     @count = 0

  231.     @x_plus = 0

  232.     @opa_plus = 0

  233.     @need_reset = false

  234.     @active = false

  235.     self.bitmap = Bitmap.new(160, 32)

  236.   end

  237.   #--------------------------------------------------------------------------

  238.   # ● 解放

  239.   #--------------------------------------------------------------------------

  240.   def dispose

  241.     if self.bitmap != nil

  242.       self.bitmap.dispose

  243.     end

  244.     super

  245.   end

  246.   #--------------------------------------------------------------------------

  247.   # ● フレーム更新

  248.   #--------------------------------------------------------------------------

  249.   def update

  250.     super

  251.     if @active

  252.       if need_reset?

  253.         @need_reset = false

  254.         @last_name = @name

  255.         text_reset

  256.       end

  257.       move_text if Momo_IconCommand::COM_NAME_MOVE

  258.     end

  259.   end

  260.   def move_text

  261.     @count += 1

  262.     @x_plus = [@count * 8, 80].min
  263.     self.x = self.x - 80 + @x_plus

  264.     self.opacity = @count * 25

  265.   end

  266.   def text_reset

  267.     @count = 0

  268.     @x_plus = 0

  269.     self.bitmap.clear

  270.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR

  271.     self.bitmap.draw_text(0, 0, 160, 32, @name)

  272.   end

  273.   def need_reset?

  274.     return (@name != @last_name or @need_reset)

  275.   end

  276. end


  277. class Scene_Battle

  278.   #--------------------------------------------------------------------------

  279.   # ● プレバトルフェーズ開始

  280.   #--------------------------------------------------------------------------

  281.   alias scene_battle_icon_command_start_phase1 start_phase1

  282.   def start_phase1

  283.     com1 = Momo_IconCommand::ATTACK_ICON_NAME

  284.     com2 = Momo_IconCommand::SKILL_ICON_NAME

  285.     com3 = Momo_IconCommand::GUARD_ICON_NAME

  286.     com4 = Momo_IconCommand::ITEM_ICON_NAME

  287.     com5 = Momo_IconCommand::BAOHU_ICON_NAME

  288.     com6 = Momo_IconCommand::ZHAO_ICON_NAME

  289.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4,com5,com6])

  290.     @actor_command_window.y = 160

  291.     @actor_command_window.back_opacity = 160

  292.     @actor_command_window.active = false

  293.     @actor_command_window.visible = false

  294.     @actor_command_window.update

  295.    
  296.     @actor2_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4,com5])

  297.     @actor2_command_window.y = 160

  298.     @actor2_command_window.back_opacity = 160

  299.     @actor2_command_window.active = false

  300.     @actor2_command_window.visible = false

  301.     @actor2_command_window.update

  302.    
  303.     scene_battle_icon_command_start_phase1

  304.   end

  305.   #--------------------------------------------------------------------------

  306.   # ● アクターコマンドウィンドウのセットアップ

  307.   #--------------------------------------------------------------------------

  308.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window

  309.   def phase3_setup_command_window

  310.     scene_battle_icon_command_phase3_setup_command_window

  311.     # アクターコマンドウィンドウの位置を設定

  312.     @actor_command_window.x = command_window_actor_x(@actor_index) - 360

  313.     @actor_command_window.y = command_window_actor_y(@actor_index)

  314.     @actor_command_window.need_reset

  315.     @actor2_command_window.x = command_window_actor_x(@actor_index) - 360

  316.     @actor2_command_window.y = command_window_actor_y(@actor_index)

  317.     @actor2_command_window.need_reset

  318.   end

  319.   def command_window_actor_x(index)

  320.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS

  321.   end

  322.   def command_window_actor_y(index)

  323.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS

  324.   end

  325. end


  326. #==============================================================================

  327. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息

  328. #==============================================================================
复制代码
如何把角色指令窗口固定在 最左边 不要再每个角色头顶上显示dsu_plus_rewardpost_czw
作者: 明特·布兰马修    时间: 2012-6-3 03:22
将最后一段脚本改为这样就可以了。
  1. #--------------------------------------------------------------------------
  2.   # ● アクターコマンドウィンドウのセットアップ
  3.   #--------------------------------------------------------------------------
  4.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  5.   def phase3_setup_command_window
  6.     scene_battle_icon_command_phase3_setup_command_window
  7.     # アクターコマンドウィンドウの位置を設定
  8.     @actor_command_window.x = @actor_index +480
  9.     @actor_command_window.y = @actor_index +160
  10.     @actor_command_window.need_reset
  11.     @actor2_command_window.x = command_window_actor_x(@actor_index)
  12.     @actor2_command_window.y = command_window_actor_y(@actor_index)
  13.     @actor2_command_window.need_reset
  14.   end
  15.   def command_window_actor_x(index)
  16.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  17.   end
  18.   def command_window_actor_y(index)
  19.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  20.   end
  21. end

  22. #==============================================================================
  23. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  24. #==============================================================================
复制代码

作者: [email protected]    时间: 2012-6-4 15:28
怎么会 只有四个选项呢?  只有攻击 ,法术,防御,物品。   下面的 逃跑和召唤 都没有显示出来 怎么弄 ,那个选项框不够长啊


‘‘──[email protected]于2012-6-4 15:29补充以下内容:

只有四个选项 ,两外两个 召唤 什么的 都没有显示了 !
’’




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