Advertisement
LeonMMS

Untitled

Dec 10th, 2020
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.69 KB | None | 0 0
  1.   def order_equips(dir)
  2.     # 0 = Arma
  3.     # 1 = Escudo
  4.     # 2 = Capacete
  5.     # 3 = Armadura
  6.     # 4 = Acessório
  7.     # 5 = Amuleto
  8.     # 6 = Capa
  9.     # 7 = Luva
  10.     # 8 = Bota
  11.     case dir
  12.     when 2 # Frente
  13.       return [3, 5, 2, 7, 6, 8, 1, 0, 4]
  14.     when 4 # Esquerda
  15.       return [7, 0, 3, 5, 2, 6, 8, 1, 4]
  16.     when 6 # Direita
  17.       return [1, 3, 5, 2, 7, 6, 8, 0, 4]
  18.     when 8 # Costas
  19.       return [7, 1, 0, 3, 5, 2, 8, 6, 4]
  20.     end
  21.   end
  22.  
  23.   def update_paperdoll
  24.     create_paperdoll unless @paperdoll
  25.     refresh_paperdoll if @character.actor.refresh_paperdoll
  26.     pattern = @character.pattern < 3 ? @character.pattern : 1
  27.     paperdoll_index = @character.attack_animation? ? @character.character_index : 0
  28.     sx = (paperdoll_index % 4 * 3 + pattern) * Configs::PDMAXFSIZE
  29.     sy = (paperdoll_index / 4 * 4 + (@character.direction - 2) / 2) * Configs::PDMAXFSIZE
  30.     @paperdoll.src_rect.set(sx, sy, Configs::PDMAXFSIZE, Configs::PDMAXFSIZE)
  31.     @paperdoll.x = x
  32.     @paperdoll.y = y
  33.     @paperdoll.z = z  
  34.   end
  35.  
  36.   def refresh_paperdoll
  37.     @paperdoll.bitmap.clear
  38.     [2,4,6,8].each{|dir|
  39.       order_equips(dir).each {|slot_id|
  40.         next unless @character.actor.equips[slot_id] && @character.actor.equips[slot_id].paperdoll_name
  41.         bitmap = Cache.paperdoll(@character.actor.equips[slot_id].paperdoll_name, @character.actor.sex)
  42.         sign = @character.actor.equips[slot_id].paperdoll_name[/^[\!\$]./]
  43.         if sign && sign.include?('$')
  44.           paperdoll_index = 0
  45.           cw = bitmap.width / 3
  46.           ch = bitmap.height / 4
  47.         else
  48.           paperdoll_index = @character.actor.equips[slot_id].paperdoll_index        
  49.           cw = bitmap.width / 12
  50.           ch = bitmap.height / 8
  51.         end        
  52.         3.times{ |pattern|
  53.           sx = (paperdoll_index % 4 * 3 + pattern) * cw
  54.           sy = (paperdoll_index / 4 * 4 + (dir - 2) / 2) * ch
  55.           rect = Rect.new(sx, sy, cw, ch)
  56.           bx = (pattern * Configs::PDMAXFSIZE)
  57.           by = (((dir - 2) / 2) * Configs::PDMAXFSIZE)
  58.           bltx = bx + ((Configs::PDMAXFSIZE - cw) / 2)
  59.           blty = by + (Configs::PDMAXFSIZE - ch)
  60.           @paperdoll.bitmap.blt(bltx, blty, bitmap, rect)
  61.         }
  62.       }
  63.     }
  64.     @character.actor.refresh_paperdoll = false
  65.   end
  66.  
  67.   def create_paperdoll
  68.     @paperdoll = Sprite.new(viewport)
  69.     @paperdoll.bitmap = Bitmap.new(Configs::PDMAXFSIZE * 3, Configs::PDMAXFSIZE * 4)
  70.     @paperdoll.ox = Configs::PDMAXFSIZE / 2
  71.     @paperdoll.oy = Configs::PDMAXFSIZE    
  72.   end
  73.  
  74.   def dispose_paperdoll#LM² - Paperdoll
  75.     return unless @paperdoll
  76.     @paperdoll.bitmap.dispose
  77.     @paperdoll.dispose
  78.     @paperdoll = nil
  79.   end  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement