Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Tutos: Checklist de la composition (...) / Sorties: Dread Mac Farlane - episode 8 / Sorties: Dread Mac Farlane - episode 7 / Jeux: Ce qui vit Dessous / News: Quoi de neuf sur Oniromancie (...) / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

442 connectés actuellement

29377677 visiteurs
depuis l'ouverture

7044 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

RPG Fusion

Tashiroworld

Tous nos partenaires

Devenir
partenaire



forums

Index du forum > Entraide > [RPG Maker VX] Calculer efficacement pour que le jeu ne rame pas


Gari - posté le 18/02/2023 à 20:09:20 (5899 messages postés) - honor

❤ 0

Domaine concerné: Script
Logiciel utilisé: RPG Maker VX
Bonjour,

J' ai un petit souci qui n'est pas lié à proprement à la mauvaise utilisation du script, mais plutôt à sa post utilisation, puisqu'elle fait ramer le jeu : pour faire simple, il s'agit d'un mini jeu de bataille navale où on gagne les points sous formes d'objets (tout va bien jusque là).
Seul souci, je dois ensuite convertir ces gains en une variable (les bateaux ont une valeur différente).
La proposition de base utilisait plusieurs événements parallèles, mais cela faisait déjà ramer la map et il était alors possible de quitter la map de décompte sans avoir obtenu tous les gains de points.
J'ai essayé de construire un événement automatique, mais c'est bien ce décompte de gains qui fait ramer la map (ouvrir le menu principal ou faire F9 en mode test solutionne le problème).
A noter que les gains ne sont pas très élevés : il y a de 10 à 13 bateaux à traiter.

