Metroid Prime SWEP is a passion project recreation of the original Metroid Prime character controller for Garry's Mod with utmost fidelity in mind. The project also ships with a comprehensive API and a multitude of hooks for developers to integrate their own add-ons.
- Save States
- Power Beam, Wave Beam, Ice Beam and Plasma Beam
- Charge Beam
- Missiles
- Super Missiles, Wavebuster, Ice Spreader and Flamethrower
- Combat Visor, Scan Visor, Thermal Visor and X-Ray Visor
- Lock On System
- Log Book System
- Space Jump, Dashing and Air Movement
- Grapple Beam
- Power Suit, Varia Suit, Gravity Suit and Phazon Suit damage reduction
- Morph Ball, Boost Ball, Spider Ball
- Bombs and Power Bombs
- And more...
| Key | Default | Action |
|---|---|---|
| IN_ATTACK | Mouse 1 | Fire Beam, Charge Beam, Bombs (Morph Ball) |
| IN_ATTACK2 | Mouse 2 | Fire Missile, Missile Combo, Power Bombs (Morph Ball) |
| IN_SPEED | Shift | Lock On, Scan, Grapple Beam, Spider Ball (Morph Ball) |
| IN_JUMP | Space Bar | Space Jump, Dash (Lock On), Boost Ball (Morph Ball) |
| KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_DOWN | Arrow Keys | Switch Beam |
| KEY_E + KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_DOWN | E + Arrow Keys | Switch Visor |
| IN_CROUCH | Left Control Key | Morph Ball / Unmorph |
An options menu is available in Sandbox mode from the Spawn Menu. It will be found in the extended portion of the menu in a category labelled "Metroid Prime". The options menu allows users and developers to tweak the display options of their session and enable / disable upgrades as they wish, granted sv_cheats is turned on.
The following commands are all accessible from the options menu:
| Command | Values | Description |
|---|---|---|
| mp_cheats_autosave | 0 / 1 | Enables or disables autosave upon dying or removing the Power Suit. |
| mp_cheats_damagetakenscale | 1 - 10 | Multiplies damage taken while using the Power Suit. |
| mp_cheats_damagegivenscale | 1 - 10 | Multiplies damage dealt while using the Power Suit. |
| mp_cheats_scandashing | 0 / 1 | Enables or disables Scan Dashing feature found in first release of Metroid Prime. |
Warning: Changing controls may have consequences and cause conflicts with other addons. Change at your own risk. Controls use the KEY enums, see the following link for a list of possible values: https://wiki.facepunch.com/gmod/Enums/KEY.
| ConVar | Values | Description |
|---|---|---|
| mp_controls_selectorlayer | 0 - 159 | Defines the visor layer key to use when changing visors. |
| mp_controls_selector1 | 0 - 159 | Defines the key to use to swap to Beam/Visor 1. |
| mp_controls_selector2 | 0 - 159 | Defines the key to use to swap to Beam/Visor 2. |
| mp_controls_selector3 | 0 - 159 | Defines the key to use to swap to Beam/Visor 3. |
| mp_controls_selector4 | 0 - 159 | Defines the key to use to swap to Beam/Visor 4. |
The following commands are all accessible from the options menu. Gestures can be used to change Beam/Visor using mouse movements instead of keyboard inputs.
| ConVar | Values | Description |
|---|---|---|
| mp_options_gestures | 0 / 1 | Enables or disables gesture feature. |
| mp_controls_gesture | 0 - 159 | Defines the key to hold down to initiate a gesture. |
| mp_options_gesturedzone | 0.1 - 1.0 | Defines the mouse movement dead zone for gestures. Default value of 0.125. |
| mp_options_gesturealpha | 0.1 - 1.0 | Defines the mouse sensitivity for gestures. Default value of 0.125. |
| mp_options_gesturehelp | 0 / 1 | Show gesture calibration on screen. |
The following commands are all accessible from the options menu:
| Command | Values | Description |
|---|---|---|
| mp_options_autoaim | 0 / 1 | Enables or disables auto-aim. |
| mp_options_viewmodelfov | 54 - 76 | Changes viewmodel FOV. |
| mp_options_widescreenfix | 0 / 1 | Stretches HUD to fill widescreen displays. |
| mp_options_visoropacity | 0 - 100 | Opacity of heads-up-display. |
| mp_options_helmetopacity | 0 - 100 | Opacity of Samus' helmet. |
| mp_options_hudlag | 0 / 1 | Enables or disables HUD lag. |
| mp_options_facereflection | 0 / 1 | Enables or disables Samus' face reflection on Combat Visor. |
| mp_options_keephud | 0 / 1 | Enables or disables HUD display even when the Power Suit is not in use. Must be in inventory. |
The following commands are all accessible from the options menu:
| Command | Args | Args | Description |
|---|---|---|---|
| mp_cheats_savestate | - | - | Save current session. |
| mp_cheats_deletestate | - | - | Delete current session. |
| mp_cheats_set_missileamount | 0 - 255 | - | Set current missile ammo count. |
| mp_cheats_set_missilecapacity | 0 - 255 | - | Set missile max ammo count. |
| mp_cheats_enable_powerbeam | 0 / 1 | - | Enables or disables Power Beam. |
| mp_cheats_enable_wavebeam | 0 / 1 | - | Enables or disables Wave Beam. |
| mp_cheats_enable_icebeam | 0 / 1 | - | Enables or disables Ice Beam. |
| mp_cheats_enable_plasmabeam | 0 / 1 | - | Enables or disables Plasma Beam |
| mp_cheats_enable_chargebeam | 0 / 1 | - | Enables or disables Charge Beam. |
| mp_cheats_enable_supermissile | 0 / 1 | - | Enables or disables Super Missile Combo. |
| mp_cheats_enable_wavebuster | 0 / 1 | - | Enables or disables Wavebuster Combo. |
| mp_cheats_enable_icespreader | 0 / 1 | - | Enables or disables Ice Spreader Combo. |
| mp_cheats_enable_flamethrower | 0 / 1 | - | Enables or disables Flamethrower Combo. |
| mp_cheats_enable_spacejump | 0 / 1 | - | Enables or disables Space Jump. |
| mp_cheats_enable_grapplebeam | 0 / 1 | - | Enables or disables Grapple Beam. |
| mp_cheats_enable_powersuit | 0 / 1 | - | Enables or disables Power Suit. |
| mp_cheats_enable_variasuit | 0 / 1 | - | Enables or disables Varia Suit. |
| mp_cheats_enable_gravitysuit | 0 / 1 | - | Enables or disables Gravity Suit. |
| mp_cheats_enable_phazonsuit | 0 / 1 | - | Enables or disables Phazon Suit. |
| mp_cheats_set_energytankamount | 0 - 14 | - | Sets base filled energy tank amount. Although this command exists, you probably shouldn't use it. |
| mp_cheats_set_energytankcapacity | 0 - 14 | 0 / 1 | First argument sets max energy tank capacity. Second argument to refill health or not. |
| mp_cheats_enable_combatvisor | 0 / 1 | - | Enables or disables Combat Visor. |
| mp_cheats_enable_scanvisor | 0 / 1 | - | Enables or disables Scan Visor. |
| mp_cheats_enable_thermalvisor | 0 / 1 | - | Enables or disables Thermal Visor. |
| mp_cheats_enable_xrayvisor | 0 / 1 | - | Enables or disables X-Ray Visor. |
| mp_cheats_enable_morphball | 0 / 1 | - | Enables or disables Morph Ball. |
| mp_cheats_enable_morphballbombs | 0 / 1 | - | Enables or disables Morph Ball Bombs. |
| mp_cheats_enable_morphballboost | 0 / 1 | - | Enables or disables Boost Ball. |
| mp_cheats_enable_morphballspider | 0 / 1 | - | Enables or disables Spider Ball. |
| mp_cheats_set_powerbombamount | 0 - 8 | - | Sets current Power Bomb count. |
| mp_cheats_set_powerbombcapacity | 0 - 8 | - | Sets Power Bomb max ammo. |
The supplied API offers methods for other addons to integrate with this project. Here you will find a guide on all available features and endpoints.
Weapons use a combination of custom damage types:
| DMG Type | Value | Weapons |
|---|---|---|
| DMG_MP_NULL | 0 | Unused |
| DMG_MP_POWER | 1 | Power Beam, Super Missile |
| DMG_MP_WAVE | 2 | Wave Beam, Wavebuster |
| DMG_MP_ICE | 4 | Ice Beam, Ice Spreader |
| DMG_MP_PLASMA | 8 | Plasma Beam, Flamethrower |
| DMG_MP_BOMB | 16 | Bombs, Power Bombs |
| DMG_MP_SPECIAL | 32 | Missile, Super Missile, Wavebuster, Ice Spreader, Flamethrower, Power Bombs |
To check for a specific damage type, use: https://wiki.facepunch.com/gmod/CTakeDamageInfo:GetDamageCustom
To add entities to the threat indication system, use the following stub in an autorun script:
game.MetroidPrimeThreats.Add("entity_class_name")There are two ways to add Log Book support to your entities. The first method declares the Log Book data directly in your shared.lua file. The second approach makes use of an autorun script to register your entity into the game. If you are the author of the entity you wish to add support for, the first approach is recommended. If you are not the author, your only option will be the second method.
Method 1
In your shared.lua file, declare the following:
ENT.LogBook = {
Description = "",
Left = Material(""), // or nil
Right = Material("") // or nil
}Values:
| Var | Description |
|---|---|
| Description | Text to be displayed on the Scan Visor upon scan completion. |
| Left | Material to be displayed on the left side of the Scan Visor upon scan completion. |
| Right | Material to be displayed on the right side of the Scan Visor upon scan completion. |
Additional Values:
| Var | Description |
|---|---|
| ScanDuration | Time required to scan entity. (Default of 1.33) |
Method 2
In your autorun script, add the following stub and change the values to your needs:
game.MetroidPrimeLogBook.Add("entity_class_name", {
Description = "",
Left = Material(""), // or nil
Right = Material("") // or nil
})VTF/VMT Templates
You can use the following templates for creating your scan images. You can resize the frame however you want as long as your final VTF dimensions are 256 x 512.
Here is what your VMT should look like:
"UnlitGeneric"
{
"$basetexture" "your/texture/path/here"
"$additive" "1"
"$vertexalpha" "1"
"$vertexcolor" "1"
}
To add grapple beam anchors, use the following stub in an autorun script:
game.MetroidPrimeAnchors.Add("entity_class_name")The Spider Ball uses surface properties to determine if it can ride along surfaces. To learn more about surface properties, see the following link: https://developer.valvesoftware.com/wiki/Material_surface_properties
By default, the Spider Ball will ride along any metallic surface. To add new surfaces, use the following stub in an autorun script:
game.MetroidPrimeSpiderSurfaces.Add("surface_prop_name")By default, the weapon will use the world space center of an entity to lock on. The API offers a way to define a lock-on attachment. The first method declares the attachment in your Initialize hook. The second approach makes use of an autorun script to register your attachment into the game. If you are the author of the entity you wish to add support for, the first approach is recommended. If you are not the author, your only option will be the second method. Attachments are dynamic, you can change the attachment at any time in your logic as long as it is called server-side. See API section for all available functions in the Entity section.
Method 1
In your Initialize hook:
function ENT:Initialize()
-- Code.
if (self.SetLockOnAttachment) then self:SetLockOnAttachment("your_attachment_name") end
endMethod 2
In your autorun script, add the following stub and change the values to your needs:
game.MetroidPrimeLockOn.Add("entity_class_name", "your_attachment_name")There are a lot of moving pieces and a lot of different states to this weapon. The project employs a number of design patterns to aid in its maintainability and debugging. At the core of the system lies four state machine classes responsible for keeping track of all timings and states. The state machines act as the data access layer for all networked properties of the weapon.
This is the default SWEP implementation. This is where all files are loaded. This layer only contains functions relevant to the GLua API and calls to the event layer.
- setup.lua : Loads all files and configurations.
- shared.lua : Standard implementation, exposes Primary Attack, Secondary Attack and Think logic.
- init.lua : Standard implementation, tells the game how the weapon should behave when dropped or equipped.
- cl_init.lua: Standard implementation, calls to the rendering stack to display the HUD and how the view should behave.
The events layer is divided into four sections:
This layer contains most of the logic for the Power Suit, everything from firing projectiles, movement, target acquisition, etc. This layer communicates with the state machines to update timings and states.
State machines are created inside InstallDataTables and are responsible for installing all necessary network variables onto a Power Suit instance. There are four state machines in total:
This is the data access layer. This is where events and hooks tap into the timings and states of the weapon. State machines act as classes and are exposed to every part of the code in order to maintain separation of concerns. Although you can interact with state machines directly, you should avoid doing so unless you know what you are doing. To access the state machines on a Power Suit instance, refer to the following code:
local weapon = ply:GetPowerSuit(); // Get Power Suit instance using API.
local armcannon = weapon.ArmCannon; // Arm Cannon state machine instance.
local helmet = weapon.Helmet; // Helmet state machine instance.
local morphball = weapon.MorphBall; // Morph Ball state machine instance.
local powersuit = weapon.PowerSuit; // Power Suit state machine instance.List of all available hooks.
MP.OnSaveState(powersuit)
Called when a Power Suit has saved its state to disk.
1. EntitypowersuitPower Suit weapon reference.
hook.Add("MP.OnSaveState", "DEBUG.OnSaveState", function(powersuit)
print("MP.OnSaveState", powersuit);
end);
MP.OnVisorChanged(powersuit, previousVisor, nextVisor)
Called when changing visors.
1. EntitypowersuitPower Suit weapon reference.
2. NumberpreviousVisorPrevious visor index.
3. NumbernextVisorNew visor index.
hook.Add("MP.OnVisorChanged", "DEBUG.OnVisorChanged", function(powersuit, previousVisor, nextVisor)
print("MP.OnVisorChanged", powersuit, previousVisor, nextVisor);
end);
MP.OnTargetChanged(powersuit, target)
Called when visor target has changed.
1. EntitypowersuitPower Suit weapon reference.
2. EntitytargetNew target.
hook.Add("MP.OnTargetChanged", "DEBUG.OnTargetChanged", function(powersuit, target)
print("MP.OnTargetChanged", powersuit, target);
end);
MP.OnScanCompleted(powersuit, target)
Called when the Scan Visor has finished scanning.
1. EntitypowersuitPower Suit weapon reference.
2. EntitytargetScanned target entity.
hook.Add("MP.OnScanCompleted", "DEBUG.OnScanCompleted", function(powersuit, target)
print("MP.OnScanCompleted", powersuit, target);
end);
MP.OnBeamChanged(powersuit, previousBeam, nextBeam)
Called when changing beams.
1. EntitypowersuitPower Suit weapon reference.
2. NumberpreviousBeamPrevious beam index.
3. NumbernextBeamNew beam index.
hook.Add("MP.OnBeamChanged", "DEBUG.OnBeamChanged", function(powersuit, previousBeam, nextBeam)
print("MP.OnBeamChanged", powersuit, previousBeam, nextBeam);
end);
MP.ChargeBeamThink(powersuit)
Called on every frame/tick the charge beam is active.
1. EntitypowersuitPower Suit weapon reference.
hook.Add("MP.ChargeBeamThink", "DEBUG.ChargeBeamThink", function(powersuit)
print("MP.ChargeBeamThink", powersuit);
end);
MP.OnMorphBall(ply, powersuit, morphball)
Called upon transitioning into Morph Ball mode.
1. EntityplyPlayer that morphed.
2. EntitypowersuitPower Suit weapon reference.
3. EntitymorphballMorph Ball entity reference.
hook.Add("MP.OnMorphBall", "DEBUG.OnMorphBall", function(ply, powersuit, morphball)
print("MP.OnMorphBall", ply, powersuit, morphball);
end);
MP.OnMorphBallUnmorph(ply, powersuit)
Called upon exiting Morph Ball mode.
1. EntityplyPlayer that unmorphed.
2. EntitypowersuitPower Suit weapon reference.
hook.Add("MP.OnMorphBallUnmorph", "DEBUG.OnMorphBallUnmorph", function(ply, powersuit)
print("MP.OnMorphBallUnmorph", ply, powersuit);
end);
MP.OnMorphBallBoost(morphball)
Called when Boost Ball fires.
1. EntitymorphballMorph Ball entity that boosted.
hook.Add("MP.OnMorphBallBoost", "DEBUG.OnMorphBallBoost", function(morphball)
print("MP.OnMorphBallBoost", morphball);
end);
MP.MorphBallSpiderThink(morphball, surfaceParent, parentPhys, parentVelocity)
Called every tick the Spider Ball is active.
1. EntitymorphballMorph Ball entity reference.
2. EntitysurfaceParentSurface entity on which Morph Ball is riding.
3. PhysObjparentPhysPhysics Object of surface parent.
4. VectorparentVelocityVelocity of parent at Morph Ball position in world coordinates.
hook.Add("MP.MorphBallSpiderThink", "DEBUG.MorphBallSpiderThink", function(morphball, surfaceParent, parentPhys, parentVelocity)
print("MP.MorphBallSpiderThink", morphball, surfaceParent, parentPhys, parentVelocity);
end);
MP.OnDash(ply, powersuit)
Called upon dashing.
1. EntityplyPlayer that dashed.
2. EntitypowersuitPower Suit weapon reference.
hook.Add("MP.OnDash", "DEBUG.OnDash", function(ply, powersuit)
print("MP.OnDash", ply, powersuit);
end);
Boolean MP.GrappleBeamThink(ply, powersuit, anchor)
Called every tick the Grapple Beam is active.
1. EntityplyPlayer grappling.
2. EntitypowersuitPower Suit weapon reference.
3. EntityanchorEntity onto which Grapple Beam is anchored.
1. BooleanReturn true to override default grapple behavior.
The following example will prevent the player from swinging and print the anchor to console.
hook.Add("MP.GrappleBeamThink", "DEBUG.GrappleBeamThink", function(ply, powersuit, anchor)
print("MP.GrappleBeamThink", ply, powersuit, anchor);
return true;
end);
MP.PreDrawPowerSuitHUD(weapon, damage)
Called before the Power Suit HUD, Visor and components have finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. NumberdamageDamage variable, used for animating HUD elements upon damage.
hook.Add("MP.PreDrawPowerSuitHUD", "DEBUG.PreDrawPowerSuitHUD", function(weapon, damage)
print("MP.PreDrawPowerSuitHUD", weapon, damage);
end);
MP.PostDrawPowerSuitHUD(weapon, damage)
Called after the Power Suit HUD, Visor and components have finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. NumberdamageDamage variable, used for animating HUD elements upon damage.
hook.Add("MP.PostDrawPowerSuitHUD", "DEBUG.PostDrawPowerSuitHUD", function(weapon, damage)
print("MP.PostDrawPowerSuitHUD", weapon, damage);
end);
Boolean MP.PreDrawBeamMenu(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
Called before drawing the Beam Menu component to the screen. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. VectorposPosition used for 3D rendering of Beam Menu.
3. AngleangleAngle used for 3D rendering of Beam Menu.
4. VectorupUp vector of angle.
5. VectorrightRight vector of angle.
6. VectorforwardForward vector of angle.
7. NumberfovCompensationFOV compensation ratio used in 3D rendering of Beam Menu.
8. NumberblendCurrent blend of render calls. Used for transparency of 3D Beam Menu.
9. BooleanwidescreenWhether or not to stretch rendering of 3D Beam Menu for wide screens.
1. BooleanReturn True to prevent drawing the default Beam Menu.
The following example will prevent rendering of the Beam Menu and print all arguments to console.
hook.Add("MP.PreDrawBeamMenu", "DEBUG.PreDrawBeamMenu", function(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
print("MP.PreDrawBeamMenu", weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen);
return true;
end);
MP.PostDrawBeamMenu(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
Called after drawing the Beam Menu component to the screen. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. VectorposPosition used for 3D rendering of Beam Menu.
3. AngleangleAngle used for 3D rendering of Beam Menu.
4. VectorupUp vector of angle.
5. VectorrightRight vector of angle.
6. VectorforwardForward vector of angle.
7. NumberfovCompensationFOV compensation ratio used in 3D rendering of Beam Menu.
8. NumberblendCurrent blend of render calls. Used for transparency of 3D Beam Menu.
9. BooleanwidescreenWhether or not to stretch rendering of 3D Beam Menu for wide screens.
hook.Add("MP.PostDrawBeamMenu", "DEBUG.PostDrawBeamMenu", function(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
print("MP.PostDrawBeamMenu", weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen);
end);
Boolean MP.PreDrawVisorMenu(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
Called before drawing the Visor Menu component to the screen. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. VectorposPosition used for 3D rendering of Visor Menu.
3. AngleangleAngle used for 3D rendering of Visor Menu.
4. VectorupUp vector of angle.
5. VectorrightRight vector of angle.
6. VectorforwardForward vector of angle.
7. NumberfovCompensationFOV compensation ratio used in 3D rendering of Visor Menu.
8. NumberblendCurrent blend of render calls. Used for transparency of 3D Visor Menu.
9. BooleanwidescreenWhether or not to stretch rendering of 3D Visor Menu for wide screens.
1. BooleanReturn True to prevent drawing the default Visor Menu.
The following example will prevent rendering of the Visor Menu and print all arguments to console.
hook.Add("MP.PreDrawVisorMenu", "DEBUG.PreDrawVisorMenu", function(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
print("MP.PreDrawVisorMenu", weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen);
return true;
end);
MP.PostDrawVisorMenu(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
Called after drawing the Visor Menu component to the screen. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. VectorposPosition used for 3D rendering of Visor Menu.
3. AngleangleAngle used for 3D rendering of Visor Menu.
4. VectorupUp vector of angle.
5. VectorrightRight vector of angle.
6. VectorforwardForward vector of angle.
7. NumberfovCompensationFOV compensation ratio used in 3D rendering of Visor Menu.
8. NumberblendCurrent blend of render calls. Used for transparency of 3D Visor Menu.
9. BooleanwidescreenWhether or not to stretch rendering of 3D Visor Menu for wide screens.
hook.Add("MP.PostDrawVisorMenu", "DEBUG.PostDrawVisorMenu", function(weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen)
print("MP.PostDrawVisorMenu", weapon, pos, angle, up, right, forward, fovCompensation, blend, widescreen);
end);
Boolean MP.PreDrawMorphBallHUD(weapon)
Called before the Morph Ball HUD has finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
1. BooleanReturn true to prevent drawing the Morph Ball HUD.
The following example will prevent drawing the default Morph Ball HUD.
hook.Add("MP.PreDrawMorphBallHUD", "DEBUG.PreDrawMorphBallHUD", function(weapon)
print("MP.PreDrawMorphBallHUD", weapon);
return true;
end);
MP.PostDrawMorphBallHUD(weapon)
Called after the Morph Ball HUD has finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
hook.Add("MP.PostDrawMorphBallHUD", "DEBUG.PostDrawMorphBallHUD", function(weapon)
print("MP.PostDrawMorphBallHUD", weapon);
end);
Boolean MP.PreDrawCombatVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
Called before the Combat Visor has finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. TablebeamCurrent beam config table.
3. TablevisorCurrent visor config table.
4. VectorhudPosPosition used to render 3D Combat Visor UI.
5. AnglehudAngleAngle used to render 3D Combat Visor UI.
6. VectorguiPosPosition used to render the static elements of the 3D Combat Visor.
7. ColorguiColorColor used to render the static elements of the 3D Combat Visor.
8. NumberfovRatioFOV ratio used for positioning of 3D elements.
9. NumbertransitionTransition interpolator. This is used to fade visors into each other upon switching.
10. NumbertransitionStartTransition start, indicates if fading in or out.
11. BooleanwidescreenBoolean used to stretch 3D elements for wide screens.
12. NumbervisorOpacityVisor opacity, set by the command mp_options_visoropacity.
1. BooleanReturn true to prevent drawing the Combat Visor.
The following example will prevent drawing the default Combat Visor.
hook.Add("MP.PreDrawCombatVisor", "DEBUG.PreDrawCombatVisor", function(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
return true;
end);
MP.PostDrawCombatVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
Called after the Combat Visor has finished drawing. This hook is called inside a 2D rendering context.
1. EntityweaponPower Suit weapon reference.
2. TablebeamCurrent beam config table.
3. TablevisorCurrent visor config table.
4. VectorhudPosPosition used to render 3D Combat Visor UI.
5. AnglehudAngleAngle used to render 3D Combat Visor UI.
6. VectorguiPosPosition used to render the static elements of the 3D Combat Visor.
7. ColorguiColorColor used to render the static elements of the 3D Combat Visor.
8. NumberfovRatioFOV ratio used for positioning of 3D elements.
9. NumbertransitionTransition interpolator. This is used to fade visors into each other upon switching.
10. NumbertransitionStartTransition start, indicates if fading in or out.
11. BooleanwidescreenBoolean used to stretch 3D elements for wide screens.
12. NumbervisorOpacityVisor opacity, set by the command mp_options_visoropacity.
hook.Add("MP.PostDrawCombatVisor", "DEBUG.PostDrawCombatVisor", function(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
print("MP.PostDrawCombatVisor", weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity);
end);
Boolean MP.PreDrawScanVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PreDrawCombatVisor.
MP.PostDrawScanVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PostDrawCombatVisor.
Boolean MP.PreDrawThermalVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PreDrawCombatVisor.
MP.PostDrawThermalVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PostDrawCombatVisor.
Boolean MP.PreDrawXRayVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PreDrawCombatVisor.
MP.PostDrawXRayVisor(weapon, beam, visor, hudPos, hudAngle, guiPos, guiColor, fovRatio, transition, transitionStart, widescreen, visorOpacity)
This hook is identical to MP.PostDrawCombatVisor.
List of all accessible API endpoints to facilitate addon integrations. To view the raw API, click here.
Entity _player:GetPowerSuit()
Get Power Suit instance of a player.
This function can return nil if the StateIdentifier variable is not set on the instance. StateIdentifier is a special variable used to indicate that the state successfully loaded.
1. EntityWeapon or nil if not in player's inventory.
Boolean, Entity _player:UsingPowerSuit(ignoreState)
Determines if a player is currently using the Power Suit.
This function can return false,nil if the StateIdentifier variable is not set on the instance. StateIdentifier is a special variable used to indicate that the state successfully loaded.
1. BooleanignoreStateIgnores checking for StateIdentifier. Not recommended unless you know what you are doing.
1. BooleanTrue if active weapon is Power Suit, False otherwise.
2. EntityWeapon instance if True, nil if False.
Boolean, Entity _player:UsingMorphBall()
Determines if a player is currently using the Morph Ball.
1. BooleanTrue if using Morph Ball, False otherwise.
2. EntityMorph Ball entity if True, False otherwise.
Boolean _entity:IsMorphBall()
Checks if the entity is a Morph Ball.
1. BooleanTrue if entity is a Morph Ball and valid, False otherwise.
Boolean _entity:IsGrappleAnchor()
Checks if the entity is a Grapple Anchor.
1. BooleanTrue if entity is a registered anchor, False otherwise.
_entity:SetIgnitable(ignitable)
Make entity ignitable when damaged by Plasma Beam.
1. BooleanignitableTrue if ignitable, False otherwise.
Boolean _entity:IsIgnitable()
Determines if entity can be ignited when damaged by Plasma Beam.
1. BooleanTrue if ignitable, False otherwise.
Boolean _entity:CanBeScanned()
Determines if entity can be scanned using the Scan Visor.
1. BooleanTrue if scannable, False otherwise.
String, Material, Material, Number _entity:GetLogBookData()
Get Log Book data from an entity.
This function returns nil if no Log Book data was found.
1. StringDescription or nil.
2. MaterialLeft image or nil.
3. MaterialRight image or nil.
4. NumberScan duration or nil.
Boolean _entity:SetXRayHot(hot)
Marks an entity as hot on the X-Ray Visor. Hot entities appear solid white.
1. BooleanhotTrue if hot, False if normal.
1. BooleanHot. False on failure.
Boolean _entity:SetXRayCold(cold)
Marks an entity as cold on the X-Ray Visor. Cold entities are invisible.
1. BooleancoldTrue if cold, False if normal.
1. BooleanCold. False on failure.
Boolean _entity:IsXRayHot()
Determines if an entity is marked as hot on the X-Ray Visor.
1. BooleanTrue if hot, False otherwise.
Boolean _entity:IsXRayCold()
Determines if an entity is marked as cold on the X-Ray Visor.
1. BooleanTrue if cold, False otherwise.
Boolean _entity:SetThermalHot(hot)
Marks an entity as hot on the Thermal Visor. Hot entities appear red.
1. BooleanhotTrue if hot, False if normal.
1. BooleanHot. False on failure.
Boolean _entity:SetThermalCold(cold)
Marks an entity as cold on the Thermal Visor. Cold entities are invisible.
1. BooleancoldTrue if cold, False if normal.
1. BooleanCold. False on failure.
Boolean _entity:IsThermalHot()
Determines if an entity is marked as hot on the Thermal Visor.
1. BooleanTrue if hot, False otherwise.
Boolean _entity:IsThermalCold()
Determines if an entity is marked as cold on the Thermal Visor.
1. BooleanTrue if cold, False otherwise.
Boolean _entity:HasHeatSignature()
Determines if an entity will appear on the Thermal Visor and is not cold.
1. BooleanTrue if has signature, False otherwise.
Boolean _entity:HasXRaySignature()
Determines if an entity is marked as cold or hot on the X-Ray Visor.
1. BooleanTrue if has signature, False otherwise.
Vector _entity:GetLockOnPosition()
Get the lock-on position of an entity.
1. VectorLock-on position.
Number _entity:GetLockOnAttachment()
Get the lock-on attachment ID.
This function returns 0 if the attachment does not exist and -1 if the model is invalid.
1. NumberLock-on attachment ID.
_entity:SetLockOnAttachment(name)
Defines the entity's lock-on attachment.
1. StringnameThe name of the attachment to use for lock-on.
Boolean _player:SavePowerSuitState()
Saves current Power Suit state to disk.
1. BooleanTrue if saved successfully, False otherwise.
Boolean _player:LoadPowerSuitState(json)
Loads a state file to the player's Power Suit.
Although you can use this function, you probably shouldn't.
1. StringjsonString containing a valid JSON state for the Power Suit.
1. BooleanTrue if loaded successfully, False otherwise.
Boolean _player:DeletePowerSuitState(reload)
Deletes current Power Suit state from disk.
1. BooleanreloadIf True, will reset weapon now. If False, will reset weapon on next spawn. Warning: If 'Auto Save' is on and you are reloading weapon on next spawn, this function will basically do nothing.
1. BooleanTrue if deleted successfully, False otherwise.
Number _player:GetPowerSuitEnergyTanks()
Determines the base amount of filled energy tanks the Power Suit starts with.
This function does not return the current health of the player. Although you can use this function, you probably shouldn't.
1. NumberBase amount of filled energy tanks, or nil on failure.
Number _player:AddPowerSuitEnergyTanks(amount, norefill)
Adds a set amount of base energy tanks.
Although you can use this function, you probably shouldn't.
1. NumberamountAmount of base energy tanks to add.
2. BooleannorefillFalse to refill health, True to prevent.
1. NumberBase amount of filled energy tanks, or nil on failure.
Number _player:SetPowerSuitEnergyTanks(amount, norefill)
Sets the amount of base energy tanks.
Although you can use this function, you probably shouldn't.
1. NumberamountAmount of base energy tanks.
2. BooleannorefillFalse to refill health, True to prevent.
1. NumberBase amount of filled energy tanks, or nil on failure.
Number _player:GetPowerSuitMaxEnergyTanks()
Determines the total energy tank capacity of a player.
1. NumberAmount of energy tanks, or nil on failure.
Number _player:AddPowerSuitMaxEnergyTanks(amount, refill)
Adds a set amount of energy tanks to the Power Suit.
1. NumberamountAmount of energy tanks to add.
2. BooleanrefillTrue to refill health, False otherwise.
1. NumberTotal amount of energy tanks, nil on failure.
Number _player:SetPowerSuitMaxEnergyTanks(amount, refill)
Sets the amount of energy tanks on the Power Suit.
1. NumberamountAmount of energy tanks to set.
2. BooleanrefillTrue to refill health, False otherwise.
1. NumberTotal amount of energy tanks, nil on failure.
Boolean _player:IsPowerSuitVisorEnabled(index)
Determines if some visor is enabled on the Power Suit.
1. NumberindexVisor index to test. (Values are 1 to 4)
1. BooleanTrue if visor is enabled, False otherwise.
Boolean _player:EnablePowerSuitVisor(index, enable)
Enables or disables a visor on the Power Suit.
1. NumberindexVisor index to enable. (Values are 1 to 4)
2. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsPowerSuitBeamEnabled(index)
Determines if some beam is enabled on the Power Suit.
1. NumberindexBeam index to test. (Values are 1 to 4)
1. BooleanTrue if beam is enabled, False otherwise.
Boolean _player:EnablePowerSuitBeam(index, enable)
Enables or disables a beam on the Power Suit.
1. NumberindexBeam index to enable. (Values are 1 to 4)
2. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsPowerSuitChargeBeamEnabled()
Determines if Charge Beam is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnablePowerSuitChargeBeam(enable)
Enables or disables Charge Beam on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsPowerSuitMissileComboEnabled(index)
Determines if some missile combo is enabled on the Power Suit.
1. NumberindexBeam index to test. (Values are 1 to 4)
1. BooleanTrue if combo is enabled, False otherwise.
Boolean _player:EnablePowerSuitMissileCombo(index, enable)
Enables or disables a missile combo on the Power Suit.
1. NumberindexBeam index to enable. (Values are 1 to 4)
2. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Number _player:GetPowerSuitAmmo(type)
Determines the current ammo count for a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to check.
1. NumberAmmo count, nil on failure.
Number _player:AddPowerSuitAmmo(type, amount)
Adds a set amount of ammo of a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to add.
2. NumberamountAmount of ammo to add.
1. NumberAmmo count, nil on failure.
Number _player:SetPowerSuitAmmo(type, amount)
Sets amount of ammo of a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to set.
2. NumberamountAmount to set.
1. NumberAmmo count, nil on failure.
Number _player:GetPowerSuitMaxAmmo(type)
Determines the max ammo capacity for a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to check.
1. NumberMax ammo count, nil on failure.
Number _player:AddPowerSuitMaxAmmo(type, amount)
Adds a set amount of ammo capacity for a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to add.
2. NumberamountCapacity to add.
1. NumberCapacity, nil on failure.
Number _player:SetPowerSuitMaxAmmo(type, amount)
Sets ammo capacity of a given type.
Currently only supports type "Missile".
1. StringtypeAmmo type to set.
2. NumberamountCapacity to set.
1. NumberCapacity, nil on failure.
Boolean _player:IsPowerSuitSpaceJumpEnabled()
Determines if Space Jump is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnablePowerSuitSpaceJump(enable)
Enables or disables Space Jump on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsPowerSuitGrappleEnabled()
Determines if Grapple Beam is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnablePowerSuitGrapple(enable)
Enables or disables Grapple Beam on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsPowerSuitSuitEnabled(suit)
Determines if some suit is enabled on the Power Suit.
1. NumbersuitSuit index to test. (Values are 1 to 4)
1. BooleanTrue if suit is enabled, False otherwise.
Boolean _player:EnablePowerSuitSuit(suit, enable)
Enables or disables a suit on the Power Suit.
1. NumbersuitSuit index to enable. (Values are 1 to 4)
2. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsMorphBallEnabled()
Determines if Morph Ball feature is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnableMorphBall(enable)
Enables or disables Morph Ball feature on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsMorphBallBombsEnabled()
Determines if Morph Ball Bombs are enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnableMorphBallBombs(enable)
Enables or disables Morph Ball Bombs feature on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsMorphBallBoostEnabled()
Determines if Boost Ball is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnableMorphBallBoost(enable)
Enables or disables Boost Ball feature on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Boolean _player:IsMorphBallSpiderEnabled()
Determines if Spider Ball is enabled on the Power Suit.
1. BooleanTrue if enabled, False otherwise.
Boolean _player:EnableMorphBallSpider(enable)
Enables or disables Spider Ball feature on the Power Suit.
1. BooleanenableTrue to enable, False otherwise.
1. BooleanTrue on success, False otherwise.
Number _player:GetPowerSuitPowerBombAmmo()
Determines the current power bomb ammo count.
1. NumberPower bomb ammo count, nil on failure.
Number _player:AddPowerSuitPowerBombAmmo(amount)
Adds a set amount of power bomb ammo.
1. NumberamountAmount of power bomb ammo to add.
1. NumberPower bomb ammo count, nil on failure.
Number _player:SetPowerSuitPowerBombAmmo(amount)
Sets power bomb ammo count.
1. NumberamountAmount of power bomb ammo to set.
1. NumberPower bomb ammo count, nil on failure.
Number _player:GetPowerSuitPowerBombMaxAmmo()
Determines the current power bomb ammo capacity.
1. NumberPower bomb ammo capacity, nil on failure.
Number _player:AddPowerSuitPowerBombMaxAmmo(amount)
Adds a set amount of power bomb ammo capacity.
1. NumberamountPower bomb ammo capacity to add.
1. NumberPower bomb ammo capacity, nil on failure.
Number _player:SetPowerSuitPowerBombMaxAmmo(amount)
Sets power bomb ammo capacity.
1. NumberamountPower bomb ammo capacity to set.
1. NumberPower bomb ammo capacity, nil on failure.
WLKRE - Programming, Testing, Source Particle Effects
TonyBoi - Multiplayer Beta Testing
Dopey - Beta Testing, Particle Effects Adviser
SLAUGH7ER - Optimization Adviser
Impulse - Porting Adviser
Retro Studios - Original Assets
Nintendo - Copyright Owner
Star1x
Chistogo
Shoax
Kieran Vax'ilian
Metroid Prime SWEP is a passion project recreation of the original Metroid Prime character controller for Garry's Mod. It is not affiliated, associated, authorized, endorsed by, or in any way officially connected to Nintendo, or any of its subsidiaries or its affiliates.
The names Metroid Prime as well as related names, marks, emblems and images are registered trademarks of their respective owners.
Start: November 2022 End: October 2023 Hours: ~800 hours Lines: ~15,500 lines


