Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
neiljwd

Dash Script, why can't I alter the current run points please?

Question

WAIT  I think Im jsut REALLY REALLy Stupid.

Don't think there was ever a problem just me being a mong.

 

I thought $game_player.run_points =350 was setting the MAX... but it wasn't it was jsut boosting the current to 350, PAST the max, so allowing me to run longer thinking the max was changed. Me sorry for wasting your time.

 

 

--------------------

Original message

-------------------

Using a Night Runner modified Dash script, originally StandWalkRun by Synthesize I  think, I can press a key and Run Faster- I know how to use a script call to increase my Max Run Points permananently.

$game_player.run_points = 350

This sets the max run points to 350, from 100 -Line 17 in Script below.

However What I want to achieve is a script call to increase the players CURRENT run points, but not over the max.

 

Say for instance They have 350 max run points, sprint through 300 leaving them at 50/350 Run Points, I''d like a script call that say adds +75 current Run Points, leaving them at 125/350.

 

Can anyone help please?

DEMO FILE ATTACHED

https://www.mediafire.com/?hix3o1oz0xb1syw

 

 

# Written by Synthesize
# Version 2.70
# January 26, 2008 (v1)
#     Revised: March 1, 2008 (v2)
#     Revised: September 4, 2010 (v2.5)
#     Revised: 8 May, 2012 (2.6, NREdit)
#     Revised: 15 Nov, 2013 (2.7, NREdit)
#===============================================================================
# Customization
#-------------------------------------------------------------------------------
module StandWalkRun
  Use_run = true   # Use Run Points?
  Use_run_sprite = true# Use a Running sprite?
  Run_speed = 5   # Player speed while running
  Walk_speed = 4  # Player speed while walking
  Run_sprite_suffix = '_dash'   # Running Sprite Suffix
  Run_points = 100   # The maximum amount of Run Points
  Run_points_restore = 20   # 1 Run Point is restored in X Frames
  Restore_run_while_walking = true   # Restore points while walking?
  Use_idle_sprite = false   # Use Idle Sprite?
  Idle_sprite_suffix = '_idle'   # idle Sprite Suffix
  Use_anime = true   # Animate your Idle Sprite?
  Idle_time = 40    # Time before sprite is animated
end
#-------------------------------------------------------------------------------
# Scene_Map:: The main functions of the script are here
#-------------------------------------------------------------------------------
class Scene_Map
  # Aliases
  alias syn_map_update update
  #-----------------------------------------------------------------------------
  # Initiate variables
  #-----------------------------------------------------------------------------
  def initialize
    if $game_player.old_character_name == nil
     $game_player.old_character_name = $game_player.character_name
    end
    @wait_time = 0
    @wait_time2 = 0
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #-----------------------------------------------------------------------------
  def update
    syn_map_update
    if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
      if $game_player.move_route_forcing == false
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"
      end
      restore_run if StandWalkRun::Use_run
      else
      $game_temp.syn_state = ""
      restore_run if StandWalkRun::Restore_run_while_walking
      call_idle($game_player.old_character_name, false) if $game_player.character_name != $game_player.old_character_name
      @wait_time = 0
      end
      if $game_temp.sprite_changed == true
      $game_player.old_character_name = $game_player.character_name
      $game_temp.sprite_changed = false
      end
    end
  #-----------------------------------------------------------------------------
  # Call_Idle:: Sets and animates the idle Sprite
  #-----------------------------------------------------------------------------
  def call_idle(sprite, anime)
    $game_player.set_step_anime(anime)
    $game_player.set_graphic(sprite)
  end
  #-----------------------------------------------------------------------------
  # Restore_Run: Restore Run Points
  #-----------------------------------------------------------------------------
  def restore_run
    if $game_player.run_points < $game_player.max_run_points
      wait(1, true)
      $game_player.run_points += 1 if @wait_time2 == StandWalkRun::Run_points_restore
      @wait_time2 = 0 if @wait_time2 == StandWalkRun::Run_points_restore
    end
  end
  #-----------------------------------------------------------------------------
  # Wait:: Allows Wait Times
  #-----------------------------------------------------------------------------
  def wait(duration, value)
    for i in 0...duration
      @wait_time += 1 if value == false
      @wait_time2 += 1 if value
      break if i >= duration / 2
    end
  end
end  
#-------------------------------------------------------------------------------
# Game_Temp:: Create current state
#-------------------------------------------------------------------------------
class Game_Temp
  attr_accessor :syn_state
  attr_accessor :sprite_changed
  alias syn_temp_init initialize
  def initialize
    @syn_state = ""
    @sprite_changed = false
    syn_temp_init
  end
end
#-------------------------------------------------------------------------------
# Game_Character:: Create the Change_Sprite method
#-------------------------------------------------------------------------------
class Game_Character
  # Attr(s)
  attr_accessor :old_character_name
  attr_accessor :run_points
  attr_accessor :max_run_points
  alias syn_ch_init initialize
  #-----------------------------------------------------------------------------
  # Initialize Variables
  #-----------------------------------------------------------------------------
  def initialize
    @run_points = StandWalkRun::Run_points
    @max_run_points = @run_points
    syn_ch_init
  end
  #-----------------------------------------------------------------------------
  # Set Setp Animation
  #-----------------------------------------------------------------------------
  def set_step_anime(value)
    @step_anime = value
    return @step_anime
  end
end
#-------------------------------------------------------------------------------
# Game_Player:: This handles the dash process
#-------------------------------------------------------------------------------
class Game_Player < Game_Character
  alias syn_player_initialize        initialize
  alias syn_player_update            update
  alias syn_player_refresh           refresh
  alias syn_player_move_type_custom  move_type_custom
  def initialize(*args, &blk)
    ret_val = syn_player_initialize(*args, &blk)
    set_walk_speed(StandWalkRun::Walk_speed)
    set_run_speed(StandWalkRun::Run_speed)
  end
  def dash?
    return false if @run_points == 0 and StandWalkRun::Use_run
    return true if Input.press?(Input::A)
  end
  def refresh
    syn_player_refresh
    self.old_character_name = @character_name
  end
  def set_run_speed(val)
    @ty_RunWalk_run_speed = [[@ty_RunWalk_walk_speed + 1, val.to_i].max, 7].min
  end
  def set_walk_speed(val)
    @ty_RunWalk_walk_speed = [[val.to_i, 1].max, 6].min
    set_run_speed(val + 1)
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #----------------------------------------------------------------------------
  def update
    if dash?
      if Input.dir4 == 0
        $game_player.set_graphic($game_player.old_character_name)
      end
      unless $game_temp.syn_state == "idle"
        if StandWalkRun::Use_run_sprite
          set_graphic(@character_name + StandWalkRun::Run_sprite_suffix)
        end
        @move_speed = @ty_RunWalk_run_speed
        @run_points -= 1
        syn_player_update
      end
    else
      @move_speed = @ty_RunWalk_walk_speed
      syn_player_update
    end
  end
  def set_graphic(character_name)
    @tile_id = 0
    @character_name = character_name
  end
  #--------------------------------------------------------------------------
  # * Move Type : Custom
  #--------------------------------------------------------------------------
  def move_type_custom
    old_ch_name = @character_name
    syn_player_move_type_custom
    if old_ch_name != @character_name # Change Graphic
      self.old_character_name = @character_name
    end
  end
end
#-------------------------------------------------------------------------------
#            * This script is not compatible with RPG Maker XP *
#-------------------------------------------------------------------------------
# Written by Synthesize
# Version 2.7
# Requested by Cerulean Sky

Edited by neiljwd

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Do this :

$game_player.run_points += X
if $game_player.run_points > 350
$game_player.run_points = 350
end

Change the X into any amount you'd like and the run points will never go beyond 350.

Hope this helps. :)

Share this post


Link to post
Share on other sites
  • 0

Thank you for the contribution black mage. :)

But I also want to be able to change my max run points through out the course of the game, as the player levels up. So won't be set  at 350 all the time.

I guess I'm gonna have to intergrate a variable that monitors the max Run Points and just go from there.... I guess?

 

No idea on scripts, I jsut hink it's something that

 

$game_player.run_points

&

$game_player.max_run_points

 

Need to be seperately defined as intergers/values when called in the game, at the moment one seems to equal the other in game.

... Though the script seems know the difference between them as it differentiates in the restore section. :S

Edited by neiljwd

Share this post


Link to post
Share on other sites
  • 0

Yeah, let's say that we have the variable for max Run Points as $MAX, and this variable ammount will be increased when the character leveled up. Then the code will be :

$game_player.run_points += X
if $game_player.run_points > $MAX
$game_player.run_points = $MAX
end

I think this will work just fine :)

Edited by black mage

Share this post


Link to post
Share on other sites
  • 0

Thank you again! handy catching you, could you just spell it out for a noob where I should bob that little code snippet. Please. :)

 

Or is that what I should be putting in my event Script call? My heads spinning with this at the moment sorry.

Share this post


Link to post
Share on other sites
  • 0

Yeah, you just need to put that codes in your event Script call. :)

Edited by black mage

Share this post


Link to post
Share on other sites
  • 0

WAIT  I think Im jsut REALLY REALLy Stupid.

Don't think there was ever a problem just me being a mong.

 

I thought $game_player.run_points =350 was setting the MAX... but it wasn't it was jsut boosting the current to 350, PAST the max, so allowing me to run longer thinking the max was changed. Me sorry for wasting your time.

 

 

--------------------

Original message

-------------------

 

 

 

 

 

Oh I tried that but I got a fixnum error, screenshot, so figured I was being even more stupid than normal.

Any idead

Dash.jpg

Edited by neiljwd

Share this post


Link to post
Share on other sites
  • 0

It's because the script haven't define where the $MAX comes from, thus it have nil value.

You need another script or event to change the the value $MAX manualy.

 

This is a simple way for changing the current $MAX.

$MAX = Value

Change "Value" into some number that you want as the max run points.

Edited by black mage

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...