Voici ce que j'avais fait en événement automatique :
image
(la première ligne et dernière ligne désactive/active un script pour afficher une fenêtre lorsqu'on obtient ou retire un objet sur map.)

J'ai essayé la double et même triple téléportation par le biais d'interrupteur, "Graphic.update" et "$Scene_Map.new", mais ces solutions n'ont pas fonctionné.

Ce que j'aimerais (deux options) :
- un événement plus efficace que celui-ci (peut-être par call script). Peut-être que je m'y suis mal pris, je ne suis pas dieu.
- modifier le script pour qu'on obtienne non pas des objets mais une augmentation de points selon une variable désignée dans le module, et qui pourrait être personnalisée dans la liste des bateaux ("Fishes" dans le module).

Voici le script :

Portion de code : Tout sélectionner

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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# =============================================================================
# Fishing MiniGame
# Version: 1.0
# Author: Omegas7
# Blog:  http://omegas7.blogspot.com    ||   http://omegadev.biz
# -----------------------------------------------------------------------------
# Features:
#    [1.0]
#       > Background & water surface images
#       > Water surface & fish have wave effect
#       > Aim with cursor image right & left
#       > Calculate strength with power meter & cursor
#       > Throw hook, if a fish is on landing area, catch.
#       > Multiple configurable sound effects
#       > Multiple configurable images
#       > Fish catching limit per session through variable (or infinite)
#       > Caught fish listing on end of session
#       > Configurable speed of power cursor & hook
#       > Link fish objects in script with items from database
#       > Receive items (fish)
#       > Fish become available through a game switch
#       > Edit chances of appearance for fish
#       > Accurate movement speed (decimal numbers) for fish
# -----------------------------------------------------------------------------
# NOTES
#       > When going to use the script, you need MINIMUN one fish available
#         (it's game switch ON)
# =============================================================================
 
module OmegaX
  module Fishing
    SessionFishLimitVariableID = 13 
    # Catchable fish per session variable ID.
    # If variable's value equals 0 or a negative number = infinite.
    
    PowerPointerSpeed = 9               # Higher = Faster
    HookThrownSpeed = 8                 # Higher = Faster
    
    ThrowSoundEffect = "Bow1"            # [Audio/SE/] folder
    CatchSoundEffect = "Item1"           # [Audio/SE/] folder
    MissSoundEffect = "Miss"             # [Audio/SE/] folder
    
    WaterSplashAnimationID = 188           # Database animation ID
    SpawningIntervals = [130,190,230]     # Possible frame intervals for spawning
    FishingBackground = "FishingBG"          # [Pictures] folder
    WaterSurface = ""            # [Pictures] folder
    FishingAim = "FishingAim"                # [Pictures] folder
    PowerBar = "FishingPowerBar"             # [Pictures] folder
    PowerPointer = "FishingPowerPointer"     # [Pictures] folder
    ThrowHook = "FishingHook"                # [Pictures] folder
    CatchMessage = "FishingCatchMessage"     # [Pictures] folder
    MissMessage = "FishingMissMessage"       # [Pictures] folder
    
    Fishes = []
    
    # Fishes[ID] = ["Graphic",ItemID,SwitchID,Speed,Chances]
    # Chances = The higher, the more probable
    Fishes[0] = ["Fish01",     300,      34,      2.0,    2]
    Fishes[1] = ["Fish02",     301,      34,      1.4,    3]
    Fishes[2] = ["Fish03",     302,      34,      1.0,    2]
    Fishes[3] = ["Fish04",     303,      35,      3.0,    1]
    Fishes[4] = ["Fish05",     304,      36,      3.0,    0.3]
  end
end
 
class OmegaFishing < Scene_Base
  include OmegaX::Fishing
  def initialize
    createArea
    createCursor
    createPossibleList
    @fishes = []
    @timer = [0,SpawningIntervals[rand(SpawningIntervals.size)]]
    @mode = "NOTHING"
    @pointerGoing = "RIGHT"
    @hookDistanceLeft = 0
    @animation = Sprite_Base.new
    @messages = []
    @limit = $game_variables[SessionFishLimitVariableID]
    executeSpawn
    executeSpawn
    @fix = false
    @caught = []
    @finished = false
  end
  def finish
    @finished = true
    @finishWindow = Window_Base.new(100,50,544 - 200,416 - 100)
    @finishWindow.contents.font.size = 18
    @finishWindow.contents.draw_text(0,0,344,20,"Navires détruits :")
    kinds = {}
    for i in 0...@caught.size
      if !kinds.keys.include?(@caught[i])
        kinds[@caught[i]] = 0
      end
      kinds[@caught[i]] += 1
    end
    for i in 0...kinds.keys.size
      @finishWindow.contents.draw_text(0,40 + (18 * i),344,20,$data_items[kinds.keys[i]].name + "    x   " +  kinds[kinds.keys[i]].to_s)
    end
  end
  def update
    @animation.update if @animation.animation?
    @water.update
    updateFishMovement
    for i in 0...@messages.size
      @messages[i].y -= 2
      @messages[i].opacity -= 2
      if @messages[i].opacity <= 0
        @messages[i].dispose
        @messages[i] = nil
      end
    end
    @messages.compact!
    if !@finished
      @timer[0] += 1
      if @timer[0] >= @timer[1]
        @timer[0] = 0
        @timer[1] = SpawningIntervals[rand(SpawningIntervals.size)]
        executeSpawn
      end
      updateCursor if @mode == "NOTHING"
      updatePointer if @mode == "POWERING"
      updateHook if @mode == "THROWING"
      if Input.trigger?(Input::B)
        finish
      end
    else
      if Input.trigger?(Input::B) 
        @finishWindow.dispose
        for i in 0...@messages.size
          @messages[i].dispose
          @messages[i] = nil
        end
        @messages.compact!
        @water.dispose
        @animation.dispose
        for i in 0...@fishes.size
          @fishes[i][0].dispose
          @fishes[i] = nil
        end
        @fishes.compact!
        @hook.dispose if @hook != nil
        @powerBar.dispose if @powerBar != nil
        @powerPointer.dispose if @powerPointer != nil
        @cursor.dispose
        @bg.dispose
        for i in 0...@caught.size
          $game_party.gain_item($data_items[@caught[i]], 1)
        end
        $game_switches[309] = true
        $scene = Scene_Map.new
      end
    end
  end
  def catch(obtained,x,y,fish = 0,id = 0)
    @messages.push(Sprite_Base.new)
    if obtained
      Audio.se_play("Audio/SE/" + CatchSoundEffect)
      @caught.push(id)
      @messages[@messages.size - 1].bitmap = Cache.picture(CatchMessage)
      @fishes[fish][0].dispose
      @fishes[fish] = nil
    else
      Audio.se_play("Audio/SE/" + MissSoundEffect)
      @messages[@messages.size - 1].bitmap = Cache.picture(MissMessage)
    end
    @fishes.compact!
    @messages[@messages.size - 1].x = x
    @messages[@messages.size - 1].y = y
    @messages[@messages.size - 1].z = 20
    @mode = "NOTHING"
    @hook.dispose
    @hook = nil
    @powerPointer.dispose
    @powerPointer = nil
    @powerBar.dispose
    @powerBar = nil
    if @limit > 0   # Limited catchable fish
      if @caught.size >= @limit
        finish
      end
    end
  end
  def updateFishMovement
    for i in 0...@fishes.size
      @fishes[i][2] += Fishes[@fishes[i][1]][3]
      while @fishes[i][2] >= 1.0
        @fishes[i][2] -= 1.0
        @fishes[i][0].x += 1
      end
      @fishes[i][0].update
    end
  end
  def updateCursor
    if Input.press?(Input::RIGHT)
      @cursor.x += 3 if @cursor.x + @cursor.width < 544
    end
    if Input.press?(Input::LEFT)
      @cursor.x -= 3 if @cursor.x > 0
    end
    if Input.trigger?(Input::C) && @mode == "NOTHING"
      @mode = "POWERING"
      @powerBar = Sprite_Base.new
      @powerBar.bitmap = Cache.picture(PowerBar)
      @powerBar.z = 10
      @powerPointer = Sprite_Base.new
      @powerPointer.bitmap = Cache.picture(PowerPointer)
      @powerPointer.z = 11
      @fix = false
      return
    end
  end
  def updatePointer
    case @pointerGoing
    when "RIGHT"
      @powerPointer.x += PowerPointerSpeed
      if @powerPointer.x + @powerPointer.width >= 544
        @pointerGoing = "LEFT"
      end
    when "LEFT"
      @powerPointer.x -= PowerPointerSpeed
      if @powerPointer.x < 0
        @pointerGoing = "RIGHT"
      end
    end
    if Input.trigger?(Input::C) && @mode == "POWERING" && @fix
      Audio.se_play("Audio/SE/" + ThrowSoundEffect)
      @mode = "THROWING"
      @hook = Sprite_Base.new
      @hook.bitmap = Cache.picture(ThrowHook)
      @hook.z = 12
      @hook.x = (@cursor.x + (@cursor.width/2)) - @hook.width/2
      @hook.y = @cursor.y
      @hookDistanceLeft = (416.0 * (@powerPointer.x/544.0)).abs
      return
    end
    @fix = true
  end
  def updateHook
    if @hookDistanceLeft > 0
      @hook.y -= HookThrownSpeed
      @hookDistanceLeft -= HookThrownSpeed
    else
      playSplash(@hook.x,@hook.y)
      hookRect = Rect.new(@hook.x,@hook.y,@hook.width,@hook.height)
      for i in 0...@fishes.size
        fishRect = Rect.new(@fishes[i][0].x,@fishes[i][0].y,@fishes[i][0].width,@fishes[i][0].height)
        if hookRect.intersects?(fishRect)
          catch(true,@hook.x,@hook.y,i,Fishes[@fishes[i][1]][1])
          return
        end
      end
      catch(false,@hook.x,@hook.y)
    end
  end
  def playSplash(x,y)
    @animation.x = x
    @animation.y = y
    @animation.start_animation($data_animations[WaterSplashAnimationID])
  end
  def executeSpawn
    @fishes.push([Sprite_Base.new,@possibleFishes[rand(@possibleFishes.size)],0.0])
    id = @fishes.size - 1
    @fishes[id][0].bitmap = Cache.picture(Fishes[@fishes[id][1]][0])
    @fishes[id][0].z = 1
    @fishes[id][0].x = -(@fishes[id][0].width)
    @fishes[id][0].y = rand(416) - 100
    @fishes[id][0].wave_amp = 8
    @fishes[id][0].wave_length = 300
    @fishes[id][0].wave_speed = 200
  end
  def createArea
    @bg = Sprite_Base.new
    @bg.bitmap = Cache.picture(FishingBackground)
    @bg.z = 0
    @water = Sprite_Base.new
    @water.bitmap = Cache.picture(WaterSurface)
    @water.z = 2
    @water.x = (544/2) - (@water.width/2)
    @water.wave_amp = 8
    @water.wave_length = 240
    @water.wave_speed = 120
  end
  def createCursor
    @cursor = Sprite_Base.new
    @cursor.bitmap = Cache.picture(FishingAim)
    @cursor.z = 10
    @cursor.x = (544/2) - (@cursor.width/2)
    @cursor.y = 416 - (@cursor.height/2)
  end
  def createPossibleList
    @possibleFishes = []
    for i in 0...Fishes.size
      if $game_switches[Fishes[i][2]]
        chances = Fishes[i][4]
        while chances > 0
          @possibleFishes.push(i)
          chances -= 1
        end
      end
    end
  end
end
 
 
# Lol I still have this snippet BigEd did once :P
class Rect
  def intersects?( rect )
    return ((((rect.x < (self.x + self.width)) && (self.x < (rect.x + rect.width))) && (rect.y < (self.y + self.height))) && (self.y < (rect.y + rect.height)))
  end
end



Merci beaucoup !


dagothig - posté le 21/02/2023 à 02:53:27 (8 messages postés)

❤ 2

Salut - Je ne sais pas si tu as encore le problème, mais il y a deux-trois trucs que tu pourrais peut-être essayer -

D'abord valider si c'est bien les changements d'items qui causent le lag. Si tu retires les changements d'item de ton event, ça suffit à se débarasser du lag? J'en devine que l'event lié ici roule en parallèle et le nombre d'item est généralement à 0 sauf dans certains cas? Un test à faire serait alors de ne faire les manips d'objets que si les variables gain_bataille_x correspondantes ne sont pas à 0.

Sinon ce serait d'éditer le script pour qu'il ajuste des variables plutôt que de donner directement des objets, comme ça tu pourrais directement les lire...

Je vois que le seul endroit où le script a l'air de donner des items est à la ligne 149 lorsqu'il fait

Portion de code : Tout sélectionner

1
2
3
4
5
 
for i in 0...@caught.size
  $game_party.gain_item($data_items[@caught[i]], 1)
end
 



Indirectement @caught contient des id d'items qui sont tirés de Fishes. L'enjeu de vouloir repurpose l'id pour que ce soit un id de variable c'est qu'il est aussi utilisé pour tirer l'info d'affichage... Je... pense que la solution la plus facile serait de tenir un tableau des noms de navires par varId?

Donc si mettons au lieu d'avoir

Portion de code : Tout sélectionner

1
2
3
 
# Fishes[ID] = ["Graphic",ItemID,SwitchID,Speed,Chances]
 



Ce serait

Portion de code : Tout sélectionner

1
2
3
4
 
# Fishes[ID] = ["Graphic",VarID,SwitchID,Speed,Chances]
# FishNames[VarID] = "Name"
 



Par exemple

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
Fishes[0] = ["Fish01", 186,      34,      2.0,    2]
Fishes[1] = ["Fish02", 187,      34,      1.4,    3]
Fishes[2] = ["Fish03", 188,      34,      1.0,    2]
Fishes[3] = ["Fish04", 189,      35,      3.0,    1]
Fishes[4] = ["Fish05", 190,      36,      3.0,    0.3]
 
FishNames = {}
FishNames[186] = "Navire"
FishNames[187] = "Croiseur"
FishNames[188] = "Porte-avion"
FishNames[189] = "Bombardier"
FishNames[190] = "Gold Porte-Avion"
 



Et ensuite il faut ajuster toutes les références à Fishes pour en prendre compte x)
Donc dans catch on pousserait donc un id de var plutôt qu'un id d'item dans @caught.

