Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Dhoom
- module FallEvent
- Terrain_ID = 6
- Fall_SE = "fall"
- Fall_Duration = 60
- Fall_Angle_Speed = 6
- #Fall_Damage = [Min, Max]
- Fall_Damage = [100,200]
- end
- end
- class Game_Temp
- attr_accessor :fallback_coordinate
- def set_fallback_coordinate(x,y)
- @fallback_coordinate = [x,y]
- end
- end
- class Game_CharacterBase
- attr_reader :angle
- alias dhoom_fallevent_gamecharacterbase_init_public_members init_public_members
- def init_public_members
- dhoom_fallevent_gamecharacterbase_init_public_members
- @angle = 0
- end
- alias dhoom_fallevent_gamecharacterbase_init_private_members init_private_members
- def init_private_members
- dhoom_fallevent_gamecharacterbase_init_private_members
- @falling = false
- end
- alias dhoom_fallevent_gamecharacterbase_update update
- def update
- update_animation
- dhoom_fallevent_gamecharacterbase_update
- return update_fall if falling?
- end
- alias dhoom_fallevent_gamecharacterbase_move_straight move_straight
- def move_straight(d, turn_ok = true)
- @temp_x = @x
- @temp_y = @y
- dhoom_fallevent_gamecharacterbase_move_straight(d, turn_ok)
- if @move_succeed
- fall_event if $game_map.terrain_tag(x, y) == Dhoom::FallEvent::Terrain_ID
- end
- end
- def falling?
- @falling
- end
- def fall_event
- return if falling?
- @falling = true
- @se = RPG::SE.new(Dhoom::FallEvent::Fall_SE) if @se.nil?
- @se.play
- end
- def update_fall
- if @opacity > 0
- @opacity -= [1, 255.0/Dhoom::FallEvent::Fall_Duration].max
- @angle += Dhoom::FallEvent::Fall_Angle_Speed
- else
- @falling = false
- if $game_party.members[0].hp <= Dhoom::FallEvent::Fall_Damage[1]
- moveto($game_temp.fallback_coordinate[0],$game_temp.fallback_coordinate[1])
- else
- moveto(@temp_x, @temp_y)
- end
- @angle = 0
- @opacity = 255
- for actor in $game_party.members
- r = Dhoom::FallEvent::Fall_Damage[0]+rand(Dhoom::FallEvent::Fall_Damage[1]-Dhoom::FallEvent::Fall_Damage[0]+1)
- actor.change_hp(-r, true)
- end
- end
- end
- end
- class Game_Player < Game_Character
- alias dhoom_fallevent_gameplayer_passable? passable?
- def passable?(x, y, d)
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- return false unless $game_map.valid?(x2, y2)
- return true if $game_map.terrain_tag(x2, y2) == Dhoom::FallEvent::Terrain_ID
- dhoom_fallevent_gameplayer_passable?(x, y, d)
- end
- alias dhoom_fallevent_gameplayer_movable? movable?
- def movable?
- return false if falling?
- dhoom_fallevent_gameplayer_movable?
- end
- end
- class Sprite_Character < Sprite_Base
- alias dhoom_fallevent_sprchara_update_other update_other
- def update_other
- dhoom_fallevent_sprchara_update_other
- self.angle = @character.angle
- if @character.falling?
- self.ox = self.width/2
- self.oy = self.height/2
- else
- if @tile_id > 0
- self.ox = 16
- self.oy = 32
- else
- self.ox = @cw / 2
- self.oy = @ch
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement