Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Decreasing Speed in Sand

Status
Not open for further replies.
Hey all,
Could anyone make me a short and simple script for a part where a player is trying to wade across a quicksand river? Basically, all I want is for the script to check if the player is on ground with terrain tag 2. If so, the player slows down to a speed of 2 ("slower"). But since it's quicksand, I also need to make the player sink if he stands still too long. All I need is for a short transition to play, maybe a SE, and then it'll warp the player to Map ID 99, coordinates (5, 15). So, let's say the player stays still for 50 frames. Too bad for the player, they get teleported back off the side of the river and have to start over.

Don't forget to increase the player's speed back to regular (I think 4) if he's off of terrain tag 2. Thanks to anyone who helps.
EDIT: Oh, forgot to mention. No SDK, please, since all of the scripts I'm using don't use SDK. Credit will be given.
 

poccil

Sponsor

Code:
class Interpreter
  def callCommonEvent(commonEventID)
    common_event = $data_common_events[commonEventID]
    if common_event != nil
      @child_interpreter = Interpreter.new(@depth + 1)
      @child_interpreter.setup(common_event.list, @event_id)
    end
    return true
  end
end

In the script section Game_Player, modify the update function:

Code:
  def update
    [b]if self.terrain_tag == 2
      # If player is in quicksand for 50 frames
      if @quicksandcount && 
        Graphics.frame_count>=@quicksandcount+50
        @quicksandcount=nil
        # replace 5 with the number of a common event
        @move_speed = 4
        $game_system.map_interpreter.callCommonEvent(5)
      end
    else
      @quicksandcount=nil
    end[/b]
    last_moving = moving?

Elsewhere in the update function:

Code:
    unless moving?
      # If player was moving last time
      if last_moving
        [b]# Step check begins here       
        unless $game_system.map_interpreter.running? or
           @move_route_forcing or 
           $game_temp.message_window_showing
         if self.terrain_tag == 2
           # On quicksand
           @move_speed = 2
           @quicksandcount = Graphics.frame_count
         end
           # Not on quicksand
           @move_speed = 4
         end
        end[/b]
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])

The custom common event can look like this:

Code:
Prepare for Transition
Play SE: 'XXXX', 80, 100
Transfer Player:[099: ?????], (005,015), Down, No Fade
Execute Transition: 'XXXXX'

Keep in mind that the above is untested.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top