On peut alors mettre à jour le snippet du début pour passer par la variable plutôt, lignes 157-159:

Portion de code : Tout sélectionner

1
2
3
4
5
 
for i in 0...@caught.size
  $game_variables[@caught[i]] += 1
end
 



Et lorsque kinds est collecté dans finish pour déterminer ce qu'on affiche les noms, on utilisera FishNames, lignes 107-109:

Portion de code : Tout sélectionner

1
2
3
4
5
 
for i in 0...kinds.keys.size
  @finishWindow.contents.draw_text(0,40 + (18 * i),344,20,FishNames[kinds.keys[i]] + "    x   " +  kinds[kinds.keys[i]].to_s)
end
 



Et à priori maintenant ce sera la variables qui sont modifiées plutôt que les items - Dans l'exemple c'est les variables 186-190 qui auraient les gains de bateaux.

Ou le script avec les modifications (si je me plante pas...)

Portion de code : Tout sélectionner

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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
 
# =============================================================================
# Fishing MiniGame
# Version: 1.0
# Author: Omegas7
# Blog:  http://omegas7.blogspot.com    ||   http://omegadev.biz
# -----------------------------------------------------------------------------
# Features:
#    [1.0]
#       > Background & water surface images
#       > Water surface & fish have wave effect
#       > Aim with cursor image right & left
#       > Calculate strength with power meter & cursor
#       > Throw hook, if a fish is on landing area, catch.
#       > Multiple configurable sound effects
#       > Multiple configurable images
#       > Fish catching limit per session through variable (or infinite)
#       > Caught fish listing on end of session
#       > Configurable speed of power cursor & hook
#       > Link fish objects in script with items from database
#       > Receive items (fish)
#       > Fish become available through a game switch
#       > Edit chances of appearance for fish
#       > Accurate movement speed (decimal numbers) for fish
# -----------------------------------------------------------------------------
# NOTES
#       > When going to use the script, you need MINIMUN one fish available
#         (it's game switch ON)
# =============================================================================
 
module OmegaX
  module Fishing
    SessionFishLimitVariableID = 13 
    # Catchable fish per session variable ID.
    # If variable's value equals 0 or a negative number = infinite.
    
    PowerPointerSpeed = 9               # Higher = Faster
    HookThrownSpeed = 8                 # Higher = Faster
    
    ThrowSoundEffect = "Bow1"            # [Audio/SE/] folder
    CatchSoundEffect = "Item1"           # [Audio/SE/] folder
    MissSoundEffect = "Miss"             # [Audio/SE/] folder
    
    WaterSplashAnimationID = 188           # Database animation ID
    SpawningIntervals = [130,190,230]     # Possible frame intervals for spawning
    FishingBackground = "FishingBG"          # [Pictures] folder
    WaterSurface = ""            # [Pictures] folder
    FishingAim = "FishingAim"                # [Pictures] folder
    PowerBar = "FishingPowerBar"             # [Pictures] folder
    PowerPointer = "FishingPowerPointer"     # [Pictures] folder
    ThrowHook = "FishingHook"                # [Pictures] folder
    CatchMessage = "FishingCatchMessage"     # [Pictures] folder
    MissMessage = "FishingMissMessage"       # [Pictures] folder
    
    Fishes = []
    
    # Fishes[ID] = ["Graphic",varID,SwitchID,Speed,Chances]
    # Chances = The higher, the more probable
    Fishes[0] = ["Fish01",     186,      34,      2.0,    2]
    Fishes[1] = ["Fish02",     187,      34,      1.4,    3]
    Fishes[2] = ["Fish03",     188,      34,      1.0,    2]
    Fishes[3] = ["Fish04",     189,      35,      3.0,    1]
    Fishes[4] = ["Fish05",     190,      36,      3.0,    0.3]
 
    FishNames = {}
 
    # FishNames[varID] = "Name"
    FishNames[186] = "Navire"
    FishNames[187] = "Croiseur"
    FishNames[188] = "Porte-avion"
    FishNames[189] = "Bombardier"
    FishNames[190] = "Gold Porte-Avion"
  end
end
 
class OmegaFishing < Scene_Base
  include OmegaX::Fishing
  def initialize
    createArea
    createCursor
    createPossibleList
    @fishes = []
    @timer = [0,SpawningIntervals[rand(SpawningIntervals.size)]]
    @mode = "NOTHING"
    @pointerGoing = "RIGHT"
    @hookDistanceLeft = 0
    @animation = Sprite_Base.new
    @messages = []
    @limit = $game_variables[SessionFishLimitVariableID]
    executeSpawn
    executeSpawn
    @fix = false
    @caught = []
    @finished = false
  end
  def finish
    @finished = true
    @finishWindow = Window_Base.new(100,50,544 - 200,416 - 100)
    @finishWindow.contents.font.size = 18
    @finishWindow.contents.draw_text(0,0,344,20,"Navires détruits :")
    kinds = {}
    for i in 0...@caught.size
      if !kinds.keys.include?(@caught[i])
        kinds[@caught[i]] = 0
      end
      kinds[@caught[i]] += 1
    end
    for i in 0...kinds.keys.size
      @finishWindow.contents.draw_text(0,40 + (18 * i),344,20,FishNames[kinds.keys[i]] + "    x   " +  kinds[kinds.keys[i]].to_s)
    end
  end
  def update
    @animation.update if @animation.animation?
    @water.update
    updateFishMovement
    for i in 0...@messages.size
      @messages[i].y -= 2
      @messages[i].opacity -= 2
      if @messages[i].opacity <= 0
        @messages[i].dispose
        @messages[i] = nil
      end
    end
    @messages.compact!
    if !@finished
      @timer[0] += 1
      if @timer[0] >= @timer[1]
        @timer[0] = 0
        @timer[1] = SpawningIntervals[rand(SpawningIntervals.size)]
        executeSpawn
      end
      updateCursor if @mode == "NOTHING"
      updatePointer if @mode == "POWERING"
      updateHook if @mode == "THROWING"
      if Input.trigger?(Input::B)
        finish
      end
    else
      if Input.trigger?(Input::B) 
        @finishWindow.dispose
        for i in 0...@messages.size
          @messages[i].dispose
          @messages[i] = nil
        end
        @messages.compact!
        @water.dispose
        @animation.dispose
        for i in 0...@fishes.size
          @fishes[i][0].dispose
          @fishes[i] = nil
        end
        @fishes.compact!
        @hook.dispose if @hook != nil
        @powerBar.dispose if @powerBar != nil
        @powerPointer.dispose if @powerPointer != nil
        @cursor.dispose
        @bg.dispose
        for i in 0...@caught.size
          $game_variables[@caught[i]] += 1
        end
        $game_switches[309] = true
        $scene = Scene_Map.new
      end
    end
  end
  def catch(obtained,x,y,fish = 0,id = 0)
    @messages.push(Sprite_Base.new)
    if obtained
      Audio.se_play("Audio/SE/" + CatchSoundEffect)
      @caught.push(id)
      @messages[@messages.size - 1].bitmap = Cache.picture(CatchMessage)
      @fishes[fish][0].dispose
      @fishes[fish] = nil
    else
      Audio.se_play("Audio/SE/" + MissSoundEffect)
      @messages[@messages.size - 1].bitmap = Cache.picture(MissMessage)
    end
    @fishes.compact!
    @messages[@messages.size - 1].x = x
    @messages[@messages.size - 1].y = y
    @messages[@messages.size - 1].z = 20
    @mode = "NOTHING"
    @hook.dispose
    @hook = nil
    @powerPointer.dispose
    @powerPointer = nil
    @powerBar.dispose
    @powerBar = nil
    if @limit > 0   # Limited catchable fish
      if @caught.size >= @limit
        finish
      end
    end
  end
  def updateFishMovement
    for i in 0...@fishes.size
      @fishes[i][2] += Fishes[@fishes[i][1]][3]
      while @fishes[i][2] >= 1.0
        @fishes[i][2] -= 1.0
        @fishes[i][0].x += 1
      end
      @fishes[i][0].update
    end
  end
  def updateCursor
    if Input.press?(Input::RIGHT)
      @cursor.x += 3 if @cursor.x + @cursor.width < 544
    end
    if Input.press?(Input::LEFT)
      @cursor.x -= 3 if @cursor.x > 0
    end
    if Input.trigger?(Input::C) && @mode == "NOTHING"
      @mode = "POWERING"
      @powerBar = Sprite_Base.new
      @powerBar.bitmap = Cache.picture(PowerBar)
      @powerBar.z = 10
      @powerPointer = Sprite_Base.new
      @powerPointer.bitmap = Cache.picture(PowerPointer)
      @powerPointer.z = 11
      @fix = false
      return
    end
  end
  def updatePointer
    case @pointerGoing
    when "RIGHT"
      @powerPointer.x += PowerPointerSpeed
      if @powerPointer.x + @powerPointer.width >= 544
        @pointerGoing = "LEFT"
      end
    when "LEFT"
      @powerPointer.x -= PowerPointerSpeed
      if @powerPointer.x < 0
        @pointerGoing = "RIGHT"
      end
    end
    if Input.trigger?(Input::C) && @mode == "POWERING" && @fix
      Audio.se_play("Audio/SE/" + ThrowSoundEffect)
      @mode = "THROWING"
      @hook = Sprite_Base.new
      @hook.bitmap = Cache.picture(ThrowHook)
      @hook.z = 12
      @hook.x = (@cursor.x + (@cursor.width/2)) - @hook.width/2
      @hook.y = @cursor.y
      @hookDistanceLeft = (416.0 * (@powerPointer.x/544.0)).abs
      return
    end
    @fix = true
  end
  def updateHook
    if @hookDistanceLeft > 0
      @hook.y -= HookThrownSpeed
      @hookDistanceLeft -= HookThrownSpeed
    else
      playSplash(@hook.x,@hook.y)
      hookRect = Rect.new(@hook.x,@hook.y,@hook.width,@hook.height)
      for i in 0...@fishes.size
        fishRect = Rect.new(@fishes[i][0].x,@fishes[i][0].y,@fishes[i][0].width,@fishes[i][0].height)
        if hookRect.intersects?(fishRect)
          catch(true,@hook.x,@hook.y,i,Fishes[@fishes[i][1]][1])
          return
        end
      end
      catch(false,@hook.x,@hook.y)
    end
  end
  def playSplash(x,y)
    @animation.x = x
    @animation.y = y
    @animation.start_animation($data_animations[WaterSplashAnimationID])
  end
  def executeSpawn
    @fishes.push([Sprite_Base.new,@possibleFishes[rand(@possibleFishes.size)],0.0])
    id = @fishes.size - 1
    @fishes[id][0].bitmap = Cache.picture(Fishes[@fishes[id][1]][0])
    @fishes[id][0].z = 1
    @fishes[id][0].x = -(@fishes[id][0].width)
    @fishes[id][0].y = rand(416) - 100
    @fishes[id][0].wave_amp = 8
    @fishes[id][0].wave_length = 300
    @fishes[id][0].wave_speed = 200
  end
  def createArea
    @bg = Sprite_Base.new
    @bg.bitmap = Cache.picture(FishingBackground)
    @bg.z = 0
    @water = Sprite_Base.new
    @water.bitmap = Cache.picture(WaterSurface)
    @water.z = 2
    @water.x = (544/2) - (@water.width/2)
    @water.wave_amp = 8
    @water.wave_length = 240
    @water.wave_speed = 120
  end
  def createCursor
    @cursor = Sprite_Base.new
    @cursor.bitmap = Cache.picture(FishingAim)
    @cursor.z = 10
    @cursor.x = (544/2) - (@cursor.width/2)
    @cursor.y = 416 - (@cursor.height/2)
  end
  def createPossibleList
    @possibleFishes = []
    for i in 0...Fishes.size
      if $game_switches[Fishes[i][2]]
        chances = Fishes[i][4]
        while chances > 0
          @possibleFishes.push(i)
          chances -= 1
        end
      end
    end
  end
