The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: toriverly on February 26, 2007, 03:29:25 PM

Title: Swimming Script!
Post by: toriverly on February 26, 2007, 03:29:25 PM
Swimming
Version: 1.7

Introduction

It seems to me that most swimming is done through event systems or Seph's vehicle script which is fine if you want to hop on a penguin to get across a river but we all know swimming isn't the same as riding a bike.  I saw a lot of requests for a swimming script so I thought I'd make one.  This is my first script that does something more interesting than displaying a window XD.

The script will cause the following when the player approaches water:

Updates
Templates
Diving Template: Edited from Mack's male
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fswimming%2520script%2520pics%2FTemplate_dive-1.png&hash=061db88896bbc4e2ec2ab2b77683810a8b369a28)
It only needs 4 frames because it is only visible for a second.
Swimming Template: Again from Mack's male
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fswimming%2520script%2520pics%2FTemplate_swim.png&hash=62a7331b7c681234773ee0d1ef87d7bb027639f0)

Screenshots
Before
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fswimming%2520script%2520pics%2FSwim_Screenie1.png&hash=9900e15a0e4ec69cf50618f626f20cc837e2a1ed)
Diving (I thought I'd show off the side view :))
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fswimming%2520script%2520pics%2FSwim_Screenie2.png&hash=10be2962ddfb0a2c5e0ed4423348a3bade52f3e5)
In the water
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fswimming%2520script%2520pics%2FSwim_Screenie3.png&hash=4ff27c820b24953f8040d977448ee2c392119969)

Script

Spoiler for Swimming Script:
[/list]
Code: [Select]
#==============================================================================#
#  Swimming!  v 1.8                                                          #
#  By: ToriVerly @ hbgames.org                                                    #
#==============================================================================#
#  Intructions:                                                                #
#------------------------------------------------------------------------------#
=begin
 Paste this script above Main and below everything else.
 For each character you will have swimming, make a swimming sprite that has the
 same name as the character but ending with "_swim" and another with "_dive" if
 DIVE_GRAPHIC is true.
    Example: "001-Fighter01_swim.png"
 
 If TREAD_ANI = true, the character will be animated while in water when they are
 not moving.  Hence a treading water effect.  Set it to false if you don't want
 the effect.
 
 Set the WATER constant to the terrain tag ID of your water tiles or whatever tile
 you want to swim through.  When you place non water tiles over water tiles (in
 a higher layer), the non water tiles will need to have a terrain tag that is
 different than WATER and not 0 or else the characters is swim through it.
 
    IMPORTANT--->make sure your water tile is passable.
 
 If you want the ability to swim to depend on a switch, set SWIM_SWITCH to the ID
 of the game switch you're using. If you don't want to use a switch, set it to nil.
 Similarily, set SWIM_ITEM, SWIM_ARMOR or SWIM_WEAPON to the ID of the item, armor
 or weapon required for swimming and nil if there is none.  You can even set more
 than one condition!
 
 The SWIM_SE will play every time you jump into water.  If you don't want a sound,
 set DIVE_SOUND_OFF to true.
 
 The SNEAK_KEY and DASH_KEY functions can be set for Mr.Mo's ABS or an input
 letters script.  If you don't have such an input system but have another dashing
 and/or sneaking system/script, change them to Input::YourKey.
     Example: Input::X
              Input::Y
 If you don't have dashing or sneaking at all, set them to nil.
 WATER_DASHING is self explanitory.  If you want to dash in water, set it to true.
 If DROWNING is on, the player will have about three seconds to get out of water
 before they die (if swimming isn't available). If it is off, water will just be
 impassable.
 Enjoy!
=end
#------------------------------------------------------------------------------#
WATER = 1
SWIM_SWITCH = 1
SWIM_ITEM = nil
SWIM_ARMOR = nil
SWIM_WEAPON = nil
SNEAK_KEY = nil #Input::Letterres["Z"] for Mr.Mo's ABS or input letters script
DASH_KEY = nil #Input::Letters["X"] for Mr.Mo's ABS or input letters script
SWIM_SE = "022-Dive02"
DROWN_SE = "021-Dive01"
DROWNING = true
WATER_DASHING = false
DIVE_SOUND_OFF = false
DIVE_GRAPHIC = true
TREAD_ANI = true
#------------------------------------------------------------------------------#

#==============================================================================#
# Game_Player                                                                  #
#------------------------------------------------------------------------------#
# Modifies the Game_Player class initialization and updating                   #
#==============================================================================#
class Game_Player < Game_Character
  attr_reader   :swim
  attr_reader   :swimming?
  attr_reader   :swim_count
  alias swim_init initialize
  def initialize
    @swim = false
    @drown_count = 0
    @swim_count = 0
    swim_init
  end
  alias swim_update update
  def update

    # Checks if swimming is triggered
    if DROWNING == true
    return jump_in if facing?(WATER, 'any', 1) and !@swim and moving?
    # Drowns if it is not available
    drown if !swim_available? and on?(WATER)
    elsif DROWNING == false
    return jump_in if facing?(WATER, 'any', 1) and !@swim and moving? and swim_available?
    end
   
    # Jumps out of water at shore
    jump_forward if !on?(WATER) and !facing?(WATER, 'any', 1) and !facing?(WATER, 'any', 2) and @swim and moving?
    # Returns original settings when out of water
    revert if @swim and !on?(WATER)
   
    # Refreshes swimming state
     swim_refresh if swimming?
  swim_update
end

    # Makes water impassable when swimming isn't available
  alias mrmo_swim_game_player_passable passable?
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # Check if it water tag
    return false if $game_map.terrain_tag(new_x,new_y) == WATER and !swim_available? and DROWNING == false
    # Old Method
    mrmo_swim_game_player_passable(x,y,d)
  end
#------------------------------------------------------------------------------#
# Custom Methods                                                               #
#------------------------------------------------------------------------------#
  # Checks swimming availability
  def swim_available?
     if SWIM_SWITCH != nil
      return true if $game_switches[SWIM_SWITCH]
      return false if !$game_switches[SWIM_SWITCH]
     end
     if SWIM_ITEM != nil
       return true if $game_party.item_number(SWIM_ITEM) != 0
       return false if $game_party.item_number(SWIM_ITEM) == 0
     end
     if SWIM_ARMOR != nil
       return true if $game_party.actors[0].armor1_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor2_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor3_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor4_id == SWIM_ARMOR
       return false
     end
     if SWIM_WEAPON != nil
       return true if $game_party.actors[0].weapon_id == SWIM_WEAPON
       return false
     end
     return true
   end
   
  # Jumps in the water if swimming is triggered
  def jump_in
    @swim = true
    unless DIVE_SOUND_OFF
     @play_sound = true
    end
   if DIVE_GRAPHIC == true
    @character_name = $game_party.actors[0].character_name
    @character_name = $game_party.actors[0].character_name + "_dive"
   end
   jump_forward if facing?(WATER, 'any', 1)
  end
 
  # Swimming setup
  def swim_refresh
      get_speed if moving?
      if !moving?
        @character_name = $game_party.actors[0].character_name
        @character_name = $game_party.actors[0].character_name + "_swim"
      end
      if @play_sound and !moving?
         Audio.se_play("Audio/SE/" + SWIM_SE , 80, 100)
         @play_sound = false
      end
         @swim = true
      if TREAD_ANI == true
         @step_anime = true
       end
     end
     
  # Drowning
  def drown
    @move_speed = 0.1
    if @drown_count <= 120
      #jump_in if !@swim
      @drown_count += 1
        if @drown_count %40 == 0
          Audio.se_play("Audio/SE/" + DROWN_SE, 80, 100)
        end
      elsif @drown_count >= 120
      @character_name = ""
      @drown_count = 0
      Audio.se_play("Audio/SE/" + SWIM_SE, 80, 100)
     $scene = Scene_Gameover.new
    end
  end
 
  # Reverts original settings when out of water
  def revert
      @character_name = $game_party.actors[0].character_name
      @swim = false
      @drown_count = 0
        unless dashing? or sneaking?
         @move_speed = 4
         @move_frequency = 6
        end
       if TREAD_ANI == true
       @step_anime = false
     end
   end
   
  # Determines Speed (Swim Leveling)
  def get_speed
    # Gets Swim Count
      @swim_count += 0.05
    case @swim_count
    when 0.05
      @swim_speed = 1
      @move_frequency = 1
    when 100
      @swim_speed =  2
      @move_frequency = 1
    when 250
      @swim_speed = 3
      @move_frequency = 1
    when 750
      @swim_speed = 4
      @move_frequency = 1
    when 2000
      @swim_speed = 5
      @move_frequency = 1
    end
    @move_speed = @swim_speed
      if WATER_DASHING == true
          if DASH_KEY != nil and Input.press?(DASH_KEY) and !sneaking?
           @move_speed = @swim_speed + 1
           @move_frequency = 6
          end
          if SNEAK_KEY != nil and Input.press?(SNEAK_KEY) and !dashing?
           @move_speed = @swim_speed -1
           @move_frequency = 2
         end
       end
     end
 
# Jumps forward
  def jump_forward
  case @direction
      when 2
        jump(0, 1)
      when 4
        jump(-1, 0)
      when 6
        jump(1, 0)
      when 8
        jump(0, -1)
      end
    end
  # Jumps backward
  def jump_backward
    case @direction
      when 2
        jump(0, -1)
      when 4
        jump(1, 0)
      when 6
        jump(-1, 0)
      when 8
        jump(0, 1)
      end
    end

  # Checks if dashing
  def dashing?
    return true if DASH_KEY != nil and Input.press?(DASH_KEY)
    return false if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
  end
  # Checks if sneaking
  def sneaking?
    return true if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
    return false if DASH_KEY != nil and Input.press?(DASH_KEY)
  end
  # Checks if swimming
  def swimming?
    return true if on?(WATER) and @swim
  end
  # Checks if player is on a terrain tag
  def on?(tag)
    return true if $game_map.terrain_tag($game_player.x, $game_player.y) == tag
  end
  # Checks if player is facing a terrain tag
  def facing?(tag, dir, dist)
    case dir
     when 2
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
     when 4
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
       end
     when 6
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
       end
     when 8
       if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
     when 'any'
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
      end
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
      end
      if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
    end
   return false if tag_x == nil or tag_y == nil
   return true if $game_map.terrain_tag(tag_x, tag_y) == tag
 end
end
#------------------------------------------------------------------------------#
# By ToriVerly
# Thanks to Mr.Mo for help with my passability issues and to Chaosg1 for my intro
# into scripting :)
#------------------------------------------------------------------------------#

Instructions

See Script

Compatibility

According to an SDK user, this script is compatible.
So far scripts that change actor graphics are buggy with this.  It can be easily fixed if you know what you're doing....:
If using another script/system that changes actor graphic
[INDENT]Find the line that changes the graphic and add to the conditions:
Code: [Select]
and if $game_player.terrain_tag != WATER
Make sure that at the top of your script, outside commenting and before anything that starts with 'class', put
Code: [Select]
WATER = 1
[or change 1 to whatever terrain tag you are using for water.]
If none of that made sense, then for now it's not compatable with any script changing graphics.
Title: Re: Swimming Script!
Post by: Snailer on February 26, 2007, 04:16:11 PM
XD

That's funny but still..
I LOVE IT !!!
good job :D
Title: Re: Swimming Script!
Post by: toriverly on February 26, 2007, 05:16:52 PM
Thanks!

but what's funny? lol
Title: Re: Swimming Script!
Post by: Blizzard on February 26, 2007, 05:26:07 PM
Sweet! ;8
Title: Re: Swimming Script!
Post by: Snailer on February 26, 2007, 05:27:34 PM
Thanks!

but what's funny? lol
A swimming script is funny :)
Title: Re: Swimming Script!
Post by: Zeriab on February 26, 2007, 06:39:35 PM
Nice  :D
Title: Re: Swimming Script!
Post by: Irock on February 26, 2007, 07:03:49 PM
I keep getting

Code: [Select]
????? 'swimming'? 28??? NameError????????
uninitialized constant Input::Letters


Never mind. Blizzard fixed it. ;D
Title: Re: Swimming Script!
Post by: blazinhandle on February 26, 2007, 07:04:21 PM
well thats useful, nice job.
Title: Re: Swimming Script!
Post by: Blizzard on February 26, 2007, 07:17:21 PM
I keep getting

Code: [Select]
????? 'swimming'? 28??? NameError????????
uninitialized constant Input::Letters
I changed it to nil.


Nvm, I fixed it for him on AIM.
Title: Re: Swimming Script!
Post by: toriverly on February 26, 2007, 07:52:33 PM
Thanks guys, i'm glad you like it :). This is my first script that does something more interesting than showing a window btw lol.  Anything you guys think I could add to it? Like I said, it probably won't happen this week because my mom is cracking the h/w whip over my head.

EDIT: How many here would like the character to "tread water" and animate (while not moving) in water?
Title: Re: Swimming Script!
Post by: Irock on February 26, 2007, 11:23:17 PM
Thanks guys, i'm glad you like it :). This is my first script that does something more interesting than showing a window btw lol.  Anything you guys think I could add to it? Like I said, it probably won't happen this week because my mom is cracking the h/w whip over my head.

EDIT: How many here would like the character to "tread water" and animate (while not moving) in water?
Me! I would also like a good splash animation for when the hero jumps in.
Title: Re: Swimming Script!
Post by: Valcos on February 27, 2007, 02:01:12 AM
Awesome!!!!  ;D I LOVE IT!!! I am adding this to my favorites.
Title: Re: Swimming Script!
Post by: :) on February 27, 2007, 02:05:15 AM
This is very nice.

*Script databse* ?
Title: Re: Swimming Script!
Post by: Valcos on February 27, 2007, 02:35:44 AM
Ok...I know this is soon, but I am like the biggest noob and I dont know how to edit the sprites. Or add the stuff to the script.
Title: Re: Swimming Script!
Post by: toriverly on February 27, 2007, 01:48:46 PM
I know I said I had homework...and I do...but it was so boring...and the script was calling me...so it's updated ;8
@Valcos: What are you adding? My crappy sprite was just the regular one cut off at the armpits.  It actually looks good if you put a little bit of blue splash around them.
@Nouman: Do I put it there? or a mod?
@Irockman1: I'd love an animation also, but I don't know anything about them  :'(
Title: Re: Swimming Script!
Post by: :) on February 27, 2007, 02:30:52 PM
@Nouman: Do I put it there? or a mod?

Once a mod sees fit to this they can move it to the database. I was just suggesting it. =D
Title: Re: Swimming Script!
Post by: Zeriab on February 27, 2007, 04:40:57 PM
Nouman, just report the topic to a moderator and write something like "Should be moved to the Script Database" in the comment field.
If you believe this topic belongs to the Script Database instead of Scripts it should be reported.
I'll let you do the honors ;)
Title: Re: Swimming Script!
Post by: Blizzard on February 27, 2007, 05:14:00 PM
I've seen this topic already and there's one flaw in the script which makes me think it's not ready for the database yet.
I think you should find a way to use the usual character spriteset without the need for an extra cut-off sprite. It's rather easy, you only need to check out how the Sprite_Character class works (mainly def update where the bitmap gets cached). If you can change that in your script, I'll move it into the database, since I'm checking this topic daily. :)
Title: Re: Swimming Script!
Post by: toriverly on February 27, 2007, 06:12:06 PM
You mean not to change the sprite or find a way to cut off the sprite without a new one?  I think most people will like the diving sprite change because that one will be totally different. (ei. cannonball or a jumpy/dashy one) I suppose the script works best with the cut off sprites, but it doesn't look right without the ripples around it...(I'll update the screen shot soon)and I was going to get a template for a sprite that does a sort of breast stroke.
Title: Re: Swimming Script!
Post by: Blizzard on February 27, 2007, 07:12:15 PM
Well, I think that can work out as well. BTW, change the preconfig of the Dask and Sneak button to nil. Most people are not using Mr. Mo's ABS. I'll move it now into the database then and you update the script ASAP. :)
Title: Re: Swimming Script!
Post by: Valcos on February 27, 2007, 10:50:48 PM
Well, my problem is not the scirpt its just that I dont know how to add or edit sprites  ^-^ Can someone help me with that or should I search it? (im jut lazy)
Title: Re: Swimming Script!
Post by: toriverly on February 28, 2007, 12:57:13 AM
There's a button that looks like a folder with three pages infront of it.  It's between the database and the script editor buttons.  It's the materials button.  Click it and you can import and export graphics for customization.  The sprites are in the Characters folder.  I reccommend Paint.net and Adobe Photoshop CS2 for editing.  Graphics Gale is supposed to be good too but I don't have it. Paint.net and Graphics Gale are free. Google them.
Title: Re: Swimming Script!
Post by: Valcos on February 28, 2007, 02:38:33 AM
Oh, ok. Thank  ;D
Title: Re: Swimming Script!
Post by: Valcos on February 28, 2007, 02:56:34 AM
I made the sprites but they dont activate when I go on the water?
Title: Re: Swimming Script!
Post by: toriverly on February 28, 2007, 03:06:17 PM
that's extremely odd. Are you getting an error? are your sprites named properly? (they must be named in YourName_whatever format not just _swim or _Swim or _swims or Yournameswim) are they in the characters folder? (I personally mess that up a lot and dump them in the animations folder and get really mad about why it's not working lmho)

EDIT: Another thing I forget, is to set the actor graphic to your new sprite (in the database under actors).  Did ya do that?
Title: Re: Swimming Script!
Post by: Valcos on February 28, 2007, 09:25:32 PM
What you mean add it to your character?
Title: Re: Swimming Script!
Post by: :) on March 01, 2007, 12:38:37 AM
sweeeeetness! nice update.
Title: Re: Swimming Script!
Post by: toriverly on March 01, 2007, 03:14:35 AM
What you mean add it to your character?
you know...tools>database>actors double click the picture and select a new one?
Title: Re: Swimming Script!
Post by: Valcos on March 01, 2007, 04:26:29 AM
Oh, you got to make a whole new character?
Title: Re: Swimming Script!
Post by: toriverly on March 01, 2007, 05:49:25 AM
I know that as soon as I make sense, you're gonna say "oh yeah I did that." but I must post this anyway for the sake of helping and being sure.
 1. Go to the Database
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fdatabase.png&hash=3b2de2b59d55b630011d7572e997b5985d43b24d)
 2. Click the 'Actors' tab
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fdatabase-actors.png&hash=1b2d2d0689ac9efc0c5838ffe352eb5b1ce2fbbd)
 3. Select your actor ^^Aluxes is highlighted there
 4. Double-click on the little sprite guy under 'Character Graphic'
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fcharactergraphic.png&hash=da285b3f90acbfd77676c45bf0b5bbd70cbe03fc)
 5. Select your new graphic
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi78.photobucket.com%2Falbums%2Fj92%2Fchastity_belted%2Fselectgraphic.png&hash=2a2c5bd801ca55342497cab1a7788a844df3079e)

Now, all the other ones (name_swim, name_dive...etc) will be imported with the 'Materials' editor thingy i told you about before into the characters file.  They should work as long as they are named GraphicThatYouJustSet_SwimOrWhatever (ei. 001-Fighter01_swim if your graphic is 001-Fighter01)
Title: Re: Swimming Script!
Post by: Valcos on March 01, 2007, 11:31:00 PM
Ok, I'll try out what you said.
Title: Re: Swimming Script!
Post by: toriverly on March 02, 2007, 03:41:43 AM
fixed two bugs (nobody else noticed them but anyway they're fixed :P) check the updated post.
Title: Re: Swimming Script!
Post by: toriverly on March 02, 2007, 11:32:45 PM
Update:
Now you can (or I should say can't) swim if you don't have a certain item, weapon or armor.  I don't know why you'd need a weapon...maybe you have the magic water rod...w/e it's up to you!

I've also fixed my weird looking template.
Title: Re: Swimming Script!
Post by: zzboy on March 03, 2007, 02:35:41 AM
I just tried the script and for some reason it just wont work. ???
Title: Re: Swimming Script!
Post by: toriverly on March 03, 2007, 06:47:48 AM
Be specific: what won't work?  Is there an error? Is it frozen?

Also, did you follow the instructions?  Remember that tiles must have the terrain tag WATER and must be passable.
Title: Re: Swimming Script!
Post by: zzboy on March 04, 2007, 02:40:45 AM
Theres an error and yes I did follow the instrucions.
Title: Re: Swimming Script!
Post by: Winged on March 04, 2007, 02:48:05 AM
Awesome script and very unique! Rep +

~Winged
Title: Re: Swimming Script!
Post by: toriverly on March 04, 2007, 03:33:35 AM
Okay...so what is the error?
Title: Re: Swimming Script!
Post by: zzboy on March 04, 2007, 04:53:10 AM
It comes up saying that it's unaccessable. If it makes any difference I use Postality Knights.
Title: Re: Swimming Script!
Post by: toriverly on March 04, 2007, 07:06:34 PM
As long as you have all the necessary pictures, i don't see what could be inaccessable?

It's prolly because of PK...I don't know anything about it so I don't know how to fix that error...sorry!
Title: Re: Swimming Script!
Post by: Houna on March 07, 2007, 04:58:05 AM
I encountered a problem too in this part of the script.

# Drowning
  def drown
    $game_screen.start_flash(Color.new(255,0,0,128), 20)
    if @drown_count <= 10
      swim if !@swim
      @drown_count += 1
    elsif @drown_count >=10
      @drown_count = 0
     $scene = Scene_Gameover.new
    end
  end


On this line @drown_count += 1 I had to delete the plus sign for it to work.
Just putting that out there for people to try if they are having trouble.
Title: Re: Swimming Script!
Post by: toriverly on March 07, 2007, 07:00:29 PM
That can't be right.  If you put =1 it will never =10 and you'll never get gameover?
I don't know if you're a scripter but += 1 means "add one" it's not a typo.  You should have a second or so while @drown_count reaches 10 and then you get a gameover.
What happened exactly before and after you removed the +?

@zzboy---I d/l PK to test, but I'm not getting an error? What did you set the constants to?
Code: [Select]
WATER = 1
SWIM_SWITCH = nil
SWIM_ITEM = nil
SWIM_ARMOR = nil
SWIM_WEAPON = nil
SNEAK_KEY = nil #Input::Letterres["Z"] for Mr.Mo's ABS or input letters script
DASH_KEY = nil #Input::Letters["X"] for Mr.Mo's ABS or input letters script
SWIM_SE = "022-Dive02"
DROWNING = false
WATER_DASHING = false
DIVE_SOUND_OFF = false
DIVE_GRAPHIC = false
TREAD_ANI = true
#---------------------------
These, what did you set them to?
Title: Re: Swimming Script!
Post by: zzboy on March 09, 2007, 12:17:43 AM
Yep.
Title: Re: Swimming Script!
Post by: zzboy on March 09, 2007, 12:40:21 AM
Oh, woops. I was reading through the whole thing and
I think found out what i did wrong. I don't think I made another character. Although I don't quite get how to do that.
Title: Re: Swimming Script!
Post by: DarkLordX on June 03, 2007, 05:47:28 AM
Alright - dumb question, I'm sure, by I don't want to alter the script in any way I'll regret later: How exactly can I make the characters swim faster? I'm fairly certain it's with these lines -

# Determines Speed (Swim Leveling)
  def get_speed
    # Gets Swim Count
      @swim_count += 0.05
    case @swim_count
    when 0.05
      @swim_speed = 1
      @move_frequency = 1
    when 100
      @swim_speed =  2
      @move_frequency = 1
    when 250
      @swim_speed = 3
      @move_frequency = 1
    when 750
      @swim_speed = 4
      @move_frequency = 1
    when 2000
      @swim_speed = 5
      @move_frequency = 1
    end

But I'm not sure what's defined as the 'Swim count' or if I want to change it.
Title: Re: Swimming Script!
Post by: toriverly on June 04, 2007, 12:17:11 AM
well, if you want a constant faster speed, just do this:
Code: [Select]
# Determines Speed (Swim Leveling)
  def get_speed
   @swim_speed = 4 #or any number from 1-6.  3 is walking pace.
    end

Spoiler for if you want the characters to learn faster::

Code: [Select]
# Determines Speed (Swim Leveling)
  def get_speed
    # Gets Swim Count
      @swim_count += 0.05 # change this 0.05 to a bigger number to make them level up
                                          # faster.  Remember, just putting 0.5 would be 10 times
                                          # faster.
    case @swim_count
    when 0.05
      @swim_speed = 1
      @move_frequency = 1
    when 100
      @swim_speed =  2
      @move_frequency = 1
    when 250
      @swim_speed = 3
      @move_frequency = 1
    when 750
      @swim_speed = 4
      @move_frequency = 1
    when 2000
      @swim_speed = 5
      @move_frequency = 1
    end
Although I don't have rmxp on this computer and I haven't scripted in ages, i'm fairly certain that should work.
enjoy :)
Title: Re: Swimming Script!
Post by: DarkLordX on June 13, 2007, 07:25:28 AM
Alright... one major problem with this script I can see so far... I'm using a caterpillar script for my party, so among the two options of drowning on or off -

If drowning is FALSE, then every time a character tries to go onto a water panel (and by the script, is immediately pushed one step backwards), the party member behind him goes onto the space where the leader just was - so you have the leader of the party unable to go into the water, yes, but all the other members are standing there on the water.

If drowning is TRUE, there are two concerns - every time you walk on a bridge over water or anything, the screen flashes red as if you were about to drown. Aside from that, if the water is only one panel wide and the character walks into it, the screen flashes red and the character jumps forward two panels - OVER the water into an area that should be inaccessible, at least for the time being. ;/
Title: Re: Swimming Script!
Post by: toriverly on June 13, 2007, 01:17:00 PM
  Sorry about the caterpillar script,   I don't get how they work at all *scripting noob here*  I haven't had a lot of time recently in fact I have a math exam in a couple of hours and history tomorrow -_- 

Anyway, the bridge is about terrain tags.  If a terrain tag is 0, the scripts reading them just phase through it and it will behave like the one under it.  It should work if you set it to 2 or w/e is not water or 0.  I can't remember if it's supposed to be a higher # than water though.
Title: Re: Swimming Script!
Post by: DarkLordX on June 13, 2007, 09:28:57 PM
Alright, thanks for the second one... but even if I did use the drowning now, they would still be jumping over 1-tile-wide streams of water.


Caterpillar script - these program it so that your party members trail behind you, or rather, they follow your exact move pattern one panel behind eachother. For example, Bob is the party leader and Joe is the second member in the party. If Bob tries to step onto a water panel, this script pushes him a step back, meaning that the last panel he was on - and coincidingly the one Joe is left on - is the water panel. So, you've got Bob unable to walk on the water, yes, but Joe is left there standing on top of it.

The only way I know could prevent this would be setting a tile as impassible based on its Terrain flag... but alas, I have no idea how or if this is possible. ;/
Title: Re: Swimming Script!
Post by: toriverly on June 13, 2007, 10:58:55 PM
The script calls upon the terrain tag the player is already standing on.  He won't jump until he's already on the water but it looks like he jumps into it.  I suppose I can take another look at it some time, but I'm way too busy right now with exams and well life.  There isn't really much point to swimming across a single tile anyway is there?  You can always just use a second tile there with another terrain tag for "shallow water" and he'll walk over it.  Anyway, I know what a caterpillar script is, but I don't know how to manipulate them.
Title: Re: Swimming Script!
Post by: DarkLordX on June 14, 2007, 10:14:22 PM
... nevermind... I think I can solve this whole problem by assigning two water autotiles with different labels.



EDIT: Hm... something's acting up, and I can't figure out what... I'm great with map layouts and programming, but not scripting...       does this script define which AUTOTILES are classified as water or can it change depending on the space?        Example... I have two of the same water autotiles on the same map. One of them (top of the tileset sheet) is defined with the terrain tag as water - the other isn't. However, the same problem occurs with the second, non-water assigned autotileset.
Title: Re: Swimming Script!
Post by: toriverly on June 16, 2007, 02:15:25 PM
lol I remember actually fixing the 1 tile bug now...but apparently it only works if drowning is off XD

np simple matter.  Try this:
Spoiler for :
Code: [Select]
#==============================================================================#
#  Swimming!  v 1.7.a                                                          #
#  By: ToriVerly @ hbgames.org                                                    #
#==============================================================================#
#  Intructions:                                                                #
#------------------------------------------------------------------------------#
=begin
 Paste this script above Main and below everything else.
 For each character you will have swimming, make a swimming sprite that has the
 same name as the character but ending with "_swim" and another with "_dive" if
 DIVE_GRAPHIC is true.
    Example: "001-Fighter01_swim.png"
 
 If TREAD_ANI = true, the character will be animated while in water when they are
 not moving.  Hence a treading water effect.  Set it to false if you don't want
 the effect.
 
 Set the WATER constant to the terrain tag ID of your water tiles or whatever tile
 you want to swim through.  When you place non water tiles over water tiles (in
 a higher layer), the non water tiles will need to have a terrain tag that is
 different than WATER and not 0 or else the characters is swim through it.
 
    IMPORTANT--->make sure your water tile is passable.
 
 If you want the ability to swim to depend on a switch, set SWIM_SWITCH to the ID
 of the game switch you're using. If you don't want to use a switch, set it to nil.
 Similarily, set SWIM_ITEM, SWIM_ARMOR or SWIM_WEAPON to the ID of the item, armor
 or weapon required for swimming and nil if there is none.  You can even set more
 than one condition!
 
 The SWIM_SE will play every time you jump into water.  If you don't want a sound,
 set DIVE_SOUND_OFF to true.
 
 The SNEAK_KEY and DASH_KEY functions can be set for Mr.Mo's ABS or an input
 letters script.  If you don't have such an input system but have another dashing
 and/or sneaking system/script, change them to Input::YourKey.
     Example: Input::X
              Input::Y
 If you don't have dashing or sneaking at all, set them to nil.
 WATER_DASHING is self explanitory.  If you want to dash in water, set it to true.
 If DROWNING is set to true, the player can jump in water if swimming is not
 available but they will get a gameover.
 Easy right? Enjoy!
=end
#------------------------------------------------------------------------------#
WATER = 1
SWIM_SWITCH = 1
SWIM_ITEM = nil
SWIM_ARMOR = nil
SWIM_WEAPON = nil
SNEAK_KEY = nil #Input::Letterres["Z"] for Mr.Mo's ABS or input letters script
DASH_KEY = nil #Input::Letters["X"] for Mr.Mo's ABS or input letters script
SWIM_SE = "022-Dive02"
DROWNING = true
WATER_DASHING = false
DIVE_SOUND_OFF = false
DIVE_GRAPHIC = true
TREAD_ANI = true
#------------------------------------------------------------------------------#

#==============================================================================#
# Game_Player                                                                  #
#------------------------------------------------------------------------------#
# Modifies the Game_Player class initialization and updating                   #
#==============================================================================#
class Game_Player < Game_Character
  attr_reader   :swim
  attr_reader   :swimming?
  attr_reader   :swim_count
  alias swim_init initialize
  def initialize
    @swim = false
    @drown_count = 0
    @swim_count = 0
    swim_init
  end
  alias swim_update update
  def update

    # Checks if swimming is triggered
    if swim_available? and on?(WATER) and !@swim
      return jump_in if facing?(WATER, 'any', 1)
    end
    # Determines if swimming and sets up the character appropriately
    if swimming?
     swim_refresh
    end
    # Drowns or prevents swimming if it is not available
    if facing?(WATER, 'any', 1) and !swim_available? and on?(WATER)
      if DROWNING == true
       drown
      elsif DROWNING == false
       move_backward
      end
    end
   # Jumps out of water at shore
    jump_forward if !on?(WATER) and !facing?(WATER, 'any', 1) and !facing?(WATER, 'any', 2) and @swim and moving?
    # Returns original settings when out of water
    revert if @swim and !on?(WATER)
  swim_update
 end
#------------------------------------------------------------------------------#
# Custom Methods                                                               #
#------------------------------------------------------------------------------#
  # Checks swimming availability
  def swim_available?
     if SWIM_SWITCH != nil
      return true if $game_switches[SWIM_SWITCH]
      return false if !$game_switches[SWIM_SWITCH]
     end
     if SWIM_ITEM != nil
       return true if $game_party.item_number(SWIM_ITEM) != 0
       return false if $game_party.item_number(SWIM_ITEM) == 0
     end
     if SWIM_ARMOR != nil
       return true if $game_party.actors[0].armor1_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor2_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor3_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor4_id == SWIM_ARMOR
       return false
     end
     if SWIM_WEAPON != nil
       return true if $game_party.actors[0].weapon_id == SWIM_WEAPON
       return false
     end
     return true
   end
   
  # Jumps in the water if swimming is triggered
  def jump_in
    @swim = true
    unless DIVE_SOUND_OFF
     @play_sound = true
    end
   if DIVE_GRAPHIC == true
    @character_name = $game_party.actors[0].character_name
    @character_name = $game_party.actors[0].character_name + "_dive"
   end
   jump_forward
  end
 
  # Swimming setup
  def swim_refresh
      get_speed if moving?
      if !moving?
        @character_name = $game_party.actors[0].character_name
        @character_name = $game_party.actors[0].character_name + "_swim"
      end
      if @play_sound and !moving?
         Audio.se_play("Audio/SE/" + SWIM_SE + ".ogg", 80, 100)
         @play_sound = false
      end
         @swim = true
      if TREAD_ANI == true
         @step_anime = true
       end
     end
     
  # Drowning
  def drown
    $game_screen.start_flash(Color.new(255,0,0,128), 20)
    if @drown_count <= 10
      jump_in if !@swim and facing?(WATER, 'any', 1)
      @drown_count += 1
    elsif @drown_count >= 10
      @drown_count = 0
     $scene = Scene_Gameover.new
    end
  end
 
  # Reverts original settings when out of water
  def revert
      @character_name = $game_party.actors[0].character_name
      @swim = false
      @drown_count = 0
        unless dashing? or sneaking?
         @move_speed = 4
         @move_frequency = 6
        end
       if TREAD_ANI == true
       @step_anime = false
     end
   end
   
  # Determines Speed (Swim Leveling)
  def get_speed
    # Gets Swim Count
      @swim_count += 0.05
    case @swim_count
    when 0.05
      @swim_speed = 1
      @move_frequency = 1
    when 100
      @swim_speed =  2
      @move_frequency = 1
    when 250
      @swim_speed = 3
      @move_frequency = 1
    when 750
      @swim_speed = 4
      @move_frequency = 1
    when 2000
      @swim_speed = 5
      @move_frequency = 1
    end
    @move_speed = @swim_speed
      if WATER_DASHING == true
          if DASH_KEY != nil and Input.press?(DASH_KEY) and !sneaking?
           @move_speed = @swim_speed + 1
           @move_frequency = 6
          end
          if SNEAK_KEY != nil and Input.press?(SNEAK_KEY) and !dashing?
           @move_speed = @swim_speed -1
           @move_frequency = 2
         end
       end
     end
 
# Jumps forward
  def jump_forward
  case @direction
      when 2
        jump(0, 1)
      when 4
        jump(-1, 0)
      when 6
        jump(1, 0)
      when 8
        jump(0, -1)
      end
    end
  # Jumps backward
  def jump_backward
    case @direction
      when 2
        jump(0, -1)
      when 4
        jump(1, 0)
      when 6
        jump(-1, 0)
      when 8
        jump(0, 1)
      end
    end

  # Checks if dashing
  def dashing?
    return true if DASH_KEY != nil and Input.press?(DASH_KEY)
    return false if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
  end
  # Checks if sneaking
  def sneaking?
    return true if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
    return false if DASH_KEY != nil and Input.press?(DASH_KEY)
  end
  # Checks if swimming
  def swimming?
    return true if on?(WATER) and @swim
  end
  # Checks if player is on a terrain tag
  def on?(tag)
    return true if $game_map.terrain_tag($game_player.x, $game_player.y) == tag
  end
  # Checks if player is facing a terrain tag
  def facing?(tag, dir, dist)
    case dir
     when 2
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
     when 4
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
       end
     when 6
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
       end
     when 8
       if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
     when 'any'
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
      end
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
      end
      if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
    end
   return false if tag_x == nil or tag_y == nil
   return true if $game_map.terrain_tag(tag_x, tag_y) == tag
 end
end
#------------------------------------------------------------------------------#
# By ToriVerly                                                                 #
#------------------------------------------------------------------------------#

Title: Re: Swimming Script!
Post by: DarkLordX on June 16, 2007, 06:11:54 PM
Alright.. what exactly should this update do? :P
Title: Re: Swimming Script!
Post by: toriverly on June 17, 2007, 04:00:40 AM
shouldn't drown on a single water tile.
Title: Re: Swimming Script!
Post by: DarkLordX on June 17, 2007, 10:05:44 PM
.. as in it won't jump? The problem isn't that they don't drown, (and they don't) it's that the jump as if they were about to drown.. ? :-X
Title: Re: Swimming Script!
Post by: toriverly on June 18, 2007, 05:48:12 AM
Okaaaaaaaaay...so, the character is supposed to drown on a single tile of water, but all that happens is the screen flashes and they jump over it unscathed?
Spoiler for This should work:
Code: [Select]
#==============================================================================#
#  Swimming!  v 1.7.b                                                          #
#  By: ToriVerly @ hbgames.org                                                    #
#==============================================================================#
#  Intructions:                                                                #
#------------------------------------------------------------------------------#
=begin
 Paste this script above Main and below everything else.
 For each character you will have swimming, make a swimming sprite that has the
 same name as the character but ending with "_swim" and another with "_dive" if
 DIVE_GRAPHIC is true.
    Example: "001-Fighter01_swim.png"
 
 If TREAD_ANI = true, the character will be animated while in water when they are
 not moving.  Hence a treading water effect.  Set it to false if you don't want
 the effect.
 
 Set the WATER constant to the terrain tag ID of your water tiles or whatever tile
 you want to swim through.  When you place non water tiles over water tiles (in
 a higher layer), the non water tiles will need to have a terrain tag that is
 different than WATER and not 0 or else the characters is swim through it.
 
    IMPORTANT--->make sure your water tile is passable.
 
 If you want the ability to swim to depend on a switch, set SWIM_SWITCH to the ID
 of the game switch you're using. If you don't want to use a switch, set it to nil.
 Similarily, set SWIM_ITEM, SWIM_ARMOR or SWIM_WEAPON to the ID of the item, armor
 or weapon required for swimming and nil if there is none.  You can even set more
 than one condition!
 
 The SWIM_SE will play every time you jump into water.  If you don't want a sound,
 set DIVE_SOUND_OFF to true.
 
 The SNEAK_KEY and DASH_KEY functions can be set for Mr.Mo's ABS or an input
 letters script.  If you don't have such an input system but have another dashing
 and/or sneaking system/script, change them to Input::YourKey.
     Example: Input::X
              Input::Y
 If you don't have dashing or sneaking at all, set them to nil.
 WATER_DASHING is self explanitory.  If you want to dash in water, set it to true.
 If DROWNING is set to true, the player can jump in water if swimming is not
 available but they will get a gameover.
 Easy right? Enjoy!
=end
#------------------------------------------------------------------------------#
WATER = 1
SWIM_SWITCH = 1
SWIM_ITEM = nil
SWIM_ARMOR = nil
SWIM_WEAPON = nil
SNEAK_KEY = nil #Input::Letterres["Z"] for Mr.Mo's ABS or input letters script
DASH_KEY = nil #Input::Letters["X"] for Mr.Mo's ABS or input letters script
SWIM_SE = "022-Dive02"
DROWNING = true
WATER_DASHING = false
DIVE_SOUND_OFF = false
DIVE_GRAPHIC = true
TREAD_ANI = true
#------------------------------------------------------------------------------#

#==============================================================================#
# Game_Player                                                                  #
#------------------------------------------------------------------------------#
# Modifies the Game_Player class initialization and updating                   #
#==============================================================================#
class Game_Player < Game_Character
  attr_reader   :swim
  attr_reader   :swimming?
  attr_reader   :swim_count
  alias swim_init initialize
  def initialize
    @swim = false
    @drown_count = 0
    @swim_count = 0
    swim_init
  end
  alias swim_update update
  def update

    # Checks if swimming is triggered
    return jump_in if facing?(WATER, 'any', 1) and !@swim and moving?
    # Determines if swimming and sets up the character appropriately
     swim_refresh if swimming?
    # Drowns or prevents swimming if it is not available
    if !swim_available? and on?(WATER)
      if DROWNING == true
       drown
      elsif DROWNING == false
       move_backward
      end
    end
   # Jumps out of water at shore
    jump_forward if !on?(WATER) and !facing?(WATER, 'any', 1) and !facing?(WATER, 'any', 2) and @swim and moving?
    # Returns original settings when out of water
    revert if @swim and !on?(WATER)
  swim_update
 end
#------------------------------------------------------------------------------#
# Custom Methods                                                               #
#------------------------------------------------------------------------------#
  # Checks swimming availability
  def swim_available?
     if SWIM_SWITCH != nil
      return true if $game_switches[SWIM_SWITCH]
      return false if !$game_switches[SWIM_SWITCH]
     end
     if SWIM_ITEM != nil
       return true if $game_party.item_number(SWIM_ITEM) != 0
       return false if $game_party.item_number(SWIM_ITEM) == 0
     end
     if SWIM_ARMOR != nil
       return true if $game_party.actors[0].armor1_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor2_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor3_id == SWIM_ARMOR
       return true if $game_party.actors[0].armor4_id == SWIM_ARMOR
       return false
     end
     if SWIM_WEAPON != nil
       return true if $game_party.actors[0].weapon_id == SWIM_WEAPON
       return false
     end
     return true
   end
   
  # Jumps in the water if swimming is triggered
  def jump_in
    @swim = true
    unless DIVE_SOUND_OFF
     @play_sound = true
    end
   if DIVE_GRAPHIC == true
    @character_name = $game_party.actors[0].character_name
    @character_name = $game_party.actors[0].character_name + "_dive"
   end
   jump_forward if facing?(WATER, 'any', 1)
  end
 
  # Swimming setup
  def swim_refresh
      get_speed if moving?
      if !moving?
        @character_name = $game_party.actors[0].character_name
        @character_name = $game_party.actors[0].character_name + "_swim"
      end
      if @play_sound and !moving?
         Audio.se_play("Audio/SE/" + SWIM_SE + ".ogg", 80, 100)
         @play_sound = false
      end
         @swim = true
      if TREAD_ANI == true
         @step_anime = true
       end
     end
     
  # Drowning
  def drown
    $game_screen.start_flash(Color.new(255,0,0,128), 20)
    if @drown_count <= 50
      #jump_in if !@swim
      @drown_count += 1
    elsif @drown_count >= 50
      @drown_count = 0
     $scene = Scene_Gameover.new
    end
  end
 
  # Reverts original settings when out of water
  def revert
      @character_name = $game_party.actors[0].character_name
      @swim = false
      @drown_count = 0
        unless dashing? or sneaking?
         @move_speed = 4
         @move_frequency = 6
        end
       if TREAD_ANI == true
       @step_anime = false
     end
   end
   
  # Determines Speed (Swim Leveling)
  def get_speed
    # Gets Swim Count
      @swim_count += 0.05
    case @swim_count
    when 0.05
      @swim_speed = 1
      @move_frequency = 1
    when 100
      @swim_speed =  2
      @move_frequency = 1
    when 250
      @swim_speed = 3
      @move_frequency = 1
    when 750
      @swim_speed = 4
      @move_frequency = 1
    when 2000
      @swim_speed = 5
      @move_frequency = 1
    end
    @move_speed = @swim_speed
      if WATER_DASHING == true
          if DASH_KEY != nil and Input.press?(DASH_KEY) and !sneaking?
           @move_speed = @swim_speed + 1
           @move_frequency = 6
          end
          if SNEAK_KEY != nil and Input.press?(SNEAK_KEY) and !dashing?
           @move_speed = @swim_speed -1
           @move_frequency = 2
         end
       end
     end
 
# Jumps forward
  def jump_forward
  case @direction
      when 2
        jump(0, 1)
      when 4
        jump(-1, 0)
      when 6
        jump(1, 0)
      when 8
        jump(0, -1)
      end
    end
  # Jumps backward
  def jump_backward
    case @direction
      when 2
        jump(0, -1)
      when 4
        jump(1, 0)
      when 6
        jump(-1, 0)
      when 8
        jump(0, 1)
      end
    end

  # Checks if dashing
  def dashing?
    return true if DASH_KEY != nil and Input.press?(DASH_KEY)
    return false if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
  end
  # Checks if sneaking
  def sneaking?
    return true if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
    return false if DASH_KEY != nil and Input.press?(DASH_KEY)
  end
  # Checks if swimming
  def swimming?
    return true if on?(WATER) and @swim
  end
  # Checks if player is on a terrain tag
  def on?(tag)
    return true if $game_map.terrain_tag($game_player.x, $game_player.y) == tag
  end
  # Checks if player is facing a terrain tag
  def facing?(tag, dir, dist)
    case dir
     when 2
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
     when 4
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
       end
     when 6
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
       end
     when 8
       if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
     when 'any'
       if $game_player.direction == 2
        tag_x = $game_player.x
        tag_y = $game_player.y + dist
      end
       if $game_player.direction == 4
        tag_x = $game_player.x - dist
        tag_y = $game_player.y
      end
       if $game_player.direction == 6
        tag_x = $game_player.x + dist
        tag_y = $game_player.y
      end
      if $game_player.direction == 8
        tag_x = $game_player.x
        tag_y = $game_player.y - dist
      end
    end
   return false if tag_x == nil or tag_y == nil
   return true if $game_map.terrain_tag(tag_x, tag_y) == tag
 end
end
#------------------------------------------------------------------------------#
# By ToriVerly                                                                 #
#------------------------------------------------------------------------------#
Now the player should jump from a square away from the water's edge so they land right in the narrow streams and will drown. If the RGSS would allow me to make the player jump straight up, it'd look better but at least it works....i think...give me feed back
Title: Re: Swimming Script!
Post by: DarkLordX on June 18, 2007, 07:41:04 PM
Yes, exactly. The previous problem is gone now, but....   although it may seem insignificant, there is a pause between the red flash and the Game Over scene call. The pause is long enough for a character to jump right out again on the other side. ;/

Don't want to be a pest... just trying to get this script all working through. ;/ (Also... for some reason, the other party members' swim animations aren't appearing now... they're just walking across the water... but I don't know if this is something to do with the swimming script or if it's just a deficiency of the Caterpillar script I'm using.)
Title: Re: Swimming Script!
Post by: toriverly on June 21, 2007, 06:45:24 AM
Okay
#1 I fixed the water passability issue.  No more followers walking on water.
#2 I have no idea how to change all party's characters' sprites and back...one way operation as far as I know...I think there's something I can do with the  .gsub! command, but so far I don't get it and the game ends up saying crap like "can't find hero_dive_swim_swim.png"...I think I should have mentioned that when you told me you were using a caterpiller but it slipped my mind XD.
#3 I like the pause giving the player a chance to save himself.  if you don't like it, change "def drown" to this:
Code: [Select]
  # Drowning
  def drown
        $game_screen.start_flash(Color.new(255,0,0,128), 20)
        $scene = Scene_Gameover.new
  end
I apologize about the party members' graphics.  The script changes the $game_player graphic but leaves the $game_party.actor graphic the same.  To change the other guys' graphics, I'd have to change $game_party.actors graphics...and I wouldn't know how to change them back once you're out the water.  :(
Title: Re: Swimming Script!
Post by: DarkLordX on June 21, 2007, 04:25:58 PM
Alright, thanks. :) Water passability thing's doing something REAL weird now... but it works great with drowning.

... quick question though: What's the scripting to add a short pause between script commands?
Title: Re: Swimming Script!
Post by: toriverly on June 21, 2007, 05:57:58 PM
Supposedly, you cant put @wait_count = whatever, but it doesn't seem to work for me so I do stuff like
Code: [Select]
if variable < desired ammount
variable +=1
elsif variable > desired ammount
do whatever
end
and then I have the update or refresh thing go through it whenever the right conditions are met.

what's wrong with the passability?
Title: Re: Swimming Script!
Post by: DarkLordX on June 22, 2007, 11:43:26 PM
Well... until further notice, I can't even use this. By now I've just decided against it. ;/

When drowning is off, and you go near a water tile, (within 1 space) the lead member goes into the Dive animation, shakes like mad, spazzes out with the other party members following suit, and does all sorts of crazy things before finally stopping in front of the water. With drowning on, I can't go within 1 tile of the water without drowning, so the Stream Hop thing would then be obsolete.
Title: Re: Swimming Script!
Post by: loloaziib on February 10, 2009, 02:46:53 PM
can you give me a DEMO
Title: Re: Swimming Script!
Post by: Mr_Wiggles on December 01, 2009, 09:17:23 AM
nice script old, wish i wouldve found this earlier wouldve came in handy for my first game i made
Title: Re: Swimming Script!
Post by: Filpez on April 22, 2010, 11:23:06 AM
I still donĀ“t understand how to put the swiming availity in a Armor. I want it to bo the armor 36 or 37 or 38 or 39 or 40. Can you explain? Pls