Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Criss-Crossing the MOG XAS HUD and DOD Change Leader Scripts

pez

Member

I have the MOG XAS HUD and the DOD Change Leader Script

The scripts work fine, however when I change the leader, the information displayed on MOG XAS HUD doesn't update, unless you open the menu and escape out of it...

Any ideas, I would really love some help on this!


Code:
#______________________________________________________________________

_________

# MOG XAS Hud V2.6

#_______________________________________________________________________________

# By Moghunter

# [url=http://www.atelier-rgss.com]http://www.atelier-rgss.com[/url]

#_______________________________________________________________________________

# Apresenta o status do herói no mapa.

# (HP,SP,Condição,Exp,level) em imagens.

#_______________________________________________________________________________

# Imagens necessarias.

#

# Nome_do_Personagem + _Face.png

# HP_Meter.png

# SP_Meter.png

# HP_Tx.png

# SP_Tx.png

# LV_Tx.png

# Bar_Meter.png

# Exp_Back.png

# Exp_Meter.png

#

#_______________________________________________________________________________

module XAS_HUD

#Posição das janelas

XASHUD_X = 0

XASHUD_Y = 370

#ID da switch que desativa a janela do Status.

DISABLE_STATUS_HUD_SWITCH = 5

#Mostrar ícones dos status

ICON_STATES = true

#Deixar o HUD opaco caso o herói estiver em cima do HUD.

FADE = true

end

$mog_rgss_xas_hud = true

###############

# Window_Base #

###############

class Window_Base < Window

def draw_maphp2(actor, x, y)

actor = $game_party.actors[0]

self.contents.font.size = 18

back = RPG::Cache.picture("BAR_Meter")

cw = back.width

ch = back.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 62, y - ch + 28, back, src_rect)

meter = RPG::Cache.picture("HP_Meter")

cw = meter.width * actor.hp / actor.maxhp

ch = meter.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 62, y - ch + 28, meter, src_rect)

text = RPG::Cache.picture("HP_Tx")

cw = text.width

ch = text.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 35, y - ch + 30, text, src_rect)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 76, y - 1, 48, 32, actor.hp.to_s, 2)

lowhp = actor.maxhp * 20 / 100

avhp = actor.maxhp * 50 / 100

if actor.hp <= lowhp

self.contents.font.color = Color.new(255,55,55,255)

elsif actor.hp <= avhp

self.contents.font.color = Color.new(255,255,55,255)

else

self.contents.font.color = Color.new(255,255,255,255)

end

self.contents.draw_text(x + 75, y - 2, 48, 32, actor.hp.to_s, 2)

end

def draw_mapsp2(actor, x, y)

actor = $game_party.actors[0]

self.contents.font.size = 18

back = RPG::Cache.picture("BAR_Meter")

cw = back.width

ch = back.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 62, y - ch + 28, back, src_rect)

meter = RPG::Cache.picture("SP_Meter")

cw = meter.width * actor.sp / actor.maxsp

ch = meter.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 62, y - ch + 28, meter, src_rect)

text = RPG::Cache.picture("SP_Tx")

cw = text.width

ch = text.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 35, y - ch + 30, text, src_rect)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 76, y - 1, 48, 32, actor.sp.to_s, 2)

self.contents.font.color = Color.new(255,255,255,255)

self.contents.draw_text(x + 75, y - 2, 48, 32, actor.sp.to_s, 2)

end

 

 

 

 

def nada

face = RPG::Cache.picture("")

end

def draw_heroface(actor,x,y)

face = RPG::Cache.picture(actor.name + "_face") rescue nada

cw = face.width

ch = face.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x , y - ch, face, src_rect)

end

def draw_actor_statemap(actor, x, y, width = 100)

if XAS_HUD::ICON_STATES == false

self.contents.font.size = 16

text = make_battler_state_text(actor, width, true)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 1, y + 1, width, 32, text)

self.contents.font.color = Color.new(250,255,255,255)

self.contents.draw_text(x, y, width, 32, text)

else

sta = []

for i in actor.states

sta.push($data_states[i].name)

for s in 0...sta.size

if s < 4

bitmap = RPG::Cache.icon(sta[s])

self.contents.blt(x + (25 * s), y + 4, bitmap, Rect.new(0, 0, 32, 32))

end

end

end

end

 

 

 

 

 

#

end

def draw_actor_levelmap(actor, x, y)

bitmap2 = RPG::Cache.picture("Exp_Back")

cw = bitmap2.width

ch = bitmap2.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 10 , y - ch + 30, bitmap2, src_rect)

 

self.contents.font.size = 16

actor = $game_party.actors[0]

if actor.next_exp != 0

rate = actor.now_exp.to_f / actor.next_exp

else

rate = 1

end

bitmap = RPG::Cache.picture("Exp_Meter")

if actor.level < 99

cw = bitmap.width * rate

else

cw = bitmap.width

end

ch = bitmap.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 10 , y - ch + 30, bitmap, src_rect)

text = RPG::Cache.picture("LV_Tx")

cw = text.width

ch = text.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 0, y - ch + 30, text, src_rect)

