永发信息网

RPG制作大师脚本Set_npc_name疑问

答案:1  悬赏:0  手机版
解决时间 2021-08-21 14:54

#==============================================================================
# 显示NPC名
#------------------------------------------------------------------------------
# 跟原版一样,EV开头的不显示,逗号后加颜色代码
# 修改某事件名的方法: # set_npc_name("新名", 事件ID, 地图ID, 是否永久生效)
# 事件ID 为空时表示当前事件 # 地图ID 为空时表示当前地图
# 是否永久生效 默认永久,否则只允许修改当前地图
#==============================================================================
# 参数设定
#==============================================================================
 module NPC
  NAME_FONT = "黑体"
  NAME_SIZE= 16
  NAME_SHADOW = false
  NAME_WIDTH = 120 end
#==============================================================================
# 重定事件名
#==============================================================================
 def set_npc_name(name, event_id = nil,map_id = nil,forever = true)
  # 处理事件 ID if event_id == nil
  event_id = $game_map.interpreter.event_id
 end
 # 处理地图 ID if map_id == nil
  $game_map.events[event_id].name = name
  map_id = $game_map.map_id else
  map_id = map_id end return unless
  forever data = load_data(sprintf("Data/Map%03d.rvdata", map_id))
 # 更改名 data.events[event_id].name = name
  save_data(data, sprintf("Data/Map%03d.rvdata", map_id))
 end
#==============================================================================
# ■ Game_Character
#==============================================================================
 class Game_Character
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
 attr_accessor :name
# 名称
#--------------------------------------------------------------------------
# ◎ 初始化对象
#--------------------------------------------------------------------------
 alias character_ini initialize def initialize character_ini
  @name = ""
 end end
#==============================================================================
# ■ Game_Event
#==============================================================================
 class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
 attr_reader :erased
#--------------------------------------------------------------------------
# ◎ 初始化对像
# map_id : 地图 ID # event : 事件 (RPG::Event)
#--------------------------------------------------------------------------
 alias event_ini initialize def initialize(map_id, event)
  event_ini(map_id, event)
  @name = @event.name
  end
 end
#==============================================================================
# ■ Game_Player
#==============================================================================
 class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ◎ 获取角色名
#--------------------------------------------------------------------------
 def name return $game_party.members[0].name end end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
 class Game_Interpreter
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
 attr_reader :event_id
 end
#==============================================================================
# ■ Sprite_Character
#==============================================================================
 class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ◎ 初始化对象
# viewport : 视区
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
 def initialize(viewport, character = nil)
  super(viewport) @character = character
  @balloon_duration = 0 ## 名称
  @name = @character.name
  set_name_sprite update
 end
#--------------------------------------------------------------------------
# ◎ 释放
#--------------------------------------------------------------------------
 def dispose dispose_balloon super ## return if
  @name_sprite == nil
  @name_sprite.bitmap.dispose
  @name_sprite.dispose
 end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
 def update super update_bitmap self.visible = (not @character.transparent)
  update_src_rect self.x =
  @character.screen_x self.y =
  @character.screen_y self.z =
  @character.screen_z self.opacity =
  @character.opacity self.blend_type = @character.blend_type self.bush_depth =
  @character.bush_depth update_balloon if
  @character.animation_id != 0
  animation = $data_animations[@character.animation_id]
  start_animation(animation) @character.animation_id = 0
 end if
  @character.balloon_id != 0
  @balloon_id = @character.balloon_id start_balloon
  @character.balloon_id = 0
 end
## 名称可视和跟随 unless @name_sprite == nil or
  @name_sprite.disposed? if
  @character.is_a?(Game_Event) and
  @character.erased
  @name_sprite.visible = false return else
  @name_sprite.visible = true end if
  @character.is_a?(Game_Player) and
  @character.in_vehicle?
  @name_sprite.visible = false return else
  @name_sprite.visible = true end if
  @name != @character.name
  @name = @character.name refresh_name_sprite
 end
  @name_sprite.x = self.x - 80
  @name_sprite.y = self.y - self.height - NPC::NAME_SIZE+2
  @name_sprite.z = self.z+1
  end
 end
