adding_a_bus_stop_which_is_a_door

Adding a bus stop which is a Door

In Hard Times architecture doors are entities which make possible to navigate between scenes. It can be a proper door, a manhole, a Metro Passage or, as we will create shortly a Bus Stop.
So now we will create a bus stop to navigate to and from our new scene (the one we created in the last guide). In fact we have to place two of them for a proper navigation! So let's go on and make it happen.

First thing we will edit our mod descriptor file to let it know that in this mod we have defined doors to be loaded at bootstrap. Go on and edit the new mods descriptor file in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Descriptor.json

And edit it, modifing the file we edited in the last guides, so that it will look like this:

{
  "modName": "MyMod_MODPKG",
  "author": "RadicalFiction",
  "gameVersion": "",
  "langFolder": "Lang",
  "itemsFolder": "Items",
  "shopsFolder": "Shops",
  "spawnersFolder": "Spawners",
  "figuresFolder": "Figure",
  "furnituresFolder": "Furnitures",
  "recipesFolder": "Recipes",
  "fishingSpotsFolder": "FishingSpots",
  "questGiversNpcsFolder": "QuestGiversNpc",
  "questsFolder": "Quests",
  "scenesFolder": "Scenes",
  "doorsFolder": "Doors"
}

As usual we added the modFolder property and set it to “Doors”, so now we have to create te actual folder in our mod's file structure:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Doors

Inside it we will create a Sprites folder to contain all the mod's sprites referring to doors:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Doors\Sprites

Lets go on and download this gracious sprite into our Doors/Sprites folder: so that we will have it like this:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Sprites\bus_stop.png

We will now define the first door to have it loaded at bootstrap. So let's create a new file in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\mod_bus_station.json

and lets put this content in it:

{
  "doorId": "mod_bus_station",
  "closedSpriteName": "bus_stop.png",
  "openSpriteName": "bus_stop.png",
  "targetScene": "Mod_Scene",
  "targetDoor": "mod_bus_station2",
  "objectToUnlock": "",
  "unlockDestroysObject": false,
  "effectOnUnlock": "",
  "unlockIsPermanent": true,
  "objectToBreak": "",
  "breakDestroysObject": false,
  "breakSound": "trash_search",
  "breakDuration": 10,
  "effectOnBreak": "break_door_effect",
  "breakIsPermanent": true,
  "isOpen": true,
  "closedMessage": "You can't open it like this",
  "achievementsOnUse": "",
  "achievementsOnOpen": "",
  "achievementsOnBreak": "BreakDoor",
  "interactableDistance": 2
}

So let's take a look at the individual properties of the door object:

  • doorId: it's the unique id of the door, we will use to reference it in the scene file.
  • closedSpriteName: we will reference here a sprite for the door when it's open
  • openSpriteName: we will reference here a sprite for the door when it's closed
  • targetScene: what scene is this door navigating to?
  • targetDoor: what door of the target scene is this door navigating to?
  • objectToUnlock: is there an object which is required to use this door (a ticket maybe?)
  • unlockDestroysObject: a boolean indicating if the opening object will be destroyed when used (true for a ticket, false for a key for example)
  • effectOnUnlock: does unlocking cast an effect on the player (maybe affecting scandal?)
  • unlockIsPermanent: is unlocking the door a permanent action or must be done everytime again?
  • objectToBreak: is there an object we can use to force this closed door open? (for example a crowbar)
  • breakDestroysObject: a boolean indicating if the breaking object will be destroyed when used
  • breakSound: reference a sound to be played while breaking the door
  • breakDuration: duration in minutes game time required to break the door
  • effectOnBreak: does breaking the door cast an effect on the player (maybe affecting scandal?)
  • breakIsPermanent: is breaking the door a permanent action or must be done everytime again?
  • isOpen: boolean stating if the door must be open by default
  • closedMessage: a string indicating the message (the lang key to it) to be shown when trying to open or break the door without the proper item (if any)
  • achievementsOnUse: a boolean stating if does this door fire an achievement when used (passing trough)
  • achievementsOnOpen: a boolean stating if does this door fire an achievement when opened
  • achievementsOnBreak: a boolean stating if does this door fire an achievement when broke
  • interactableDistance: the distance in game units (64px) from which the door will be interactable with

Since two doors are needed to create a usable path we will now define the sister door to the one we created before, connected to it and thus making navigation possible.
Let's create a new file in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\mod_bus_station2.json

And let's fill it with this content:

{
  "doorId": "mod_bus_station2",
  "closedSpriteName": "bus_stop.png",
  "openSpriteName": "bus_stop.png",
  "targetScene": "zero",
  "targetDoor": "mod_bus_station",
  "objectToUnlock": "",
  "unlockDestroysObject": false,
  "effectOnUnlock": "",
  "unlockIsPermanent": true,
  "objectToBreak": "",
  "breakDestroysObject": false,
  "breakSound": "trash_search",
  "breakDuration": 10,
  "effectOnBreak": "break_door_effect",
  "breakIsPermanent": true,
  "isOpen": true,
  "closedMessage": "You can't open it like this",
  "achievementsOnUse": "",
  "achievementsOnOpen": "",
  "achievementsOnBreak": "BreakDoor",
  "interactableDistance": 2
}

Note that this doors targets the first door we made.

Ok, now we have the two doors defined. We still have to add them to some scenes, because each door knows where it is pointed to (targetScene and targetDoor) but can still be placed in a scene descriptor to make it spawn in our scene of choice. We decided in the second door we made to make it point to the zero scene (zero is the id of the first scene of the game). So now we will have to create a proper descriptor file for this scene in our mod, to load the new door in the existing base scene.
Let's start by creating a “zero” folder in our Scenes folder in the mod base folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Scenes\zero

In there we will create a Descriptor.json file to contain our door data:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Scenes\zero\Descriptor.json

Open it and put this content in it:

{
  "sceneId": "zero",
  "sceneDirectory": {},
  "doOverwriteBaseproperties": false,
  "pavementSpriteName": "",
  "objects": [ ],
  "doors": [
	{
	  "modDoodId": "mod_bus_station",
	  "modDoorPositionX":  -18.7,
	  "modDoorPositionY": 0,
	  "modDoorRotation": 0,
	  "doorSpawnPointDeltaX": 0,
	  "doorSpawnPointDeltaY": 0,
	  "doorColliderWidth": 1,
	  "doorColliderHeight": 2,
	  "doorColliderTrigger": true
	}
  ],
  "shops": [ ],
  "spawners": [ ]
}

Let's note a couple important things:

  • doOverwriteBaseproperties is set to false. This is done because we are just adding entities to this scene, which is already defined elsewhere (in this case is in the Vanilla game, but could have been any other mod loaded before this one). Setting this to false tells the modding engine we don't want to mess up with scene base properties, because we will only add new entities (a door in this case, but could have been any other scene entity such as shops, spawners, objects).
  • doors is containing our scene door object, referencing the door we created before (mod_bus_station) and setting proper position and collider infos.
  • doorSpawnPointDeltaX and doorSpawnPointDeltaY represents the point (in game units and relative to the door position) where a player coming to this door will spawn.
  • doorColliderTrigger if set to true the collider will be just a trigger and will not be blocking.

Since our bus stations/doors will be connecting the first scene with the modded scene we will have to add the second door to the new scene we made in the previous guide. Let's open it's Descriptor.json file located in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Scenes\Mod_Scene\Descriptor.json

And let's add the new door in the doors list:

{

  /** WARNING: I OMITTED THE REST OF THE FILE. WE ONLY NEED TO EDIT THE "doors" LIST! **/

  "doors": [
	{
	  "modDoodId": "mod_bus_station2",
	  "modDoorPositionX":  0,
	  "modDoorPositionY": 0,
	  "modDoorRotation": 0,
	  "doorSpawnPointDeltaX": 0,
	  "doorSpawnPointDeltaY": 0,
	  "doorColliderWidth": 1,
	  "doorColliderHeight": 2,
	  "doorColliderTrigger": true
	}
  ]
	
   /** WARNING: I OMITTED THE REST OF THE FILE. WE ONLY NEED TO EDIT THE "doors" LIST! **/
	
}

If everything went well you should now be able to start again the game with no errors(!). Be sure you have your new mod active and start a new game.
Now you should be able to find the bus stops in the two scenes, located in the points where you set them to spawn in the scenes description files: Well done you bus tycoon!

If you have problems or find errors in this guide please get in touch at info@tempi-duri.net.

You could leave a comment if you were logged in.
  • adding_a_bus_stop_which_is_a_door.txt
  • Last modified: 2019/02/18 11:32
  • by thorfinio