Bienvenue visiteur !
|
Statistiques
Liste des membres
Contact
Mentions légales
311 connectés actuellement
30945716 visiteurs depuis l'ouverture
1754 visiteurs aujourd'hui
Partenaires
Tous nos partenaires
Devenir partenaire
|
crazyboko -
posté le 20/02/2018 à 00:52:23 (76 messages postés)
| | Domaine concerné: Script
Logiciel utilisé: RPG Maker XP
Salut à tous !
Me voilà bloquer dans mon projet à cause d'un script, ça faisait longtemps !
C'est le sprite reflection de rpgmaker xp.
Donc il y a un effet miroir sur les cases de terrain 7.
Il me faudrait cet effet sur les cases de terrain 7 et celles de terrain 6 (et pouvoir passer de l'une à l'autre de façon fluide).
J'ai beau changer les 7 par des 6 dans le script, je n'arrive à rien (et encore moins 6 et 7). Ça me fait plein de bug graphique.
Je remets le script ici si quelqu'un sait comment faire... Ce serait super cool !
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
| #==============================================================================
# ■ Sprite_Reflection
# Based on Sprite_Mirror, Modified By: JmsPlDnl, rewritten entirely by Rataime
#==============================================================================
CATERPILLAR_COMPATIBLE = true
class Game_Party
attr_reader :characters
end
class Sprite_Reflection < RPG::Sprite
attr_accessor :character
def initialize(viewport=nil, character=nil,self_angle = 180)
super(viewport)
@character = character
@self_angle=self_angle
self.opacity=0
@reflected=false
@former=false
@moving=false
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)==7
@reflected=true
@former=true
end
update
end
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = (@character.pattern) * @cw
sy = (@character.direction - 2) / 2 * @ch
if @character.direction== 6
sy = ( 4- 2) / 2 * @ch
end
if @character.direction== 4
sy = ( 6- 2) / 2 * @ch
end
if @character.direction != 4 and @character.direction != 6
sy = (@character.direction - 2) / 2 * @ch
end
end
self.x = @character.screen_x
self.y = @character.screen_y-5
@moving=!(@character.real_x%128==0 and @character.real_y%128==0)
@d=@character.direction
@rect=[sx, sy, @cw, @ch]
if !(@moving)
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)==7
@reflected=true
@former=true
else
@reflected=false
@former=false
end
else
case @d
when 2
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+2)==7
@reflected=true
if @former==false
@offset = (@character.screen_y%32)*@ch/32
@rect=[sx, sy, @cw, @offset]
self.y=@character.screen_y-5
end
else
@reflected=false
end
when 4
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)!=7
@offset = ((@character.screen_x-@cw/2)%32)*@cw/32
@rect=[sx, sy, @offset, @ch]
self.x=@character.screen_x
else
@reflected=true
if @former==false
@offset = ((@character.screen_x-@cw/2)%32)*@cw/32
@rect=[sx+@offset, sy, @cw-@offset, @ch]
self.x=@character.screen_x-@offset
end
end
when 6
if $game_map.terrain_tag(@character.real_x/128+1,@character.real_y/128+1)!=7
@offset = ((@character.screen_x-@cw/2)%32)*@cw/32
@rect=[sx+@offset, sy, @cw-@offset, @ch]
self.x=@character.screen_x-@offset
else
@reflected=true
if @former==false
@offset = ((@character.screen_x-@cw/2)%32)*@cw/32
@rect=[sx, sy, @offset, @ch]
self.x=@character.screen_x
end
end
when 8
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+2)==7
@reflected=true
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)!=7
@offset = (@character.screen_y%32)*@ch/32
@rect=[sx, sy, @cw, @offset]
self.y=@character.screen_y-5
end
else
@reflected=false
end
end
end
if @reflected
self.opacity=35
else
@rect=[sx, sy, @cw, @ch]
self.opacity=0
end
if $game_map.terrain_tag((@character.real_x+64)/128,@character.real_y/128+2)!=7
if $game_map.terrain_tag((@character.real_x+64)/128,@character.real_y/128+2)!=7
@rect[1]= @rect[1]+@ch/2
@rect[3]= @rect[3]/2
self.y = self.y - @ch/2
else
@reflected=false
end
end
self.src_rect.set(@rect[0],@rect[1],@rect[2],@rect[3])
@character.is_a?(Game_Player) ? self.z = 9 : self.z = 5
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
self.angle = @self_angle
end
end
#===================================================
# ▼ CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias reflect_initialize initialize
def initialize(viewport, character = nil)
@character = character
@reflection = []
super(viewport)
if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["r"])
@reflection.push(Sprite_Reflection.new(viewport,@character))
end
if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["hero_r"])
@reflection.push(Sprite_Reflection.new(viewport,$game_player))
#===================================================
# ● Compatibility with fukuyama's caterpillar scrîpt
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
@reflection.push(Sprite_Reflection.new(viewport,member))
end
end
#===================================================
# ● End of the compatibility
#===================================================
end
reflect_initialize(viewport, @character)
end
alias reflect_update update
def update
reflect_update
if @reflection!=nil
for reflect in @reflection
reflect.update
end
end
end
end |
|
NanakyTim -
posté le 20/02/2018 à 01:09:01 (23817 messages postés)
| | T'es pas dans la bonne section du forum, il faut poster dans l'entraide
Aussi, pense à utiliser la balise "code" pour les scripts, ça rend plus lisible et ça aide à sélectionner pour ceux qui voudraient t'aider.
Je déplace et édite.
Malheureusement je m'y connais pas assez pour t'aider. Bon courage !
|
Héros ou Fléau ? Devenez le Roi de Quineroy ! ~ Plongez dans l'univers sombre du Darkans ! ~ Dimens Reis... Allez y faire un tour. ~ Rangez votre chambre ! ~ Avez-vous peur du noir ? ~ Sauvez le futur, en allant dans le passé: BOCALATOR... |
crazyboko -
posté le 20/02/2018 à 09:15:24 (76 messages postés)
| | Oups ! Désolé !
Merci pour les modifications !
Edit :
J'ai trouvé une version modifiée du script qui me permet de faire ce que je veux (en gros case 7 comme avant et case 6 pour une version un peu modifiée du reflet mais qui me convient très bien).
Coup de bol !
SAUF QUE...
Y a un bug incompréhensible. Avant de me servir de ce script modifié, j'ai retesté mon jeu là où il y a des reflets. Et des maps ont des ratés fatales.
Exemple :
https://ibb.co/cqav8H
L'oiseau en haut à droite doit avoir son reflet dans l'eau. A cette position, bug fatal:
https://ibb.co/c2EBhc
Alors que si je le place juste à côté :
https://ibb.co/krqOvx
Là, aucun problème. Il peut même passer sur la case à côté. Tant qu'il n'est pas dessus au départ tout va bien.
J'ai le même bug sur toutes les cases qui lui ressemblent.
J'aimerais comprendre ce bug avant de me servir de ce script, car là c'est un appel au bug/crash incompréhensible.
Voici le code :
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
| #==============================================================================
# ? Sprite_Reflection
# Based on Sprite_Mirror, Modified By: JmsPlDnl, rewritten entirely by Rataime
# 18/04/07 : Script modifié par MGCaladtogel pour améliorer le rendu visuel
# sur l'autotile RTP : "Water01" : le mettre en ID de terrain = 6
#==============================================================================
CATERPILLAR_COMPATIBLE = true
#----------------------------------------------------------------------------
class Game_Party
attr_reader :characters
end
#----------------------------------------------------------------------------
class Sprite_Reflection < RPG::Sprite
attr_accessor :character
#--------------------------------------------------------------------------
def initialize(viewport=nil, character=nil,self_angle = 180)
super(viewport)
@character = character
@self_angle=self_angle
self.opacity=0
@reflected=false
@former=false
@moving=false
@c_h = false
@c_g = 0
@c_d = 0
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)>=6
corr_auto(@character.real_x/128,@character.real_y/128+1)
@reflected=true
@former=true
end
update
end
#--------------------------------------------------------------------------
def type_auto(x, y)
val = $game_map.terrain_tag(x, y)
return (val != 6 ? false : true)
end
#--------------------------------------------------------------------------
def corr_auto(x, y)
val0 = $game_map.terrain_tag(x,y)
val1 = $game_map.terrain_tag(x-1,y)
val2 = $game_map.terrain_tag(x+1,y)
if val1 < 6
@c_g = (@cw-32)/2
@c_g += 8 if val0 == 6
end
if val2 < 6
@c_d = (@cw-32)/2
@c_d += 8 if val0 == 6
end
end
#--------------------------------------------------------------------------
def update
@c_h = false
@c_g = 0
@c_d = 0
@m = false
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = (@character.pattern) * @cw
sy = (@character.direction - 2) / 2 * @ch
if @character.direction== 6
sy = ( 4- 2) / 2 * @ch
end
if @character.direction== 4
sy = ( 6- 2) / 2 * @ch
end
if @character.direction != 4 and @character.direction != 6
sy = (@character.direction - 2) / 2 * @ch
end
end
self.x = @character.screen_x
self.y = @character.screen_y-5
@moving=!(@character.real_x%128==0 and @character.real_y%128==0)
@d=@character.direction
@rect=[sx, sy, @cw, @ch]
if !(@moving)
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)>=6
corr_auto(@character.real_x/128,@character.real_y/128+1)
@reflected=true
@former=true
else
@reflected=false
@former=false
end
else
case @d
when 2
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+2)>=6
corr_auto(@character.real_x/128,@character.real_y/128+2)
@reflected=true
if @former==false
@offset = @ch - (32 - ((@character.real_y/4)%32))
@rect=[sx, sy, @cw, @offset]
end
else
@reflected = ($game_map.terrain_tag(@character.real_x/128,
@character.real_y/128+1)>=6 ? true : false)
if @reflected
@offset = @ch - ((32+5) - (@character.real_y/4)%32)
@rect=[sx, sy + @offset, @cw, @ch - @offset]
self.y -= @offset
end
end
when 4
if $game_map.terrain_tag((@character.real_x+127)/128 - 1,@character.real_y/128+1)<6
if $game_map.terrain_tag((@character.real_x+127)/128,@character.real_y/128+1)>=6
@offset = (@character.real_x/4)%32 + (@cw-32)/2
@offset -= 8 if type_auto((@character.real_x+127)/128,@character.real_y/128+1)
@rect=[sx, sy, @offset, @ch]
@reflected=true
@c_h = true
end
else
@reflected=true
if @former==false
@offset = (@character.real_x/4)%32 + (@cw-32)/2
@offset += 8 if type_auto((@character.real_x)/128,@character.real_y/128+1)
@rect=[sx+@offset, sy, @cw-@offset, @ch]
self.x -= @offset
end
end
when 6
if $game_map.terrain_tag(@character.real_x/128+1,@character.real_y/128+1)<6
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)>=6
@offset = (@character.real_x/4)%32 + (@cw-32)/2
@offset += 8 if type_auto(@character.real_x/128,@character.real_y/128+1)
@rect=[sx+@offset, sy, @cw-@offset, @ch]
self.x -= @offset
@reflected=true
end
else
@reflected=true
if @former==false
@offset = (@character.real_x / 4)%32 + (@cw-32)/2
@offset -= 8 if type_auto((@character.real_x+127)/128,@character.real_y/128+1)
@rect=[sx, sy, @offset, @ch]
@c_h = true
end
end
when 8
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+2)>=6
corr_auto(@character.real_x/128,@character.real_y/128+2)
@reflected=true
if $game_map.terrain_tag(@character.real_x/128,@character.real_y/128+1)<6
@offset = @ch - (32 - ((@character.real_y/4)%32))
@rect=[sx, sy, @cw, @offset]
end
else
@reflected = ($game_map.terrain_tag(@character.real_x/128,
@character.real_y/128+1)>=6 ? true : false)
if @reflected
@offset = @ch - ((32+5) - (@character.real_y/4)%32)
@rect=[sx, sy + @offset, @cw, @ch - @offset]
self.y -= @offset
end
end
end
end
if @reflected
self.opacity=128
else
@rect=[sx, sy, @cw, @ch]
self.opacity=0
end
if @reflected and $game_map.terrain_tag((@character.real_x+64)/128,
(@character.real_y+127)/128+2)<6
if $game_map.terrain_tag((@character.real_x+64)/128,
(@character.real_y+127)/128)>=6 and
$game_map.terrain_tag((@character.real_x+64)/128,
(@character.real_y+127)/128+1)>=6
@offset = [(@ch - (32+5)) - (32 - (@character.real_y/4)%32)%32, 0].max
@rect[1] += @offset
@rect[3] -= @offset
self.y -= @offset
else
lim = (type_auto((@character.real_x+64)/128,
(@character.real_y+127)/128+1) ? (32-8) : (32+5))
if @rect[3] > lim
diff = @rect[3] - lim
@rect[1] += diff
@rect[3] = lim
self.y -= diff
end
end
else
@reflected=false
end
corr_h = 0
if @c_h or ($game_map.terrain_tag((@character.real_x)/128,
(@character.real_y+127)/128)<6 and
$game_map.terrain_tag((@character.real_x)/128,
(@character.real_y+127)/128+1)>=6)
if type_auto((@character.real_x)/128, (@character.real_y+127)/128+1) or
type_auto((@character.real_x+127)/128, (@character.real_y+127)/128+1)
corr_h = 13
else
corr_h = 4
end
end
self.x -= @c_d
self.src_rect.set(@rect[0] + @c_d, @rect[1], @rect[2] - @c_g - @c_d,
@rect[3] - corr_h)
@character.is_a?(Game_Player) ? self.z = 9 : self.z = 5
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
self.angle = @self_angle
end
end
#===================================================
# ? CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias reflect_initialize initialize
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
@character = character
@reflection = []
super(viewport)
if (character.is_a?(Game_Event) and character.list!=nil and
character.list[0].code == 108 and character.list[0].parameters == ["r"])
@reflection.push(Sprite_Reflection.new(viewport,@character))
end
if (character.is_a?(Game_Event) and character.list!=nil and
character.list[0].code == 108 and character.list[0].parameters == ["hero_r"])
@reflection.push(Sprite_Reflection.new(viewport,$game_player))
#===================================================
# ? Compatibility with fukuyama's caterpillar scrîpt
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
@reflection.push(Sprite_Reflection.new(viewport,member))
end
end
#===================================================
# ? End of the compatibility
#===================================================
end
reflect_initialize(viewport, @character)
end
#--------------------------------------------------------------------------
alias reflect_update update
#--------------------------------------------------------------------------
def update
reflect_update
if @reflection!=nil
for reflect in @reflection
reflect.update
end
end
end
end |
Merci d'avance !
Edit 2 :
C'est bon ! J'ai réussi à faire ce que je voulais avec le sprite reflection de base et des événements. Sans faire de concession, à part sur la complexité d'utilisation mais pas grave.
En tout cas, attention au script ci-dessus qui semble fantastique. Gros bug si un événement démarre sur une case à reflet + au ras d'une sans reflet. Idem après un combat.
Merci à ceux qui ont lu mais qui n'ont pas su aider.
| Index du forum > Entraide > [RESOLU] [RPG Maker XP]Problème avec un script de réflection des sprites
|
|
|