[XP] Advanced Swimming System

Started by diagostimo, July 14, 2012, 04:06:42 am

Previous topic - Next topic

diagostimo

July 14, 2012, 04:06:42 am Last Edit: February 18, 2013, 02:35:43 am by Blizzard
Advanced Swimming System
Authors: Diagostimo
Version: 1.0
Type: Custom Movement System
Key Term: Custom Movement System



Introduction

This script will allow you to setup terrain tags that enable you to swim upon, once you are swimming on the tile it the becomes passible until you leave the water.


Features


  • set terrain tags to swim uppon

  • press C button to enter water

  • changes graphic of the character when swiming

  • enable/dissable oxegen, also choose between oxegen being dispalyed as a bar or images




Screenshots

Spoiler: ShowHide







Demo

http://www.mediafire.com/?3uju8c2s3l8vaaw


Script


Spoiler: ShowHide

###############################################################################
# CREDITS TO DIAGOSTIMO FOR THE CREATION OF THIS SCRIPT
###############################################################################
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                     B E G I N  C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
module Swim_Config
=begin
 #-=-=-=-=-=-=-=-=-=-=-#
 # * script calls      #
 #-=-=-=-=-=-=-=-=-=-=-#
 #changes the value of oxegen pictures if PICTURE_MODE is true
 $game_system.oxegen_pictures = VALUE
 
 #changes the max oxegen when bar mode is active
 $game_system.oxegen_max = VALUE
 #-=-=-=-=-=-=-=-=-=-=-#
 # * end script calls  #
 #-=-=-=-=-=-=-=-=-=-=-#
=end
 #Extension of the filename to change the swimming graphic
 SWIM_EXTENSION = '_swim'
 #Terrain tag of water to swim on
 WATER_TERRAIN = 2
 #oxegen timer when in water (true/false)
 OXEGEN_TIMER = true
 #picture mode if true, bar mode if false
 PICTURE_MODE = true
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
 # * if oxegen timer is true                                               #
 #-------------------------------------------------------------------------#
 # * if the picture mode is true                                           #
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
 #Picture name of the oxegen picture to show
 PICTURE_NAME = 'bubble'
 #initial amount of oxegen pictures
 PICTURES = 5
 #how many frames does it take for 1 oxegen picture to disapear?
 PICTURE_FRAMES = 100
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
 # * if the picture mode is not true (bar mode)                            #
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
 #how many initial oxegen blocks(pixles) are there?
 OXEGEN = 100
 #the frame rate each oxegen block(pixle) decreases
 OXEGEN_COUNT = 10
