#------------------------------------------------------------------------------#状态决定行走图色相色调 v1.3# #如果角色中了某种特殊状态,则会自动改变此角色的色相或者色调。##p.s.已经有了色调的行走图则继续往下偏移。##编写 by 精灵使者,改进 by enchao_lim#增添了读取进度和普通状态下的角色偏移#改进了异常色调如果相同的话的判断算法#可以使用灰色的色调和覆盖颜色,但是在菜单以外其他地方无效。#------------------------------------------------------------------------------#定义恒量module SRSR # 设定颜色更换『状态编号 => [Red,Gree,Blue]』 State_color = { 1 => [50,50,50], 2 => [128,0,0], 3 => [128,128,0] } # 设定色相更换『状态编号 => [hue]』 State_hue = { 1 => [330], 2 => [60], 3 => [30], } # 设定改变颜色方式,0(色调) 或者 1(覆盖)或者 2(色相) Change_type = 0endclass Window_Base alias new_initialize initialize def initialize(_x,_y,_w,_h) new_initialize(_x,_y,_w,_h) @graphics = {} for i in 0...$data_actors.size @graphics[i] = nil end @_x = self.x @_y = self.y end def draw_actor_graphic(actor,x,y) @graphics[actor.id].dispose if @graphics[actor.id] != nil @graphics[actor.id] == nil @delta_hue = 0 @state_num = 0 if SRSR::Change_type == 2 for i in actor.states #如果角色中状态就加上偏移值 if SRSR::State_hue[i] != nil @delta_hue += SRSR::State_hue[i][0] @state_num += 1 end end #防止两种以上状态叠加出现相同色调的状况 if @state_num > 1 for i in actor.states if SRSR::State_hue[i] != nil #当与某一个颜色重复或者与普通色调相同时 if @delta_hue % 360 == SRSR::State_hue[i][0] or @delta_hue %360 == 0 @delta_hue += 179 #加上一个质数尽量避免重复 end end end end #最后计算 @delta_hue %= 360 end bitmap = RPG::Cache.character(actor.character_name, actor.character_hue + @delta_hue) cw = bitmap.width/4 ch = bitmap.height/4 @graphics[actor.id] = Sprite.new @graphics[actor.id].bitmap = bitmap @graphics[actor.id].src_rect.set(0,0,cw,ch) x = x +16 - cw / 2 y = y +16 - ch @graphics[actor.id].x = x @graphics[actor.id].y = y @graphics[actor.id].z = self.z + 1 @graphics[actor.id].opacity = 0 tone = [0,0,0,0] case SRSR::Change_type when 0 for i in actor.states if SRSR::State_color[i] != nil tone[0] = (tone[0] + SRSR::State_color[i][0]) % 256 tone[1] = (tone[1] + SRSR::State_color[i][1]) % 256 tone[2] = (tone[2] + SRSR::State_color[i][2]) % 256 tone[3] = 255 end end @graphics[actor.id].tone.set(tone[0],tone[1],tone[2],tone[3]) when 1 for i in actor.states if SRSR::State_color[i] != nil tone[0] = (tone[0] + SRSR::State_color[i][0]) % 256 tone[1] = (tone[1] + SRSR::State_color[i][1]) % 256 tone[2] = (tone[2] + SRSR::State_color[i][2]) % 256 tone[3] = 192 end end @graphics[actor.id].color.set(tone[0],tone[1],tone[2],tone[3]) end end alias new_update update def update if @_x != self.x or @_y != self.y for i in 0...$data_actors.size if @graphics[i] != nil dx = self.x - @_x dy = self.y - @_y @graphics[i].x += dx @graphics[i].y += dy end end @_x = self.x @_y = self.y end for i in 0...$data_actors.size if @graphics[i] != nil @graphics[i].update @graphics[i].opacity = 255 if @graphics[i].opacity != 255 end end new_update end alias new_dispose dispose def dispose new_dispose for i in 0...$data_actors.size @graphics[i].dispose if @graphics[i] != nil @graphics[i] = nil end endend#==============================================================================# ■ Game_Actor#------------------------------------------------------------------------------# 处理角色的类。本类在 Game_Actors 类 ($game_actors)# 的内部使用、Game_Party 类请参考 ($game_party) 。#==============================================================================class Game_Actor #-------------------------------------------------------------------------- # ● 色调的计算 # character_hue :原始人物色调 # delta_hue :色调的偏移值 #-------------------------------------------------------------------------- def character_hue @delta_hue = 0 @state_num = 0 if SRSR::Change_type == 2 for i in states #如果角色中状态就加上偏移值 if SRSR::State_hue[i] != nil @delta_hue += SRSR::State_hue[i][0] @state_num += 1 end end #防止两种以上状态叠加出现相同色调的状况 if @state_num > 1 for i in states if SRSR::State_hue[i] != nil #当与某一个颜色重复或者与普通色调相同时 if @delta_hue % 360 == SRSR::State_hue[i][0] or @delta_hue %360 == 0 @delta_hue += 179 #加上一个质数尽量避免重复 end end end end #最后计算 @delta_hue %= 360 end return @character_hue + @delta_hue endend#==============================================================================# ■ Game_Player#------------------------------------------------------------------------------# 处理主角的类。事件启动的判定、以及地图的滚动等功能。# 本类的实例请参考 $game_player。#=============================================================================class Game_Player #-------------------------------------------------------------------------- # ● 色调的计算 # character_hue :原始人物色调 # delta_hue :色调的偏移值 #-------------------------------------------------------------------------- def character_hue @delta_hue = 0 @state_num = 0 if SRSR::Change_type == 2 and $game_party.actors[0] != nil for i in $game_party.actors[0].states #如果角色中状态就加上偏移值 if SRSR::State_hue[i] != nil @delta_hue += SRSR::State_hue[i][0] @state_num += 1 end end #防止两种以上状态叠加出现相同色调的状况 if @state_num > 1 for i in $game_party.actors[0].states if SRSR::State_hue[i] != nil #当与某一个颜色重复或者与普通色调相同时 if @delta_hue % 360 == SRSR::State_hue[i][0] or @delta_hue %360 == 0 @delta_hue += 179 #加上一个质数尽量避免重复 end end end end #最后计算 @delta_hue %= 360 end return @character_hue + @delta_hue end def character_hue=(hue) @character_hue = hue endend复制代码