#--------------------------------------------------------------------------
# ○ 设定 NPC 名称
#--------------------------------------------------------------------------
 def set_name_sprite return if
  @character.name[0, 2] == "EV" return if
  @character.name == "" return if
  @character.character_name == "" return if @character.is_a?(Game_Event) and
  @character.erased
  @color_board = Window_Base.new(0,0,33,33)
  @color_board.visible = false
  @name_sprite = Sprite.new
  @name_sprite.bitmap = Bitmap.new(NPC::NAME_WIDTH, NPC::NAME_SIZE+2)
  @name_sprite.bitmap.font.name = NPC::NAME_FONT
  @name_sprite.bitmap.font.size = NPC::NAME_SIZE
  @name_sprite.bitmap.font.shadow = NPC::NAME_SHADOW refresh_name_sprite
 end
#--------------------------------------------------------------------------
# ○ 更新 NPC 名称
#--------------------------------------------------------------------------
 def refresh_name_sprite
  name,color_index = @name.split(/,/)
  color_index = 0 if
  color_index == "" @name_sprite.bitmap.font.color =
  @color_board.text_color(color_index.to_i)
  @name_sprite.bitmap.clear
  @name_sprite.bitmap.draw_text(0,0,160,NPC::NAME_SIZE+2,name,1)
  end
 end

 

就是这个脚本,自己分开的原文本基本连在一起。

现在第27行,也就是这一段开始都出错。

问下出错的原因,是否我分段分错了,或者其他的什么原因。

还请帮忙改下。

# 处理地图 ID if map_id == nil
  $game_map.events[event_id].name = name
  map_id = $game_map.map_id else
  map_id = map_id end return unless
  forever data = load_data(sprintf("Data/Map%03d.rvdata", map_id))

 end

最佳答案
插入下边这个脚本#==============================================================================# ■ Game_Party#------------------------------------------------------------------------------# 处理同伴的类。包含金钱以及物品的信息。本类的实例# 请参考 $game_party。#==============================================================================class Game_Party#--------------------------------------------------------------------------# ● 加入同伴# actor_id : 角色 ID#--------------------------------------------------------------------------def add_actor(actor_id)# 获取角色actor = $game_actors[actor_id]# 同伴人数未满 5 人、本角色不在队伍中的情况下if @actors.size < 5 and not @actors.include?(actor)# 添加角色@actors.push(actor)# 还原主角$game_player.refreshendendend#==============================================================================# ■ Window_MenuStatus#------------------------------------------------------------------------------# 显示菜单画面和同伴状态的窗口。#==============================================================================class Window_MenuStatus#--------------------------------------------------------------------------# ● 刷新#--------------------------------------------------------------------------def refreshself.contents.clear@item_max = $game_party.actors.sizefor i in 0...$game_party.actors.sizex = 64y = i * 86actor = $game_party.actors[i]draw_actor_graphic(actor, x - 40, y + 70)draw_actor_name(actor, x, y)draw_actor_class(actor, x + 144, y)draw_actor_level(actor, x, y + 24)draw_actor_state(actor, x + 90, y + 24)draw_actor_exp(actor, x, y + 48)draw_actor_hp(actor, x + 236, y + 24)draw_actor_sp(actor, x + 236, y + 48)endend#--------------------------------------------------------------------------# ● 刷新光标矩形#--------------------------------------------------------------------------def update_cursor_rectif @index < 0self.cursor_rect.emptyelseself.cursor_rect.set(0, @index * 86, self.width - 32, 76)endendend
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
送别朋友离世的诗句,悼念朋友去世的诗词
LGKP275现市场零售价是多少
有没有很大很大个的果冻?哪里卖?
爱国名言中国古代,中外领袖论学习的名言警句
痛经有什么办法
我二大爷的三外甥的儿子的媳妇是谁
江岸区武汉时代天音钢琴培训哪位知道具体地址
弹弹堂中副手怎么弄?
用你说的这个中药祛斑霜效果怎么样?斑会除根
关于语文阅读,求答语文阅读这样出:请阅读第X
玩魔兽延迟高
冒险岛CS吸怪哪里稳定
放在水平桌面上的圆形薄壁容器高20cm,能容纳2
牛排做法啊
这个卡通头像叫什么名字?
推荐资讯
保定创建文明城的标语,关于文明的名言
如何贱踏自己的自尊?
全城戒备的电影全集哪个网址有?
爱情唯美的句子短句子,几句唯美的歌词关于生
呼市七夕之夜联谊会是否愿意参加
蔡甸区武汉利成驾校报名处(树藩大街)地址在什
松鼠鱼怎么改刀,松鼠鱼怎么做简单且美味?
为什么青尼罗河流量稳定而白尼罗河则不是?
电脑由vista换成xp之后内置麦克风怎么不能用
什摸是恋爱 愁啊
The students are going to meet----the scho
神舟K470什么时候正式上市啊?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?