001 Game Creator Guide

Game Recipe #5 - Sprint with Stamina (Using Statistics) for 001 Game Creator

Game Recipe #5 – Sprint with Stamina (Using Statistics)

Overview

In this recipe, we will walk through the scripting required to implement a sprint system. We will be using a Stamina statistic to limit the length of time the player can run. Using statistics enables us to easily increase maximum stamina as the player levels up, and modify it via items and equipment.

Requirements

  • A map to run around in.
  • (Optional) Icon for the Stamina statistic.
  • (Optional) Icon for the Sprint control.

Setup (Part 1)

  1. From the editor’s main view, open the Statistics menu.

    1. Add a new statistic. You may name it whatever you want, but for this recipe we’ll call it Stamina.
    2. Optionally, add a graphic.
    3. Click OK to save and close the window.
  2. Open the Controls menu.

    1. Add a new control. You may name it whatever you want, but for this recipe we’ll call it Sprint.
    2. Add a default key/button. This can be whatever button you want to use to sprint; we’ll use RShift (Right Shift) as an example.
    3. Optionally, add a graphic.
    4. Click OK to save and close the window.
  3. Open the Input Triggers menu.

    1. Select Regular Game (or whatever input set you have set as the default, if you’ve changed it.)
    2. Add a new Control Combination.
      1. Click the empty rectangle to open the Input window.
        1. Select the Sprint control from the Defined Control list.
        2. Click OK to save and close the window.
      2. With the name of your control showing in the rectangle, click the Pressed button to add the input to the control combination.
      3. Click Edit Script.
        1. Add a Change Maximum Speed event.
          1. Select (Main) as your actor.
          2. Set the Maximum Speed to your desired sprinting speed.
          3. Click OK to save and close the event.
        2. Add a Comparison Branch event.
          1. Click the use value box beside Expression and select Current Statistic under the Actor category.
            1. Select (Main) as your actor.
            2. Select Stamina as the statistic.
            3. Click OK to save and close the use value.
          2. Select > (Greater Than) for the operator.
          3. Enter 0 as the value.
          4. Click OK to save and close the event.
        3. Add a Control Branch event.
          1. Select Sprint for the control.
          2. Click OK to save and close the event.
          3. Note that this event should be connected to the left side of the Comparison Branch above.
        4. Add a Delay event.
          1. Leave Time blank.
          2. Click OK to save and close the event.
          3. Note that this event should be connected to the left side of the Control Branch above.
        5. Click on the Control Branch to highlight it.
        6. Add a second Change Maximum Speed event.
          1. Select (Main) for your actor.
          2. Set Maximum Speed to your desired walking speed.
          3. Click OK to save and close the event.
          4. Note that this event should be connected to the right side of the Control Branch above.
        7. Connect the right side of the Comparison Branch to the top of the second (lower) Change Maximum Speed event.
        8. Your script should look similar to the screenshot below.
        9. Click OK to save and close the script.
      4. Click OK to save and close the window.
    3. Click OK to save and close the Input Triggers.

Setup (Part 2)

  1. Open the Players and Party Members menu.

    1. Select your main actor from the list on the left, if it isn’t already selected.
    2. In the Statistic Progression section, click on the box next to Stamina.
      1. Set the statistic curve however you want. Keep in mind that these values will determine how long the player can sprint, so you’ll want the value to start at an acceptable level. We’ll start with 100 as an example.
      2. Click OK to save and close the statistic curve.
    3. Click Edit Actor.
      1. Click Add and select While / Timer to add a new trigger.
        1. Enable the checkboxes beside While Condition and Interval.
        2. Click the use value box beside While Condition.
          1. Select Control Pressed under the Main Party / Game category.
            1. Select Sprint for Control.
            2. Click OK to save and close the window.
        3. Enter 0.2 for Interval. You can use other values, but 0.2 tends to work well.
        4. Click OK to save the trigger and open the script.
          1. Add a Comparison Branch.
            1. Click the use value button beside Expression.
              1. Select Current Statistic from the Actor category.
                1. For Actor, select (Main).
                2. For Statistic, select Stamina.
                3. Click OK to close the window.
            2. Select < (Less Than) for Operator.
            3. Enter 0 for Value.
            4. Click OK to save and close the event.
          2. Add a Change Current Statistic event.
            1. For Actor, select (Main).
            2. For Statistic, select Stamina.
            3. For Current Value, choose Set from the dropdown list and enter 0.
            4. Click OK to save and close the event.
            5. Note that this event is connected to the left side of the Comparison Branch above.
          3. Click on the Comparison Branch to highlight it.
          4. Add another Change Current Statistic event.
            1. For Actor, select (Main).
            2. For Statistic, select Stamina.
            3. For Current Value, choose Subtract from the dropdown list and enter 15.
            4. For Transition Duration, enter 0.2 or whatever number you used for the trigger interval.
            5. Click OK to save and close the event.
            6. Note that this event is connected to the right side of the Comparison Branch above.
          5. Click OK to save and close the script.
      2. Click Add and select While / Timer to add another new trigger.
        1. Enable the checkboxes beside While Condition and Interval.
        2. Click the use value box beside While Condition.
          1. Select Logical NOT under the Structure category.
            1. Click the use value box next to Value.
              1. Select Control Pressed under the Main Party / Game category.
                1. Select Sprint for Control.
                2. Click OK to save and close the window.
            2. Click OK to save and close the window.
        3. Enter 0.2 for Interval. You can use other values, but 0.2 tends to work well.
        4. Click OK to save the trigger and open the script.
          1. Add a Comparison Branch.
            1. Click the use value button beside Expression.
              1. Select Current Statistic from the Actor category.
                1. For Actor, select (Main).
                2. For Statistic, select Stamina.
                3. Click OK to close the window.
            2. Select > (Greater Than) for Operator.
            3. Click the use value button beside Value.
              1. Select Maximum Statistic from the Actor category.
                1. For Actor, select (Main).
                2. For Statistic, select Stamina.
                3. Click OK to close the window.
            4. Click OK to save and close the event.
          2. Add a Change Current Statistic event.
            1. For Actor, select (Main).
            2. For Statistic, select Stamina.
            3. For Current Value, choose Set from the dropdown list and then click the use value button.
              1. Select Maximum Statistic from the Actor category.
                1. For Actor, select (Main).
                2. For Statistic, select Stamina.
                3. Click OK to close the window.
            4. Click OK to save and close the event.
            5. Note that this event is connected to the left side of the Comparison Branch above.
          3. Click on the Comparison Branch to highlight it.
          4. Add another Change Current Statistic event.
            1. For Actor, select (Main).
            2. For Statistic, select Stamina.
            3. For Current Value, choose Add from the dropdown list and enter 10.
            4. For Transition Duration, enter 0.2 or whatever number you used for the trigger interval.
            5. Click OK to save and close the event.
            6. Note that this event is connected to the right side of the Comparison Branch above.
          5. Click OK to save and close the script.
      3. Click OK to save and close the Actor.
    4. Click OK to save and close the window.
  2. Test out your new sprint button!

Notes

By default, numbers will pop up over your character when the stamina is changed. You can disable these numbers by disabling the Damage Numbers option under Game Settings > Visual Settings.

To adjust how long the player is able to sprint, you can change either the amounts added and subtracted in the While / Timer triggers in your main actor (lower values will result in slower changes) or the total stamina capacity via the statistic curves in the Players and Party Members menu. Keep in mind that because Stamina is a statistic, it can be affected by equipment, items, and magic. If you intend for the player to find stat-boosting armor, healing potions, and buffing spells, you may want to use lower values in the statistic curve to balance it out. On the other hand, if your weapons cost stamina to use and enemies will be casting debuffs, you might increase the base stats. Play around with the values to see what works best for your game!

SteamSolo.com