end
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                     E N D   C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_System                                                    
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_System
 attr_accessor :oxegen_picture_count
 attr_accessor :oxegen_pictures
 attr_accessor :oxegen_max
 attr_accessor :oxegen
 attr_accessor :oxegen_count
 alias init_swim initialize
 def initialize
   init_swim
   @oxegen_picture_count = 0
   @oxegen_pictures = Swim_Config::PICTURES
   @oxegen_max = Swim_Config::OXEGEN
   @oxegen = @oxegen_max
   @oxegen_count = Swim_Config::OXEGEN_COUNT
 end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Player                                              
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Player < Game_Character
 attr_accessor :character_name
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Map                                                
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Map
   attr_accessor :passages
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Character                                                  
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Character
 attr_reader :swimming
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Window_Oxegen                                                    
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Window_Oxegen < Window_Base
 def initialize
   if Swim_Config::PICTURE_MODE == true
     @image = RPG::Cache.picture(Swim_Config::PICTURE_NAME)
     @oxegen_picture_amount = $game_system.oxegen_pictures
     super(0, 0, ((@image.width + 5) * $game_system.oxegen_pictures) + 32, @image.height + 32)
   else
     super(0, 0, $game_system.oxegen_max + 34, 7 + 32)
   end
   self.contents = Bitmap.new(width - 32, height - 32)
   self.active = false
   self.opacity = 0
   self.visible = true
   refresh
 end
 def refresh
   self.contents.clear
   if Swim_Config::PICTURE_MODE == true
     if $game_player.swimming == true
       if @oxegen_picture_amount > -1
         if $game_system.oxegen_picture_count > 0
           $game_system.oxegen_picture_count -= 1
         else
           $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
           @oxegen_picture_amount -= 1
         end
         for i in 0 ... @oxegen_picture_amount
           rect = Rect.new(0, 0, @image.width, @image.height)
           self.contents.blt(0 + (@image.width + 5) * i, 0, @image, rect, 255)
         end
       else
         $game_temp.gameover = true
       end
     else
       @oxegen_picture_amount = $game_system.oxegen_pictures
     end
   else
     if $game_player.swimming == true
       rect = Rect.new(0, 0, $game_system.oxegen_max + 2, 7)
       bitmap = Bitmap.new(rect.width, rect.height)
       bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 0, 255))
       self.contents.blt(0, 0, bitmap, rect)
       if $game_system.oxegen_count > 0 && $game_system.oxegen > 0
         $game_system.oxegen_count -= 1
       else
         $game_system.oxegen_count = Swim_Config::OXEGEN_COUNT
         $game_system.oxegen -= 1
       end
       if $game_system.oxegen > 0
         rect = Rect.new(0, 0, $game_system.oxegen, 5)
         bitmap = Bitmap.new(rect.width, rect.height)
         bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 255, 255))
         self.contents.blt(1, 1, bitmap, rect)
       else
         $game_temp.gameover = true
       end  
     end
   end
 end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Scene_Map                                                  
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Scene_Map
 alias main_swim main
 def main
   @oxegen_window = Window_Oxegen.new if Swim_Config::OXEGEN_TIMER == true
   main_swim
   @oxegen_window.dispose if Swim_Config::OXEGEN_TIMER == true
 end
 alias update_swim update
 def update
   if Swim_Config::OXEGEN_TIMER == true
     @oxegen_window.refresh
     if $game_player.swimming == true
       @oxegen_window.visible = true
     else
       @oxegen_window.visible = false
     end
   end
   update_swim
 end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Player                                                    
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Player
 EXTENSION = "_swim"
 TERRAIN = 2
 
 def change_water_passable(passage=0)
   @water = []
   (0...$game_map.width).each {|x|
     (0...$game_map.height).each {|y|
       [2, 1, 0].each {|i|
          id = $game_map.data[x, y, i]
          @water << id if $game_map.terrain_tags[id] == Swim_Config::WATER_TERRAIN
   }}}
   # This code will get all the possible tile id with
   # water terrain tags
   @water.each {|i|  $game_map.passages[i] = passage  }
   # then this code will change all the water passages
 end
 
 alias update_swim update
 def update
   if $game_map.terrain_tag(@x, @y) != Swim_Config::WATER_TERRAIN
     player = $game_party.actors[0]
     if @swimming == true
       $game_system.oxegen = $game_system.oxegen_max if
         Swim_Config::OXEGEN_TIMER == true && Swim_Config::PICTURE_MODE == false
       change_water_passable(15)
       orig_name = player.character_name.split(Swim_Config::SWIM_EXTENSION)
       $game_player.character_name = orig_name[0]
       player.set_graphic(orig_name[0], player.character_hue, player.battler_name, player.battler_hue)
       @step_anime = false
       @swimming = false
     end
     if @direction == 2
       if $game_map.terrain_tag(@x, @y + 1) == Swim_Config::WATER_TERRAIN
         if Input.trigger?(Input::C)
           if Swim_Config::OXEGEN_TIMER && Swim_Config::PICTURE_MODE == true
             $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
           elsif Swim_Config::OXEGEN_TIMER == true && Swim_Config::PICTURE_MODE == false
             #set bar timer
           end
           change_water_passable(0)
           swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
           $game_player.character_name = swim_graphic
           player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
           @step_anime = true
           @swimming = true
           move_down
         end
       end
     elsif @direction == 4
       if $game_map.terrain_tag(@x - 1, @y) == Swim_Config::WATER_TERRAIN
         if Input.trigger?(Input::C)
           $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
           change_water_passable(0)
           swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
           $game_player.character_name = swim_graphic
           player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
           @step_anime = true
           @swimming = true
           move_left
         end
       end
     elsif @direction == 6
       if $game_map.terrain_tag(@x + 1, @y) == Swim_Config::WATER_TERRAIN
         if Input.trigger?(Input::C)
           $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
           change_water_passable(0)
           swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
           $game_player.character_name = swim_graphic
           player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
           @step_anime = true
           @swimming = true
           move_right
         end
       end
     elsif @direction == 8
       if $game_map.terrain_tag(@x, @y - 1) == Swim_Config::WATER_TERRAIN
         if Input.trigger?(Input::C)
           $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
           change_water_passable(0)
           swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
           $game_player.character_name = swim_graphic
           player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
           @step_anime = true
           @swimming = true
           move_up
         end
       end
     end
   end
   update_swim
 end
end




Instructions

place above main and below default scripts, see the script for configuration

Compatibility

no known compatibility issues, please report any if found


Credits and Thanks


  • Diagostimo for the creation of the script

  • the demo contains templates i am unsure who created, if you feel there name needs credited just say




Author's Notes

use of this script in commercial games is prohibited, credit would be appreciated but not required.

whitespirits

OK guys so this script is clashing i think with blizz abs

here is my error

Spoiler: ShowHide


this is script

Spoiler: ShowHide
#==============================================================================
# ** Swimming System v1.0
#==============================================================================
# Author: Diagostimo
#==============================================================================
module Swim_Config
  #----------------------------------------------------------------------------
  # BEGIN CONFIGURATION
  #----------------------------------------------------------------------------
  SWIMABLE_EVENTS = {
                    #MAP_ID => [ARRAY OF EVENT ID'S]
                      1 => [1, 2, 3, 4, 5, 6],
                      2 => []
                    }
  #Extension of the filename to change the swimming graphic
  SWIM_EXTENSION = '_swim'
  #Terrain tag of water to swim on
  WATER_TERRAIN = 2
  #----------------------------------------------------------------------------
  # END CONFIGURATION
  #----------------------------------------------------------------------------
end
#==============================================================================
# ** Game Character
#==============================================================================
class Game_Character
  #----------------------------------------------------------------------------
  # * Public Instance Variables
  #----------------------------------------------------------------------------
  attr_accessor :swimming
  #----------------------------------------------------------------------------
  # * Object Initialization
  #----------------------------------------------------------------------------
  alias init_diag_swim initialize
  def initialize
    init_diag_swim
    @swimming = false
  end
  #----------------------------------------------------------------------------
  # * Passable?
  #----------------------------------------------------------------------------
  alias passable_diag_swim passable?
  def passable?(x, y, d)
    target_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    target_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false if !@swimming && $game_map.terrain_tag(target_x, target_y) == 2
    passable_diag_swim(x, y, d)
  end
end
#==============================================================================
# ** Game Player
#==============================================================================
class Game_Player < Game_Character
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  alias update_player_diag_swim update
  def update
    if Input.trigger?(Input::C) && !@swimming
      d = @direction
      target_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      target_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      if $game_map.terrain_tag(target_x, target_y) == 2
        player = $game_party.actors[0]
        swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
        player.set_graphic(swim_graphic, player.character_hue,
            player.battler_name, player.battler_hue)
        refresh
        @step_anime = true
        @swimming = true
        move_forward
      end
    end
    update_player_diag_swim
    if @swimming && $game_map.terrain_tag(@x, @y) != 2
      @swimming = false
      @step_anime = false
      player = $game_party.actors[0]
      orig_name = player.character_name.split(Swim_Config::SWIM_EXTENSION)
      player.set_graphic(orig_name[0], player.character_hue,
          player.battler_name, player.battler_hue)
      refresh
    end
  end
end
#==============================================================================
# ** Game Event
#==============================================================================
class Game_Event < Game_Character
  #----------------------------------------------------------------------------
  # * Move Down
  #----------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    if $game_map.terrain_tag(@x, @y + 1) == 2 && !@swimming &&
        Swim_Config::SWIMABLE_EVENTS[$game_map.map_id].include?(@id) &&
        $game_map.passable?(@x, @y, 2, self)
      @swimming = true
      @step_anime = true
      @character_name += Swim_Config::SWIM_EXTENSION
    elsif $game_map.terrain_tag(@x, @y + 1) == 2 && !@swimming &&
        Swim_Config::SWIMABLE_EVENTS[$game_map.map_id].include?(@id) &&
        !$game_map.passable?(@x, @y, 2, self)
        return
    end
    super(turn_enabled)
  end
  #----------------------------------------------------------------------------
  # Move Left
  #----------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    if $game_map.terrain_tag(@x - 1, @y) == 2 && !@swimming &&
        Swim_Config::SWIMABLE_EVENTS[$game_map.map_id].include?(@id) &&
        $game_map.passable?(@x, @y, 4, self)
      @swimming = true
      @step_anime = true
      @character_name += Swim_Config::SWIM_EXTENSION
    end
    super(turn_enabled)
  end
  #----------------------------------------------------------------------------
  # Move Right
  #----------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    if $game_map.terrain_tag(@x + 1, @y) == 2 && !@swimming &&
        Swim_Config::SWIMABLE_EVENTS[$game_map.map_id].include?(@id) &&
        $game_map.passable?(@x, @y, 6, self)
      @swimming = true
      @step_anime = true
      @character_name += Swim_Config::SWIM_EXTENSION
    end
    super(turn_enabled)
  end
  #----------------------------------------------------------------------------
  # Move Up
  #----------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    if $game_map.terrain_tag(@x, @y - 1) == 2 && !@swimming &&
        Swim_Config::SWIMABLE_EVENTS[$game_map.map_id].include?(@id) &&
        $game_map.passable?(@x, @y, 8, self)
      @swimming = true
      @step_anime = true
      @character_name += Swim_Config::SWIM_EXTENSION
    end
    super(turn_enabled)
  end
  #----------------------------------------------------------------------------
  # Frame Update
  #----------------------------------------------------------------------------
  alias update_event update
  def update
    update_event
    if @swimming && $game_map.terrain_tag(@x, @y) != 2
      @swimming = false
      @step_anime = false
      orig_name = @character_name.split(Swim_Config::SWIM_EXTENSION)
      @character_name = orig_name[0]
      refresh
    end
  end
end

KK20

I have merged your topic with the original script's posting. Please, in the future, if you have a question or a problem with a script that you can find in the script database, post in that topic instead of starting a new one. Who knows if other users may happen to have the same question as you.
Also, you forgot the code tags. There is also nothing wrong with providing a link to where you got the script from.

I believe the problem is due to different superclasses. Game_Player extends Map_Actor in BlizzABS while this script assumes the default (Game_Character).
Spoiler: ShowHide

###############################################################################
# CREDITS TO DIAGOSTIMO FOR THE CREATION OF THIS SCRIPT
###############################################################################
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                     B E G I N  C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
module Swim_Config
=begin
  #-=-=-=-=-=-=-=-=-=-=-#
  # * script calls      #
  #-=-=-=-=-=-=-=-=-=-=-#
  #changes the value of oxegen pictures if PICTURE_MODE is true
  $game_system.oxegen_pictures = VALUE
 
  #changes the max oxegen when bar mode is active
  $game_system.oxegen_max = VALUE
  #-=-=-=-=-=-=-=-=-=-=-#
  # * end script calls  #
  #-=-=-=-=-=-=-=-=-=-=-#
=end
  #Extension of the filename to change the swimming graphic
  SWIM_EXTENSION = '_swim'
  #Terrain tag of water to swim on
  WATER_TERRAIN = 2
  #oxegen timer when in water (true/false)
  OXEGEN_TIMER = true
  #picture mode if true, bar mode if false
  PICTURE_MODE = true
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
  # * if oxegen timer is true                                               #
  #-------------------------------------------------------------------------#
  # * if the picture mode is true                                           #
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
  #Picture name of the oxegen picture to show
  PICTURE_NAME = 'bubble'
  #initial amount of oxegen pictures
  PICTURES = 5
  #how many frames does it take for 1 oxegen picture to disapear?
  PICTURE_FRAMES = 100
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
  # * if the picture mode is not true (bar mode)                            #
  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
  #how many initial oxegen blocks(pixles) are there?
  OXEGEN = 100
  #the frame rate each oxegen block(pixle) decreases
  OXEGEN_COUNT = 10
end
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                     E N D   C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_System                                                     
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_System
  attr_accessor :oxegen_picture_count
  attr_accessor :oxegen_pictures
  attr_accessor :oxegen_max
  attr_accessor :oxegen
  attr_accessor :oxegen_count
  alias init_swim initialize
  def initialize
    init_swim
    @oxegen_picture_count = 0
    @oxegen_pictures = Swim_Config::PICTURES
    @oxegen_max = Swim_Config::OXEGEN
    @oxegen = @oxegen_max
    @oxegen_count = Swim_Config::OXEGEN_COUNT
  end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Player                                             
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Player < Map_Actor
  attr_accessor :character_name
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Map                                                 
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Map
    attr_accessor :passages
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Character                                                   
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Character
  attr_reader :swimming
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Window_Oxegen                                                   
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Window_Oxegen < Window_Base
  def initialize
    if Swim_Config::PICTURE_MODE == true
      @image = RPG::Cache.picture(Swim_Config::PICTURE_NAME)
      @oxegen_picture_amount = $game_system.oxegen_pictures
      super(0, 0, ((@image.width + 5) * $game_system.oxegen_pictures) + 32, @image.height + 32)
    else
      super(0, 0, $game_system.oxegen_max + 34, 7 + 32)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    self.active = false
    self.opacity = 0
    self.visible = true
    refresh
  end
  def refresh
    self.contents.clear
    if Swim_Config::PICTURE_MODE == true
      if $game_player.swimming == true
        if @oxegen_picture_amount > -1
          if $game_system.oxegen_picture_count > 0
            $game_system.oxegen_picture_count -= 1
          else
            $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
            @oxegen_picture_amount -= 1
          end
          for i in 0 ... @oxegen_picture_amount
            rect = Rect.new(0, 0, @image.width, @image.height)
            self.contents.blt(0 + (@image.width + 5) * i, 0, @image, rect, 255)
          end
        else
          $game_temp.gameover = true
        end
      else
        @oxegen_picture_amount = $game_system.oxegen_pictures
      end
    else
      if $game_player.swimming == true
        rect = Rect.new(0, 0, $game_system.oxegen_max + 2, 7)
        bitmap = Bitmap.new(rect.width, rect.height)
        bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 0, 255))
        self.contents.blt(0, 0, bitmap, rect)
        if $game_system.oxegen_count > 0 && $game_system.oxegen > 0
          $game_system.oxegen_count -= 1
        else
          $game_system.oxegen_count = Swim_Config::OXEGEN_COUNT
          $game_system.oxegen -= 1
        end
        if $game_system.oxegen > 0
          rect = Rect.new(0, 0, $game_system.oxegen, 5)
          bitmap = Bitmap.new(rect.width, rect.height)
          bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 255, 255))
          self.contents.blt(1, 1, bitmap, rect)
        else
          $game_temp.gameover = true
        end   
      end
    end
  end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Scene_Map                                                 
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Scene_Map
  alias main_swim main
  def main
    @oxegen_window = Window_Oxegen.new if Swim_Config::OXEGEN_TIMER == true
    main_swim
    @oxegen_window.dispose if Swim_Config::OXEGEN_TIMER == true
  end
  alias update_swim update
  def update
    if Swim_Config::OXEGEN_TIMER == true
      @oxegen_window.refresh
      if $game_player.swimming == true
        @oxegen_window.visible = true
      else
        @oxegen_window.visible = false
      end
    end
    update_swim
  end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Player                                                   
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Player < Map_Actor
  EXTENSION = "_swim"
  TERRAIN = 2
 
  def change_water_passable(passage=0)
    @water = []
    (0...$game_map.width).each {|x|
      (0...$game_map.height).each {|y|
        [2, 1, 0].each {|i|
           id = $game_map.data[x, y, i]
           @water << id if $game_map.terrain_tags[id] == Swim_Config::WATER_TERRAIN
    }}}
    # This code will get all the possible tile id with
    # water terrain tags
    @water.each {|i|  $game_map.passages[i] = passage  }
    # then this code will change all the water passages
  end
 
  alias update_swim update
  def update
    if $game_map.terrain_tag(@x, @y) != Swim_Config::WATER_TERRAIN
      player = $game_party.actors[0]
      if @swimming == true
        $game_system.oxegen = $game_system.oxegen_max if
          Swim_Config::OXEGEN_TIMER == true && Swim_Config::PICTURE_MODE == false
        change_water_passable(15)
        orig_name = player.character_name.split(Swim_Config::SWIM_EXTENSION)
        $game_player.character_name = orig_name[0]
        player.set_graphic(orig_name[0], player.character_hue, player.battler_name, player.battler_hue)
        @step_anime = false
        @swimming = false
      end
      if @direction == 2
        if $game_map.terrain_tag(@x, @y + 1) == Swim_Config::WATER_TERRAIN
          if Input.trigger?(Input::C)
            if Swim_Config::OXEGEN_TIMER && Swim_Config::PICTURE_MODE == true
              $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
            elsif Swim_Config::OXEGEN_TIMER == true && Swim_Config::PICTURE_MODE == false
              #set bar timer
            end
            change_water_passable(0)
            swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
            $game_player.character_name = swim_graphic
            player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
            @step_anime = true
            @swimming = true
            move_down
          end
        end
      elsif @direction == 4
        if $game_map.terrain_tag(@x - 1, @y) == Swim_Config::WATER_TERRAIN
          if Input.trigger?(Input::C)
            $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
            change_water_passable(0)
            swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
            $game_player.character_name = swim_graphic
            player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
            @step_anime = true
            @swimming = true
            move_left
          end
        end
      elsif @direction == 6
        if $game_map.terrain_tag(@x + 1, @y) == Swim_Config::WATER_TERRAIN
          if Input.trigger?(Input::C)
            $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
            change_water_passable(0)
            swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
            $game_player.character_name = swim_graphic
            player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
            @step_anime = true
            @swimming = true
            move_right
          end
        end
      elsif @direction == 8
        if $game_map.terrain_tag(@x, @y - 1) == Swim_Config::WATER_TERRAIN
          if Input.trigger?(Input::C)
            $game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
            change_water_passable(0)
            swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
            $game_player.character_name = swim_graphic
            player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
            @step_anime = true
            @swimming = true
            move_up
          end
        end
      end
    end
    update_swim
  end
end

If this doesn't work, the two scripts are currently incompatible.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

whitespirits

September 30, 2014, 05:04:02 pm #3 Last Edit: September 30, 2014, 05:21:45 pm by whitespirits
thank you will try it, sorry i didnt see it on this site.


ok so i tested it and when i walk to water the bubbles flash and thats it