❤ 0 Auteur : TDS
Logiciel : RPG Maker VX
Nombre de scripts : 1
Source (version 1.4) : [url]https://forums.rpgmakerweb.com/index.php?threads/sprite-reflection.172/
Conditions d'utilisation
- Vous ne pouvez pas utiliser ce script dans vos projets commerciaux.
Instructions :
1. Copier le script au-dessus de "Main" dans la section "Materials" sous n'importe quel nom. Ensuite créez-vous une carte.
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
| #==============================================================================
# ** TDS Sprite Reflect
# Version: 1.7
#------------------------------------------------------------------------------
# This script makes specially desigated areas reflect the character sprite and
# events.
#==============================================================================
# Instructions:
#
# Create areas using the area creator of the map editor and call them "Reflect".
#
# For events you can use these two commands in part of their name.
#
# Reflect
#
# Any event with "Reflect" as part of it's name will have the reflect effect on
# the special areas of the map.
#
#
# /OFFSET[#]
#
# [#] = Numerical value of the offset.
#
# Example:
# /OFFSET[10]
#
# Offset changes the Y offset of the sprite in the water.(How far is the
# Reflection from the characters original standing point)
#
#
# $game_player.reflect_offset = #
#
# # = Value of the character offset.
#
# Just the same as the event offset except this one handles the characters
# offset reflection.
#==============================================================================
#--------------------------------------------------------------------------
# * Constants for activating the wave effect on the water
#--------------------------------------------------------------------------
WATER_WAVE_EFFECT = true
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display characters. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Reflect < Sprite_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :character
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# character : character (Game_Character)
# offset : offset value from the characters starting point.
#--------------------------------------------------------------------------
def initialize(viewport = nil, character = nil, offset = nil)
super(viewport)
self.visible = false
@character = character
@player_offset = $game_player.reflect_offset
@offset = (@character.is_a?(Game_Player) ? @player_offset : offset)
sprite_setup
update
end
#--------------------------------------------------------------------------
# * Sprite Setup
#--------------------------------------------------------------------------
def sprite_setup
self.bitmap = Cache.character(@character.character_name)
self.angle = 180
self.mirror = true
self.opacity = 120
sign = @character.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
@cw = bitmap.width / 3
@ch = bitmap.height / 4
else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
if @character.is_a?(Game_Player)
self.ox = @cw / 2
self.oy = 8 + @ch + $game_player.reflect_offset
else
self.ox = @cw / 2
self.oy = 8 + @ch + @offset
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z
if WATER_WAVE_EFFECT == true
self.wave_amp = 1
self.wave_length = 1
self.wave_speed = 3
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Create Character Sprite
#--------------------------------------------------------------------------
alias tds_sprite_reflection_create_characters create_characters
def create_characters
tds_sprite_reflection_create_characters
@character_sprites = []
@event_reflection_sprite = []
@reflecting_events = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
for i in $game_map.events.keys.sort
@event_name_offset = $game_map.events[i].name
@event_name_offset[ /\/OFFSET\[(.*?)\]/ ]
sprite = Sprite_Reflect.new(@viewport1, $game_map.events[i], $1 != nil ? $1.to_i : 0)
if $game_map.events[i].name.include?("Reflect")
@event_reflection_sprite.push(sprite)
@reflecting_events.push($game_map.events[i])
end
end
@reflection_sprite = Sprite_Reflect.new(@viewport1, $game_player, 0)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias tds_sprite_reflection_update update
def update
tds_sprite_reflection_update
if $game_player.current_area_name == "Reflect"
if $game_player.moving? == false
@reflection_sprite.visible = true
end
else
@reflection_sprite.visible = false
end
for i in 0...@reflecting_events.size
if @reflecting_events[i].current_area_name == "Reflect"
if @reflecting_events[i].moving? == false
@event_reflection_sprite[i].visible = true
end
else
@event_reflection_sprite[i].visible = false
end
end
if @reflection_sprite.visible == true
@reflection_sprite.update
end
for i in 0...@event_reflection_sprite.size
if @event_reflection_sprite[i].visible == true
@event_reflection_sprite[i].update
end
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :reflect_offset # Character Reflection Offset
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias tds_sprite_reflection_initialize initialize
def initialize
tds_sprite_reflection_initialize
@reflect_offset = 0
end
#--------------------------------------------------------------------------
# * Determine if in Area
# area : Area data (RPG::Area)
#--------------------------------------------------------------------------
def in_area?(area)
return false if area == nil
return false if $game_map.map_id != area.map_id
return false if @x < area.rect.x
return false if @y < area.rect.y
return false if @x >= area.rect.x + area.rect.width
return false if @y >= area.rect.y + area.rect.height
return true
end
#--------------------------------------------------------------------------
# * Current Area Name
#--------------------------------------------------------------------------
def current_area_name
# Checks the areas in the maps
for area in $data_areas.values
# If the character is currently on an area
if in_area?(area) == true
# Give the value of the name of the area to the return variable
return_area_name = area.name
# Break loop
break
end
end
return return_area_name
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Clear Starting Flag
#--------------------------------------------------------------------------
def name
return @event.name
end
end |
2. Ensuite créer un "Area" sous le nom de "Reflect".
Dans l'exemple de ma photo, j'ai besoin de créer deux "Area" sous le nom de "Reflect" - un pour chaque cours d'eau.
Spoiler (cliquez pour afficher)
3. Maintenant, vous devez déterminer la position du "Area" selon la région où vous voulez avoir de la réflexion. Pour faire ainsi, cliquer sur l' "Area" désirer puis cliquer sur "Espace" sur votre clavier. Vous devriez voir cette boite ;
Spoiler (cliquez pour afficher)
4. Maintenant, créer un "EVENT" afin de créer un "NPC" sur la carte. Il est important de nommer cet "EVENT" sous le nom de "REFLECT". Puis lorsque cet "EVENT" passe dans la zone déterminer au numéro 4, sont "SPRITE" est réfléchie sur la case juste en dessous. (Le processus parallèle de l'évènement n'est pas obligatoire, le screen n'est pas de moi)
Spoiler (cliquez pour afficher)
NOTE : Si vous voulez que le reflet soit plus loin, changez simplement le nom de l' "EVENT" pour "Reflect /OFFSET[40]" au lieu de juste "REFLECT" comme mentionné au numéro 5 ci-haut.
(Utile pour faire un reflet dans l'eau même si l'évènement est sur une montagne).
Mis à jour le 21 novembre 2020.
|