[RMVX ACE] CONVERT RGSS2 TO RGSS3

Posts

Pages: 1
I've been looking for a script which enables myself to customize shakes.
All I want to do is to shake only windows during battles and I actually found a script but it's RGSS2.
Could you convert the script to RGSS3?

http://img.atwikiimg.com/www20.atwiki.jp/type74rx-t/attach/175/294/rx2_damage_plus_shake.txt
I haven't had to mess with the battle scene, but taking a quick look, you may be able to manually shake the window by rapidly shifting around its x & y coordinates. I think the variable's name is "@message_window".

so making a parallel process common event which is triggered by a switch with a script that says something like

@message_window.x += -2 + rand(4)
wait(2)
@message_window.x = 0

should add or subtract 1 or 2 pixels to the window's x coordinate, which would give it a shake effect when the switch is on.
Thank you for your reply!
I did exactly what you said and the following error occurred.
Do you know why this happened?

Try this:

#
#    ダメージを受けたときにウインドウをシェイク(RGSS2)
#  シェイク:(C)2011 イノビア
#  アレンジ:(C)2011 TYPE74RX-T
#

# カスタマイズポイント:10~11行目

module RX_T
  SHAKE_TIMES = 64
  MOVES_WINDOW = 32
  # ※:SHAKE_TIMES:シェイク回数、MOVES_WINDOW:ウインドウの最大移動量
end

def shake(shakes = 64, moves = 32)
  # ウィンドウハンドルを取得して hwnd に代入
  # FindWindow関数を使った方が良いかもしれませんが。
 
  get_a_win = Win32API.new('user32','GetActiveWindow','v','l')
  hwnd = get_a_win.call()
 
  # ウィンドウの現在位置を取得 (スクリーン座標系)
  get_w_rect = Win32API.new('user32', 'GetWindowRect', 'l p', 'l')
  tmp = [0, 0, 0, 0].pack("l4")
  get_w_rect.call(hwnd, tmp)
  wRect = tmp.unpack("l4")
 
  # ウィンドウをシェイク♪
  # 以下では shakes 回シェイク、最大移動量を moves ピクセルまで(乱数)
  mw = Win32API.new('user32', 'MoveWindow', 'l l l l l l', 'l')
  i=0
  while i < shakes do
    mw.call(hwnd,wRect[0]+rand(moves),wRect[1]+rand(moves),wRect[2]-wRect[0],wRect[3]-wRect[1],1)
    i += 1
    sleep(0.01)
  end
 
  # 元の位置に戻す
  mw.call(hwnd,wRect[0],wRect[1],wRect[2]-wRect[0],wRect[3]-wRect[1],1)
end

class Scene_Battle < Scene_Base

  alias :apply_item_effects_shakeit :apply_item_effects unless $@
  def apply_item_effects(target, item)
    # Call the original method
    apply_item_effects_shakeit(target, item)
    # Then call the shake method if the action result means we shake it!
    shake(RX_T::SHAKE_TIMES, RX_T::MOVES_WINDOW) if target.actor? and target.result.hp_damage > 0
  end
end

I threw it in a demo project here too.

e: For reference, I only changed the bottom part and put it in the closest equivalent location in the battle code I could quickly dig up. The shake code itself is independent of RGSS2/3 so I didn't touch that part at all.
author=happydeadman
Thank you for your reply!
I did exactly what you said and the following error occurred.
Do you know why this happened?



No not really. lol

I would probably try it 100 different ways until I learned why though...

I think the game is trying to access @message_window from the game interpreter, but @message_window doesn't exist there, so it calls it NilClass. I think we'd have to put something in front of it like $game_screen, or $game_map, wherever that variable exists... so it would look something like "$game_screen.message_window.x" (this wont work, already tried)

Anyway, I'm not familiar with the Battle_Scene or how to access its elements from common events. But it looks like you should have a real fix now!
author=GreatRedSpirit
I threw it in a demo project here too.

e: For reference, I only changed the bottom part and put it in the closest equivalent location in the battle code I could quickly dig up. The shake code itself is independent of RGSS2/3 so I didn't touch that part at all.


You perfectly converted the old script to the new one.
I really appreciate your help.

I think the author of the original script should have removed default shakes to make games look better.
It's a bit strange to shake twice when actors are attacked.
Please tell me if you know how to remove the default shakes.

author=Infinite
Anyway, I'm not familiar with the Battle_Scene or how to access its elements from common events. But it looks like you should have a real fix now!


Thank you for your reply!
I'm not familiar with this kind of matters,either...
Probably I should learn a program language first.
Oh sure. In Game_Actor @ line 531 there's
def perform_damage_effect
    $game_troop.screen.start_shake(5, 5, 10)
    @sprite_effect_type = :blink
    Sound.play_actor_damage
  end
Just remove the start_shake method there so it's something like:
def perform_damage_effect
    #$game_troop.screen.start_shake(5, 5, 10)
    @sprite_effect_type = :blink
    Sound.play_actor_damage
  end
It perfectly works!
Thank you so much for your help!
Glad to help :)

If you want to replace the original shake entirely you can go to the Game_Screen class on line 119 where there's:
def start_shake(power, speed, duration)
    @shake_power = power
    @shake_speed = speed
    @shake_duration = duration
  end
You can replace that with
def start_shake(power, speed, duration)
    #@shake_power = power
    #@shake_speed = speed
    #@shake_duration = duration
    shake(RX_T::SHAKE_TIMES, RX_T::MOVES_WINDOW)
  end
and that should replace the original Ace shake with the new window shake script through the entire game. (although I haven't tested it)
I don't know why but shakes are a little bit delayed.
It'll be perfect if the default shakes are accurately replaced.
I'm pretty satisfied with your work though :)
https://www.youtube.com/watch?v=H7RCXrpThSg&feature=youtu.be
Pages: 1