self.contents.font.size = 18

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 30, y - 4, 24, 32, actor.level.to_s, 1)

self.contents.font.color = Color.new(255,255,255,255)

self.contents.draw_text(x + 31, y - 5, 24, 32, actor.level.to_s, 1)

end

end

##############

# Game_Actor #

##############

class Game_Actor < Game_Battler

def now_exp

return @exp - @exp_list[@level]

end

def next_exp

return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0

end

end

#####################

# Window_Status_Map #

#####################

class Window_HUD < Window_Base

def initialize

super(0, 0, 270, 125)

self.contents = Bitmap.new(width - 32, height - 32)

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

self.contents.font.bold = true

self.contents.font.name = "Georgia"

self.opacity = 0

@actor = $game_party.actors[0]

if @actor != nil

@old_hp = @actor.hp

@old_sp = @actor.sp

@old_level = @actor.level

@old_state = @actor.states.to_s

@old_exp = @actor.exp

refresh

end

end

def refresh

self.contents.clear

draw_maphp2(@actor, 5, 35)

draw_mapsp2(@actor, -35, 55)

draw_heroface(@actor, 0, 60)

draw_actor_statemap(@actor, 140, 62, 70)

draw_actor_levelmap(@actor, 45, 10)

@old_hp = @actor.hp

@old_sp = @actor.sp

@old_level = @actor.level

@old_state = @actor.states.to_s

@old_exp = @actor.exp

end

def update

if XAS_HUD::FADE == true

x = ($game_player.real_x - $game_map.display_x) / 4

y = ($game_player.real_y - $game_map.display_y) / 4

hud_size_x = 180

hud_size_y = 100

oc_range_x = hud_size_x + XAS_HUD::XASHUD_X

oc_range_y = hud_size_y + XAS_HUD::XASHUD_Y

if x < oc_range_x and x > XAS_HUD::XASHUD_X - 5 and

y > XAS_HUD::XASHUD_Y and y < oc_range_y

self.contents_opacity -= 10 if self.contents_opacity > 120

else

self.contents_opacity += 10 if self.contents_opacity < 255

end

end

if @actor != nil

if @old_hp != @actor.hp or

@old_sp != @actor.sp or

@old_level != @actor.level or

@old_state != @actor.states.to_s or

@old_exp != @actor.exp

refresh

end

end

end

end

###############

# Game_Player #

###############

class Game_Player < Game_Character

attr_accessor :wref

end

#############

# Scene_Map #

#############

class Scene_Map

alias mog11_main main

def main

@sthero = Window_HUD.new

@sthero.x = XAS_HUD::XASHUD_X

@sthero.y = XAS_HUD::XASHUD_Y

if $game_switches[XAS_HUD::DISABLE_STATUS_HUD_SWITCH] == false

@sthero.visible = true

else

@sthero.visible = false

end

mog11_main

@sthero.dispose

end

alias mog11_update update

def update

if $game_switches[XAS_HUD::DISABLE_STATUS_HUD_SWITCH] == false

@sthero.visible = true

else

@sthero.visible = false

end

@sthero.update

mog11_update

end

end

Code:
 

#------------------#

#Dod Change Leader #

#by:Dodoop #

#version:1.0 #

#------------------#

#Muda o líder quando uma certa tecla for pressionada no mapa.

module Dodoop

#Tecla que devera ser pressiona para mudar o líder.

CHANGE_LEADER_INPUT = Input::L

end

class Scene_Map

alias change_leader update

def update

change_leader

if Input.trigger?(Dodoop::CHANGE_LEADER_INPUT)

leader_read

end

end

def leader_read

@actors = []

for i in 0...$game_party.actors.size

@actors[i] = $game_party.actors[i]

end

for i in [email=1...@actors.size]1...@actors.size[/email]

$game_party.actors[i - 1] = @actors[i]

end

$game_party.actors[@actors.size - 1] = @actors[0]

$game_player.refresh

end

end

Files Needed...

Bar_Meter.png


Exp_Back.png


Exp_Meter.png


HP_Meter.png


HP_Tx.png


LV_Tx.png


SP_Meter.png


SP_Tx.PNG


Hero_Face.PNG
 

pez

Member

Still not working,

The "face picture" plus the "status" of the Actor doesn't update, unless you open and close the game menu.
BTW you might need an extra ""/Graphics/(Actor Name)_Face.png"" and ""/icons/(Status Name).png"" to see the effect or the game will crash.

So far I have it so the HP and SP updates when you change leader....

More thoughts?
 

Atoa

Member

This HUD script code is really in a mess...

The last thing i can think:

Add this after the line 29 in dod change leader
Code:
if @sthero != nil

  @sthero.dispose

  @sthero = Window_HUD.new

  @sthero.x = XAS_HUD::XASHUD_X

  @sthero.y = XAS_HUD::XASHUD_Y

  if $game_switches[XAS_HUD::DISABLE_STATUS_HUD_SWITCH] == false

    @sthero.visible = true

  else

    @sthero.visible = false

  end

  @sthero.update

end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top