SHOW:
|
|
- or go back to the newest paste.
1 | #=============================================================================== | |
2 | # ** RBS - Ramiro's Battle System (PART II - Classes And Modules) | |
3 | # Version 2.2 | |
4 | # Difficulty Very Hard. | |
5 | - | # + little shield Addon by Stesc |
5 | + | # + small Shield Addon by Stesc |
6 | #------------------------------------------------------------------------------- | |
7 | # If you don't know what to do... DO NOT EDIT THIS FILE. | |
8 | #------------------------------------------------------------------------------- | |
9 | # YANFLY SCRIPTS COMPATIBILITY: | |
10 | # | |
11 | # Common ways to test if an YF script works: | |
12 | # | |
13 | # First of all, put the Unlisted YEA script BEFORE the RBS, why before? because | |
14 | # YEA is 'older' (in terms of published date) and the compatibility patches are | |
15 | # made with the RBS (that supports a way to mix both battle systems altogether) | |
16 | # | |
17 | # If the script does not work properly, you may put it AFTER RBS and TRY AGAIN. | |
18 | # | |
19 | # If even with that change the script does not work, you may then call it a | |
20 | # "compatibility issue" and I will, eventually, make a patch for it. | |
21 | # | |
22 | # Why are you making compatibility patches? | |
23 | # | |
24 | # It's quite simple, YF scripts sometimes overrite some methods that I had to | |
25 | # alias or vice-versa. in that cases, Yanfly or I should need to make a Patch. | |
26 | # To run the scripts toguether. | |
27 | # | |
28 | # The next section will show HOW TO APPLY each script, knowkn in wich order | |
29 | # and if it needs or not this patch. | |
30 | # | |
31 | # | |
32 | # | |
33 | # List of Compatible YEA scripts: | |
34 | # BATTLE SCRIPTS: | |
35 | # - Ace Battle Engine (Insert BEFORE RBS) | |
36 | # Known Issues: Disable one of the popup systems or YEA popup or | |
37 | # RBS popup. | |
38 | # - Lunatic Objects (Doesn't infleunce the place) | |
39 | # Known Issues: None. | |
40 | # - TargetManager (Doesn't infleunce the place) | |
41 | # Known Issues: None. | |
42 | # - CastAnimations (Doesn't infleunce the place) | |
43 | # Known Issues: None. | |
44 | # | |
45 | # OTHER YF SCRIPTS: | |
46 | # Because other YF scripts won't collide with this battle system. | |
47 | # They should be compatible. If there is an incompatibility issue, just | |
48 | # ask and I'll do as much as I can to repair it. | |
49 | #------------------------------------------------------------------------------- | |
50 | # License: | |
51 | #Copyright (c) 2012, Ramiro Rojo | |
52 | #All rights reserved. | |
53 | # | |
54 | #Redistribution and use in source and binary forms, with or without | |
55 | #modification, are permitted provided that the following conditions are met: | |
56 | # | |
57 | #1. Redistributions of source code must retain the above copyright notice, this | |
58 | # list of conditions and the following disclaimer. | |
59 | #2. Redistributions in binary form must reproduce the above copyright notice, | |
60 | # this list of conditions and the following disclaimer in the documentation | |
61 | # and/or other materials provided with the distribution. | |
62 | # | |
63 | #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
64 | #ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
65 | #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
66 | #DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
67 | #ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
68 | #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
69 | #LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
70 | #ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
71 | #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
72 | #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
73 | # | |
74 | #The views and conclusions contained in the software and documentation are those | |
75 | #of the authors and should not be interpreted as representing official policies, | |
76 | #either expressed or implied, of the FreeBSD Project. | |
77 | #=============================================================================== | |
78 | ||
79 | #=============================================================================== | |
80 | # BEGIN MODULE SECTION | |
81 | #=============================================================================== | |
82 | ||
83 | module Cache | |
84 | ||
85 | #----------------------------------------------------------------------------- | |
86 | # Constants | |
87 | #----------------------------------------------------------------------------- | |
88 | @@icon_bitmaps = {} | |
89 | ||
90 | def self.get_icon_bitmap(icon_index) | |
91 | if !@@icon_bitmaps[icon_index] || @@icon_bitmaps[icon_index].disposed? | |
92 | bmp = Bitmap.new(24,24) | |
93 | bitmap = Cache.system("Iconset") | |
94 | rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) | |
95 | bmp.blt(0, 0, bitmap, rect) | |
96 | @@icon_bitmaps[icon_index] = bmp | |
97 | end | |
98 | @@icon_bitmaps[icon_index] | |
99 | end | |
100 | ||
101 | class << self | |
102 | alias rbs_cache_clear clear | |
103 | ||
104 | def clear | |
105 | @@icon_bitmaps ||= {} | |
106 | @@icon_bitmaps.clear | |
107 | rbs_cache_clear | |
108 | end | |
109 | end | |
110 | ||
111 | end | |
112 | ||
113 | #=============================================================================== | |
114 | # * BattleCamera module | |
115 | #------------------------------------------------------------------------------- | |
116 | # Controls the camera`s position on the battlefield. | |
117 | # It can be zoomed in and out. | |
118 | #=============================================================================== | |
119 | module BattleCamera | |
120 | ||
121 | #----------------------------------------------------------------------------- | |
122 | # Starts the camera | |
123 | #----------------------------------------------------------------------------- | |
124 | def self.start | |
125 | self.reset | |
126 | end | |
127 | ||
128 | #----------------------------------------------------------------------------- | |
129 | # Resets the camera | |
130 | #----------------------------------------------------------------------------- | |
131 | def self.reset | |
132 | @center_x = Graphics.width / 2 | |
133 | @center_y = Graphics.height / 2 | |
134 | @current_x = @desired_x = @center_x | |
135 | @current_y = @desired_y = @center_y | |
136 | @current_zoom = @desired_zoom = 1.0 | |
137 | @zoom_time = 0 | |
138 | @movement_time = 0 | |
139 | @target = :screen | |
140 | end | |
141 | ||
142 | #----------------------------------------------------------------------------- | |
143 | # Corrects a position | |
144 | #----------------------------------------------------------------------------- | |
145 | def self.correct_position(pos, current, current_zoom, center) | |
146 | return ((pos - current) * (current_zoom - 1.0) + pos - (current - center)) | |
147 | end | |
148 | ||
149 | #----------------------------------------------------------------------------- | |
150 | # Corrects the x position given | |
151 | #----------------------------------------------------------------------------- | |
152 | def self.correct_x(x) | |
153 | return correct_position(x, @current_x, @current_zoom, @center_x) | |
154 | end | |
155 | ||
156 | #----------------------------------------------------------------------------- | |
157 | # Corrects the y position given | |
158 | #----------------------------------------------------------------------------- | |
159 | def self.correct_y(y) | |
160 | return correct_position(y, @current_y, @current_zoom, @center_y) | |
161 | end | |
162 | ||
163 | #----------------------------------------------------------------------------- | |
164 | # Corrects the zoom given | |
165 | #----------------------------------------------------------------------------- | |
166 | def self.correct_zoom(zoom, x=nil, y=nil, zoom_effective=true) | |
167 | if BattleConfig::BattleCamera_UsePanoramicCamera | |
168 | if !x || !y || !zoom_effective | |
169 | return zoom * @current_zoom | |
170 | else | |
171 | return ((y - @center_y * 130 / 100) * 0.005 + 1.0) * @current_zoom | |
172 | end | |
173 | else | |
174 | return zoom * @current_zoom | |
175 | end | |
176 | end | |
177 | ||
178 | #----------------------------------------------------------------------------- | |
179 | # Corrects the angle given | |
180 | #----------------------------------------------------------------------------- | |
181 | def self.correct_angle(angle) | |
182 | return angle | |
183 | end | |
184 | ||
185 | #----------------------------------------------------------------------------- | |
186 | # Corrects the mirror value given | |
187 | #----------------------------------------------------------------------------- | |
188 | def self.correct_mirror(mirror) | |
189 | return mirror | |
190 | end | |
191 | ||
192 | #----------------------------------------------------------------------------- | |
193 | # Calculates the difference of movement in the frame | |
194 | #----------------------------------------------------------------------------- | |
195 | def self.calculate_display_change(current, desired, count) | |
196 | ((current * (count - 1) + desired) / count) | |
197 | end | |
198 | ||
199 | #----------------------------------------------------------------------------- | |
200 | # Updates the camera. | |
201 | #----------------------------------------------------------------------------- | |
202 | def self.update | |
203 | @center_x = Graphics.width / 2 | |
204 | @center_y = Graphics.height / 2 | |
205 | if @zoom_time > 0 | |
206 | @current_zoom = self.calculate_display_change(@current_zoom, @desired_zoom, @zoom_time) | |
207 | @zoom_time -= 1 | |
208 | end | |
209 | ||
210 | if @movement_time > 0 | |
211 | @current_x = self.calculate_display_change(@current_x, @desired_x, @movement_time) | |
212 | @current_y = self.calculate_display_change(@current_y, @desired_y, @movement_time) | |
213 | @movement_time -= 1 | |
214 | end | |
215 | ||
216 | if @target != :screen && !moving? | |
217 | cx = 0 | |
218 | cy = 0 | |
219 | @target.each do |i| | |
220 | cx += i.current_x | |
221 | cy += i.current_y | |
222 | end | |
223 | if @target.size > 0 | |
224 | cx /= @target.size | |
225 | cy /= @target.size | |
226 | end | |
227 | @current_x = cx | |
228 | @current_y = cy | |
229 | end | |
230 | ||
231 | end | |
232 | ||
233 | #----------------------------------------------------------------------------- | |
234 | # Sets the movement of the Camera. | |
235 | #----------------------------------------------------------------------------- | |
236 | def self.set_movement(x, y, time) | |
237 | @desired_x = x | |
238 | @desired_y = y | |
239 | @movement_time = time | |
240 | end | |
241 | ||
242 | #----------------------------------------------------------------------------- | |
243 | # Sets the zoom of the Camera. | |
244 | #----------------------------------------------------------------------------- | |
245 | def self.set_zoom(zoom, time) | |
246 | @desired_zoom = zoom | |
247 | @zoom_time = time | |
248 | end | |
249 | ||
250 | #----------------------------------------------------------------------------- | |
251 | # Sets the target of the Camera. | |
252 | #----------------------------------------------------------------------------- | |
253 | def self.set_target(target) | |
254 | @target = target | |
255 | end | |
256 | ||
257 | #----------------------------------------------------------------------------- | |
258 | # Checks if the camera is moving. | |
259 | #----------------------------------------------------------------------------- | |
260 | def self.moving? | |
261 | return ( @movement_time > 0 || @zoom_time > 0 ) | |
262 | end | |
263 | ||
264 | end | |
265 | ||
266 | #=============================================================================== | |
267 | # * BattleInterpreter module | |
268 | #------------------------------------------------------------------------------- | |
269 | # This module manages the battle's actions and keeps track of all of them. | |
270 | # it can read commands for using in battle animations. | |
271 | #=============================================================================== | |
272 | module BattleInterpreter | |
273 | ||
274 | #----------------------------------------------------------------------------- | |
275 | # CONSTANTS | |
276 | #----------------------------------------------------------------------------- | |
277 | Commands = {} | |
278 | ||
279 | #============================================================================= | |
280 | # * BattleInterpreter::Action | |
281 | #----------------------------------------------------------------------------- | |
282 | # An action used by the battle interpreter module. | |
283 | # It stores information of the action used and process part of them. | |
284 | #============================================================================= | |
285 | class Action | |
286 | ||
287 | #--------------------------------------------------------------------------- | |
288 | # Class properties | |
289 | #--------------------------------------------------------------------------- | |
290 | attr_reader :original_user | |
291 | attr_reader :original_target | |
292 | attr_accessor :user | |
293 | attr_accessor :targets | |
294 | attr_accessor :item | |
295 | attr_accessor :loop_depth | |
296 | attr_accessor :linked_actions | |
297 | attr_accessor :paused | |
298 | ||
299 | #--------------------------------------------------------------------------- | |
300 | # Starts an action | |
301 | #--------------------------------------------------------------------------- | |
302 | def initialize(spriteset, user, targets, sequence, item, can_counter=true) | |
303 | @extra_affected_battlers = [] | |
304 | @sequence = sequence | |
305 | @user = user | |
306 | @targets = targets | |
307 | @item = item | |
308 | @loop_depth = 0 | |
309 | @wait_count = 0 | |
310 | @original_user = user | |
311 | @original_targets = targets | |
312 | @spriteset = spriteset | |
313 | @counter_check = can_counter | |
314 | @linked_actions = [] | |
315 | @paused = false | |
316 | compile_data | |
317 | end | |
318 | ||
319 | #--------------------------------------------------------------------------- | |
320 | # Checks if a counter can be realized | |
321 | #--------------------------------------------------------------------------- | |
322 | def counter_active? | |
323 | return @counter_check | |
324 | end | |
325 | ||
326 | #--------------------------------------------------------------------------- | |
327 | # Evaluates parameters | |
328 | #--------------------------------------------------------------------------- | |
329 | def eval_data(data) | |
330 | make_parameters(data)[0] | |
331 | end | |
332 | ||
333 | #--------------------------------------------------------------------------- | |
334 | # Sets the wait time of the action | |
335 | #--------------------------------------------------------------------------- | |
336 | def wait(wait) | |
337 | @wait_count = wait | |
338 | end | |
339 | ||
340 | #--------------------------------------------------------------------------- | |
341 | # Makes the parameters for an action | |
342 | #--------------------------------------------------------------------------- | |
343 | def make_parameters(parameters) | |
344 | return [] if !parameters | |
345 | a = @user | |
346 | b = @targets[0] | |
347 | t = @targets | |
348 | s = $game_siwtches | |
349 | v = $game_variables | |
350 | result = [] | |
351 | parameters.split(',').each do |i| | |
352 | r = Kernel.eval(i) rescue nil | |
353 | result.push(r) | |
354 | end | |
355 | return result | |
356 | end | |
357 | ||
358 | #--------------------------------------------------------------------------- | |
359 | # Compiles the data for the action | |
360 | #--------------------------------------------------------------------------- | |
361 | def compile_data | |
362 | @commands = get_compile_commands(@sequence) | |
363 | end | |
364 | ||
365 | #--------------------------------------------------------------------------- | |
366 | # Returns the compiled result | |
367 | #--------------------------------------------------------------------------- | |
368 | def get_compile_commands(data) | |
369 | result = [] | |
370 | data.split(';').each do |line| | |
371 | next if (line.gsub(/\s/mi) {''}) == '' | |
372 | line += ';' | |
373 | if line[/((\s+)?)(.*?)(:(.*?))?;/mi] | |
374 | result.push([$3.upcase, make_parameters($5)]) | |
375 | end | |
376 | end | |
377 | return result | |
378 | end | |
379 | ||
380 | #--------------------------------------------------------------------------- | |
381 | # Updates the action | |
382 | #--------------------------------------------------------------------------- | |
383 | def update | |
384 | return if @paused | |
385 | if (@wait_count && @wait_count > 0) | |
386 | @wait_count -= 1 | |
387 | return | |
388 | end | |
389 | call_next_command | |
390 | end | |
391 | ||
392 | #--------------------------------------------------------------------------- | |
393 | # Calls next command | |
394 | #--------------------------------------------------------------------------- | |
395 | def call_next_command | |
396 | return if @commands.size == 0 || (@wait_count && @wait_count > 0) | |
397 | initial_depth = current_depth = @loop_depth | |
398 | command, params = next_command | |
399 | raise sprintf(Vocab::Error_CommandNotRecognized, command) if !Commands[command] | |
400 | has_depth, link_method = Commands[command] | |
401 | current_depth += 1 | |
402 | result = [] | |
403 | if has_depth | |
404 | while initial_depth != current_depth && @commands.size > 0 | |
405 | i = next_command | |
406 | nested_command, nested_params = i | |
407 | if Commands[nested_command] && Commands[nested_command][0] | |
408 | current_depth += 1 | |
409 | elsif nested_command[/END/mi] | |
410 | current_depth -= 1 | |
411 | end | |
412 | result.push(i) | |
413 | end | |
414 | if initial_depth == current_depth | |
415 | params.push(result) | |
416 | @loop_depth += 1 | |
417 | else | |
418 | raise Vocab::Error_TagSintaxError | |
419 | end | |
420 | end | |
421 | link_method.call(self, params) | |
422 | call_next_command | |
423 | end | |
424 | ||
425 | #--------------------------------------------------------------------------- | |
426 | # Gets the next command | |
427 | #--------------------------------------------------------------------------- | |
428 | def next_command | |
429 | @commands.shift | |
430 | end | |
431 | ||
432 | #--------------------------------------------------------------------------- | |
433 | # Insert commands as next | |
434 | #--------------------------------------------------------------------------- | |
435 | def insert_commands_as_next(commands) | |
436 | @commands = commands + @commands | |
437 | end | |
438 | ||
439 | #--------------------------------------------------------------------------- | |
440 | # Checks if the action is running | |
441 | #--------------------------------------------------------------------------- | |
442 | def running? | |
443 | return (@commands.size > 0 || @wait_count > 0) | |
444 | end | |
445 | ||
446 | #--------------------------------------------------------------------------- | |
447 | # Pauses the action | |
448 | #--------------------------------------------------------------------------- | |
449 | def pause | |
450 | @paused = true | |
451 | end | |
452 | ||
453 | #--------------------------------------------------------------------------- | |
454 | # Checks if the action is paused | |
455 | #--------------------------------------------------------------------------- | |
456 | def paused? | |
457 | @paused | |
458 | end | |
459 | ||
460 | #--------------------------------------------------------------------------- | |
461 | # Resumes the action | |
462 | #--------------------------------------------------------------------------- | |
463 | def resume | |
464 | @paused = false | |
465 | call_next_command | |
466 | end | |
467 | ||
468 | #--------------------------------------------------------------------------- | |
469 | # Stops the action | |
470 | #--------------------------------------------------------------------------- | |
471 | def abort | |
472 | @commands.clear | |
473 | @wait_count = 0 | |
474 | end | |
475 | ||
476 | #--------------------------------------------------------------------------- | |
477 | # Analizes targets by a string | |
478 | #--------------------------------------------------------------------------- | |
479 | def analize_target_string(string, origin_valid = true, screen_valid = false) | |
480 | case string | |
481 | when /(.*?) except (.*)/im | |
482 | t1 = analize_target_string($1, origin_valid, screen_valid) | |
483 | t2 = analize_target_string($2, origin_valid, screen_valid) | |
484 | return t1 - t2 | |
485 | when /(.*?) but (.*)/im | |
486 | t1 = analize_target_string($1, origin_valid, screen_valid) | |
487 | t2 = analize_target_string($2, origin_valid, screen_valid) | |
488 | return t1 - t2 | |
489 | when /(\d+) random ([\w\s]+)/im | |
490 | num = $1.to_i | |
491 | targets = analize_target_string($2, false, false) | |
492 | result = [] | |
493 | num.times do |i| | |
494 | result.push(targets[rand(targets.size)]) | |
495 | end | |
496 | return result | |
497 | when /original (\w+)/im | |
498 | case $1 | |
499 | when /user/im | |
500 | return [@original_user] | |
501 | when /target(s?)/im | |
502 | return @original_targets | |
503 | end | |
504 | when /dead battler(s?)/im | |
505 | return $game_troop.dead_members + $game_party.dead_members | |
506 | when /dead all(y||es)/im | |
507 | case @user.confusion_level | |
508 | when 0 | |
509 | return @user.friend_unit.dead_members | |
510 | when 1 | |
511 | return @user.enemy_unit.dead_members+@user.friend_unit.dead_members | |
512 | when 2 | |
513 | return @user.enemy_unit.dead_members | |
514 | end | |
515 | when /dead enem(y||ies)/im | |
516 | case @user.confusion_level | |
517 | when 0 | |
518 | return @user.enemy_unit.dead_members | |
519 | when 1 | |
520 | return @user.enemy_unit.dead_members+@user.friend_unit.dead_members | |
521 | when 2 | |
522 | return @user.friend_unit.dead_members | |
523 | end | |
524 | when /battler(s?)/im | |
525 | return $game_troop.alive_members + $game_party.alive_members | |
526 | when /all(y||es)/im | |
527 | case @user.confusion_level | |
528 | when 0 | |
529 | return @user.friend_unit.alive_members | |
530 | when 1 | |
531 | return @user.enemy_unit.alive_members+@user.friend_unit.alive_members | |
532 | when 2 | |
533 | return @user.enemy_unit.alive_members | |
534 | end | |
535 | when /friend(s?)/im | |
536 | case @user.confusion_level | |
537 | when 0 | |
538 | group = @user.friend_unit.alive_members | |
539 | when 1 | |
540 | group = @user.enemy_unit.alive_members+@user.friend_unit.alive_members | |
541 | when 2 | |
542 | group = @user.enemy_unit.alive_members | |
543 | end | |
544 | return group - [@user] | |
545 | when /enem(y||ies)/im | |
546 | case @user.confusion_level | |
547 | when 0 | |
548 | return @user.enemy_unit.alive_members | |
549 | when 1 | |
550 | return @user.enemy_unit.alive_members+@user.friend_unit.alive_members | |
551 | when 2 | |
552 | return @user.friend_unit.alive_members | |
553 | end | |
554 | when /target(s?)/im | |
555 | return @targets | |
556 | when /user/im | |
557 | return [@user] | |
558 | when /screen/im | |
559 | if screen_valid | |
560 | return :screen | |
561 | else | |
562 | raise Vocab::Error_ScreenNotValid | |
563 | end | |
564 | when /origin/im | |
565 | if origin_valid | |
566 | return :origin | |
567 | else | |
568 | raise Vocab::Error_OriginNotValid | |
569 | end | |
570 | end | |
571 | return nil | |
572 | ||
573 | end | |
574 | ||
575 | #--------------------------------------------------------------------------- | |
576 | # Get the sprites of battlers. | |
577 | #--------------------------------------------------------------------------- | |
578 | def get_battler_sprites(battlers) | |
579 | result = [] | |
580 | @spriteset.battler_sprites.each do |i| | |
581 | result.push(i) if battlers.any? {|j| i.battler == j } | |
582 | end | |
583 | return result | |
584 | end | |
585 | ||
586 | #--------------------------------------------------------------------------- | |
587 | # gets the battler sprites of a determined target string | |
588 | #--------------------------------------------------------------------------- | |
589 | def analize_battler_sprites_string(string, origin_valid = true, screen_valid = false) | |
590 | battlers = analize_target_string(string, origin_valid, screen_valid) | |
591 | return battlers if battlers.is_a?(Symbol) | |
592 | return battlers ? get_battler_sprites(battlers) : [] | |
593 | end | |
594 | ||
595 | def affected_battlers | |
596 | targets + [user] + @extra_affected_battlers | |
597 | end | |
598 | ||
599 | end | |
600 | ||
601 | class LoopingAction < BattleInterpreter::Action | |
602 | ||
603 | def next_command | |
604 | new_command = @commands.shift | |
605 | @commands.push(new_command) | |
606 | return new_command | |
607 | end | |
608 | ||
609 | end | |
610 | ||
611 | #----------------------------------------------------------------------------- | |
612 | # Starts the interpreter | |
613 | #----------------------------------------------------------------------------- | |
614 | def self.start(spriteset) | |
615 | self.reset | |
616 | @spriteset = spriteset | |
617 | end | |
618 | ||
619 | #----------------------------------------------------------------------------- | |
620 | # Resets the interpreter | |
621 | #----------------------------------------------------------------------------- | |
622 | def self.reset | |
623 | Commands.clear | |
624 | @looping_actions = {} | |
625 | @actions = [] | |
626 | end | |
627 | ||
628 | #----------------------------------------------------------------------------- | |
629 | # Adds an action | |
630 | #----------------------------------------------------------------------------- | |
631 | def self.add_action(user, targets, sequence, item, can_counter = true) | |
632 | action = BattleInterpreter::Action.new(@spriteset, user, targets, sequence, item, can_counter) | |
633 | @actions.push(action) if @actions | |
634 | action | |
635 | end | |
636 | ||
637 | #----------------------------------------------------------------------------- | |
638 | # Updates the interpreter | |
639 | #----------------------------------------------------------------------------- | |
640 | def self.update | |
641 | current_battlers = [] | |
642 | @actions.each do |i| | |
643 | i.update | |
644 | if i.running? | |
645 | i.affected_battlers.each do |j| | |
646 | current_battlers.push(j) | |
647 | end | |
648 | else | |
649 | @actions.delete(i) | |
650 | end | |
651 | end | |
652 | @looping_actions.each_pair do |battler, action| | |
653 | action.update if !current_battlers.include?(battler) | |
654 | end | |
655 | end | |
656 | ||
657 | #----------------------------------------------------------------------------- | |
658 | # Checks if the interpreter is running | |
659 | #----------------------------------------------------------------------------- | |
660 | def self.running? | |
661 | return true if @actions.any? {|i| i.running? && !i.paused?} | |
662 | return true if BattleCamera.moving? | |
663 | return true if @spriteset.animation? | |
664 | return false | |
665 | end | |
666 | ||
667 | #----------------------------------------------------------------------------- | |
668 | # Adds a looping action to an user | |
669 | #----------------------------------------------------------------------------- | |
670 | def self.add_looping_action(user, sequence) | |
671 | action = BattleInterpreter::LoopingAction.new(@spriteset, user, [user], sequence, nil) | |
672 | @looping_actions[user] = action | |
673 | action | |
674 | end | |
675 | ||
676 | def self.pause_looping_action(user) | |
677 | @looping_actions[user].pause if @looping_actions[user] | |
678 | end | |
679 | ||
680 | def self.resume_looping_action(user) | |
681 | @looping_actions[user].resume if @looping_actions[user] | |
682 | end | |
683 | ||
684 | end | |
685 | ||
686 | #============================================================================== | |
687 | # Β¦ BattleManager | |
688 | #============================================================================== | |
689 | ||
690 | module BattleManager | |
691 | ||
692 | #----------------------------------------------------------------------------- | |
693 | # Checks if the battle is a surprise battle | |
694 | #----------------------------------------------------------------------------- | |
695 | def self.surprise? | |
696 | return @surprise | |
697 | end | |
698 | ||
699 | #----------------------------------------------------------------------------- | |
700 | # Checks if the battle is a preemptive battle | |
701 | #----------------------------------------------------------------------------- | |
702 | def self.preemptive? | |
703 | return @preemptive | |
704 | end | |
705 | ||
706 | class << self | |
707 | ||
708 | #--------------------------------------------------------------------------- | |
709 | # Alias methods | |
710 | #--------------------------------------------------------------------------- | |
711 | alias rbs_battle_manager_process_victory process_victory | |
712 | ||
713 | #----------------------------------------------------------------------------- | |
714 | # Process victory | |
715 | #----------------------------------------------------------------------------- | |
716 | def process_victory | |
717 | for member in $game_party.alive_members | |
718 | sequence = member.get_victory_sequence | |
719 | BattleInterpreter.add_action(member, [member], sequence, nil, false) | |
720 | end | |
721 | rbs_battle_manager_process_victory | |
722 | end | |
723 | end | |
724 | ||
725 | end | |
726 | #=============================================================================== | |
727 | # END MODULE SECTION | |
728 | #=============================================================================== | |
729 | #=============================================================================== | |
730 | # BEGIN SPRITE SECTION | |
731 | #=============================================================================== | |
732 | ||
733 | #=============================================================================== | |
734 | # Β¦ Sprite_Battler | |
735 | #=============================================================================== | |
736 | class Sprite_Battler < Sprite_Base | |
737 | ||
738 | #----------------------------------------------------------------------------- | |
739 | # Alias methods | |
740 | #----------------------------------------------------------------------------- | |
741 | alias rbs_sprite_battler_initialize initialize | |
742 | alias rbs_sprite_battler_update update | |
743 | alias rbs_sprite_battler_animation? animation? | |
744 | alias rbs_sprite_battler_dispose dispose | |
745 | ||
746 | #----------------------------------------------------------------------------- | |
747 | # Class Properties | |
748 | #----------------------------------------------------------------------------- | |
749 | attr_reader :current_x | |
750 | attr_reader :current_y | |
751 | attr_reader :original_x | |
752 | attr_reader :original_y | |
753 | ||
754 | #----------------------------------------------------------------------------- | |
755 | # Resets the position. | |
756 | #----------------------------------------------------------------------------- | |
757 | def reset_position | |
758 | @character_started = true | |
759 | @original_battler = @battler | |
760 | @original_x = @battler.screen_x | |
761 | @original_y = @battler.screen_y | |
762 | @current_x = @desired_x = @original_x | |
763 | @current_y = @desired_y = @original_y | |
764 | @jump_count = 0 | |
765 | @jump_axis = 0 | |
766 | @jump_value = 0 | |
767 | @movement_count = 0 | |
768 | @frame_count = 0 | |
769 | @frame_delay = 16 | |
770 | @last_battler = battler | |
771 | @battler_index = @battler.default_battler_index | |
772 | @frame = 0 | |
773 | @pose = 0 | |
774 | @poses = 1 | |
775 | @frames = 1 | |
776 | @frame_style = :rmvx | |
777 | @loops = 0 | |
778 | @last_battle_index = 0 | |
779 | @desired_zoom_x = @current_zoom_x = 1 | |
780 | @desired_zoom_y = @current_zoom_y = 1 | |
781 | @current_angle = @desired_angle = 0 | |
782 | @angle_time = 0 | |
783 | @zoom_time = 0 | |
784 | @current_opacity = @desired_opacity = 0 | |
785 | @opacity_time = 0 | |
786 | @battler_name_result = '' | |
787 | @mirrored_sprite = false | |
788 | @effect_opacity = 255 | |
789 | @effect_ox = 0 | |
790 | @effect_height = 0 | |
791 | @balloon_id = 0 | |
792 | @need_refresh = true | |
793 | @last_battler = nil | |
794 | @last_battler_name = '' | |
795 | @last_battler_hue = 0 | |
796 | end | |
797 | ||
798 | def make_return_sequence(include_stand=true) | |
799 | return if !@battler | |
800 | seq = '' | |
801 | if (@original_x != @current_x) || (@original_y != @current_y) | |
802 | seq = @battler.get_return_sequence | |
803 | end | |
804 | BattleInterpreter.add_action(@battler, [@battler], seq, nil, false) | |
805 | if @battler.alive? && include_stand | |
806 | BattleInterpreter.add_looping_action(@battler, @battler.get_stand_sequence) | |
807 | end | |
808 | end | |
809 | ||
810 | #----------------------------------------------------------------------------- | |
811 | # Sets the mirror value | |
812 | #----------------------------------------------------------------------------- | |
813 | def set_mirror_value(value) | |
814 | @mirrored_sprite = value | |
815 | end | |
816 | ||
817 | #----------------------------------------------------------------------------- | |
818 | # Creates the sprite | |
819 | #----------------------------------------------------------------------------- | |
820 | def initialize(viewport, battler=nil) | |
821 | @weapon_sprites = [] | |
822 | @character_started = false | |
823 | @afterimages = [] | |
824 | @afterimages_visible = false | |
825 | @afterimage_separation = 8 | |
826 | @animation_reg = [] | |
827 | rbs_sprite_battler_initialize(viewport, battler) | |
828 | end | |
829 | ||
830 | #----------------------------------------------------------------------------- | |
831 | # Dispose | |
832 | #----------------------------------------------------------------------------- | |
833 | def dispose | |
834 | dispose_afterimages | |
835 | dispose_weapon_sprites | |
836 | dispose_balloon | |
837 | rbs_sprite_battler_dispose | |
838 | end | |
839 | ||
840 | #----------------------------------------------------------------------------- | |
841 | # Dispose afterimages | |
842 | #----------------------------------------------------------------------------- | |
843 | def dispose_afterimages | |
844 | @afterimages.each do |i| | |
845 | i.dispose | |
846 | end | |
847 | @afterimages.clear | |
848 | end | |
849 | ||
850 | #----------------------------------------------------------------------------- | |
851 | # Dispose weapon sprites | |
852 | #----------------------------------------------------------------------------- | |
853 | def dispose_weapon_sprites | |
854 | @weapon_sprites.each do |i| | |
855 | i.dispose | |
856 | end | |
857 | end | |
858 | ||
859 | #----------------------------------------------------------------------------- | |
860 | # Checks if the sprite is moving? | |
861 | #----------------------------------------------------------------------------- | |
862 | def moving? | |
863 | return false if !@battler | |
864 | return (@movement_count > 0 || @angle_time > 0 || @zoom_time > 0 || @opacity_time > 0 ) | |
865 | end | |
866 | ||
867 | #-------------------------------------------------------------------------- | |
868 | # ? Update blink effect | |
869 | #-------------------------------------------------------------------------- | |
870 | def update_blink | |
871 | @effect_opacity = (@effect_duration % 10 < 5) ? 255 : 0 | |
872 | end | |
873 | #-------------------------------------------------------------------------- | |
874 | # ? Opdates appear effect | |
875 | #-------------------------------------------------------------------------- | |
876 | def update_appear | |
877 | @effect_opacity = (16 - @effect_duration) * 16 | |
878 | end | |
879 | #-------------------------------------------------------------------------- | |
880 | # ? Opdates disappear effect | |
881 | #-------------------------------------------------------------------------- | |
882 | def update_disappear | |
883 | @effect_opacity = 256 - (32 - @effect_duration) * 10 | |
884 | end | |
885 | #-------------------------------------------------------------------------- | |
886 | # ? Update collapse effect | |
887 | #-------------------------------------------------------------------------- | |
888 | def update_collapse | |
889 | self.blend_type = 1 | |
890 | self.color.set(255, 128, 128, 128) | |
891 | @effect_opacity = 256 - (48 - @effect_duration) * 6 | |
892 | end | |
893 | ||
894 | #-------------------------------------------------------------------------- | |
895 | # ? Reverts the sprite to normal | |
896 | #-------------------------------------------------------------------------- | |
897 | def revert_to_normal | |
898 | self.blend_type = 0 | |
899 | self.color.set(0, 0, 0, 0) | |
900 | @effect_opacity = 255 | |
901 | @effect_ox = @battler_width / 2 if bitmap | |
902 | @effect_height = 0 | |
903 | end | |
904 | ||
905 | #-------------------------------------------------------------------------- | |
906 | # ? Updates boss collpase | |
907 | #-------------------------------------------------------------------------- | |
908 | def update_boss_collapse | |
909 | alpha = @effect_duration * 120 / bitmap.height | |
910 | @effect_ox = @battler_width / 2 + @effect_duration % 2 * 4 - 2 | |
911 | self.blend_type = 1 | |
912 | self.color.set(255, 255, 255, 255 - alpha) | |
913 | @effect_opacity = alpha | |
914 | @effect_height -= 1 | |
915 | Sound.play_boss_collapse2 if @effect_duration % 20 == 19 | |
916 | end | |
917 | #-------------------------------------------------------------------------- | |
918 | # ? updates instant collapse | |
919 | #-------------------------------------------------------------------------- | |
920 | def update_instant_collapse | |
921 | @effect_opacity = 0 | |
922 | end | |
923 | ||
924 | #----------------------------------------------------------------------------- | |
925 | # Frame update | |
926 | #----------------------------------------------------------------------------- | |
927 | def update | |
928 | if @battler && (!@character_started || @battler != @original_battler) | |
929 | start = @character_started | |
930 | reset_position | |
931 | if start | |
932 | @current_opacity = @desired_opacity = 255 | |
933 | start_effect(:appear) | |
934 | update | |
935 | make_return_sequence | |
936 | end | |
937 | elsif !@battler && @original_battler | |
938 | @original_battler = nil | |
939 | end | |
940 | set_animation_origin if @animation | |
941 | rbs_sprite_battler_update | |
942 | if @battler | |
943 | update_battler_position | |
944 | update_battler_pose | |
945 | update_afterimages | |
946 | update_weapon_sprites | |
947 | update_balloon | |
948 | end | |
949 | ||
950 | end | |
951 | ||
952 | #----------------------------------------------------------------------------- | |
953 | # Update positions. | |
954 | #----------------------------------------------------------------------------- | |
955 | def update_battler_position | |
956 | if @movement_count > 0 | |
957 | @current_x = BattleCamera.calculate_display_change(@current_x, @desired_x, @movement_count) | |
958 | @current_y = BattleCamera.calculate_display_change(@current_y, @desired_y, @movement_count) | |
959 | if @jump_count > 0 | |
960 | @jump_value = BattleCamera.calculate_display_change(@jump_value, @jump_axis, @jump_count) | |
961 | @jump_count -= 1 | |
962 | elsif @jump_value != 0 | |
963 | @jump_axis = 0 | |
964 | @jump_count = @movement_count - 1 | |
965 | end | |
966 | @movement_count -= 1 | |
967 | end | |
968 | ||
969 | if @zoom_time > 0 | |
970 | @current_zoom_x = BattleCamera.calculate_display_change(@current_zoom_x, @desired_zoom_x, @zoom_time) | |
971 | @current_zoom_y = BattleCamera.calculate_display_change(@current_zoom_y, @desired_zoom_y, @zoom_time) | |
972 | @zoom_time -= 1 | |
973 | end | |
974 | ||
975 | if @angle_time > 0 | |
976 | @current_angle = BattleCamera.calculate_display_change(@current_angle, @desired_angle, @angle_time) | |
977 | @angle_time -= 1 | |
978 | end | |
979 | ||
980 | if @opacity_time > 0 | |
981 | @current_opacity = BattleCamera.calculate_display_change(@current_opacity, @desired_opacity, @opacity_time) | |
982 | @opacity_time -= 1 | |
983 | end | |
984 | ||
985 | @original_x = @battler.screen_x | |
986 | @original_y = @battler.screen_y | |
987 | ||
988 | self.x = BattleCamera.correct_x( @current_x ) | |
989 | self.y = BattleCamera.correct_y( @current_y - @jump_value - @effect_height / 2) | |
990 | self.z = @current_y + 100 | |
991 | self.zoom_x = BattleCamera.correct_zoom(@current_zoom_x, @current_x, @current_y, @battler.zoom_effective?) | |
992 | self.zoom_y = BattleCamera.correct_zoom(@current_zoom_y, @current_x, @current_y, @battler.zoom_effective?) | |
993 | self.angle = BattleCamera.correct_angle(@current_angle) | |
994 | self.mirror = BattleCamera.correct_mirror(@battler.enemy? ? @mirrored_sprite : !@mirrored_sprite) | |
995 | self.opacity = @current_opacity * @effect_opacity / 255 | |
996 | self.visible = @effect_type || @battler.exist? | |
997 | end | |
998 | ||
999 | #----------------------------------------------------------------------------- | |
1000 | # Get the max frame number | |
1001 | #----------------------------------------------------------------------------- | |
1002 | def max_frames | |
1003 | return @frame_style == -2 ? @frames * 2 : @frames | |
1004 | end | |
1005 | ||
1006 | #----------------------------------------------------------------------------- | |
1007 | # Gets the real frame number | |
1008 | #----------------------------------------------------------------------------- | |
1009 | def real_frame | |
1010 | return @frame < @frames ? @frame : (max_frames - @frame - 1) | |
1011 | end | |
1012 | ||
1013 | #----------------------------------------------------------------------------- | |
1014 | # Updates the current pose | |
1015 | #----------------------------------------------------------------------------- | |
1016 | def update_battler_pose | |
1017 | ||
1018 | if @loops != 0 | |
1019 | if @frame_style < 0 | |
1020 | @frame_count = (@frame_count + 1) % @frame_delay | |
1021 | if @frame_count == 0 | |
1022 | @frame = (@frame + 1) % max_frames | |
1023 | @loops -= 1 if @frame == 0 && @loops > 0 | |
1024 | end | |
1025 | else | |
1026 | @frame = @frame_style | |
1027 | end | |
1028 | end | |
1029 | o_x = @battler_width * real_frame | |
1030 | o_y = @battler_height * @pose + @effect_height | |
1031 | bh = [@battler_height + @effect_height, 1].max | |
1032 | self.src_rect.set(o_x, o_y, @battler_width, bh) | |
1033 | end | |
1034 | ||
1035 | #----------------------------------------------------------------------------- | |
1036 | # Makes the new battler name | |
1037 | #----------------------------------------------------------------------------- | |
1038 | def make_battler_name | |
1039 | if @need_refresh || @last_battler != self.battler || | |
1040 | @last_battler_name != battler.battler_name || | |
1041 | @last_battler_hue != battler.battler_hue | |
1042 | @last_battler_name = battler.battler_name | |
1043 | @last_battler_hue = battler.battler_hue | |
1044 | @need_refresh = false | |
1045 | @last_battler = self.battler | |
1046 | battler_name = @battler.battler_name.sub(/\[(\d+),(\d+)\]/i) { '' } | |
1047 | battler_name = @battler_index == 0 ? @battler.battler_name : "#{@battler.battler_name}_#{@battler_index}" | |
1048 | files = Dir.glob("Graphics/Battlers/#{battler_name}*") | |
1049 | @battler_name_result = (files.size > 0) ? files[0] : battler_name | |
1050 | @battler_name_result.gsub! (/Graphics\/Battlers\//mi) {''} | |
1051 | end | |
1052 | return @battler_name_result | |
1053 | end | |
1054 | ||
1055 | #----------------------------------------------------------------------------- | |
1056 | # Updates the bitmap | |
1057 | #----------------------------------------------------------------------------- | |
1058 | def update_bitmap | |
1059 | battler_name = make_battler_name | |
1060 | new_bitmap = Cache.battler(battler_name, @battler.battler_hue) | |
1061 | if self.bitmap != new_bitmap | |
1062 | data = [] | |
1063 | if battler_name[/\[(.*?),(.*?)\]/i] | |
1064 | @frames = eval($1) | |
1065 | @poses = eval($2) | |
1066 | else | |
1067 | @poses = BattleConfig::DefaultPoses | |
1068 | @frames = BattleConfig::DefaultFrames | |
1069 | end | |
1070 | @frame_delay = 16 | |
1071 | @frame_style = -2 | |
1072 | @loops = -1 | |
1073 | self.bitmap = new_bitmap | |
1074 | @battler_width = self.bitmap.width / @frames | |
1075 | @battler_height = self.bitmap.height / @poses | |
1076 | @effect_ox = @battler_width / 2 if bitmap | |
1077 | init_visibility | |
1078 | end | |
1079 | end | |
1080 | ||
1081 | #----------------------------------------------------------------------------- | |
1082 | # Updates the weapon sprites | |
1083 | #----------------------------------------------------------------------------- | |
1084 | def update_weapon_sprites | |
1085 | @weapon_sprites.each do |i| | |
1086 | if i.animation? | |
1087 | i.update | |
1088 | else | |
1089 | i.dispose | |
1090 | @weapon_sprites.delete(i) | |
1091 | end | |
1092 | end | |
1093 | end | |
1094 | ||
1095 | #----------------------------------------------------------------------------- | |
1096 | # Updates original position. | |
1097 | #----------------------------------------------------------------------------- | |
1098 | def update_origin | |
1099 | if bitmap | |
1100 | self.ox = @effect_ox | |
1101 | self.oy = @battler_height + @effect_height | |
1102 | end | |
1103 | end | |
1104 | #----------------------------------------------------------------------------- | |
1105 | # Sets the movememnt | |
1106 | #----------------------------------------------------------------------------- | |
1107 | def set_movement(x, y, jump, time) | |
1108 | @desired_x = x | |
1109 | @desired_y = y | |
1110 | @jump_count = time / 2 | |
1111 | @jump_axis = jump | |
1112 | @jump_value = 0 | |
1113 | @movement_count = time | |
1114 | end | |
1115 | #----------------------------------------------------------------------------- | |
1116 | # Sets the pose | |
1117 | #----------------------------------------------------------------------------- | |
1118 | def set_pose(character_index, pose, style, loops, interval) | |
1119 | @poses = 0 if !@poses | |
1120 | @battler_index = character_index | |
1121 | @frame = 0 | |
1122 | @frame_delay = interval | |
1123 | @pose = pose if pose < @poses | |
1124 | @frame_style = style | |
1125 | @loops = loops | |
1126 | @need_refresh = true | |
1127 | end | |
1128 | #----------------------------------------------------------------------------- | |
1129 | # Sets the zoom | |
1130 | #----------------------------------------------------------------------------- | |
1131 | def set_zoom(x, y, time) | |
1132 | @desired_zoom_x = x | |
1133 | @desired_zoom_y = y | |
1134 | @zoom_time = time | |
1135 | end | |
1136 | ||
1137 | #----------------------------------------------------------------------------- | |
1138 | # Sets the angle | |
1139 | #----------------------------------------------------------------------------- | |
1140 | def set_angle(angle, time) | |
1141 | @desired_angle = angle | |
1142 | @angle_time = time | |
1143 | end | |
1144 | ||
1145 | #----------------------------------------------------------------------------- | |
1146 | # Sets the opacity | |
1147 | #----------------------------------------------------------------------------- | |
1148 | def set_opacity(opacity, time) | |
1149 | @desired_opacity = opacity | |
1150 | @opacity_time = time | |
1151 | end | |
1152 | ||
1153 | #----------------------------------------------------------------------------- | |
1154 | # Checks if the sprite is on animation | |
1155 | #----------------------------------------------------------------------------- | |
1156 | def animation? | |
1157 | return rbs_sprite_battler_animation? || moving? || (@effect_duration > 0) | |
1158 | end | |
1159 | ||
1160 | #-------------------------------------------------------------------------- | |
1161 | # ? Starts new effect | |
1162 | #-------------------------------------------------------------------------- | |
1163 | def start_effect(effect_type) | |
1164 | @effect_type = effect_type | |
1165 | case @effect_type | |
1166 | when :appear | |
1167 | @effect_duration = 16 | |
1168 | @battler_visible = true | |
1169 | when :disappear | |
1170 | @effect_duration = 32 | |
1171 | @battler_visible = false | |
1172 | when :whiten | |
1173 | @effect_duration = 16 | |
1174 | @battler_visible = true | |
1175 | when :blink | |
1176 | @effect_duration = 20 | |
1177 | @battler_visible = true | |
1178 | when :collapse | |
1179 | @effect_duration = 48 | |
1180 | @battler_visible = false | |
1181 | when :boss_collapse | |
1182 | @effect_duration = @battler_height | |
1183 | @battler_visible = false | |
1184 | when :instant_collapse | |
1185 | @effect_duration = 16 | |
1186 | @battler_visible = false | |
1187 | end | |
1188 | revert_to_normal | |
1189 | end | |
1190 | ||
1191 | #----------------------------------------------------------------------------- | |
1192 | # Sets the sprites of the animation | |
1193 | #----------------------------------------------------------------------------- | |
1194 | def animation_set_sprites(frame) | |
1195 | cell_data = frame.cell_data | |
1196 | @ani_sprites.each_with_index do |sprite, i| | |
1197 | next unless sprite | |
1198 | pattern = cell_data[i, 0] | |
1199 | if !pattern || pattern < 0 | |
1200 | sprite.visible = false | |
1201 | next | |
1202 | end | |
1203 | sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2 | |
1204 | sprite.visible = true | |
1205 | sprite.src_rect.set(pattern % 5 * 192, | |
1206 | pattern % 100 / 5 * 192, 192, 192) | |
1207 | if @ani_mirror | |
1208 | sprite.x = @ani_ox - cell_data[i, 1] | |
1209 | sprite.y = @ani_oy + cell_data[i, 2] | |
1210 | sprite.angle = BattleCamera.correct_angle(360 - cell_data[i, 4]) | |
1211 | sprite.mirror = BattleCamera.correct_mirror(cell_data[i, 5] == 0) | |
1212 | else | |
1213 | sprite.x = @ani_ox + cell_data[i, 1] | |
1214 | sprite.y = @ani_oy + cell_data[i, 2] | |
1215 | sprite.angle = BattleCamera.correct_angle(cell_data[i, 4]) | |
1216 | sprite.mirror = BattleCamera.correct_mirror(cell_data[i, 5] == 1) | |
1217 | end | |
1218 | sprite.z = self.z + 300 + i | |
1219 | sprite.ox = 96 | |
1220 | sprite.oy = 96 | |
1221 | sprite.zoom_x = BattleCamera.correct_zoom(cell_data[i, 3] / 100.0, @current_x, @current_y, zoom_effective?) | |
1222 | sprite.zoom_y = BattleCamera.correct_zoom(cell_data[i, 3] / 100.0, @current_x, @current_y, zoom_effective?) | |
1223 | sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 | |
1224 | sprite.blend_type = cell_data[i, 7] | |
1225 | end | |
1226 | end | |
1227 | ||
1228 | def zoom_effective? | |
1229 | return false if !@battler | |
1230 | @battler.zoom_effective? | |
1231 | end | |
1232 | ||
1233 | #----------------------------------------------------------------------------- | |
1234 | # Updates the animation | |
1235 | #----------------------------------------------------------------------------- | |
1236 | def update_animation | |
1237 | return unless @animation | |
1238 | @ani_duration -= 1 | |
1239 | if @ani_duration % @ani_rate == 0 | |
1240 | if @ani_duration > 0 | |
1241 | frame_index = @animation.frame_max | |
1242 | frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate | |
1243 | animation_set_sprites(@animation.frames[frame_index]) | |
1244 | @animation.timings.each do |timing| | |
1245 | animation_process_timing(timing) if timing.frame == frame_index | |
1246 | end | |
1247 | else | |
1248 | end_animation | |
1249 | end | |
1250 | end | |
1251 | end | |
1252 | #----------------------------------------------------------------------------- | |
1253 | # Updates afterimages | |
1254 | #----------------------------------------------------------------------------- | |
1255 | def update_afterimages | |
1256 | @animation_reg.push([self.bitmap, @current_x, @current_y - @jump_value, | |
1257 | self.z, | |
1258 | @current_zoom_x, @current_zoom_y, | |
1259 | self.src_rect.clone, self.ox, self.oy, | |
1260 | @current_angle, self.mirror]) | |
1261 | @afterimages.each_with_index do |afterimage, i| | |
1262 | j = @animation_reg.size - ((i + 1) * @afterimage_separation) | |
1263 | reg = @animation_reg[j] | |
1264 | next if !reg | |
1265 | afterimage.update(i, @afterimages.size, reg, self) | |
1266 | end | |
1267 | end | |
1268 | ||
1269 | #----------------------------------------------------------------------------- | |
1270 | # Sets the afterimages | |
1271 | #----------------------------------------------------------------------------- | |
1272 | def set_aftermages(value, count, separation) | |
1273 | @afterimages_visible = value | |
1274 | dispose_afterimages | |
1275 | @afterimages.clear | |
1276 | if @afterimages_visible | |
1277 | count.times do |i| | |
1278 | @afterimages.push(Sprite_Afterimage.new(viewport)) | |
1279 | end | |
1280 | end | |
1281 | @afterimage_separation = separation | |
1282 | end | |
1283 | ||
1284 | #----------------------------------------------------------------------------- | |
1285 | # Sets a weapon sprite by icons | |
1286 | #----------------------------------------------------------------------------- | |
1287 | def set_weapon_icon(x_corr, y_corr, start_angle, end_angle, time, left_hand=false, over=false) | |
1288 | if left_hand | |
1289 | if @battler.weapons[1] | |
1290 | bitmap = get_equip_sprite_icon(@battler.weapons[1]) | |
1291 | else | |
1292 | return | |
1293 | end | |
1294 | else | |
1295 | if @battler.weapons[0] | |
1296 | bitmap = get_equip_sprite_icon(@battler.weapons[0]) | |
1297 | else | |
1298 | return | |
1299 | end | |
1300 | end | |
1301 | sprite = Sprite_Weapon.new(self, bitmap, time, 1, 1, over, true) | |
1302 | sprite.set_angles(start_angle, end_angle) | |
1303 | sprite.setup_correction(x_corr, y_corr) | |
1304 | @weapon_sprites.push(sprite) | |
1305 | end | |
1306 | ||
1307 | def set_shield_icon(x_corr, y_corr, start_angle, end_angle, time, over=false) | |
1308 | ||
1309 | ||
1310 | - | bitmap = get_equip_sprite_icon(@battler.armors[0]) |
1310 | + | if @battler.armors[0] |
1311 | bitmap = get_equip_sprite_icon(@battler.armors[0]) | |
1312 | else | |
1313 | return | |
1314 | end | |
1315 | sprite = Sprite_Weapon.new(self, bitmap, time, 1, 1, over, true) | |
1316 | sprite.set_angles(start_angle, end_angle) | |
1317 | sprite.setup_correction(x_corr, y_corr) | |
1318 | @weapon_sprites.push(sprite) | |
1319 | end | |
1320 | ||
1321 | def get_equip_sprite_icon(equip) | |
1322 | Cache.get_icon_bitmap(equip.icon_index) | |
1323 | end | |
1324 | ||
1325 | def set_weapon_sprite(bitmap_name, x_corr, y_corr, frames, interval, over) | |
1326 | time = frames * interval + 1 | |
1327 | bitmap = get_weapon_bitmap_anime(bitmap_name) | |
1328 | sprite = Sprite_Weapon.new(self, bitmap, time, frames, interval, over, false) | |
1329 | sprite.setup_correction(x_corr, y_corr) | |
1330 | @weapon_sprites.push(sprite) | |
1331 | end | |
1332 | ||
1333 | def get_weapon_bitmap_anime(bitmap, hue=0) | |
1334 | name = @battler.battler_name.sub(/\[(\d+),(\d+)\]/i) { '' } | |
1335 | bitmap_name = "#{name}_#{bitmap}" | |
1336 | if FileTest.exists?("Graphics/Battlers/#{bitmap_name}") | |
1337 | return Cache.battler(bitmap_name, hue) | |
1338 | else | |
1339 | return Cache.battler(bitmap, hue) | |
1340 | end | |
1341 | end | |
1342 | ||
1343 | #-------------------------------------------------------------------------- | |
1344 | # ? ????????????? | |
1345 | #-------------------------------------------------------------------------- | |
1346 | def start_balloon(balloon_id) | |
1347 | dispose_balloon | |
1348 | @balloon_id = balloon_id | |
1349 | @balloon_duration = 8 * balloon_speed + balloon_wait | |
1350 | @balloon_sprite = ::Sprite.new(viewport) | |
1351 | @balloon_sprite.bitmap = Cache.system("Balloon") | |
1352 | @balloon_sprite.ox = 16 | |
1353 | @balloon_sprite.oy = 32 | |
1354 | update_balloon | |
1355 | end | |
1356 | #-------------------------------------------------------------------------- | |
1357 | # ? ??????????? | |
1358 | #-------------------------------------------------------------------------- | |
1359 | def dispose_balloon | |
1360 | if @balloon_sprite | |
1361 | @balloon_sprite.dispose | |
1362 | @balloon_sprite = nil | |
1363 | end | |
1364 | @balloon_id = 0 | |
1365 | end | |
1366 | #-------------------------------------------------------------------------- | |
1367 | # ? ??????????? | |
1368 | #-------------------------------------------------------------------------- | |
1369 | def update_balloon | |
1370 | return if @balloon_id == 0 | |
1371 | if @balloon_duration > 0 | |
1372 | @balloon_duration -= 1 | |
1373 | if @balloon_duration > 0 | |
1374 | @balloon_sprite.x = BattleCamera.correct_x(@current_x) | |
1375 | @balloon_sprite.y = BattleCamera.correct_y(@current_y - @battler_height) | |
1376 | @balloon_sprite.z = self.z + 200 | |
1377 | sx = balloon_frame_index * 32 | |
1378 | sy = (@balloon_id - 1) * 32 | |
1379 | @balloon_sprite.src_rect.set(sx, sy, 32, 32) | |
1380 | else | |
1381 | end_balloon | |
1382 | end | |
1383 | end | |
1384 | end | |
1385 | #-------------------------------------------------------------------------- | |
1386 | # ? ??????????? | |
1387 | #-------------------------------------------------------------------------- | |
1388 | def end_balloon | |
1389 | dispose_balloon | |
1390 | @balloon_id = 0 | |
1391 | end | |
1392 | #-------------------------------------------------------------------------- | |
1393 | # ? ????????????? | |
1394 | #-------------------------------------------------------------------------- | |
1395 | def balloon_speed | |
1396 | return 8 | |
1397 | end | |
1398 | #-------------------------------------------------------------------------- | |
1399 | # ? ????????????????? | |
1400 | #-------------------------------------------------------------------------- | |
1401 | def balloon_wait | |
1402 | return 12 | |
1403 | end | |
1404 | #-------------------------------------------------------------------------- | |
1405 | # ? ??????????????? | |
1406 | #-------------------------------------------------------------------------- | |
1407 | def balloon_frame_index | |
1408 | return 7 - [(@balloon_duration - balloon_wait) / balloon_speed, 0].max | |
1409 | end | |
1410 | ||
1411 | end | |
1412 | ||
1413 | #=============================================================================== | |
1414 | # Β¦ Sprite_Weapon | |
1415 | #------------------------------------------------------------------------------- | |
1416 | # The class that controls weapon animations. | |
1417 | #=============================================================================== | |
1418 | class Sprite_Weapon < Sprite | |
1419 | ||
1420 | attr_reader :anime_count | |
1421 | ||
1422 | def initialize(sprite, bitmap, anime_count, frames=1, frame_interval=1, over=false, icon=false) | |
1423 | super(sprite.viewport) | |
1424 | @sprite = sprite | |
1425 | @anime_count = anime_count | |
1426 | @current_angle = 0 | |
1427 | @end_angle = 0 | |
1428 | @frames = frames | |
1429 | @frame_interval = frame_interval | |
1430 | @frame_count = 0 | |
1431 | @frame = 0 | |
1432 | @over = over | |
1433 | @x_correction = @y_correction = 0 | |
1434 | self.bitmap = bitmap | |
1435 | @bw = self.bitmap.width / @frames | |
1436 | @bh = self.bitmap.height | |
1437 | self.mirror = sprite.battler.enemy? | |
1438 | self.ox = icon ? @bw : @bw / 2 | |
1439 | self.oy = @bh | |
1440 | update_rect | |
1441 | end | |
1442 | ||
1443 | def update | |
1444 | super | |
1445 | return if @anime_count < 1 | |
1446 | update_animation | |
1447 | @anime_count -= 1 | |
1448 | end | |
1449 | ||
1450 | def update_animation | |
1451 | update_angle | |
1452 | update_frame | |
1453 | update_rect | |
1454 | update_coordinates | |
1455 | end | |
1456 | ||
1457 | def update_angle | |
1458 | @current_angle = (@current_angle * (@anime_count - 1) + @end_angle) / @anime_count | |
1459 | self.angle = @sprite.angle + @current_angle | |
1460 | end | |
1461 | ||
1462 | def update_frame | |
1463 | @frame_count = (@frame_count + 1) % @frame_interval | |
1464 | @frame = (@frame + 1) % @frames if @frame_count == 0 | |
1465 | end | |
1466 | ||
1467 | def update_rect | |
1468 | self.src_rect.set(@bw * @frame, 0, @bw, @bh) | |
1469 | end | |
1470 | ||
1471 | def animation? | |
1472 | return (@anime_count > 0) | |
1473 | end | |
1474 | ||
1475 | def update_coordinates | |
1476 | self.x = BattleCamera.correct_x(@sprite.current_x + @x_correction) | |
1477 | self.y = BattleCamera.correct_y(@sprite.current_y + @y_correction) | |
1478 | self.z = @over ? @sprite.z + 1 : @sprite.z - 1 | |
1479 | self.zoom_x = @sprite.zoom_x | |
1480 | self.zoom_y = @sprite.zoom_y | |
1481 | ||
1482 | end | |
1483 | ||
1484 | def set_angles(start_angle, end_angle) | |
1485 | @current_angle = start_angle | |
1486 | @end_angle = end_angle | |
1487 | end | |
1488 | ||
1489 | def setup_correction(x, y) | |
1490 | @x_correction = x | |
1491 | @y_correction = y | |
1492 | end | |
1493 | ||
1494 | end | |
1495 | ||
1496 | #=============================================================================== | |
1497 | # Β¦ Sprite_Afterimage | |
1498 | #------------------------------------------------------------------------------- | |
1499 | # The class that controls afterimage processing. | |
1500 | #=============================================================================== | |
1501 | ||
1502 | class Sprite_Afterimage < Sprite | |
1503 | ||
1504 | #----------------------------------------------------------------------------- | |
1505 | # Updates the afterimage | |
1506 | #----------------------------------------------------------------------------- | |
1507 | def update(index, size, data, sprite) | |
1508 | super() | |
1509 | self.bitmap = data[0] | |
1510 | self.x = BattleCamera.correct_x(data[1]) | |
1511 | self.y = BattleCamera.correct_y(data[2]) | |
1512 | self.z = data[3] | |
1513 | self.zoom_x = BattleCamera.correct_zoom(data[4], data[1], data[2], sprite.battler.zoom_effective?) | |
1514 | self.zoom_y = BattleCamera.correct_zoom(data[5], data[1], data[2], sprite.battler.zoom_effective?) | |
1515 | self.src_rect = data[6] | |
1516 | self.ox = data[7] | |
1517 | self.oy = data[8] | |
1518 | self.angle = BattleCamera.correct_angle(data[9]) | |
1519 | self.mirror = data[10] | |
1520 | self.opacity = 255 - (index * 255 / size) | |
1521 | end | |
1522 | ||
1523 | end | |
1524 | ||
1525 | #============================================================================== | |
1526 | # Β¦ Sprite_BattlePicture | |
1527 | #============================================================================== | |
1528 | ||
1529 | class Sprite_BattlePicture < Sprite_Base | |
1530 | #-------------------------------------------------------------------------- | |
1531 | # ? ????????? | |
1532 | # picture : Game_Picture | |
1533 | #-------------------------------------------------------------------------- | |
1534 | def initialize(viewport, picture) | |
1535 | super(viewport) | |
1536 | @picture = picture | |
1537 | update | |
1538 | end | |
1539 | #-------------------------------------------------------------------------- | |
1540 | # ? ?? | |
1541 | #-------------------------------------------------------------------------- | |
1542 | def dispose | |
1543 | bitmap.dispose if bitmap | |
1544 | super | |
1545 | end | |
1546 | #-------------------------------------------------------------------------- | |
1547 | # ? ?????? | |
1548 | #-------------------------------------------------------------------------- | |
1549 | def update | |
1550 | super | |
1551 | update_bitmap | |
1552 | update_origin | |
1553 | update_position | |
1554 | update_zoom | |
1555 | update_other | |
1556 | end | |
1557 | #----------------------------------------------------------------------------- | |
1558 | # Updates the bitmap | |
1559 | #----------------------------------------------------------------------------- | |
1560 | def update_bitmap | |
1561 | if @picture.name.is_a?(Integer) | |
1562 | self.bitmap = Cache.get_icon_bitmap(@picture.name) | |
1563 | else | |
1564 | self.bitmap = Cache.picture(@picture.name) | |
1565 | end | |
1566 | end | |
1567 | ||
1568 | #-------------------------------------------------------------------------- | |
1569 | # ? ????? | |
1570 | #-------------------------------------------------------------------------- | |
1571 | def update_origin | |
1572 | if @picture.origin == 0 | |
1573 | self.ox = 0 | |
1574 | self.oy = 0 | |
1575 | else | |
1576 | self.ox = bitmap.width / 2 | |
1577 | self.oy = bitmap.height / 2 | |
1578 | end | |
1579 | end | |
1580 | #-------------------------------------------------------------------------- | |
1581 | # ? ????? | |
1582 | #-------------------------------------------------------------------------- | |
1583 | def update_position | |
1584 | self.x = BattleCamera.correct_x(@picture.x) | |
1585 | self.y = BattleCamera.correct_y(@picture.y) | |
1586 | self.z = @picture.number | |
1587 | end | |
1588 | #-------------------------------------------------------------------------- | |
1589 | # ? ?????? | |
1590 | #-------------------------------------------------------------------------- | |
1591 | def update_zoom | |
1592 | self.zoom_x = BattleCamera.correct_zoom(@picture.zoom_x / 100.0) | |
1593 | self.zoom_y = BattleCamera.correct_zoom(@picture.zoom_y / 100.0) | |
1594 | end | |
1595 | #-------------------------------------------------------------------------- | |
1596 | # ? ?????? | |
1597 | #-------------------------------------------------------------------------- | |
1598 | def update_other | |
1599 | self.opacity = @picture.opacity | |
1600 | self.blend_type = @picture.blend_type | |
1601 | self.angle = @picture.angle | |
1602 | self.tone.set(@picture.tone) | |
1603 | end | |
1604 | ||
1605 | def start_animation_ex(animation, mirror = false) | |
1606 | start_animation(animation, mirror) | |
1607 | end | |
1608 | ||
1609 | ||
1610 | ||
1611 | end | |
1612 | ||
1613 | #=============================================================================== | |
1614 | # Β¦ Spriteset_Battle | |
1615 | #=============================================================================== | |
1616 | ||
1617 | class Spriteset_Battle | |
1618 | ||
1619 | #-------------------------------------------------------------------------- | |
1620 | # ? Class variables | |
1621 | #-------------------------------------------------------------------------- | |
1622 | @@inverted_x_cache = {} | |
1623 | @@inverted_y_cache = {} | |
1624 | @@inverted_both_cache = {} | |
1625 | ||
1626 | #-------------------------------------------------------------------------- | |
1627 | # ? Alias methods | |
1628 | #-------------------------------------------------------------------------- | |
1629 | alias rbs_spriteset_battle_initialize initialize | |
1630 | alias rbs_spriteset_battle_battleback1_bitmap battleback1_bitmap | |
1631 | alias rbs_spriteset_battle_battleback2_bitmap battleback2_bitmap | |
1632 | ||
1633 | #-------------------------------------------------------------------------- | |
1634 | # ? Creates the spriteset | |
1635 | #-------------------------------------------------------------------------- | |
1636 | def initialize | |
1637 | rbs_spriteset_battle_initialize | |
1638 | @battler_sprites = @enemy_sprites + @actor_sprites | |
1639 | @icon_sprites = {} | |
1640 | end | |
1641 | ||
1642 | def create_actors | |
1643 | @actor_sprites = $game_party.members.collect do |actor| | |
1644 | Sprite_Battler.new(@viewport1, actor) | |
1645 | end | |
1646 | end | |
1647 | ||
1648 | ||
1649 | def update_actors | |
1650 | @actor_sprites.each do |sprite| | |
1651 | if !sprite.battler | |
1652 | @actor_sprites.delete(sprite) | |
1653 | sprite.dispose | |
1654 | else | |
1655 | sprite.update | |
1656 | end | |
1657 | end | |
1658 | $game_party.members.each do |actor| | |
1659 | if !@actor_sprites.any? { |sprite| sprite.battler == actor} | |
1660 | new_sprite = Sprite_Battler.new(@viewport1, actor) | |
1661 | @actor_sprites.push(new_sprite) | |
1662 | new_sprite.update | |
1663 | if $game_troop.turn_count > 0 || BattleManager.turn_end? | |
1664 | BattleInterpreter.add_action(actor, [actor], actor.get_presentation_sequence, nil) | |
1665 | SceneManager.scene.wait_for_battle_interpreter | |
1666 | end | |
1667 | end | |
1668 | end | |
1669 | end | |
1670 | ||
1671 | #-------------------------------------------------------------------------- | |
1672 | # ? checks if animating | |
1673 | #-------------------------------------------------------------------------- | |
1674 | def animation? | |
1675 | battler_sprites.any? {|sprite| sprite.animation? || sprite.moving? || BattleCamera.moving? } | |
1676 | end | |
1677 | ||
1678 | #-------------------------------------------------------------------------- | |
1679 | # ? gets the battler sprites | |
1680 | #-------------------------------------------------------------------------- | |
1681 | def battler_sprites | |
1682 | @actor_sprites + @enemy_sprites | |
1683 | end | |
1684 | ||
1685 | #-------------------------------------------------------------------------- | |
1686 | # ? Get the battler sprite of a target | |
1687 | #-------------------------------------------------------------------------- | |
1688 | def battler_sprite(battler) | |
1689 | @battler_sprites.each do |i| | |
1690 | return i if i.battler == battler | |
1691 | end | |
1692 | end | |
1693 | ||
1694 | #-------------------------------------------------------------------------- | |
1695 | # ? Creates the lower battleback | |
1696 | #-------------------------------------------------------------------------- | |
1697 | def create_battleback1 | |
1698 | @back1_sprite = Plane.new(@viewport1) | |
1699 | @back1_sprite.bitmap = battleback1_bitmap | |
1700 | @back1_sprite.z = 0 | |
1701 | end | |
1702 | #-------------------------------------------------------------------------- | |
1703 | # ? Creats the upper battleback | |
1704 | #-------------------------------------------------------------------------- | |
1705 | def create_battleback2 | |
1706 | @back2_sprite = Plane.new(@viewport1) | |
1707 | @back2_sprite.bitmap = battleback2_bitmap | |
1708 | @back2_sprite.z = 1 | |
1709 | end | |
1710 | ||
1711 | #-------------------------------------------------------------------------- | |
1712 | # ? Updates lower battleback | |
1713 | #-------------------------------------------------------------------------- | |
1714 | def update_battleback1 | |
1715 | z = BattleConfig::Battleback_NormalZoom | |
1716 | ox = @back1_sprite.bitmap.width * 3 / 4 | |
1717 | oy = @back1_sprite.bitmap.height * 3 / 4 | |
1718 | @back1_sprite.ox = -BattleCamera.correct_x(ox) | |
1719 | @back1_sprite.oy = -BattleCamera.correct_y(oy) | |
1720 | zoom = BattleCamera.correct_zoom(BattleConfig::Battleback_NormalZoom) | |
1721 | @back1_sprite.zoom_x = @back1_sprite.zoom_y = zoom | |
1722 | end | |
1723 | #-------------------------------------------------------------------------- | |
1724 | # ? Updates upper battleback | |
1725 | #-------------------------------------------------------------------------- | |
1726 | def update_battleback2 | |
1727 | z = BattleConfig::Battleback_NormalZoom | |
1728 | ox = @back2_sprite.bitmap.width * 3 / 4 | |
1729 | oy = @back2_sprite.bitmap.height * 3 / 4 | |
1730 | @back2_sprite.ox = -BattleCamera.correct_x(ox) | |
1731 | @back2_sprite.oy = -BattleCamera.correct_y(oy) | |
1732 | zoom = BattleCamera.correct_zoom(BattleConfig::Battleback_NormalZoom) | |
1733 | @back2_sprite.zoom_x = @back2_sprite.zoom_y = zoom | |
1734 | end | |
1735 | ||
1736 | #-------------------------------------------------------------------------- | |
1737 | # ? Gets the bitmap of lower battleback | |
1738 | #-------------------------------------------------------------------------- | |
1739 | def battleback1_bitmap | |
1740 | if BattleConfig::UsingDefaultBattlebacks | |
1741 | return create_mirrored_battleback(rbs_spriteset_battle_battleback1_bitmap) | |
1742 | else | |
1743 | return rbs_spriteset_battle_battleback1_bitmap | |
1744 | end | |
1745 | end | |
1746 | ||
1747 | #-------------------------------------------------------------------------- | |
1748 | # ? Gets the bitmap of upper battleback | |
1749 | #-------------------------------------------------------------------------- | |
1750 | def battleback2_bitmap | |
1751 | if BattleConfig::UsingDefaultBattlebacks | |
1752 | return create_mirrored_battleback(rbs_spriteset_battle_battleback2_bitmap) | |
1753 | else | |
1754 | return rbs_spriteset_battle_battleback2_bitmap | |
1755 | end | |
1756 | end | |
1757 | ||
1758 | #-------------------------------------------------------------------------- | |
1759 | # ? Creates the sprite of the battleback for compatibility | |
1760 | #-------------------------------------------------------------------------- | |
1761 | def create_mirrored_battleback(battleback) | |
1762 | org_w = battleback.width | |
1763 | org_h = battleback.height | |
1764 | bw = battleback.width << 1 | |
1765 | bh = battleback.height << 1 | |
1766 | bmp = Bitmap.new(bw, bh) | |
1767 | bmp.blt(org_w >> 1, org_h >> 1, battleback, battleback.rect) | |
1768 | battleback.dispose | |
1769 | return bmp | |
1770 | end | |
1771 | ||
1772 | def make_return_sequence(include_stand=true) | |
1773 | battler_sprites.each do |i| | |
1774 | i.make_return_sequence(include_stand) | |
1775 | end | |
1776 | end | |
1777 | ||
1778 | #-------------------------------------------------------------------------- | |
1779 | # ? ???????????? | |
1780 | #-------------------------------------------------------------------------- | |
1781 | def update_pictures | |
1782 | $game_troop.screen.pictures.each do |pic| | |
1783 | @picture_sprites[pic.number] ||= Sprite_BattlePicture.new(@viewport2, pic) | |
1784 | @picture_sprites[pic.number].update | |
1785 | end | |
1786 | end | |
1787 | ||
1788 | end | |
1789 | ||
1790 | #=============================================================================== | |
1791 | # END SPRITE SECTION | |
1792 | #=============================================================================== | |
1793 | ||
1794 | #=============================================================================== | |
1795 | # BEGIN GAME DATA SECTION | |
1796 | #=============================================================================== | |
1797 | ||
1798 | #=============================================================================== | |
1799 | # * RPG::BaseItem | |
1800 | #=============================================================================== | |
1801 | module RPG | |
1802 | class BaseItem | |
1803 | ||
1804 | #--------------------------------------------------------------------------- | |
1805 | # Gets attack skill id | |
1806 | #--------------------------------------------------------------------------- | |
1807 | def get_atk_skill_id | |
1808 | return self.note[/<atk skill id:(.*?)>/mi] ? eval($1) : nil | |
1809 | end | |
1810 | ||
1811 | #--------------------------------------------------------------------------- | |
1812 | # Gets guard skill id | |
1813 | #--------------------------------------------------------------------------- | |
1814 | def get_guard_skill_id | |
1815 | return self.note[/<guard skill id:(.*?)>/mi] ? eval($1) : nil | |
1816 | end | |
1817 | ||
1818 | #--------------------------------------------------------------------------- | |
1819 | # Gets a sequence | |
1820 | #--------------------------------------------------------------------------- | |
1821 | def get_sequence(key) | |
1822 | ex = BattleConfig::Default_SequenceNotes | |
1823 | reg = /<sequence:#{key}>(.*?)<\/sequence>/mi | |
1824 | ex_r = '' | |
1825 | if self.is_a?(RPG::Actor) || self.is_a?(RPG::Enemy) | |
1826 | ex_r = (ex[reg] ? $1 : '') | |
1827 | end | |
1828 | return self.note[reg] ? $1 : ex_r | |
1829 | end | |
1830 | ||
1831 | #--------------------------------------------------------------------------- | |
1832 | # Gets a sequence | |
1833 | #--------------------------------------------------------------------------- | |
1834 | def get_turn_start_sequence | |
1835 | get_sequence('turn start') | |
1836 | end | |
1837 | ||
1838 | #--------------------------------------------------------------------------- | |
1839 | # Gets a sequence | |
1840 | #--------------------------------------------------------------------------- | |
1841 | def get_turn_end_sequence | |
1842 | get_sequence('turn end') | |
1843 | end | |
1844 | ||
1845 | #--------------------------------------------------------------------------- | |
1846 | # Gets a sequence | |
1847 | #--------------------------------------------------------------------------- | |
1848 | def get_presentation_sequence | |
1849 | get_sequence('presentation') | |
1850 | end | |
1851 | ||
1852 | #--------------------------------------------------------------------------- | |
1853 | # Gets a sequence | |
1854 | #--------------------------------------------------------------------------- | |
1855 | def get_surprised_sequence | |
1856 | get_sequence('surprised') | |
1857 | end | |
1858 | ||
1859 | #--------------------------------------------------------------------------- | |
1860 | # Gets a sequence | |
1861 | #--------------------------------------------------------------------------- | |
1862 | def get_preemptive_sequence | |
1863 | get_sequence('preemptive') | |
1864 | end | |
1865 | ||
1866 | #--------------------------------------------------------------------------- | |
1867 | # Gets a sequence | |
1868 | #--------------------------------------------------------------------------- | |
1869 | def get_attack_sequence | |
1870 | get_sequence('attack') | |
1871 | end | |
1872 | ||
1873 | #--------------------------------------------------------------------------- | |
1874 | # Gets a sequence | |
1875 | #--------------------------------------------------------------------------- | |
1876 | def get_guard_sequence | |
1877 | get_sequence('guard') | |
1878 | end | |
1879 | ||
1880 | #--------------------------------------------------------------------------- | |
1881 | # Gets a sequence | |
1882 | #--------------------------------------------------------------------------- | |
1883 | def get_counter_sequence | |
1884 | get_sequence('counter') | |
1885 | end | |
1886 | ||
1887 | #--------------------------------------------------------------------------- | |
1888 | # Gets a sequence | |
1889 | #--------------------------------------------------------------------------- | |
1890 | def get_die_sequence | |
1891 | get_sequence('die') | |
1892 | end | |
1893 | ||
1894 | #--------------------------------------------------------------------------- | |
1895 | # Gets a sequence | |
1896 | #--------------------------------------------------------------------------- | |
1897 | def get_dead_sequence | |
1898 | get_sequence('dead') | |
1899 | end | |
1900 | ||
1901 | #--------------------------------------------------------------------------- | |
1902 | # Gets a sequence | |
1903 | #--------------------------------------------------------------------------- | |
1904 | def get_revive_sequence | |
1905 | get_sequence('revive') | |
1906 | end | |
1907 | ||
1908 | #--------------------------------------------------------------------------- | |
1909 | # Gets a sequence | |
1910 | #--------------------------------------------------------------------------- | |
1911 | def get_victory_sequence | |
1912 | get_sequence('victory') | |
1913 | end | |
1914 | ||
1915 | #--------------------------------------------------------------------------- | |
1916 | # Gets a sequence | |
1917 | #--------------------------------------------------------------------------- | |
1918 | def get_substitute_sequence | |
1919 | get_sequence('substitute') | |
1920 | end | |
1921 | ||
1922 | #--------------------------------------------------------------------------- | |
1923 | # Gets a sequence | |
1924 | #--------------------------------------------------------------------------- | |
1925 | def get_reflect_sequence | |
1926 | get_sequence('reflect') | |
1927 | end | |
1928 | ||
1929 | #--------------------------------------------------------------------------- | |
1930 | # Gets a sequence | |
1931 | #--------------------------------------------------------------------------- | |
1932 | def get_item_use_sequence | |
1933 | get_sequence('item') | |
1934 | end | |
1935 | ||
1936 | #--------------------------------------------------------------------------- | |
1937 | # Gets a sequence | |
1938 | #--------------------------------------------------------------------------- | |
1939 | def get_skill_use_sequence | |
1940 | get_sequence('skill') | |
1941 | end | |
1942 | ||
1943 | #--------------------------------------------------------------------------- | |
1944 | # Gets a sequence | |
1945 | #--------------------------------------------------------------------------- | |
1946 | def get_stand_sequence | |
1947 | get_sequence('stand') | |
1948 | end | |
1949 | ||
1950 | #--------------------------------------------------------------------------- | |
1951 | # Gets a sequence | |
1952 | #--------------------------------------------------------------------------- | |
1953 | def get_evade_sequence | |
1954 | get_sequence('evade') | |
1955 | end | |
1956 | ||
1957 | #--------------------------------------------------------------------------- | |
1958 | # Gets a sequence | |
1959 | #--------------------------------------------------------------------------- | |
1960 | def get_miss_sequence | |
1961 | get_sequence('miss') | |
1962 | end | |
1963 | ||
1964 | #--------------------------------------------------------------------------- | |
1965 | # Gets a sequence | |
1966 | #--------------------------------------------------------------------------- | |
1967 | def get_return_sequence | |
1968 | get_sequence('return position') | |
1969 | end | |
1970 | ||
1971 | #--------------------------------------------------------------------------- | |
1972 | # Gets the sequence used when actor is processing an input | |
1973 | #--------------------------------------------------------------------------- | |
1974 | def get_action_selection_sequence | |
1975 | get_sequence('action selection') | |
1976 | end | |
1977 | ||
1978 | #--------------------------------------------------------------------------- | |
1979 | # Gets the default battler index | |
1980 | #--------------------------------------------------------------------------- | |
1981 | def get_default_battler_index | |
1982 | return self.note[/<default battler index:(.*?)>/mi] ? eval($1) : nil | |
1983 | end | |
1984 | ||
1985 | end | |
1986 | end | |
1987 | ||
1988 | class RPG::Skill < RPG::UsableItem | |
1989 | ||
1990 | #--------------------------------------------------------------------------- | |
1991 | # Gets a sequence | |
1992 | #--------------------------------------------------------------------------- | |
1993 | def get_attack_sequence | |
1994 | get_sequence('skill') == '' ? get_sequence('attack') : get_sequence('skill') | |
1995 | end | |
1996 | ||
1997 | end | |
1998 | ||
1999 | class RPG::Item < RPG::UsableItem | |
2000 | ||
2001 | #--------------------------------------------------------------------------- | |
2002 | # Gets a sequence | |
2003 | #--------------------------------------------------------------------------- | |
2004 | def get_attack_sequence | |
2005 | get_sequence('item') == '' ? get_sequence('attack') : get_sequence('skill') | |
2006 | end | |
2007 | ||
2008 | end | |
2009 | ||
2010 | ||
2011 | #=============================================================================== | |
2012 | # END GAME DATA SECTION | |
2013 | #=============================================================================== | |
2014 | ||
2015 | #=============================================================================== | |
2016 | # BEGIN GAME OBJECTS SECTION | |
2017 | #=============================================================================== | |
2018 | ||
2019 | #=============================================================================== | |
2020 | # Β¦ Game_Battler | |
2021 | #=============================================================================== | |
2022 | class Game_Battler | |
2023 | ||
2024 | def friend_unit | |
2025 | return [] | |
2026 | end | |
2027 | ||
2028 | def enemy_unit | |
2029 | return [] | |
2030 | end | |
2031 | ||
2032 | def counter_skill_id | |
2033 | return attack_skill_id | |
2034 | end | |
2035 | ||
2036 | def zoom_effective? | |
2037 | return true | |
2038 | end | |
2039 | ||
2040 | end | |
2041 | ||
2042 | #============================================================================== | |
2043 | # Β¦ Game_Enemy | |
2044 | #============================================================================== | |
2045 | class Game_Enemy < Game_Battler | |
2046 | ||
2047 | #----------------------------------------------------------------------------- | |
2048 | # Class atributes | |
2049 | #----------------------------------------------------------------------------- | |
2050 | attr_reader :atk_animation_id1 | |
2051 | attr_reader :atk_animation_id2 | |
2052 | ||
2053 | #----------------------------------------------------------------------------- | |
2054 | # Alias methods | |
2055 | #----------------------------------------------------------------------------- | |
2056 | alias rbs_game_enemy_initialize initialize | |
2057 | ||
2058 | #----------------------------------------------------------------------------- | |
2059 | # Object Creation | |
2060 | #----------------------------------------------------------------------------- | |
2061 | def initialize(index, enemy_id) | |
2062 | rbs_game_enemy_initialize(index, enemy_id) | |
2063 | @atk_animation_id1 = enemy.note[/<atk ani1:(.*?)>/im] ? eval($1) : BattleConfig::DefaultEnemey_Ani1ID | |
2064 | @atk_animation_id2 = enemy.note[/<atk ani2:(.*?)>/im] ? eval($1) : BattleConfig::DefaultEnemey_Ani2ID | |
2065 | @counter_skill_id = enemy.note[/<counter skill id:(.*?)>/im] ? eval($1) : attack_skill_id | |
2066 | @weapon_1_id = enemy.note[/<weapon 1 id:(.*?)>/im] ? eval($1) : 0 | |
2067 | @weapon_2_id = enemy.note[/<weapon 2 id:(.*?)>/im] ? eval($1) : 0 | |
2068 | end | |
2069 | ||
2070 | #-------------------------------------------------------------------------- | |
2071 | # ? Get the attack skll id | |
2072 | #-------------------------------------------------------------------------- | |
2073 | def attack_skill_id | |
2074 | id = enemy.get_atk_skill_id | |
2075 | return id ? id : super | |
2076 | end | |
2077 | #-------------------------------------------------------------------------- | |
2078 | # ? Get the guard skill id | |
2079 | #-------------------------------------------------------------------------- | |
2080 | def guard_skill_id | |
2081 | id = enemy.get_guard_skill_id | |
2082 | return id ? id : super | |
2083 | end | |
2084 | ||
2085 | #-------------------------------------------------------------------------- | |
2086 | # ? Get sequence | |
2087 | #-------------------------------------------------------------------------- | |
2088 | def get_turn_start_sequence | |
2089 | return enemy.presentation_sequence | |
2090 | end | |
2091 | ||
2092 | #-------------------------------------------------------------------------- | |
2093 | # ? Get sequence | |
2094 | #-------------------------------------------------------------------------- | |
2095 | def get_turn_end_sequence | |
2096 | return enemy.presentation_sequence | |
2097 | end | |
2098 | ||
2099 | #-------------------------------------------------------------------------- | |
2100 | # ? Get sequence | |
2101 | #-------------------------------------------------------------------------- | |
2102 | def get_presentation_sequence | |
2103 | return enemy.get_presentation_sequence | |
2104 | end | |
2105 | ||
2106 | #-------------------------------------------------------------------------- | |
2107 | # ? Get sequence | |
2108 | #-------------------------------------------------------------------------- | |
2109 | def get_surprised_sequence | |
2110 | return enemy.get_surprised_sequence | |
2111 | end | |
2112 | ||
2113 | #-------------------------------------------------------------------------- | |
2114 | # ? Get sequence | |
2115 | #-------------------------------------------------------------------------- | |
2116 | def get_preemptive_sequence | |
2117 | return enemy.get_preemptive_sequence | |
2118 | end | |
2119 | ||
2120 | #-------------------------------------------------------------------------- | |
2121 | # ? Get sequence | |
2122 | #-------------------------------------------------------------------------- | |
2123 | def get_attack_sequence | |
2124 | return enemy.get_attack_sequence | |
2125 | end | |
2126 | ||
2127 | #-------------------------------------------------------------------------- | |
2128 | # ? Get sequence | |
2129 | #-------------------------------------------------------------------------- | |
2130 | def get_guard_sequence | |
2131 | return enemy.get_guard_sequence | |
2132 | end | |
2133 | ||
2134 | #-------------------------------------------------------------------------- | |
2135 | # ? Get sequence | |
2136 | #-------------------------------------------------------------------------- | |
2137 | def get_counter_sequence | |
2138 | return enemy.get_counter_sequence | |
2139 | end | |
2140 | ||
2141 | #-------------------------------------------------------------------------- | |
2142 | # ? Get sequence | |
2143 | #-------------------------------------------------------------------------- | |
2144 | def get_die_sequence | |
2145 | return enemy.get_die_sequence | |
2146 | end | |
2147 | ||
2148 | #-------------------------------------------------------------------------- | |
2149 | # ? Get sequence | |
2150 | #-------------------------------------------------------------------------- | |
2151 | def get_dead_sequence | |
2152 | return enemy.get_dead_sequence | |
2153 | end | |
2154 | ||
2155 | #-------------------------------------------------------------------------- | |
2156 | # ? Get sequence | |
2157 | #-------------------------------------------------------------------------- | |
2158 | def get_revive_sequence | |
2159 | return enemy.get_revive_sequence | |
2160 | end | |
2161 | ||
2162 | #-------------------------------------------------------------------------- | |
2163 | # ? Get sequence | |
2164 | #-------------------------------------------------------------------------- | |
2165 | def get_victory_sequence | |
2166 | return enemy.get_victory_sequence | |
2167 | end | |
2168 | ||
2169 | #-------------------------------------------------------------------------- | |
2170 | # ? Get sequence | |
2171 | #-------------------------------------------------------------------------- | |
2172 | def get_substitute_sequence | |
2173 | return enemy.get_substitute_sequence | |
2174 | end | |
2175 | ||
2176 | #-------------------------------------------------------------------------- | |
2177 | # ? Get sequence | |
2178 | #-------------------------------------------------------------------------- | |
2179 | def get_reflect_sequence | |
2180 | return enemy.get_substitute_sequence | |
2181 | end | |
2182 | ||
2183 | #-------------------------------------------------------------------------- | |
2184 | # ? Get sequence | |
2185 | #-------------------------------------------------------------------------- | |
2186 | def get_item_use_sequence | |
2187 | return enemy.get_item_use_sequence | |
2188 | end | |
2189 | ||
2190 | #-------------------------------------------------------------------------- | |
2191 | # ? Get sequence | |
2192 | #-------------------------------------------------------------------------- | |
2193 | def get_skill_use_sequence | |
2194 | return enemy.get_skill_use_sequence | |
2195 | end | |
2196 | ||
2197 | #-------------------------------------------------------------------------- | |
2198 | # ? Get sequence | |
2199 | #-------------------------------------------------------------------------- | |
2200 | def get_stand_sequence | |
2201 | seq = '' | |
2202 | states.each do |i| | |
2203 | next if !i | |
2204 | seq += i.get_stand_sequence | |
2205 | end | |
2206 | return seq == '' ? enemy.get_stand_sequence : seq | |
2207 | end | |
2208 | ||
2209 | #-------------------------------------------------------------------------- | |
2210 | # ? Get sequence | |
2211 | #-------------------------------------------------------------------------- | |
2212 | def get_evade_sequence | |
2213 | return enemy.get_evade_sequence | |
2214 | end | |
2215 | ||
2216 | #-------------------------------------------------------------------------- | |
2217 | # ? Get sequence | |
2218 | #-------------------------------------------------------------------------- | |
2219 | def get_miss_sequence | |
2220 | return enemy.get_miss_sequence | |
2221 | end | |
2222 | ||
2223 | #-------------------------------------------------------------------------- | |
2224 | # ? Get sequence | |
2225 | #-------------------------------------------------------------------------- | |
2226 | def get_return_sequence | |
2227 | return enemy.get_return_sequence | |
2228 | end | |
2229 | ||
2230 | #----------------------------------------------------------------------------- | |
2231 | # Gets friend unit | |
2232 | #----------------------------------------------------------------------------- | |
2233 | def friend_unit | |
2234 | return $game_troop | |
2235 | end | |
2236 | ||
2237 | #----------------------------------------------------------------------------- | |
2238 | # Gets enemy unit | |
2239 | #----------------------------------------------------------------------------- | |
2240 | def enemy_unit | |
2241 | return $game_party | |
2242 | end | |
2243 | ||
2244 | #----------------------------------------------------------------------------- | |
2245 | # Gets default battler index | |
2246 | #----------------------------------------------------------------------------- | |
2247 | def default_battler_index | |
2248 | a = enemy.get_default_battler_index | |
2249 | return a ? a : BattleConfig::DefaultEnemyIndex | |
2250 | end | |
2251 | ||
2252 | #----------------------------------------------------------------------------- | |
2253 | # Gets the real presentation action according to situation | |
2254 | #----------------------------------------------------------------------------- | |
2255 | def get_real_presentation_action | |
2256 | return get_dead_sequence if dead? | |
2257 | BattleManager.surprise? ? get_preemptive_sequence : (BattleManager.preemptive? ? get_surprised_sequence : get_presentation_sequence ) | |
2258 | end | |
2259 | ||
2260 | #----------------------------------------------------------------------------- | |
2261 | # Gets the counter skill id | |
2262 | #----------------------------------------------------------------------------- | |
2263 | def counter_skill_id | |
2264 | return @counter_skill_id | |
2265 | end | |
2266 | ||
2267 | #----------------------------------------------------------------------------- | |
2268 | # has dia sequence? | |
2269 | #----------------------------------------------------------------------------- | |
2270 | def die_sequence? | |
2271 | return enemy.note[/<die sequence on>/mi] ? true : false | |
2272 | end | |
2273 | ||
2274 | #----------------------------------------------------------------------------- | |
2275 | # Get weapons | |
2276 | #----------------------------------------------------------------------------- | |
2277 | def weapons | |
2278 | result = [] | |
2279 | result.push($data_weapons[@weapon_1_id]) if @weapon_1_id > 0 | |
2280 | result.push($data_weapons[@weapon_2_id]) if @weapon_2_id > 0 | |
2281 | return result | |
2282 | end | |
2283 | ||
2284 | end | |
2285 | ||
2286 | #============================================================================== | |
2287 | # Β¦ Game_Actor | |
2288 | #============================================================================== | |
2289 | class Game_Actor < Game_Battler | |
2290 | ||
2291 | #----------------------------------------------------------------------------- | |
2292 | # Class atributes | |
2293 | #----------------------------------------------------------------------------- | |
2294 | attr_accessor :battler_name | |
2295 | attr_accessor :battler_hue | |
2296 | attr_accessor :counter_skill_id | |
2297 | ||
2298 | #----------------------------------------------------------------------------- | |
2299 | # Alias methods | |
2300 | #----------------------------------------------------------------------------- | |
2301 | alias rbs_game_actor_setup setup | |
2302 | alias rbs_game_actor_make_actions make_actions | |
2303 | ||
2304 | #-------------------------------------------------------------------------- | |
2305 | # ? Setups an actor by ID | |
2306 | #-------------------------------------------------------------------------- | |
2307 | def setup(actor_id) | |
2308 | rbs_game_actor_setup(actor_id) | |
2309 | @battler_name = actor.note[/<battler name:(.*?)>/im] ? $1 : @character_name | |
2310 | @battler_hue = actor.note[/<battler hue:(.*?)>/im] ? $1.to_i : 0 | |
2311 | @custom_screen_x = actor.note[/<screen x:(.*?)>/im] ? $1.to_i : nil | |
2312 | @custom_screen_y = actor.note[/<screen y:(.*?)>/im] ? $1.to_i : nil | |
2313 | id1 = actor.note[/<atk ani1:(.*?)>/im] ? Kernel.eval($1) : ($data_classes[@class_id].note[/<atk ani1:(.*?)>/im] ? Kernel.eval($1) : BattleConfig::DefaultEnemey_Ani1ID) | |
2314 | id2 = actor.note[/<atk ani2:(.*?)>/im] ? Kernel.eval($1) : ($data_classes[@class_id].note[/<atk ani2:(.*?)>/im] ? Kernel.eval($1) : BattleConfig::DefaultEnemey_Ani2ID) | |
2315 | @default_atk_animation_id1 = id1 | |
2316 | @default_atk_animation_id2 = id2 | |
2317 | c_s_id = $data_classes[@class_id].note[/<counter skill id:(.*?)>/im] ? Kernel.eval($1) : attack_skill_id | |
2318 | @counter_skill_id = actor.note[/<counter skill id:(.*?)>/im] ? Kernel.eval($1) : c_s_id | |
2319 | end | |
2320 | ||
2321 | #-------------------------------------------------------------------------- | |
2322 | # ? Use sprite? | |
2323 | #-------------------------------------------------------------------------- | |
2324 | def use_sprite? | |
2325 | return true | |
2326 | end | |
2327 | ||
2328 | #-------------------------------------------------------------------------- | |
2329 | # ? Get battle screen x position | |
2330 | #-------------------------------------------------------------------------- | |
2331 | def screen_x | |
2332 | return 0 if !self.index | |
2333 | return @custom_screen_x ? @custom_screen_x : BattleConfig::ActorPos[self.index][0] | |
2334 | end | |
2335 | ||
2336 | #-------------------------------------------------------------------------- | |
2337 | # ? Get battle screen y position | |
2338 | #-------------------------------------------------------------------------- | |
2339 | def screen_y | |
2340 | return 0 if !self.index | |
2341 | return @custom_screen_y ? @custom_screen_y : BattleConfig::ActorPos[self.index][1] | |
2342 | end | |
2343 | ||
2344 | #-------------------------------------------------------------------------- | |
2345 | # ? Get battle screen z position | |
2346 | #-------------------------------------------------------------------------- | |
2347 | def screen_z | |
2348 | return 100 | |
2349 | end | |
2350 | ||
2351 | #-------------------------------------------------------------------------- | |
2352 | # ? Get sequence | |
2353 | #-------------------------------------------------------------------------- | |
2354 | def get_turn_start_sequence | |
2355 | seq = '' | |
2356 | equips.each do |i| | |
2357 | next if !i | |
2358 | seq += i.get_turn_start_sequence | |
2359 | end | |
2360 | return seq != '' ? seq : actor.get_turn_start_sequence | |
2361 | end | |
2362 | ||
2363 | #-------------------------------------------------------------------------- | |
2364 | # ? Get sequence | |
2365 | #-------------------------------------------------------------------------- | |
2366 | def get_turn_end_sequence | |
2367 | seq = '' | |
2368 | equips.each do |i| | |
2369 | next if !i | |
2370 | seq += i.get_turn_end_sequence | |
2371 | end | |
2372 | return seq != '' ? seq : actor.get_turn_end_sequence | |
2373 | end | |
2374 | ||
2375 | #-------------------------------------------------------------------------- | |
2376 | # ? Get sequence | |
2377 | #-------------------------------------------------------------------------- | |
2378 | def get_presentation_sequence | |
2379 | seq = '' | |
2380 | equips.each do |i| | |
2381 | next if !i | |
2382 | seq += i.get_presentation_sequence | |
2383 | end | |
2384 | return seq != '' ? seq : actor.get_presentation_sequence | |
2385 | end | |
2386 | ||
2387 | #-------------------------------------------------------------------------- | |
2388 | # ? Get sequence | |
2389 | #-------------------------------------------------------------------------- | |
2390 | def get_surprised_sequence | |
2391 | seq = '' | |
2392 | equips.each do |i| | |
2393 | next if !i | |
2394 | seq += i.get_surprised_sequence | |
2395 | end | |
2396 | return seq != '' ? seq : actor.get_surprised_sequence | |
2397 | end | |
2398 | ||
2399 | #-------------------------------------------------------------------------- | |
2400 | # ? Get sequence | |
2401 | #-------------------------------------------------------------------------- | |
2402 | def get_preemptive_sequence | |
2403 | seq = '' | |
2404 | equips.each do |i| | |
2405 | next if !i | |
2406 | seq += i.get_preemptive_sequence | |
2407 | end | |
2408 | return seq != '' ? seq : actor.get_preemptive_sequence | |
2409 | end | |
2410 | ||
2411 | #-------------------------------------------------------------------------- | |
2412 | # ? Get sequence | |
2413 | #-------------------------------------------------------------------------- | |
2414 | def get_attack_sequence | |
2415 | seq = '' | |
2416 | equips.each do |i| | |
2417 | next if !i | |
2418 | seq += i.get_attack_sequence | |
2419 | end | |
2420 | return seq != '' ? seq : actor.get_attack_sequence | |
2421 | end | |
2422 | ||
2423 | #-------------------------------------------------------------------------- | |
2424 | # ? Get sequence | |
2425 | #-------------------------------------------------------------------------- | |
2426 | def get_guard_sequence | |
2427 | seq = '' | |
2428 | equips.each do |i| | |
2429 | next if !i | |
2430 | seq += i.get_guard_sequence | |
2431 | end | |
2432 | return seq != '' ? seq : actor.get_guard_sequence | |
2433 | end | |
2434 | ||
2435 | #-------------------------------------------------------------------------- | |
2436 | # ? Get sequence | |
2437 | #-------------------------------------------------------------------------- | |
2438 | def get_counter_sequence | |
2439 | seq = '' | |
2440 | equips.each do |i| | |
2441 | next if !i | |
2442 | seq += i.get_counter_sequence | |
2443 | end | |
2444 | return seq != '' ? seq : actor.get_counter_sequence | |
2445 | end | |
2446 | ||
2447 | #-------------------------------------------------------------------------- | |
2448 | # ? Get sequence | |
2449 | #-------------------------------------------------------------------------- | |
2450 | def get_die_sequence | |
2451 | seq = '' | |
2452 | equips.each do |i| | |
2453 | next if !i | |
2454 | seq += i.get_die_sequence | |
2455 | end | |
2456 | return seq != '' ? seq : actor.get_die_sequence | |
2457 | end | |
2458 | ||
2459 | #-------------------------------------------------------------------------- | |
2460 | # ? Get sequence | |
2461 | #-------------------------------------------------------------------------- | |
2462 | def get_dead_sequence | |
2463 | seq = '' | |
2464 | equips.each do |i| | |
2465 | next if !i | |
2466 | seq += i.get_dead_sequence | |
2467 | end | |
2468 | return seq != '' ? seq : actor.get_dead_sequence | |
2469 | end | |
2470 | ||
2471 | #-------------------------------------------------------------------------- | |
2472 | # ? Get sequence | |
2473 | #-------------------------------------------------------------------------- | |
2474 | def get_revive_sequence | |
2475 | seq = '' | |
2476 | equips.each do |i| | |
2477 | next if !i | |
2478 | seq += i.get_revive_sequence | |
2479 | end | |
2480 | return seq != '' ? seq : actor.get_revive_sequence | |
2481 | end | |
2482 | ||
2483 | #-------------------------------------------------------------------------- | |
2484 | # ? Get sequence | |
2485 | #-------------------------------------------------------------------------- | |
2486 | def get_victory_sequence | |
2487 | seq = '' | |
2488 | equips.each do |i| | |
2489 | next if !i | |
2490 | seq += i.get_victory_sequence | |
2491 | end | |
2492 | return seq != '' ? seq : actor.get_victory_sequence | |
2493 | end | |
2494 | ||
2495 | #-------------------------------------------------------------------------- | |
2496 | # ? Get sequence | |
2497 | #-------------------------------------------------------------------------- | |
2498 | def get_substitute_sequence | |
2499 | seq = '' | |
2500 | equips.each do |i| | |
2501 | next if !i | |
2502 | seq += i.get_substitute_sequence | |
2503 | end | |
2504 | return seq != '' ? seq : actor.get_substitute_sequence | |
2505 | end | |
2506 | ||
2507 | #-------------------------------------------------------------------------- | |
2508 | # ? Get sequence | |
2509 | #-------------------------------------------------------------------------- | |
2510 | def get_reflect_sequence | |
2511 | seq = '' | |
2512 | equips.each do |i| | |
2513 | next if !i | |
2514 | seq += i.get_reflect_sequence | |
2515 | end | |
2516 | return seq != '' ? seq : actor.get_reflect_sequence | |
2517 | end | |
2518 | ||
2519 | #-------------------------------------------------------------------------- | |
2520 | # ? Get sequence | |
2521 | #-------------------------------------------------------------------------- | |
2522 | def get_item_use_sequence | |
2523 | seq = '' | |
2524 | equips.each do |i| | |
2525 | next if !i | |
2526 | seq += i.get_item_use_sequence | |
2527 | end | |
2528 | return seq != '' ? seq : actor.get_item_use_sequence | |
2529 | end | |
2530 | ||
2531 | #-------------------------------------------------------------------------- | |
2532 | # ? Get sequence | |
2533 | #-------------------------------------------------------------------------- | |
2534 | def get_skill_use_sequence | |
2535 | seq = '' | |
2536 | equips.each do |i| | |
2537 | next if !i | |
2538 | seq += i.get_skill_use_sequence | |
2539 | end | |
2540 | return seq != '' ? seq : actor.get_skill_use_sequence | |
2541 | end | |
2542 | ||
2543 | #-------------------------------------------------------------------------- | |
2544 | # ? Get sequence | |
2545 | #-------------------------------------------------------------------------- | |
2546 | def get_stand_sequence | |
2547 | seq = '' | |
2548 | equips.each do |i| | |
2549 | next if !i | |
2550 | seq += i.get_stand_sequence if seq == '' | |
2551 | end | |
2552 | states.each do |i| | |
2553 | next if !i | |
2554 | seq += i.get_stand_sequence if seq == '' | |
2555 | end | |
2556 | return seq != '' ? seq : actor.get_stand_sequence | |
2557 | end | |
2558 | ||
2559 | #-------------------------------------------------------------------------- | |
2560 | # ? Get sequence | |
2561 | #-------------------------------------------------------------------------- | |
2562 | def get_evade_sequence | |
2563 | seq = '' | |
2564 | equips.each do |i| | |
2565 | next if !i | |
2566 | seq += i.get_evade_sequence | |
2567 | end | |
2568 | return seq != '' ? seq : actor.get_evade_sequence | |
2569 | end | |
2570 | ||
2571 | #-------------------------------------------------------------------------- | |
2572 | # ? Get sequence | |
2573 | #-------------------------------------------------------------------------- | |
2574 | def get_miss_sequence | |
2575 | seq = '' | |
2576 | equips.each do |i| | |
2577 | next if !i | |
2578 | seq += i.get_miss_sequence if seq == '' | |
2579 | end | |
2580 | return seq != '' ? seq : actor.get_miss_sequence | |
2581 | end | |
2582 | ||
2583 | #-------------------------------------------------------------------------- | |
2584 | # ? Get sequence | |
2585 | #-------------------------------------------------------------------------- | |
2586 | def get_return_sequence | |
2587 | seq = '' | |
2588 | equips.each do |i| | |
2589 | next if !i | |
2590 | seq += i.get_return_sequence if seq == '' | |
2591 | end | |
2592 | states.each do |i| | |
2593 | next if !i | |
2594 | seq += i.get_return_sequence if seq == '' | |
2595 | end | |
2596 | return seq != '' ? seq : actor.get_return_sequence | |
2597 | end | |
2598 | ||
2599 | #--------------------------------------------------------------------------- | |
2600 | # Gets the sequence used when actor is processing an input | |
2601 | #--------------------------------------------------------------------------- | |
2602 | def get_action_selection_sequence | |
2603 | seq = '' | |
2604 | equips.each do |i| | |
2605 | next if !i | |
2606 | seq += i.get_action_selection_sequence if seq == '' | |
2607 | end | |
2608 | states.each do |i| | |
2609 | next if !i | |
2610 | seq += i.get_action_selection_sequence if seq == '' | |
2611 | end | |
2612 | return seq != '' ? seq : actor.get_action_selection_sequence | |
2613 | end | |
2614 | ||
2615 | #----------------------------------------------------------------------------- | |
2616 | # Gets the real presentation action according to situation | |
2617 | #----------------------------------------------------------------------------- | |
2618 | def get_real_presentation_action | |
2619 | return get_dead_sequence if dead? | |
2620 | BattleManager.surprise? ? get_surprised_sequence : (BattleManager.preemptive? ? get_preemptive_sequence : get_presentation_sequence ) | |
2621 | end | |
2622 | ||
2623 | #----------------------------------------------------------------------------- | |
2624 | # Performs collapse effect | |
2625 | #----------------------------------------------------------------------------- | |
2626 | def perform_collapse_effect | |
2627 | case collapse_type | |
2628 | when 0 | |
2629 | @sprite_effect_type = :collapse | |
2630 | Sound.play_enemy_collapse | |
2631 | when 1 | |
2632 | @sprite_effect_type = :boss_collapse | |
2633 | Sound.play_boss_collapse1 | |
2634 | when 2 | |
2635 | @sprite_effect_type = :instant_collapse | |
2636 | end | |
2637 | end | |
2638 | ||
2639 | #----------------------------------------------------------------------------- | |
2640 | # Has die sequence | |
2641 | #----------------------------------------------------------------------------- | |
2642 | def die_sequence? | |
2643 | return actor.note[/<die sequence on>/mi] ? true : false | |
2644 | end | |
2645 | ||
2646 | #-------------------------------------------------------------------------- | |
2647 | # ? Get the attack skill id | |
2648 | #-------------------------------------------------------------------------- | |
2649 | def attack_skill_id | |
2650 | id = actor.get_atk_skill_id | |
2651 | wpns = weapons.compact | |
2652 | if wpns.size > 0 | |
2653 | w = wpns[rand(wpns.size)] | |
2654 | id2 = w.get_atk_skill_id | |
2655 | id = id2 if id2 | |
2656 | end | |
2657 | return id ? id : super | |
2658 | end | |
2659 | #-------------------------------------------------------------------------- | |
2660 | # ? Get the guard skill id | |
2661 | #-------------------------------------------------------------------------- | |
2662 | def guard_skill_id | |
2663 | id = actor.get_guard_skill_id | |
2664 | armrs = armors.compact | |
2665 | if armrs.size > 0 | |
2666 | a = armrs[rand(armrs.size)] | |
2667 | id2 = a.get_guard_skill_id | |
2668 | id = id2 if id2 | |
2669 | end | |
2670 | return id ? id : super | |
2671 | end | |
2672 | ||
2673 | #----------------------------------------------------------------------------- | |
2674 | # Get friend unit | |
2675 | #----------------------------------------------------------------------------- | |
2676 | def friend_unit | |
2677 | return $game_party | |
2678 | end | |
2679 | ||
2680 | #----------------------------------------------------------------------------- | |
2681 | # Get enemy unit | |
2682 | #----------------------------------------------------------------------------- | |
2683 | def enemy_unit | |
2684 | return $game_troop | |
2685 | end | |
2686 | ||
2687 | #----------------------------------------------------------------------------- | |
2688 | # Get default battler index | |
2689 | #----------------------------------------------------------------------------- | |
2690 | def default_battler_index | |
2691 | a = actor.get_default_battler_index | |
2692 | return a ? a : BattleConfig::DefaultActorIndex | |
2693 | end | |
2694 | ||
2695 | #----------------------------------------------------------------------------- | |
2696 | # Get attack animation 1 | |
2697 | #----------------------------------------------------------------------------- | |
2698 | def atk_animation_id1 | |
2699 | if dual_wield? | |
2700 | return weapons[0].animation_id if weapons[0] | |
2701 | return weapons[1] ? 0 : @default_atk_animation_id1 | |
2702 | else | |
2703 | return weapons[0] ? weapons[0].animation_id : 1 | |
2704 | end | |
2705 | end | |
2706 | ||
2707 | #----------------------------------------------------------------------------- | |
2708 | # Get attack animation 2 | |
2709 | #----------------------------------------------------------------------------- | |
2710 | def atk_animation_id2 | |
2711 | if dual_wield? | |
2712 | return weapons[1] ? weapons[1].animation_id : @default_atk_animation_id2 | |
2713 | else | |
2714 | return 0 | |
2715 | end | |
2716 | end | |
2717 | ||
2718 | #----------------------------------------------------------------------------- | |
2719 | # Get counter attack skill id | |
2720 | #----------------------------------------------------------------------------- | |
2721 | def counter_skill_id | |
2722 | id = @counter_skill_id | |
2723 | equips.each do |i| | |
2724 | next if !i | |
2725 | id = i.note[/<counter skill id:(.*?)>/im] ? Kernel.eval($1) : id | |
2726 | end | |
2727 | return id | |
2728 | end | |
2729 | ||
2730 | end | |
2731 | ||
2732 | #============================================================================== | |
2733 | # Β¦ Game_Picture | |
2734 | #------------------------------------------------------------------------------ | |
2735 | # ??????????????????? Game_Pictures ?????????? | |
2736 | # ?????????????????????????? | |
2737 | #============================================================================== | |
2738 | ||
2739 | class Game_Picture | |
2740 | ||
2741 | #----------------------------------------------------------------------------- | |
2742 | # Class atributes | |
2743 | #----------------------------------------------------------------------------- | |
2744 | attr_accessor :animation_id | |
2745 | attr_accessor :animation_flip | |
2746 | ||
2747 | #----------------------------------------------------------------------------- | |
2748 | # Alias methods | |
2749 | #----------------------------------------------------------------------------- | |
2750 | alias rbs_game_picture_init_basic init_basic | |
2751 | ||
2752 | #----------------------------------------------------------------------------- | |
2753 | # Start basic information | |
2754 | #----------------------------------------------------------------------------- | |
2755 | def init_basic | |
2756 | @animation_id = 0 | |
2757 | @animation_flip = false | |
2758 | rbs_game_picture_init_basic | |
2759 | end | |
2760 | ||
2761 | #----------------------------------------------------------------------------- | |
2762 | # Move ex | |
2763 | #----------------------------------------------------------------------------- | |
2764 | def move_ex(x, y, duration) | |
2765 | @target_x = x.to_f | |
2766 | @target_y = y.to_f | |
2767 | @duration = duration | |
2768 | end | |
2769 | ||
2770 | #----------------------------------------------------------------------------- | |
2771 | # Set zoom | |
2772 | #----------------------------------------------------------------------------- | |
2773 | def set_zoom(zoom_x, zoom_y, duration) | |
2774 | @target_zoom_x = zoom_x.to_f | |
2775 | @target_zoom_y = zoom_y.to_f | |
2776 | @duration = duration | |
2777 | end | |
2778 | ||
2779 | #----------------------------------------------------------------------------- | |
2780 | # Set opacity | |
2781 | #----------------------------------------------------------------------------- | |
2782 | def set_opacity(opacity, duration) | |
2783 | @target_opacity = opacity.to_f | |
2784 | @duration = duration | |
2785 | end | |
2786 | ||
2787 | #----------------------------------------------------------------------------- | |
2788 | # Set animation | |
2789 | #----------------------------------------------------------------------------- | |
2790 | def set_animation(animation_id, flip=false) | |
2791 | @animation_id = animation_id | |
2792 | @animation_flip = flip | |
2793 | end | |
2794 | ||
2795 | end | |
2796 | ||
2797 | #=============================================================================== | |
2798 | # END GAME OBJECTS SECTION | |
2799 | #=============================================================================== | |
2800 | ||
2801 | #=============================================================================== | |
2802 | # BEGIN WINDOW SECTION | |
2803 | #=============================================================================== | |
2804 | ||
2805 | if !$imported["YEA-BattleEngine"] # If you use YEA please configure it from YEA. | |
2806 | ||
2807 | ||
2808 | ||
2809 | end # if $imported["YEA-BattleEngine"] | |
2810 | ||
2811 | #============================================================================== | |
2812 | # Β¦ Window_BattleItem | |
2813 | #============================================================================== | |
2814 | class Window_BattleItem < Window_ItemList | |
2815 | ||
2816 | #-------------------------------------------------------------------------- | |
2817 | # ? Object creation | |
2818 | #-------------------------------------------------------------------------- | |
2819 | def initialize(help_window, info_viewport) | |
2820 | y = Graphics.height - window_height | |
2821 | super(0, y, window_width, window_height) | |
2822 | self.visible = false | |
2823 | @help_window = help_window | |
2824 | @info_viewport = info_viewport | |
2825 | end | |
2826 | ||
2827 | #-------------------------------------------------------------------------- | |
2828 | # ? Get window width | |
2829 | #-------------------------------------------------------------------------- | |
2830 | def window_width | |
2831 | Graphics.width | |
2832 | end | |
2833 | ||
2834 | #-------------------------------------------------------------------------- | |
2835 | # ? Get window height | |
2836 | #-------------------------------------------------------------------------- | |
2837 | def window_height | |
2838 | fitting_height(visible_line_number) | |
2839 | end | |
2840 | ||
2841 | #-------------------------------------------------------------------------- | |
2842 | # ? Get visible line muber | |
2843 | #-------------------------------------------------------------------------- | |
2844 | def visible_line_number | |
2845 | return 4 | |
2846 | end | |
2847 | ||
2848 | ||
2849 | end | |
2850 | ||
2851 | #============================================================================== | |
2852 | # Β¦ Window_BattleSkill | |
2853 | #------------------------------------------------------------------------------ | |
2854 | # ??????????????????????????? | |
2855 | #============================================================================== | |
2856 | ||
2857 | class Window_BattleSkill < Window_SkillList | |
2858 | ||
2859 | #-------------------------------------------------------------------------- | |
2860 | # ? Object Creation | |
2861 | #-------------------------------------------------------------------------- | |
2862 | def initialize(help_window, info_viewport) | |
2863 | y = Graphics.height - window_height | |
2864 | super(0, y, window_width, window_height) | |
2865 | self.visible = false | |
2866 | @help_window = help_window | |
2867 | @info_viewport = info_viewport | |
2868 | end | |
2869 | #-------------------------------------------------------------------------- | |
2870 | # ? Gets window width | |
2871 | #-------------------------------------------------------------------------- | |
2872 | def window_width | |
2873 | Graphics.width | |
2874 | end | |
2875 | #-------------------------------------------------------------------------- | |
2876 | # ? Gets window height | |
2877 | #-------------------------------------------------------------------------- | |
2878 | def window_height | |
2879 | fitting_height(visible_line_number) | |
2880 | end | |
2881 | ||
2882 | #-------------------------------------------------------------------------- | |
2883 | # ? Get visible line muber | |
2884 | #-------------------------------------------------------------------------- | |
2885 | def visible_line_number | |
2886 | return 4 | |
2887 | end | |
2888 | ||
2889 | end | |
2890 | ||
2891 | #=============================================================================== | |
2892 | # END WINDOW SECTION | |
2893 | #=============================================================================== | |
2894 | ||
2895 | #=============================================================================== | |
2896 | # BEGIN SCENE SECTION | |
2897 | #=============================================================================== | |
2898 | ||
2899 | #============================================================================== | |
2900 | # Β¦ Scene_Battle | |
2901 | #============================================================================== | |
2902 | class Scene_Battle < Scene_Base | |
2903 | #-------------------------------------------------------------------------- | |
2904 | # ? Alias methods | |
2905 | #-------------------------------------------------------------------------- | |
2906 | alias rbs_scene_battle_start start | |
2907 | alias rbs_scene_battle_post_start post_start | |
2908 | alias rbs_scene_battle_battle_start battle_start | |
2909 | alias rbs_scene_battle_use_item use_item | |
2910 | alias rbs_scene_battle_update_basic update_basic | |
2911 | alias rbs_scene_battle_start_actor_command_selection start_actor_command_selection | |
2912 | alias rbs_scene_battle_next_command next_command | |
2913 | alias rbs_scene_battle_prior_command prior_command | |
2914 | ||
2915 | #-------------------------------------------------------------------------- | |
2916 | # ? Start scene | |
2917 | #-------------------------------------------------------------------------- | |
2918 | def start | |
2919 | BattleCamera.start | |
2920 | rbs_scene_battle_start | |
2921 | BattleInterpreter.start(@spriteset) | |
2922 | setup_battle_commands | |
2923 | end | |
2924 | ||
2925 | #-------------------------------------------------------------------------- | |
2926 | # ? Post star scene | |
2927 | #-------------------------------------------------------------------------- | |
2928 | def post_start | |
2929 | rbs_scene_battle_post_start | |
2930 | show_presentation_animation | |
2931 | end | |
2932 | ||
2933 | #-------------------------------------------------------------------------- | |
2934 | # ? Start battle | |
2935 | #-------------------------------------------------------------------------- | |
2936 | def battle_start | |
2937 | rbs_scene_battle_battle_start | |
2938 | end | |
2939 | ||
2940 | #-------------------------------------------------------------------------- | |
2941 | # ? Get next command | |
2942 | #-------------------------------------------------------------------------- | |
2943 | def next_command | |
2944 | if BattleManager.actor | |
2945 | actor = BattleManager.actor | |
2946 | BattleInterpreter.add_looping_action(actor, actor.get_stand_sequence) | |
2947 | BattleInterpreter.add_action(actor, [actor], actor.get_turn_end_sequence, $data_skills[1]) | |
2948 | wait_for_battle_interpreter | |
2949 | end | |
2950 | rbs_scene_battle_next_command | |
2951 | end | |
2952 | ||
2953 | #-------------------------------------------------------------------------- | |
2954 | # ? Get Prior command | |
2955 | #-------------------------------------------------------------------------- | |
2956 | def prior_command | |
2957 | if BattleManager.actor | |
2958 | actor = BattleManager.actor | |
2959 | BattleInterpreter.add_looping_action(actor, actor.get_stand_sequence) | |
2960 | BattleInterpreter.add_action(actor, [actor], actor.get_turn_end_sequence, $data_skills[1]) | |
2961 | wait_for_battle_interpreter | |
2962 | end | |
2963 | rbs_scene_battle_prior_command | |
2964 | end | |
2965 | ||
2966 | #-------------------------------------------------------------------------- | |
2967 | # ? Show presentation animation | |
2968 | #-------------------------------------------------------------------------- | |
2969 | def show_presentation_animation | |
2970 | @spriteset.update | |
2971 | act = @party_command_window.active | |
2972 | @party_command_window.deactivate | |
2973 | @party_command_window.hide | |
2974 | for member in $game_party.members+$game_troop.members | |
2975 | sequence = member.get_real_presentation_action | |
2976 | BattleInterpreter.add_action(member, [member], sequence, $data_skills[1]) | |
2977 | end | |
2978 | wait_for_battle_interpreter | |
2979 | wait(20) | |
2980 | @spriteset.make_return_sequence | |
2981 | wait_for_battle_interpreter | |
2982 | if $imported["YEA-BattleEngine"] | |
2983 | @party_command_window.show | |
2984 | @party_command_window.active = act | |
2985 | else | |
2986 | @party_command_window.activate | |
2987 | @party_command_window.show | |
2988 | end | |
2989 | end | |
2990 | ||
2991 | #-------------------------------------------------------------------------- | |
2992 | # ? Start actor command selection | |
2993 | #-------------------------------------------------------------------------- | |
2994 | def start_actor_command_selection | |
2995 | if BattleManager.actor | |
2996 | actor = BattleManager.actor | |
2997 | BattleInterpreter.add_looping_action(actor, actor.get_action_selection_sequence) | |
2998 | BattleInterpreter.add_action(actor, [actor], actor.get_turn_start_sequence, $data_skills[1]) | |
2999 | wait_for_battle_interpreter | |
3000 | end | |
3001 | rbs_scene_battle_start_actor_command_selection | |
3002 | end | |
3003 | ||
3004 | #-------------------------------------------------------------------------- | |
3005 | # ? Show attack animation | |
3006 | #-------------------------------------------------------------------------- | |
3007 | def show_attack_animation(targets) | |
3008 | show_normal_animation(targets, @subject.atk_animation_id1, false) | |
3009 | wait_for_animation | |
3010 | show_normal_animation(targets, @subject.atk_animation_id2, true) | |
3011 | end | |
3012 | ||
3013 | #-------------------------------------------------------------------------- | |
3014 | # ? Use item | |
3015 | #-------------------------------------------------------------------------- | |
3016 | def use_item | |
3017 | setup_dead_battlers | |
3018 | item = @subject.current_action.item | |
3019 | sequence = get_sequence(@subject, item) | |
3020 | @log_window.display_use_item(@subject, item) | |
3021 | @subject.use_item(item) | |
3022 | if $imported["YEA-LunaticObjects"] | |
3023 | lunatic_object_effect(:before, item, @subject, @subject) | |
3024 | end | |
3025 | if sequence == '' | |
3026 | refresh_status | |
3027 | targets = @subject.current_action.make_targets.compact | |
3028 | show_animation(targets, item.animation_id) | |
3029 | targets.each {|target| item.repeats.times { invoke_item(target, item) } } | |
3030 | else | |
3031 | targets = @subject.current_action.make_targets.compact | |
3032 | if $imported["YEA-TargetManager"] | |
3033 | if item.for_random? | |
3034 | targets = targets.collect do |target| | |
3035 | alive_random_target(target, item) | |
3036 | end | |
3037 | end | |
3038 | end | |
3039 | process_casting_animation if $imported["YEA-CastAnimations"] | |
3040 | BattleInterpreter.add_action(@subject, targets, sequence, item) | |
3041 | wait_for_battle_interpreter | |
3042 | end | |
3043 | if $imported["YEA-LunaticObjects"] | |
3044 | lunatic_object_effect(:after, item, @subject, @subject) | |
3045 | end | |
3046 | finish_item_use | |
3047 | end | |
3048 | ||
3049 | def setup_dead_battlers | |
3050 | @dead_battlers = [] | |
3051 | for battler in $game_troop.dead_members+$game_party.dead_members | |
3052 | @dead_battlers.push(battler) if battler.dead? | |
3053 | end | |
3054 | end | |
3055 | ||
3056 | def finish_item_use | |
3057 | @spriteset.make_return_sequence | |
3058 | wait_for_battle_interpreter | |
3059 | for battler in $game_troop.members+$game_party.members | |
3060 | if battler.dead? && !@dead_battlers.include?(battler) | |
3061 | @dead_battlers.delete(battler) | |
3062 | if battler.die_sequence? | |
3063 | sequence = battler.get_die_sequence | |
3064 | BattleInterpreter.add_action(battler, [battler], sequence, nil, false) | |
3065 | else | |
3066 | battler.perform_collapse_effect | |
3067 | end | |
3068 | elsif battler.alive? && @dead_battlers.include?(battler) | |
3069 | sequence = battler.get_revive_sequence | |
3070 | BattleInterpreter.add_action(battler, [battler], sequence, nil, false) | |
3071 | end | |
3072 | end | |
3073 | wait_for_battle_interpreter | |
3074 | end | |
3075 | ||
3076 | #-------------------------------------------------------------------------- | |
3077 | # ? Gets the sequence for an item | |
3078 | #-------------------------------------------------------------------------- | |
3079 | def get_sequence(subject, item) | |
3080 | sequence = item.get_attack_sequence | |
3081 | if item.is_a?(RPG::Skill) and item.id == subject.attack_skill_id | |
3082 | seq = subject.get_attack_sequence | |
3083 | if seq != '' | |
3084 | sequence = seq | |
3085 | end | |
3086 | elsif item.is_a?(RPG::Skill) and item.id == subject.guard_skill_id | |
3087 | seq = subject.get_guard_sequence | |
3088 | if seq != '' | |
3089 | sequence = seq | |
3090 | end | |
3091 | end | |
3092 | if sequence == '' | |
3093 | if item.is_a?(RPG::Skill) | |
3094 | seq = subject.get_skill_use_sequence | |
3095 | if seq != '' | |
3096 | sequence = seq | |
3097 | end | |
3098 | elsif item.is_a?(RPG::Item) | |
3099 | seq = subject.get_item_use_sequence | |
3100 | if seq != '' | |
3101 | sequence = seq | |
3102 | end | |
3103 | end | |
3104 | end | |
3105 | return sequence | |
3106 | end | |
3107 | ||
3108 | #-------------------------------------------------------------------------- | |
3109 | # ? Wait for battle interpreter | |
3110 | #-------------------------------------------------------------------------- | |
3111 | def wait_for_battle_interpreter | |
3112 | update_for_wait while BattleInterpreter.running? | |
3113 | wait_for_animation | |
3114 | end | |
3115 | ||
3116 | #-------------------------------------------------------------------------- | |
3117 | # ? Basic update | |
3118 | #-------------------------------------------------------------------------- | |
3119 | def update_basic | |
3120 | rbs_scene_battle_update_basic | |
3121 | BattleCamera.update | |
3122 | BattleInterpreter.update | |
3123 | end | |
3124 | ||
3125 | #-------------------------------------------------------------------------- | |
3126 | # ? Show animation ex | |
3127 | #-------------------------------------------------------------------------- | |
3128 | def show_animation_ex(targets, animation_id, mirror = false) | |
3129 | return if !targets || targets.empty? | |
3130 | animation = $data_animations[animation_id] | |
3131 | if animation | |
3132 | if animation.to_screen? | |
3133 | target = targets[0] | |
3134 | target.start_animation(animation, mirror) | |
3135 | else | |
3136 | targets.each do |target| | |
3137 | target.start_animation(animation, mirror) | |
3138 | end | |
3139 | end | |
3140 | end | |
3141 | end | |
3142 | ||
3143 | #-------------------------------------------------------------------------- | |
3144 | # ? Apply item efects | |
3145 | #-------------------------------------------------------------------------- | |
3146 | def apply_item_effects_ex(user, target, item) | |
3147 | if $imported["YEA-LunaticObjects"] | |
3148 | lunatic_object_effect(:prepare, item, user, target) | |
3149 | end | |
3150 | target.item_apply(user, item) | |
3151 | if $imported["YEA-LunaticObjects"] | |
3152 | lunatic_object_effect(:during, item, user, target) | |
3153 | end | |
3154 | refresh_status | |
3155 | @log_window.display_action_results(target, item) | |
3156 | end | |
3157 | ||
3158 | #-------------------------------------------------------------------------- | |
3159 | # ? Invoke counter attack | |
3160 | #-------------------------------------------------------------------------- | |
3161 | def invoke_counter_attack_ex(user, target, item) | |
3162 | @log_window.display_counter(target, item) | |
3163 | attack_skill = $data_skills[target.counter_skill_id] | |
3164 | sequence = attack_skill.get_counter_sequence | |
3165 | sequence = target.get_counter_sequence if sequence == '' | |
3166 | BattleInterpreter.add_action(target, [user], sequence, attack_skill, false) | |
3167 | @log_window.display_action_results(target, attack_skill) | |
3168 | end | |
3169 | ||
3170 | #-------------------------------------------------------------------------- | |
3171 | # ? Invoke magic reflection | |
3172 | #-------------------------------------------------------------------------- | |
3173 | def invoke_magic_reflection_ex(action, target) | |
3174 | item = action.item | |
3175 | user = action.user | |
3176 | @log_window.display_reflection(target, item) | |
3177 | action.targets.delete(target) | |
3178 | action.targets.push(user) | |
3179 | sequence = target.get_reflect_sequence | |
3180 | BattleInterpreter.add_action(target, [user], sequence, item, false) | |
3181 | end | |
3182 | ||
3183 | #-------------------------------------------------------------------------- | |
3184 | # ? Apply substitute | |
3185 | #-------------------------------------------------------------------------- | |
3186 | def apply_substitute_ex(action, target, item) | |
3187 | if check_substitute(target, item) | |
3188 | substitute = target.friends_unit.substitute_battler | |
3189 | if substitute && target != substitute && !@substitutes.include?(substitute) | |
3190 | @log_window.display_substitute(substitute, target) | |
3191 | sequence = substitute.get_substitute_sequence | |
3192 | action.targets.delete(target) | |
3193 | action.targets.push(substitute) | |
3194 | @substitutes.push(substitute) | |
3195 | BattleInterpreter.add_action(substitute, [target], sequence, item) | |
3196 | end | |
3197 | end | |
3198 | end | |
3199 | ||
3200 | #-------------------------------------------------------------------------- | |
3201 | # ? Get battler sprites | |
3202 | #-------------------------------------------------------------------------- | |
3203 | def get_sprites(battlers) | |
3204 | battlers.collect do |battler| | |
3205 | @spriteset.battler_sprite(battler) | |
3206 | end | |
3207 | end | |
3208 | ||
3209 | end | |
3210 | ||
3211 | #=============================================================================== | |
3212 | # END SCENE SECTION | |
3213 | #=============================================================================== | |
3214 | ||
3215 | #=============================================================================== | |
3216 | # START YEA COMPATIBILITY | |
3217 | #=============================================================================== | |
3218 | ||
3219 | if $imported["YEA-BattleEngine"] | |
3220 | ||
3221 | #============================================================================== | |
3222 | # Β¦ Sprite_Popup | |
3223 | #============================================================================== | |
3224 | ||
3225 | class Scene_Battle < Scene_Base | |
3226 | attr_accessor :spriteset | |
3227 | end | |
3228 | ||
3229 | class Sprite_Popup < Sprite_Base | |
3230 | ||
3231 | attr_accessor :current_x | |
3232 | attr_accessor :current_y | |
3233 | ||
3234 | alias rbs_yea_sprite_popup_create_popup_bitmap create_popup_bitmap | |
3235 | ||
3236 | #-------------------------------------------------------------------------- | |
3237 | # create_popup_bitmap | |
3238 | #-------------------------------------------------------------------------- | |
3239 | def create_popup_bitmap | |
3240 | rbs_yea_sprite_popup_create_popup_bitmap | |
3241 | @current_x = @battler.sprite.current_x | |
3242 | @current_y = @battler.sprite.current_y | |
3243 | @current_x += rand(4) - rand(4) if @battler.sprite.popups.size >= 1 | |
3244 | @current_x -= SceneManager.scene.spriteset.viewport1.ox | |
3245 | @current_y = @battler.sprite.current_y - @battler.sprite.oy/2 | |
3246 | @current_y -= @battler.sprite.oy/2 if @battler.actor? | |
3247 | @current_y -= SceneManager.scene.spriteset.viewport1.oy | |
3248 | update | |
3249 | end | |
3250 | ||
3251 | #-------------------------------------------------------------------------- | |
3252 | # update | |
3253 | #-------------------------------------------------------------------------- | |
3254 | def update | |
3255 | super | |
3256 | @current_zoom_x = 0 if !@current_zoom_x | |
3257 | @current_zoom_y = 0 if !@current_zoom_y | |
3258 | @current_x = self.x if !@current_x | |
3259 | @current_y = self.y if !@current_y | |
3260 | #--- | |
3261 | if @flags.include?("critical") && YEA::BATTLE::FLASH_CRITICAL | |
3262 | @hue_duration = 2 if @hue_duration == nil || @hue_duration == 0 | |
3263 | @hue_duration -= 1 | |
3264 | self.bitmap.hue_change(15) if @hue_duration <= 0 | |
3265 | end | |
3266 | #--- | |
3267 | if @zoom_direction == "up" | |
3268 | @current_zoom_x = [@current_zoom_x + 0.075, @target_zoom].min | |
3269 | @current_zoom_y = [@current_zoom_y + 0.075, @target_zoom].min | |
3270 | else | |
3271 | @current_zoom_x = [@current_zoom_x - 0.075, @target_zoom].max | |
3272 | @current_zoom_y = [@current_zoom_y - 0.075, @target_zoom].max | |
3273 | end | |
3274 | self.zoom_x = BattleCamera.correct_zoom(@current_zoom_x) | |
3275 | self.zoom_y = BattleCamera.correct_zoom(@current_zoom_y) | |
3276 | ||
3277 | self.x = BattleCamera.correct_x(@current_x) | |
3278 | self.y = BattleCamera.correct_y(@current_y) | |
3279 | ||
3280 | #--- | |
3281 | @full -= 1 | |
3282 | return if @full > 0 | |
3283 | @current_y -= 1 | |
3284 | self.opacity -= @fade | |
3285 | self.y = BattleCamera.correct_y(@current_y) | |
3286 | end | |
3287 | ||
3288 | end | |
3289 | ||
3290 | class Sprite_Battler < Sprite_Base | |
3291 | ||
3292 | alias rbs_yea_create_new_popup create_new_popup | |
3293 | ||
3294 | #-------------------------------------------------------------------------- | |
3295 | # new method: create_new_popup | |
3296 | #-------------------------------------------------------------------------- | |
3297 | def create_new_popup(value, rules, flags) | |
3298 | return if @battler == nil | |
3299 | return if flags & @popup_flags != [] | |
3300 | for popup in @popups | |
3301 | popup.current_y -= 24 | |
3302 | end | |
3303 | rbs_yea_create_new_popup(value, rules, flags) | |
3304 | end | |
3305 | ||
3306 | end | |
3307 | ||
3308 | end | |
3309 | ||
3310 | #=============================================================================== | |
3311 | # END YEA COMPATIBILITY | |
3312 | #=============================================================================== | |
3313 | ||
3314 | #=============================================================================== | |
3315 | # END OF FILE!!! | |
3316 | #=============================================================================== |