Damage Types and Health Systems
Understand the intricacies of combat in Garry's Mod by exploring damage types and health systems. This section details how different attacks affect players and NPCs, and how custom health systems can be implemented for varied gameplay.
Combat in Garry's Mod can range from simple prop-based skirmishes to complex gamemodes with intricate health and damage mechanics. While the base game has a straightforward health system, many gamemodes and addons introduce more nuanced approaches. Understanding the various damage types—such as blunt, bullet, fire, and energy—and how they interact with different entities is crucial for effective combat. Furthermore, learning to implement custom health systems can allow for unique gameplay mechanics, like armor, regeneration, or specialized resistances.
Common Damage Types:
- Blunt: Typically from melee weapons or falling objects.
- Bullet: From firearms.
- Fire: From incendiary weapons or environmental hazards.
- Energy: From sci-fi weapons or special abilities.
- Fall Damage: Sustained from falling too far.
Implementing Custom Health Systems:
- Lua Scripting: The most common method involves using Lua to override or supplement the default health variable.
- Armor Systems: Add an armor value that absorbs a portion of incoming damage before health is affected.
- Regeneration: Implement health regeneration over time, either passively or through specific items/abilities.
- Damage Modifiers: Create resistances or vulnerabilities to specific damage types for certain entities.
Many gamemodes, such as DarkRP or zombie survival, feature custom health and damage systems to enhance realism or gameplay challenge. Exploring these gamemodes can provide excellent examples of how these systems are implemented. For developers, the `Player:SetHealth()` and `Entity:TakeDamage()` functions are fundamental for manipulating health and damage.
| Damage Type | Typical Source | Effect |
|---|---|---|
| Blunt | Melee weapons, impacts. | Standard health reduction. |
| Bullet | Firearms. | Standard health reduction, can be affected by armor. |
| Fire | Flamethrowers, explosions. | Can cause damage over time (DoT). |
| Fall Damage | High falls. | Sificant health reduction upon landing. |