-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapwindowstatus.rb
More file actions
158 lines (157 loc) · 6.11 KB
/
mapwindowstatus.rb
File metadata and controls
158 lines (157 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
###------------------------------------------------------------------------###
### > Map Window Status ###
### > Criado por Klarth ###
### > Esse script permite que toda vez que algum personagem mude o seu ###
### status no mapa, uma janela de aviso apareça informando a mudança. ###
#-----------------------------------------------------------------------------#
# Configurações do script: #
#-----------------------------------------------------------------------------#
module Status_Win_Conf
#### Texto que aparece caso o grupo ganhe um status
TEXT_GROUP_GAIN = "O grupo ganhou o status: "
#### Texto que aparece caso o grupo perca um status
TEXT_GROUP_LOSE = "O grupo perdeu o status: "
#### Texto que aparece antes do nome do personagem
TEXT_ACTOR = ""
#### Texto que aparece caso um personagem ganhe um status
TEXT_ACTOR_GAIN = " ganhou o status: "
#### Texto que aparece caso um personagem perca um status
TEXT_ACTOR_LOSE = " perdeu o status: "
###### Tempo em frames que a janela ficará no mapa
TIME = 140
###### Caminho completo da SE que tocará. Deixe em branco caso não queira
SE_NAME = "Audio/SE/Item1"
##### Cor do texto quando um personagem ganhar um status
COLOR_GAIN = Color.new(0,255,0,255)
##### Cor do texto quando um personagem perder um status
COLOR_LOSE = Color.new(255,100,100,255)
##### Nome da windowskin da janela (Obs: Deve estar dentro da pasta System)
WINDOWSKIN = "Window"
end
class Window_StatusChange < Window_Base
include Status_Win_Conf
def initialize
super(0,0,0,0)
#---------------------------------------------------------------------
# Algumas configurações da janela
#---------------------------------------------------------------------
self.arrows_visible = false
self.opacity = 0
self.padding = 0
self.tone = Tone.new(0,0,0,0)
@wait_time = 0
@text = ""
self.windowskin = Cache.system(WINDOWSKIN)
self.hide
end
#-------------------------------------------------------------------------
# status_id: Id do estado que ganhou
#
# actor_id: Id do actor que ganhou o estado.
# Se for 0 todo o grupo ganhou o estado
#
# type - 0: adicionou status
# 1: retirou status
#-------------------------------------------------------------------------
def show_window(status_id, actor_id, type)
#-------------------------------------------------------------------------
# Aqui é montado o texto a ser exibido
#-------------------------------------------------------------------------
@text = ""
if (type == 0)
actor_id == 0 ? @text += TEXT_GROUP_GAIN :
@text += TEXT_ACTOR + $data_actors[actor_id].name +
TEXT_ACTOR_GAIN
@text += $data_states[status_id].name + "!"
else
actor_id == 0 ? @text += TEXT_GROUP_LOSE :
@text += TEXT_ACTOR + $data_actors[actor_id].name +
TEXT_ACTOR_LOSE
@text += $data_states[status_id].name + "!"
end
#-------------------------------------------------------------------------
# Nessa parte são calculados a largura, a altura, o x e o y
# de acordo com o tamanho do texto
#-------------------------------------------------------------------------
self.contents.font.size = 18
t_size = text_size(@text).width
self.width = t_size + 60
self.height = 40
self.x = (Graphics.width - self.width)/2
self.y = -10
self.contents = Bitmap.new(self.width, self.height)
#-------------------------------------------------------------------------
# Aqui é desenhado o icone do status
#-------------------------------------------------------------------------
draw_icon($data_states[status_id].icon_index, 14, 8)
#--------------------------------------------------------------------------
# Aqui é desenhado o texto
#--------------------------------------------------------------------------
type == 0 ? self.contents.font.color = COLOR_GAIN :
self.contents.font.color = COLOR_LOSE
self.contents.font.size = 18
self.contents.draw_text(45, 10, t_size + 300, 20, @text)
self.show
self.open
end
#--------------------------------------------------------------------------
# Atualiza a janela. É chamado todo frame.
#--------------------------------------------------------------------------
def update
super
self.y += 3 if self.y < 16
self.opacity += 13 if self.opacity < 200
@wait_time += 1
self.close if @wait_time >= TIME
end
#--------------------------------------------------------------------------
# Abre a janela realizando a animação
#--------------------------------------------------------------------------
def open
super
self.y = -10
self.opacity = 0
@wait_time = 0
Audio.se_play(SE_NAME) if SE_NAME != ""
end
end
#----------------------------------------------------------------------------
# Modificação no metódo que muda o status da classe Game_Interpreter
#----------------------------------------------------------------------------
class Game_Interpreter
def command_313
iterate_actor_var(@params[0], @params[1]) do |actor|
already_dead = actor.dead?
if @params[2] == 0
actor.add_state(@params[3])
else
actor.remove_state(@params[3])
end
actor.perform_collapse_effect if actor.dead? && !already_dead
end
if SceneManager.scene.is_a?(Scene_Map)
SceneManager.scene.status_window.show_window(@params[3], @params[1], @params[2])
end
end
end
#-----------------------------------------------------------------------------
# Modificações necessárias na classe Scene_Map
#-----------------------------------------------------------------------------
class Scene_Map
attr_accessor :status_window
alias klarth_start start
alias klarth_update update
alias klarth_terminate terminate
def start
klarth_start
@status_window = Window_StatusChange.new
end
def update
klarth_update
@status_window.update
end
def terminate
@status_window.dispose
klarth_terminate
end
end