måndag 11 maj 2015

Hotline Miami 2 Level Editor

Jonatan here, I figured I should write a little post about the level editor we're working on for HLM2. It's pretty close to completion, so I wanted to show off some of the features it's got, and maybe get some feedback in case I have forgotten to add something crucial.

Upon starting the editor, the first thing you will see is the Level Options. Here you choose what character you want to design the level for, as well as specifying music and whether the level is a cutscene or not. Enabling cutscene editing means you won't be able to place any enemies. You also get a preview of what enemies are available for the player character you've chosen. Sadly most characters are only able to fight one or two different factions, enabling them to fight all enemies would mean a ton of work for Dennis and the editor would likely take at least another four to six months to finish. 
 
After setting up the basics of the level, you start building. You have bunch of different tilesets to choose from to create the levels flooring, and you can choose to encapsulate the patches of floor you place using the tools below the floor preview. You are also able to use flood fill and the sample tool to easily find what color and sprite sheet a specific tile have.

You also have the option of placing walls, doors and windows independently.

http://3.bp.blogspot.com/-TgPSds_pLmI/VVD3ZiK_KiI/AAAAAAAAASw/LLGTDkmhJz8/s1600/EditorBuild.png
Once you're done with your basic layout, it's time to add furniture and other objects. Since there are tons of assets in the game, we decided to add a search function for this. Basically if you want to add a bed, you enter the search term "bed" and the list will be narrowed down to all the sprites that has the word "bed" in their name. A lot of the sprites have a subset of variations within the sprite, and you can easily browse and choose one with the buttons near the bottom of the screen.

 
After furnishing your level it's time to place enemies. This is very straight forward, simply select the enemy you want to place and click the spot you want to place it in. There are several different types of enemies, with slightly different behaviors and weapons to choose from. 

http://4.bp.blogspot.com/-6IpOWDiPuY8/VVD2ETBLwQI/AAAAAAAAASA/NjXcrqVMDZ8/s1600/EditorEnemies.png

When you're done furnishing your level and have added your enemies you need to place your player character and its escape vehicle in order to be able to play the level. You do this under the Level tab. If you're making a stand alone level that is not part of a campaign you can also add a VHS cover for your level as well as enter the name of the level designer.

This is also where you place floor transitions, which are objects that allows the player to move between floors of a level.

If your level is meant to be a part of a campaign, you can use the campaign editor to string together a bunch of levels with optional intros and outros, as well as add credits if you're a team of designers. Here you also have the option to add a VHS cover for a group of levels (intro, main level, and outro). The intros and outros are not required to be cutscenes, but are named after how the structure in the main campaign works.

So if you want to add cutscenes to your levels, you first have to click the cutscene checkbox in the Level Options dialogue (see first image) in order to get access to the Cutscene Editor. The Cutscene Editor was a challenge to design, and the structure I came up with is slightly more complex than the regular editor.

The workflow consists of adding triggers, then adding frames to which you can attach actions.
The trigger can be an area which triggers the cutscene if entered, there's also character based triggers so that you can for instance create characters which can be talked to if clicked or approached.
Once a trigger is set you can start adding frames. A frame is basically a container for different actions that you want to play simultaneously. Let's say you for instance want a bunch of NPCs to approach the player when the cutscene is triggered, and then start talking to him. To do this you create a frame where the characters walk toward the player, once all the characters have reached their end positions the cutscene will move onto the next frame where you add the dialogue action. After this you can add a stop sequence action which will allow the player to start moving again once the dialogue is done.


You can add multi-step cutscenes by specifying a new trigger after the first sequence has been executed, followed by more frames and actions.

Now, I'd like to make sure people know what they're getting before we release the editor, so that people won't be too disappointed by some of the restrictions we've had to make. So here's a list of things I know people won't be too happy about.

-Not all enemies will be available for all characters, in fact most characters are only able to fight one or two different factions.

-The cutscene editor is not super flexible, you won't be able to freely move or remove actions and frames. Basically you have to create each frame and action in an absolute order. Clicking any of the remove buttons will remove the latest action/frame/trigger. So let's say that you have created ten frames with three actions each, and you find an error in the first frame, then you are basically screwed and have to delete all frames and actions up to that point. 

Triggers are semi-independent of the frames, so you will be able to change the last placed trigger at any time until you add a stop sequence action. If you have several triggers you will not be able to go back and change the first one without deleting all the frames up until that point.

-Adding custom graphics for player/enemy sprites is something we're looking into, but if at all possible it will not be available upon launch.

-You will not be able to use your own music for the levels, this would be too problematic due to the likeliness of copyright infringements, sorry. The music from the first game will likely not be available either due to the fact that we only licensed the songs for one game.

-You will not be able to create levels that has both cutscene content and enemies, due to endless possibilities of game breaking bugs.

-Currently you need to save your level before testing it, or any changes since you last saved it will be lost. I'm definitely gonna try my hardest to see if I can fix this before release, as it is a major inconvenience.

-There will likely be no online highscore boards for user created levels.

Note: We will talk to Abstraction Games when they begin porting the editor to see if they can do anything about these issues.

And finally, here's a preliminary index of all functions/menu options. If you see a crucial feature missing that I haven't already addressed in the text above, please let me know in the comment feel so I have a chance of adding it before release (if possible).

Top menu:

File
  -New Level
  -Save Level
  -Load Level
  -Play Level
  -Create Campaign
  -Quit
Edit
  -Clear Walls
  -Clear Tiles
  -Clear Objects
  -Clear Characters
  -Delete Floor
Level
  -New Floor
  -Next Floor
  -Previous Floor
  -Create Cutscene
Options
  -Level Settings
  -Editor Settings (*)
  -Show Grid
Help
  -About
  -Manual
  -Check Content (check if the level is playable)

Level Tab
  -Place player
  -Place vehicle
  -Place floor transition
  -Add VHS cover
  -Add author info
  -Various mouse and keyboard commands (see image #1)

Enemy Tab
  -Place enemies
  -Select between enemies/factions
  -Choose what weapon enemy has
  -Various mouse and keyboard commands (see image #4)

Items Tab
  -Search field for finding an object to place
  -A list of available objects to place based on keyword entered
  -Preview window
  -Buttons for browsing/choosing a variation of the object's sprite
  -Various mouse and keyboard commands (see image #3)

Build Tab
  -Preview window for the currently selected tile
  -Checkboxes for selecting between tilesets
  -Tile selector for selecting a specific tile within a tileset
  -Capsule button for capsuling a set of tiles with the currently selected wall type
  -Sample button for sampling an already placed tile in the level
  -Flood fill button for replacing a set of tiles with the currently selected tile
  -Wall selector
  -Capsule wall button for drawing a rectangle of walls (a room for instance)
  -Various mouse and keyboard commands (see image #2)

Cutscene Editor Actions
  -Add dialogue
    -Choose what character should be in focus for each line
    -Select what face should be displayed during each line
  -Play sound
  -Play music
  -Stop music
    -Select whether to fade out or stop immediately
  -Stop sequence
    -Select whether this is the end of the cutscene or not
  -Next level
    -Option to choose how fast the level will fade out

Cutscene Character Actions
  -Walk to
    -Here you can create a path with up to six waypoints the selected character will follow
    -Select walking speed (normal/fast/slow)
    -Option to redraw the path
  -Change sprite
    -Select from a list of different sprites
  -Animate sprite
    -Choose if the animation should loop
    -Choose if the animation should pause for a specified amount of time between loops
  -Attack
    -Make the character attack using the currently held weapon (only works for specific sprites)
  -Die
    -The NPCs will automatically die if hit by a bullet or an attack, but you can also manually make 
     them die if you should so wish (only works for specific sprites)
  -Trigger
    -You can make a character trigger the cutscene using this, either by proximity to the player or if
     the player clicks while close. You can also choose the required distance for the cutscene to be 
     triggered.
   -Delete
     -A character that is referenced to in any added action will not be deletable until the action is 
      removed.

Cutscene Frame Tab
   -Add trigger
     -Draw an area which if entered will trigger the current sequence of the cutscene
   -Add frame
     -Adds a new frame to the cutscene
   -Add Action
     -Brings up a menu where you can choose from the different cutscene actions
   -Frame focus
     -Select what character should have camera focus for the current frame
   -Cutscene preview list
     -Displays all the frames and actions you've added
   -Delete Trigger
     -Deletes the trigger set for the current sequence
   -Delete Frame
     -Deletes the current frame and all of its actions
   -Delete Action
     -Deletes the last action added

Cutscene NPC Tab

NPCs
   -Name
    -Enter a name for your NPC that will be used to reference it
   -Sprite
    -Choose a sprite for your NPC
   -All Sprites checkbox
    -If you want to add a non-human interactable
   -Solid
    -If checked the player will not be able to move through the NPC
   -Killable
    -Select whether the NPC should die from player attacks or not (only applies to certain sprites)

Items to pick up (not fully implemented)
  -Name (?)
   -Enter a name for your item that will be used to reference it
  -Visible checkbox
   -In case you want an item to appear at a certain point
  -Active
   -If the player should be able to pick it up right away or later
  -Finish
   -If you want the player to have to pick up the item in order to clear the cutscene

UPDATE1: The Gun Tab in the Level Editor wasn't omitted here because there is some secret to it (we haven't added ALL the weapons from the first game, just a select few),but rather it seems a bit useless as it should be able to fit under the Enemy or Level tab and will likely be removed before release. Also, while you will be able to use the dodging enemies, we will probably skip the prisoners for now as the only character that can fight them is the prisoner/guard version of The Rat.

UPDATE2: Thanks for all the feedback! I've added a couple of features on my to do list. You will now be able to add some environmental effects, like rain, darkness or sunshine to your levels, and I almost forgot the elevators. The limitation for no cutscenes in a level with enemies has been removed, as I figured out a couple of ways to go around it. I'm also going to look at the possibility for creating levels for specific masks/fans as that would indeed be cool to see.