Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # // 06/04/2011
- $imported = {} if $imported == nil
- $imported["ISS-Core"] = true
- #==============================================================================#
- # Object
- #==============================================================================#
- class Object
- #--------------------------------------------------------------------------#
- # * new-method :acquire
- #--------------------------------------------------------------------------#
- def self.acquire( filename )
- File.open( filename, "r" ) { |f| eval( f.read ) }
- end
- end
- #==============================================================================#
- # ISS
- #==============================================================================#
- module ISS
- #==============================================================================#
- # Circle
- #==============================================================================#
- class Circle
- def initialize( x, y, radius ) ; @x, @y, @radius = x, y, radius end
- def get_angle_xy ( angle )
- rx = @x + @radius * cos( angle )
- ry = @y + @radius * sin( angle )
- end
- def set_xy( x, y ) ; @x, @y = x, y end
- end
- #==============================================================================#
- # Pos
- #==============================================================================#
- class Pos
- attr_accessor :x # // X
- attr_accessor :y # // Y
- attr_accessor :z # // Z
- def initialize( x, y, z=0 ) ; @x = x ; @y = y ; @z = z end
- def ==( otherpos )
- return ( @x == otherpos.x && @y == otherpos.y && @z == otherpos.z )
- end
- end
- #==============================================================================#
- # Pop_Handler
- #==============================================================================#
- class Pop_Handler
- attr_accessor :x
- attr_accessor :y
- attr_accessor :ox
- attr_accessor :oy
- attr_accessor :x_velocity
- attr_accessor :y_velocity
- attr_accessor :x_boost
- attr_accessor :y_boost
- attr_accessor :x_add
- attr_accessor :y_add
- attr_accessor :cap_duration
- attr_accessor :finished
- attr_accessor :pause_update
- attr_accessor :gravity
- attr_accessor :floor_val
- GRAVITY = 0.58
- TRANCEPARENT_START = 40
- TRANCEPARENT_X_SLIDE = 0
- def initialize( x, y )
- @start_settings = [x, y, 0, 0]
- @cap_duration = 80
- @x_velocity = 0.4
- @y_velocity = 1.5
- @x_boost = 8
- @y_boost = 4
- @x_add = 0
- @y_add = 4
- @gravity = GRAVITY
- @floor_val = 0
- reset
- end
- def reset
- @x, @y, @ox, @oy = *@start_settings
- @finished = false
- @pause_update = false
- prep_pop
- end
- def damage_x_init_velocity()
- return @x_velocity * ( rand(@x_boost) + @x_add )
- end
- def damage_y_init_velocity()
- return @y_velocity * ( rand(@y_boost) + @y_add )
- end
- def prep_pop
- @now_x_speed = damage_x_init_velocity
- @now_y_speed = damage_y_init_velocity
- @potential_x_energy = 0.0
- @potential_y_energy = 0.0
- @speed_off_x = rand(2)
- @pop_duration = @cap_duration
- end
- def update
- return if @finished or @pause_update
- if @pop_duration <= TRANCEPARENT_START
- @x += TRANCEPARENT_X_SLIDE if @speed_off_x == 0
- @x -= TRANCEPARENT_X_SLIDE if @speed_off_x == 1
- end
- n = @oy + @now_y_speed
- if n <= @floor_val #0
- @now_y_speed *= -1
- @now_y_speed /= 2
- @now_x_speed /= 2
- end
- @oy = [n, @floor_val].min #max
- @potential_y_energy += @gravity
- speed = @potential_y_energy.floor
- @now_y_speed -= speed
- @potential_y_energy -= speed
- @potential_x_energy += @now_x_speed
- speed = @potential_x_energy.floor
- @ox += speed if @speed_off_x == 0
- @ox -= speed if @speed_off_x == 1
- @potential_x_energy -= speed
- @pop_duration -= 1
- if @pop_duration == 0
- @finished = true
- end
- end
- end
- end
- #==============================================================================#
- # Game_Character
- #==============================================================================#
- class Game_Character
- #--------------------------------------------------------------------------#
- # * new-method :get_xy_infront
- #--------------------------------------------------------------------------#
- def get_xy_infront( dist, sway )
- case direction
- when 2 # // Down
- return [x+sway, y+dist]
- when 4 # // Left
- return [x-dist, y+sway]
- when 6 # // Right
- return [x+dist, y-sway]
- when 8 # // Up
- return [x-sway, y-dist]
- end
- end
- #--------------------------------------------------------------------------
- # * Calculate X Distance From Target X
- #--------------------------------------------------------------------------
- def distance_x_from_tx(tx)
- sx = @x - tx
- if $game_map.loop_horizontal? # When looping horizontally
- if sx.abs > $game_map.width / 2 # Larger than half the map width?
- sx -= $game_map.width # Subtract map width
- end
- end
- return sx
- end
- #--------------------------------------------------------------------------
- # * Calculate Y Distance From Target Y
- #--------------------------------------------------------------------------
- def distance_y_from_ty(ty)
- sy = @y - ty
- if $game_map.loop_vertical? # When looping vertically
- if sy.abs > $game_map.height / 2 # Larger than half the map height?
- sy -= $game_map.height # Subtract map height
- end
- end
- return sy
- end
- #--------------------------------------------------------------------------
- # * Move toward Character
- #--------------------------------------------------------------------------
- def move_toward_char( char )
- move_toward_xy( char.x, char.y )
- end
- #--------------------------------------------------------------------------
- # * Move away from Character
- #--------------------------------------------------------------------------
- def move_away_from_char( char )
- move_away_from_xy( char.x, char.y )
- end
- #--------------------------------------------------------------------------
- # * Move toward XY
- #--------------------------------------------------------------------------
- def move_toward_xy( x, y )
- sx = distance_x_from_tx(x)
- sy = distance_y_from_ty(y)
- if sx != 0 or sy != 0
- if sx.abs > sy.abs # Horizontal distance is longer
- sx > 0 ? move_left : move_right # Prioritize left-right
- if @move_failed and sy != 0
- sy > 0 ? move_up : move_down
- end
- else # Vertical distance is longer
- sy > 0 ? move_up : move_down # Prioritize up-down
- if @move_failed and sx != 0
- sx > 0 ? move_left : move_right
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Move away from XY
- #--------------------------------------------------------------------------
- def move_away_from_xy( x, y )
- sx = distance_x_from_tx(x)
- sy = distance_y_from_ty(y)
- if sx != 0 or sy != 0
- if sx.abs > sy.abs # Horizontal distance is longer
- sx > 0 ? move_right : move_left # Prioritize left-right
- if @move_failed and sy != 0
- sy > 0 ? move_down : move_up
- end
- else # Vertical distance is longer
- sy > 0 ? move_down : move_up # Prioritize up-down
- if @move_failed and sx != 0
- sx > 0 ? move_right : move_left
- end
- end
- end
- end
- end
- #==============================================================================#
- # Spriteset_Map
- #==============================================================================#
- class Spriteset_Map
- #--------------------------------------------------------------------------#
- # * alias-method :initialize
- #--------------------------------------------------------------------------#
- alias :iss000_spm_initialize :initialize unless $@
- def initialize()
- @tilemap_maxtime = 2
- @tilemap_uptime = 0
- iss000_spm_initialize()
- end
- #--------------------------------------------------------------------------#
- # * overwrite-method :initialize
- #--------------------------------------------------------------------------#
- def update_tilemap()
- @tilemap_uptime -= 1 unless @tilemap_uptime == 0
- @tilemap.ox = $game_map.display_x / 8
- @tilemap.oy = $game_map.display_y / 8
- if @tilemap_uptime == 0
- 3.times { @tilemap.update() }
- @tilemap_uptime = @tilemap_maxtime
- end
- end
- end
- #==============================================================================#
- # Window_Base
- #==============================================================================#
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Draw HP
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # width : Width
- #--------------------------------------------------------------------------
- def draw_actor_hp(actor, x, y, width = 120)
- draw_actor_hp_gauge(actor, x, y, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
- self.contents.font.color = hp_color(actor)
- last_font_size = self.contents.font.size
- xr = x + width
- self.contents.font.size = 18
- if width < 120
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.hp, 2)
- else
- self.contents.draw_text(xr - 99, y, 44, WLH, actor.hp, 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxhp, 2)
- end
- #if width < 120
- # self.contents.draw_text(xr - 44, y, 44, WLH, sprintf("%04d", actor.hp), 2)
- #else
- # self.contents.draw_text(xr - 99, y, 44, WLH, sprintf("%04d", actor.hp), 2)
- # self.contents.font.color = normal_color
- # self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- # self.contents.draw_text(xr - 44, y, 44, WLH, sprintf("%04d", actor.maxhp), 2)
- #end
- self.contents.font.size = last_font_size
- end
- #--------------------------------------------------------------------------
- # * Draw MP
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # width : Width
- #--------------------------------------------------------------------------
- def draw_actor_mp(actor, x, y, width = 120)
- draw_actor_mp_gauge(actor, x, y, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
- self.contents.font.color = mp_color(actor)
- last_font_size = self.contents.font.size
- xr = x + width
- self.contents.font.size = 18
- if width < 120
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.mp, 2)
- else
- self.contents.draw_text(xr - 99, y, 44, WLH, actor.mp, 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxmp, 2)
- end
- self.contents.font.size = last_font_size
- end
- #--------------------------------------------------------------------------
- # * Draw HP gauge
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # width : Width
- #--------------------------------------------------------------------------
- def draw_actor_hp_gauge(actor, x, y, width = 120)
- #gw = width * actor.hp / actor.maxhp
- gc1 = hp_gauge_color1
- gc2 = hp_gauge_color2
- #self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
- #self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
- val, max = actor.hp, actor.maxhp
- rect = Rect.new( x, y+WLH-6, width, 4 )
- draw_round_grad_bar( rect, val, max, gc1, gc2, gauge_back_color )
- end
- #--------------------------------------------------------------------------
- # * Draw MP Gauge
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # width : Width
- #--------------------------------------------------------------------------
- def draw_actor_mp_gauge(actor, x, y, width = 120)
- #gw = width * actor.mp / [actor.maxmp, 1].max
- gc1 = mp_gauge_color1
- gc2 = mp_gauge_color2
- #self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
- #self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
- val, max = actor.mp, actor.maxmp
- rect = Rect.new( x, y+WLH-6, width, 4 )
- draw_round_grad_bar( rect, val, max, gc1, gc2, gauge_back_color )
- end
- end
- #==============================================================================#
- # Game_Character
- #==============================================================================#
- class Game_Character
- attr_accessor :lastpos
- #--------------------------------------------------------------------------#
- # * alias method :initialize
- #--------------------------------------------------------------------------#
- alias iss003_gc_initialize initialize unless $@
- def initialize
- iss003_gc_initialize()
- @lastpos = ::ISS::Pos.new(self.x, self.y, 0)
- @screenrect = Rect.new(0, 0, 544, 416)
- end
- #--------------------------------------------------------------------------#
- # * new method :onScreen?
- #--------------------------------------------------------------------------#
- def onScreen?
- r = @screenrect
- return ( screen_x >= r.x && screen_x < r.width &&
- screen_y >= r.y && screen_y < r.height )
- end
- end
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment