How adskdev/random_asylum_addon works
Purpose and Runtime
Random Asylum is a server-hosted Garry’s Mod gamemode focused on timed, round-based deathmatch where players receive random scripted weapons (SWEPs) whenever they spawn. It runs in Garry’s Mod’s Lua gamemode lifecycle, with separate server, client, and shared loading paths.
Entry metadata and gamemode registration are in:
• addon.json
• gamemodes/randomasylum/randomasylum.txt
• gamemodes/randomasylum/gamemode/shared.lua
Bootstrap and Realm Separation
The gamemode’s load boundary follows Garry’s Mod conventions: server initialization establishes authoritative gameplay logic, client initialization loads presentation code, and shared definitions bridge both realms.
• Server bootstrap: gamemodes/randomasylum/gamemode/init.lua
• Client bootstrap: gamemodes/randomasylum/gamemode/cl_init.lua
• Shared gamemode definition: gamemodes/randomasylum/gamemode/shared.lua
This separation is central: rounds, spawning, weapon assignment, and player state are server-authoritative; HUD rendering is client-side.
Round Lifecycle Controller
Round management is the primary control-flow coordinator. It governs waiting/start/end transitions, round duration, and minimum-player gating using server-configurable ConVars. At round completion it initiates map voting rather than implementing map selection internally.
• gamemodes/randomasylum/gamemode/round_management.lua
• gamemodes/randomasylum/gamemode/init.lua
Expected flow: server waits for enough players, starts a timed round, tracks its progress, ends the round, presents results, and hands off to MapVote for map transition.
Spawn and Random Weapon Distribution
The weapon subsystem applies the core game rule at player spawn: select eligible SWEPs from the server’s installed weapon collection and grant the configured count. It filters banned utility weapons and conditionally permits admin-only weapons.
• gamemodes/randomasylum/gamemode/weapon_system.lua
• gamemodes/randomasylum/gamemode/init.lua
This is an integration boundary with arbitrary installed SWEP addons: the gamemode consumes their registered weapon definitions but does not own their behavior.
Player State, Statistics, and Appearance
Per-player gameplay state includes round kills and deaths, which feed round results and HUD status. Appearance handling is isolated from combat and provides an admin-controlled model-change command.
• gamemodes/randomasylum/gamemode/player_appearance.lua
• gamemodes/randomasylum/gamemode/round_management.lua
The player model command is an administrative server control path, distinct from automatic spawn/round processing.
Client HUD and Results Presentation
The custom HUD is the client-facing projection of round state: remaining time, active-player information, and end-of-round results. It depends on state replicated or exposed from server-side round management rather than owning game decisions.
• gamemodes/randomasylum/gamemode/hud_system.lua
• gamemodes/randomasylum/gamemode/cl_init.lua
Killfeed behavior is deliberately external; the recommended Advanced Killfeed addon supplies that presentation concern.
External Dependencies and Operations
Garry’s Mod provides the Lua runtime, hooks, player/weapon APIs, ConVars, and networking facilities. The gamemode is distributed as a Steam Workshop addon and expects server operators to configure ConVars via console or server.cfg.
Map rotation depends on the external MapVote addon, invoked automatically after rounds. Optional audio, death-sound, spawn-protection, and killfeed addons augment behavior but are not part of the gamemode’s core architecture.
Main entry points: round_management.lua Round Controller · init.lua Server Bootstrap · shared.lua Shared Definition · cl_init.lua Client Bootstrap
Components 14
Gamemode Loading
Garry’s Mod loads separate server, client, and shared paths.
- Addon Metadata
addon.json - Gamemode Registration
gamemodes/randomasylum/randomasylum.txt - Shared Definition · Definitions loaded in both server and client realms.
gamemodes/randomasylum/gamemode/shared.lua - Server Bootstrap · Loads authoritative gameplay systems.
gamemodes/randomasylum/gamemode/init.lua - Client Bootstrap · Loads client presentation code.
gamemodes/randomasylum/gamemode/cl_init.lua
Server Gameplay
Authoritative round and spawn behavior.
- Round Controller · Gates, times, starts, and ends deathmatch rounds.
gamemodes/randomasylum/gamemode/round_management.lua - Round Player State · Tracks per-player round kills and deaths for results and HUD.
- Random Weapon System · Selects eligible SWEPs and grants the configured count on spawn.
gamemodes/randomasylum/gamemode/weapon_system.lua - Player Appearance · Provides an admin-controlled player-model change path.
gamemodes/randomasylum/gamemode/player_appearance.lua
Client Presentation
Client-side view of replicated round state.
- HUD and Results · Renders timer, active-player status, and round results.
gamemodes/randomasylum/gamemode/hud_system.lua
Other components
- Garry's Mod Runtime · Provides Lua lifecycle, hooks, APIs, ConVars, and networking.
- Installed SWEP Addons · Registered weapon definitions consumed by the gamemode.
- MapVote Addon · Selects the next map after a completed round.
- Server Operators · Configure gameplay ConVars through console or server.cfg.
Connections 18
- Addon Metadata → Gamemode Registration: packages
- Gamemode Registration → Garry's Mod Runtime: registered with
- Garry's Mod Runtime → Server Bootstrap: server lifecycle
- Garry's Mod Runtime → Client Bootstrap: client lifecycle
- Garry's Mod Runtime → Shared Definition: shared lifecycle
- Server Bootstrap → Round Controller: loads
- Server Bootstrap → Random Weapon System: loads
- Server Bootstrap → Player Appearance: loads
- Client Bootstrap → HUD and Results: loads
- Shared Definition → Server Bootstrap: bridges realm
- Shared Definition → Client Bootstrap: bridges realm
- Server Operators → Round Controller: configure ConVars
- Round Controller → Round Player State: tracks
- Round Controller → Random Weapon System: drives spawn flow
- Random Weapon System → Installed SWEP Addons: selects from
- Round Controller → MapVote Addon: starts after round
- Round Controller → HUD and Results: replicates round state
- Round Player State → HUD and Results: exposes stats