end
 
 
# Lol I still have this snippet BigEd did once :P
class Rect
  def intersects?( rect )
    return ((((rect.x < (self.x + self.width)) && (self.x < (rect.x + rect.width))) && (rect.y < (self.y + self.height))) && (self.y < (rect.y + rect.height)))
  end
end
 




Gari - posté le 21/02/2023 à 08:00:48 (5899 messages postés) - honor

❤ 0

J'ai tout dit au début, c'est bien lié à cet event en autorun.

Et... wouah. C'est presque ce que recherchais, je cherche juste à ce qu'une seule variable s'additionne (les fishes donnent un nombre de points différents).
Donc si je peux rajouter ça au module, derrière la variable ce sera parfait.

Là j'ai rééssayé de calculer avec les variables, en mettant des conditions, mais ça rame toujours. Je me demande pourquoi... (le scene map new dans le script ou un refresh qui manque, je sais pas).

Edit :
Bon, j'ai tenté, mais je vais pas tester parce que ça marchera jamais.
En gros j'ai créé un nouveau tableau avec la liste des points dans le module :

Portion de code : Tout sélectionner

1
2
3
4
5
6
    # FishPoints[varID] = Valeur
    FishPoints[186] = 30
    FishPoints[187] = 20
    FishPoints[188] = 10
    FishPoints[189] = 50
    FishPoints[190] = 100



Et juste avant le $scene = Scene_Map.new, j'essaye de faire que la variable en jeu qui gère les points de bataille navale additionne le bousin. A la base l'interrupteur est là pour enclencher le calcul des résultats.

Portion de code : Tout sélectionner

1
$game_variables[61] += @FishPoints


Je suppose qu'il manque le truc pour lui faire comprendre que je veux qu'il multiplie le nombre de points par la variable.
Et il faut que je reset ces variables au début du script ou quand c'est fini ou quand ça commence, aussi.
Comme c'est peut-être mieux quand ça commence, c'est dans initialize ?
Quelque chose comme :

Portion de code : Tout sélectionner

1
@fishes_variables = 0


Mais je suppose qu'il manque aussi des trucs...

Index du forum > Entraide > [RPG Maker VX] Calculer efficacement pour que le jeu ne rame pas

repondre up

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers