Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on September 29, 2009, 07:34:17 am

Title: [XP] Dash and Sneak
Post by: G_G on September 29, 2009, 07:34:17 am
Dash and Sneak
Authors: game_guy
Version: 1.1
Type: Custom Movement System
Key Term: Custom Movement System



Introduction

This script adds a little running and sneaking to your game. Don't use this if you're using Blizz-Abs because Blizz-Abs already has a running and sneaking.


Features




Screenshots

N/A


Demo

v1.0 Demo
MediaFire (http://mediafire.com/download.php?t431zmdndmm)

v1.1 Coming Soon


Script

Spoiler: ShowHide

#===============================================================================
# Dash and Sneak
# Author game_guy
# Version 1.1
#-------------------------------------------------------------------------------
# Intro:
# This script adds a little running and sneaking to your game. Don't use this
# if you're using Blizz-Abs because Blizz-Abs already has a running and
# sneaking.
#
# Features:
# Allows Running and Sneaking
# Allows Custom Walking, Running, and Sneaking Speeds
# Allows Custom Running and Sneaking Buttons
# Detects Walking, Running, and Sneaking
#
# Instructions:
# First the default run button is Shift. The default sneak button is Alt.
# You can change them if you're familiar with the Input module.
#
# You can alter the Walking, Running, and Sneaking speed in the config below.
# You can also detect if the player is running by doing this in a condiotional
# branch.
# GameGuy.running? if he's running it will return true else it will return false
# To check sneaking use
# GameGuy.sneaking?
# For just walking use
# GameGuy.walking?
#
# You can also disable run and sneak. To do so do this.
# GameGuy.run_on to turn run on
# GameGuy.run_off to turn run off
# GameGuy.sneak_on to turn sneak on
# GameGuy.sneak_off to turn sneak off
# You can then make it possible so that you need certain equipment equipped
# to be able to do this.
#
# It is recommended to turn the running and sneaking off during cutscenes so
# simply do this. GameGuy.run_off or to turn it back on GameGuy.run_on and thats
# all.
#
# Credits:
# game_guy ~ for making it
# RoseSkye ~ helping me think of a script
#===============================================================================
module GameGuy
 #===========================================================================
 # Begin Config
 #===========================================================================
 #===========================================================================
 # RunButton       = The button used to run. Default is Shift.
 #
 #===========================================================================
 RunButton         = Input::SHIFT
 #===========================================================================
 # SneakButton     = The button used to sneak. Default is Control.
 #
 #===========================================================================
 SneakButton       = Input::ALT
 #===========================================================================
 # WalkingSpeed    = The normal walking speed for when walking.
 #
 #===========================================================================
 WalkingSpeed      = 4
 #===========================================================================
 # RunningSpeed    = The speed for when running.
 #
 #===========================================================================
 RunningSpeed      = 5
 #===========================================================================
 # SneakingSpeed   = The speed for when sneaking.
 #
 #===========================================================================
 SneakingSpeed     = 2
 #===========================================================================
 # End Config
 #===========================================================================
 def self.run_on
   $game_system.run_allowed = true
 end
 def self.run_off
   $game_system.run_allowed = false
   $game_player.move_speed = GameGuy::WalkingSpeed
 end
 def self.sneaking?
   if Input.press?(GameGuy::SneakButton) && !Input.press?(GameGuy::RunButton)
     return true
   else
     return false
   end
 end
 def self.running?
   if Input.press?(GameGuy::RunButton)
     return true
   else
     return false
   end
 end
 def self.walking?
   unless Input.press?(GameGuy::RunButton)
     unless Input.press?(GameGuy::SneakButton)
       return true
     else
       return false
     end
   else
     return false
   end
 end
 def self.run_off
   $game_system.run_on = false
 end
 def self.sneak_off
   $game_system.sneak_on = false
 end
 def self.run_on
   $game_system.run_on = true
 end
 def self.sneak_on
   $game_system.sneak_on = true
 end
end
class Game_System
 attr_accessor :run_allowed
 attr_accessor :sneak_on
 attr_accessor :run_on
 alias gg_dash_lat initialize
 def initialize
   @run_allowed = true
   @sneak_on = true
   @run_on = true
   gg_dash_lat
 end
end
class Game_Character
 attr_accessor :move_speed
end
class Scene_Map
 alias gg_dash_update_lat update
 def update
   if $game_system.run_allowed
     if Input.press?(GameGuy::RunButton) &&
         $game_system.run_on
       $game_player.move_speed = GameGuy::RunningSpeed
     elsif Input.press?(GameGuy::SneakButton) &&
         $game_system.sneak_on
       $game_player.move_speed = GameGuy::SneakingSpeed
     else
       $game_player.move_speed = GameGuy::WalkingSpeed
     end
   end
   gg_dash_update_lat
 end
end



Instructions

In the script.


Compatibility

Not tested with SDK.


Credits and Thanks




Author's Notes

Give Credits and Enjoy!
Title: Re: [XP] Dash and Sneak
Post by: RoseSkye on September 29, 2009, 07:34:54 am
First post, I win.
Title: Re: [XP] Dash and Sneak
Post by: fugibo on September 29, 2009, 08:11:46 am
Quote from: RoseSkye on September 29, 2009, 07:34:54 am
First post, I win.


Second post, I win twice as much.
Title: Re: [XP] Dash and Sneak
Post by: G_G on September 29, 2009, 10:09:40 pm
any comments on the actual script itself? Yes I know this can be easily evented but....I was bored
Title: Re: [XP] Dash and Sneak
Post by: Blizzard on September 30, 2009, 05:03:40 am
It's a nice thing if you don't want to bother with events.
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 29, 2009, 10:51:07 pm
I have to say this is the first running script I found that can use conditional branch's to detect if the player is or not. Plus be able to turn it on and off.
This is just what I needed for my game ;3

However can you set it so you can disable the run/sneak separately? I'd like to make items that if you have it equipted you can run, and another to stealth. However I only see away to turn them both on or off together.
Title: Re: [XP] Dash and Sneak
Post by: G_G on October 29, 2009, 10:58:19 pm
updated so you can disable running and sneaking.
TO do what you want to do make a parallel process to see if any actors are wearing the equipped thing then follow the syntaxes in the script.

@mods/blizz: I would move this but I'm not sure if it should.
Its been unmoved awhile before I became a mod so I figured it'd stay here. Move it if it should be moved though I wasnt sure.
Title: Re: [XP] Dash and Sneak
Post by: Calintz on October 29, 2009, 11:11:51 pm
I was just about to say that this should be an event system, LMAO ...
Maybe I'll just have to add the sneak feature to CARJES!! Then what G_G!? XD!!
Title: Re: [XP] Dash and Sneak
Post by: G_G on October 29, 2009, 11:14:20 pm
Hey I know this can be easily evented, I just prefer it when scripting makes it easier. Go ahead and add it to CARJES. lol
I just like it when scripts make my eventing life easier.
Title: Re: [XP] Dash and Sneak
Post by: Calintz on October 29, 2009, 11:33:18 pm
Haha, I on the other hand find eventing much easier.
The ability to do things may be limited in some ways, but it's all laid out for you.

No surprises ...
Use the interface to point and click. This does that. If this, then that.

Scripting goes to the roots. Takes memorization of codes, and the ability to comprehend the coding. Without somebody teaching me, I doubt I will ever learn. I need help for things that are relatively unknown to me if I wish to master them.

I can edit code, but as far as writing my own ... out of the question.
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 29, 2009, 11:39:55 pm
Edit: was a small conflict with another script, had to move things around.
and it was from a new game :P
Title: Re: [XP] Dash and Sneak
Post by: G_G on October 29, 2009, 11:44:16 pm
Try starting a new game. I dont get the error thats odd.

You cant do this from a loaded game thats probably why.

@calintz: Get me back into eventing D: I find it boring and hard to get into, especially when you know how to script and pretty much can event with scripting.
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 29, 2009, 11:48:08 pm
The off switch causes the play to be stuck in place now >.< I have an event that you can walk over to turn it on and off. it worked in the other! But now walking over the off one gets the player stuck in place.

Also if I use a conditional branch to change sprites if running/sneaking rather default that way or if you have/don't have the item to do it, or even if it's set to off, the speed wont change, however the sprites will :/
Title: Re: [XP] Dash and Sneak
Post by: G_G on October 29, 2009, 11:51:11 pm
@Taiine: I'll look into it tomorrow, upload a demo so I can see the bugs, and I'll fix it. Its pretty late over here so I probably made some scripting mistakes.
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 29, 2009, 11:54:19 pm
Okay I'll put together a test game with it to show the issue.
Title: Re: [XP] Dash and Sneak
Post by: Calintz on October 30, 2009, 12:09:54 am
Well, if anything will do the trick, it's gonna be my evented snowboard minigame.
Title: Re: [XP] Dash and Sneak
Post by: Blizzard on October 30, 2009, 03:14:57 am
*looks at template* *looks at this topic* It's a match, ready to move. *pulls G_G's arm and points to the move button*
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 30, 2009, 05:08:16 am
http://www.easy-share.com/1908292360/DanStest.exe

Theres the example.

The top two plants are the 'off' switches and freaze the player in place if walked over.
The path over the water checks if you are running and if so jump it.
the bottom plans are the 'on' switches that.. can't be tested cause off freazes you :/

Edit: I also just tried it in a parallel process to have it off at game start, that and even an auto run/self off switch and it will still freaze the player in place and not allow them to walk.
Title: Re: [XP] Dash and Sneak
Post by: G_G on October 30, 2009, 08:29:55 pm
Have no idea why it just freezes like that. But I'm going to completely remake the script and carefully make sure I dont mess up anything.
Title: Re: [XP] Dash and Sneak
Post by: Aqua on October 30, 2009, 08:31:28 pm
Autoruns don't allow the player to move - they're mostly used for cutscenes.

Parallel process allows the player to move. You should be using these for the events.
Title: Re: [XP] Dash and Sneak
Post by: Taiine on October 30, 2009, 08:48:00 pm
Quote from: Aqua on October 30, 2009, 08:31:28 pm
Autoruns don't allow the player to move - they're mostly used for cutscenes.

Parallel process allows the player to move. You should be using these for the events.


The off command will freaze the player with both auto runs AND Parallel process. It also will freeze the player using a 'player touch' event, as shown in my sample of the bug.
The auto run I spoke of was just for that, to have it off at the very start of the game where my cutscene runs and all other 'turn off' commands are done. and it froze the player in place.