mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-22 23:57:01 +00:00
Update 6.8
This commit is contained in:
@@ -13,7 +13,7 @@ class Game_Character
|
||||
attr_accessor :character_name
|
||||
attr_accessor :character_hue
|
||||
attr_reader :opacity
|
||||
attr_reader :blend_type
|
||||
attr_accessor :blend_type
|
||||
attr_accessor :direction
|
||||
attr_accessor :pattern
|
||||
attr_accessor :pattern_surf
|
||||
@@ -25,10 +25,15 @@ class Game_Character
|
||||
attr_reader :move_speed
|
||||
attr_accessor :walk_anime
|
||||
attr_writer :bob_height
|
||||
attr_accessor :under_everything #under even grass
|
||||
attr_accessor :under_player #always under the player, but over grass, etc.
|
||||
attr_accessor :under_everything # under even grass
|
||||
attr_accessor :under_player # always under the player, but over grass, etc.
|
||||
attr_accessor :direction_fix
|
||||
attr_accessor :always_on_top
|
||||
attr_accessor :forced_bush_depth
|
||||
attr_reader :move_route
|
||||
attr_accessor :shadow_offset
|
||||
attr_accessor :animation_speed
|
||||
attr_accessor :step_anime
|
||||
|
||||
def initialize(map = nil)
|
||||
@map = map
|
||||
@@ -79,9 +84,12 @@ class Game_Character
|
||||
@moved_this_frame = false
|
||||
@locked = false
|
||||
@prelock_direction = 0
|
||||
@under_everything=false
|
||||
@under_everything = false
|
||||
@under_player = false
|
||||
@forced_z=nil
|
||||
@forced_z = nil
|
||||
@forced_bush_depth = nil
|
||||
@shadow_offset =0
|
||||
@animation_speed = nil #override if the animation speed needs to be different from move speed
|
||||
end
|
||||
|
||||
def at_coordinate?(check_x, check_y)
|
||||
@@ -106,6 +114,15 @@ class Game_Character
|
||||
@opacity = opacity
|
||||
end
|
||||
|
||||
def set_animation_speed(speed)
|
||||
#echoln "animation_speed = #{speed}"
|
||||
@animation_speed = speed
|
||||
end
|
||||
|
||||
def reset_animation_speed(speed)
|
||||
@animation_speed = nil
|
||||
end
|
||||
|
||||
def move_speed=(val)
|
||||
return if val == @move_speed
|
||||
@move_speed = val
|
||||
@@ -213,6 +230,10 @@ class Game_Character
|
||||
end
|
||||
|
||||
def calculate_bush_depth
|
||||
if @forced_bush_depth
|
||||
@bush_depth = @forced_bush_depth
|
||||
return
|
||||
end
|
||||
if @tile_id > 0 || @always_on_top || jumping?
|
||||
@bush_depth = 0
|
||||
else
|
||||
@@ -240,6 +261,26 @@ class Game_Character
|
||||
return $game_map.terrain_tag(facing[1], facing[2])
|
||||
end
|
||||
|
||||
#like pbFacingTerrainTag, but doesn't care about passability
|
||||
def getTerrainTagDirectlyInFront()
|
||||
x = $game_player.x
|
||||
y= $game_player.y
|
||||
|
||||
case @direction
|
||||
when DIRECTION_UP
|
||||
y= $game_player.y-1
|
||||
when DIRECTION_DOWN
|
||||
y= $game_player.y+1
|
||||
when DIRECTION_LEFT
|
||||
x= $game_player.x-1
|
||||
when DIRECTION_RIGHT
|
||||
x= $game_player.x+1
|
||||
end
|
||||
return $game_map.terrain_tag(x, y)
|
||||
end
|
||||
def getTerrainTag()
|
||||
return $game_map.terrain_tag($game_player.x, $game_player.y)
|
||||
end
|
||||
|
||||
def passable?(x, y, d, strict = false)
|
||||
return false if self == $game_player && $game_switches[SWITCH_LOCK_PLAYER_MOVEMENT]
|
||||
@@ -247,7 +288,7 @@ class Game_Character
|
||||
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
|
||||
return false unless self.map.valid?(new_x, new_y)
|
||||
if self.character_name == "SHARPEDO" || self.character_name == "nightmare"
|
||||
return false if pbFacingTerrainTag().id==:SharpedoObstacle
|
||||
return false if pbFacingTerrainTag().id == :SharpedoObstacle
|
||||
end
|
||||
return true if @through
|
||||
|
||||
@@ -346,13 +387,14 @@ class Game_Character
|
||||
return 0 if @under_player
|
||||
return 999 if @always_on_top
|
||||
return @forced_z if @forced_z
|
||||
return 999 if @on_bridge && $PokemonGlobal.bridge <= 0
|
||||
z = screen_y_ground
|
||||
if @tile_id > 0
|
||||
begin
|
||||
return z + self.map.priorities[@tile_id] * 32
|
||||
rescue
|
||||
return 0
|
||||
#raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
|
||||
# raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
|
||||
end
|
||||
end
|
||||
# Add z if height exceeds 32
|
||||
@@ -361,10 +403,14 @@ class Game_Character
|
||||
|
||||
def opposite_direction
|
||||
case @direction
|
||||
when DIRECTION_LEFT; return DIRECTION_RIGHT
|
||||
when DIRECTION_RIGHT; return DIRECTION_LEFT
|
||||
when DIRECTION_UP; return DIRECTION_DOWN
|
||||
when DIRECTION_DOWN; return DIRECTION_UP
|
||||
when DIRECTION_LEFT;
|
||||
return DIRECTION_RIGHT
|
||||
when DIRECTION_RIGHT;
|
||||
return DIRECTION_LEFT
|
||||
when DIRECTION_UP;
|
||||
return DIRECTION_DOWN
|
||||
when DIRECTION_DOWN;
|
||||
return DIRECTION_UP
|
||||
else
|
||||
return DIRECTION_ALL
|
||||
end
|
||||
@@ -389,7 +435,6 @@ class Game_Character
|
||||
end
|
||||
|
||||
def force_move_route(move_route)
|
||||
#echoln screen_z() if self == $game_player
|
||||
if @original_move_route == nil
|
||||
@original_move_route = @move_route
|
||||
@original_move_route_index = @move_route_index
|
||||
@@ -458,6 +503,28 @@ class Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def move_type_away_from_player
|
||||
# Calculate distance from player
|
||||
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
|
||||
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
|
||||
|
||||
# If far from player, just move randomly
|
||||
if sx.abs + sy.abs >= 20
|
||||
move_random
|
||||
return
|
||||
end
|
||||
# Randomized movement behavior
|
||||
case rand(6)
|
||||
when 0..3
|
||||
move_away_from_player # move in the opposite direction
|
||||
when 4
|
||||
move_random # occasional random step
|
||||
when 5
|
||||
move_forward # maybe just move forward
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def move_type_custom
|
||||
return if jumping? || moving?
|
||||
while @move_route_index < @move_route.list.size
|
||||
@@ -602,6 +669,14 @@ class Game_Character
|
||||
pbSEPlay(command.parameters[0])
|
||||
when 45 then
|
||||
eval(command.parameters[0])
|
||||
when PBMoveRoute::PlayAnimation then
|
||||
playAnimation(command.parameters[0],@x,@y)
|
||||
when PBMoveRoute::FlyForward then
|
||||
fly_forward
|
||||
when PBMoveRoute::SetFloatingOn then
|
||||
@floating = true
|
||||
when PBMoveRoute::SetFloatingOff then
|
||||
@floating = false
|
||||
end
|
||||
@move_route_index += 1
|
||||
end
|
||||
@@ -886,6 +961,15 @@ class Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def fly_forward
|
||||
case @direction
|
||||
when DIRECTION_LEFT, DIRECTION_UP then
|
||||
move_upper_left
|
||||
when DIRECTION_RIGHT, DIRECTION_DOWN then
|
||||
move_upper_right
|
||||
end
|
||||
end
|
||||
|
||||
def move_forward
|
||||
case @direction
|
||||
when 2 then
|
||||
@@ -915,19 +999,19 @@ class Game_Character
|
||||
@direction_fix = last_direction_fix
|
||||
end
|
||||
|
||||
def jump_forward
|
||||
def jump_forward(distance = 1)
|
||||
case $game_player.direction
|
||||
when DIRECTION_DOWN
|
||||
x_direction = 0
|
||||
y_direction = 1
|
||||
y_direction = distance
|
||||
when DIRECTION_UP
|
||||
x_direction = 0
|
||||
y_direction = -1
|
||||
y_direction = 0 - distance
|
||||
when DIRECTION_LEFT
|
||||
x_direction = -1
|
||||
x_direction = 0 - distance
|
||||
y_direction = 0
|
||||
when DIRECTION_RIGHT
|
||||
x_direction = 1
|
||||
x_direction = distance
|
||||
y_direction = 0
|
||||
else
|
||||
x_direction = 0
|
||||
@@ -937,6 +1021,7 @@ class Game_Character
|
||||
end
|
||||
|
||||
def jump(x_plus, y_plus)
|
||||
@jump_in_place = (x_plus == 0 && y_plus == 0)
|
||||
if x_plus != 0 || y_plus != 0
|
||||
if x_plus.abs > y_plus.abs
|
||||
(x_plus < 0) ? turn_left : turn_right
|
||||
@@ -963,18 +1048,24 @@ class Game_Character
|
||||
if self.is_a?(Game_Player)
|
||||
$PokemonTemp.dependentEvents.pbMoveDependentEvents
|
||||
end
|
||||
triggerLeaveTile
|
||||
if x_plus != 0 || y_plus != 0
|
||||
triggerLeaveTile
|
||||
end
|
||||
end
|
||||
|
||||
def jumpForward
|
||||
case self.direction
|
||||
when 2 then
|
||||
jumpTowards(self.direction)
|
||||
end
|
||||
|
||||
def jumpTowards(direction)
|
||||
case direction
|
||||
when DIRECTION_DOWN then
|
||||
jump(0, 1) # down
|
||||
when 4 then
|
||||
when DIRECTION_LEFT then
|
||||
jump(-1, 0) # left
|
||||
when 6 then
|
||||
when DIRECTION_RIGHT then
|
||||
jump(1, 0) # right
|
||||
when 8 then
|
||||
when DIRECTION_UP then
|
||||
jump(0, -1) # up
|
||||
end
|
||||
end
|
||||
@@ -1131,12 +1222,14 @@ class Game_Character
|
||||
# 6 => @stop_count > 0 # 0 seconds
|
||||
if @stop_count >= self.move_frequency_real
|
||||
case @move_type
|
||||
when 1 then
|
||||
when MOVE_TYPE_RANDOM then
|
||||
move_type_random
|
||||
when 2 then
|
||||
when MOVE_TYPE_TOWARDS_PLAYER then
|
||||
move_type_toward_player
|
||||
when 3 then
|
||||
when MOVE_TYPE_CUSTOM then
|
||||
move_type_custom
|
||||
when MOVE_TYPE_AWAY_PLAYER then
|
||||
move_type_away_from_player
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1167,7 +1260,10 @@ class Game_Character
|
||||
end
|
||||
# End of a step, so perform events that happen at this time
|
||||
if !jumping? && !moving?
|
||||
Events.onStepTakenFieldMovement.trigger(self, self)
|
||||
unless @jump_in_place
|
||||
Events.onStepTakenFieldMovement.trigger(self, self)
|
||||
end
|
||||
@jump_in_place = false
|
||||
calculate_bush_depth
|
||||
@stopped_this_frame = true
|
||||
elsif !@moved_last_frame || @stopped_last_frame # Started a new step
|
||||
@@ -1205,11 +1301,30 @@ class Game_Character
|
||||
# it takes to move half a tile (or a whole tile if cycling). We assume the
|
||||
# game uses square tiles.
|
||||
real_speed = (jumping?) ? jump_speed_real : move_speed_real
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (real_speed * 2.0)
|
||||
frames_per_pattern *= 2 if move_speed >= 5 # Cycling speed or faster
|
||||
if @animation_speed
|
||||
base = Game_Map::REAL_RES_X / 2.0
|
||||
frames_per_pattern = base / @animation_speed
|
||||
else
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (real_speed * 2.0)
|
||||
frames_per_pattern *= 2 if move_speed >= 5 # Cycling speed or faster
|
||||
end
|
||||
return if @anime_count < frames_per_pattern
|
||||
# Advance to the next animation frame
|
||||
@pattern = (@pattern + 1) % 4
|
||||
@anime_count -= frames_per_pattern
|
||||
end
|
||||
|
||||
# def distance_from_player
|
||||
# dx = (@x - $game_player.x).abs
|
||||
# dy = (@y - $game_player.y).abs
|
||||
# return (dx + dy)-1 #-1 because not counting the event's or the player"s current tile
|
||||
# end
|
||||
def distance_from_player
|
||||
return Float::INFINITY if self.map_id != $game_map.map_id
|
||||
dx = (@x - $game_player.x).abs
|
||||
dy = (@y - $game_player.y).abs
|
||||
return (dx + dy) - 1
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user