This add-on is a library that lets you configure building bounds and their room bounds.
It provides functions to:
- get the current building & room of any
Player
orEntity
- check if a room has all of its doors closed
The configured rooms can have:
- a full voice volume everywhere
- no voices heard from outside the room when all doors are closed
- disallowed jump
There is no gamemode requirement.
The voice range replacement feature should work on all gamemodes that do not do special things. There are a few things to know:
- The DarkRP mechanism is hacked in order to make the replacement fully operational.
- The DarkRP shows who can hear who, but clients do not know whether doors are open of closed!
- I picked the safest display: you are the talker and the listener cannot hear you when the room's doors are closed. The listener will not be listed in the listeners list because your game does not know door states.
To help you through the process of getting bounding boxes, there is a Sandbox toolgun tool under the Rooms category named Rooms Areas.
For a building or a room, you proceed by attacking the walls, the ceiling and the floor. If you cannot attack indoor surfaces, attack the corresponding outdoor surfaces. Every time you attack a surface, the bounding box is extended.
When you are done with a building or a room, the tool generates room:addArea()
Lua instructions, which you can edit into building:setBuildingBounds()
instructions.
For every configured map, you need to make a Lua file in lua/config/rooms_lib_mr/maps/
. Name it MAP_NAME.lua
where MAP_NAME
is the name of the map, as in MAP_NAME.bsp
.
- 🖤 SHARED:
no value
Building:addLightArea
(int areaId, Vector min, Vector max)
(usage not recommended) - 🖤 SHARED:
Room
Building:addRoom
(string name, boolean handleVoice, table lights, any lightArea)
Adds aRoom
to the building
Arguments:name
: the name of the buildinghandleVoice
: activate the voice range managementlights
: (usage not recommended)lightArea
: (usage not recommended), allowed types:int
&table
ofint
- 🖤 SHARED:
table
Building:getBuildingBounds
()
Returns a table of 2 values:{Vector min, Vector max}
The returned value is not a copy! - 🖤 SHARED:
int
Building:getId
()
Returns the index of the building
The value is identical on the server and the client, so it can be used for networking. - 🖤 SHARED:
string
Building:getName
()
Returns the name of the building - 🖤 SHARED:
table
Building:getRooms
()
Seerooms_lib_mr.getRooms()
- 🖤 SHARED:
no value
Building:setBuildingBounds
(Vector min, Vector max)
Sets the bounding box of the building
- 🖤 SHARED:
no value
Room:addArea
(Vector min, Vector max)
Adds a bounding box to the room
Room bounding boxes is not required to be within theBuilding
bounding box.
Usually a room only has 1 bounding box.
A room can have as many bounding boxes are necessary. - 🖤 SHARED:
Building
Room:getBuilding
()
Returns theBuilding
this room belongs to - 🖤 SHARED:
string
Room:getBuildingName
()
Returns the name of theBuilding
this room belongs to - 🖤 SHARED:
int
Room:getId
()
Returns the index of the room
The value is identical on the server and the client, so it can be used for networking. - 🖤 SHARED:
string
Room:getName
()
Returns the name of the room - 💙 SERVER:
boolean
Room:hasOpenDoors
()
Returnstrue
if at least 1 door is open or missing, otherwisefalse
Returnstrue
if doors are undefined - 🖤 SHARED:
boolean
Room:isInRoom
(any arg)
Returns ifarg
is located in the room
arg
can be of the following types:Player
,Entity
,Vector
. - 🖤 SHARED:
no value
Room:setDoors
(table doors)
Sets the doors of the room
doors
is a list of elements of the following type:DoorByHammerid
(see below),int
(MapCreationIDs),Entity
(usually for doors created by Lua code).
This class is a wrapper around the door Entity
, so Entity
methods can be used on it.
It is meant to be used in your configuration file.
Unlike the MapCreationID
, the hammerid
do not change when modifying a map.
- 🖤 SHARED:
DoorByHammerid
DoorByHammerid
(int hammerid)
Constructor - 💙 SERVER:
Entity
DoorByHammerid:getEntity
()
Returns the doorEntity
- 🖤 SHARED:
Building
rooms_lib_mr.addBuilding
(string name)
Creates a new building - 🖤 SHARED:
no value
rooms_lib_mr.addForbiddenJumpLocation
(any roomOrBuilding)
Adds a room or a building into locations with forbidden jump
roomOrBuilding
can be aBuilding
or aRoom
. - 🖤 SHARED:
Building, string
rooms_lib_mr.getBuilding
(any arg)
Returns the building and the building name of the location ofarg
This function ignores room bounding boxes, so it is faster thanrooms_lib_mr.getRoom()
.
If a no building matches, all 2 returned values arenil
.
arg
can be of the following types:Player
,Entity
,Vector
. - 🖤 SHARED:
Building
rooms_lib_mr.getBuildingFromId
(int id)
Returns the building with the specified index - 🖤 SHARED:
Building
rooms_lib_mr.getBuildingFromName
(string name)
Returns the building with the specified name - 🖤 SHARED:
Building
rooms_lib_mr.getBuildingFromRoom
(Room room)
SeeRoom:getBuilding()
- 🖤 SHARED:
string
rooms_lib_mr.getBuildingNameFromRoom
(Room room)
SeeRoom:getBuildingName()
- 🖤 SHARED:
table
rooms_lib_mr.getBuildings
()
Returns a copy of the list of buildings, with index used as table keys - 🖤 SHARED:
int
rooms_lib_mr.getIdFromBuilding
()
SeeBuilding:getId()
- 🖤 SHARED:
int
rooms_lib_mr.getIdFromRoom
(Room room)
SeeRoom:getId()
- 🖤 SHARED:
string
rooms_lib_mr.getFullRoomLabel
(string building_name, string room_name)
Returns the concatenation ofbuilding_name
," - "
androom_name
, if all arguments are non-emptystring
s
Returnsbuilding_name
orroom_name
if only 1 argument is non-emptystring
s
Returns"Unknown location"
otherwise - 🖤 SHARED:
int, Building, string
rooms_lib_mr.getLightArea
(any arg)
(usage not recommended)
arg
can be of the following types:Player
,Entity
,Vector
. - 🖤 SHARED:
string
rooms_lib_mr.getNameFromBuilding
()
SeeBuilding:getName()
- 🖤 SHARED:
string
rooms_lib_mr.getNameFromRoom
(Room room)
SeeRoom:getName()
- 🖤 SHARED:
Room, string, Building, string
rooms_lib_mr.getRoom
(any arg)
Returns the room, the room name, the building and the building name of the location ofarg
If a no room matches, the 1st and the 2nd returned values arenil
.
If a no building matches, all 4 returned values arenil
.
arg
can be of the following types:Player
,Entity
,Vector
. - 🖤 SHARED:
Room
rooms_lib_mr.getRoomFromId
(int id)
Returns the room with the specified index - 🖤 SHARED:
Room
rooms_lib_mr.getRoomFromName
(string name, Building building)
Retrieves a room by its name, only if it belongs tobuilding
building
is optional. - 🖤 SHARED:
table
rooms_lib_mr.getRooms
(Building building)
Returns a new list of the rooms, ordered by index
building
is optional. Ifbuilding
is specified, the returned table only contains its rooms. Ifbuilding
is not specified, the keys in the returned table are the room indexes. - 🖤 SHARED:
boolean
rooms_lib_mr.isInArea
(table area, any arg)
Returns ifarg
is located withinarea
bounds
area
is a table with the keysmin
&max
and withVector
values.
arg
can be of the following types:Player
,Entity
,Vector
. - 🖤 SHARED:
no value
rooms_lib_mr.removeForbiddenJumpLocation
(any roomOrBuilding)
Removes a room or a building into locations with forbidden jump
roomOrBuilding
can be aBuilding
or aRoom
.