Wired Damage Detector
From GMod Wiki
Wiremod Tool | Back |
Brief
Detects when props are damaged and outputs damage information.
Instructions
Placed using Primary fire. Primary fire on a wired damage detector to update its "Include Constrained Props" option. Secondary fire to link and detect damage on a specific entity. By default, the detector is linked to itself.
Inputs
- On: Switch to "1" to begin detecting damage. If this is set to "0" (default), the detector will stop checking and no damage will be detected.
- Entity: Receives entity data to link the detector to an entity via wire.
- Entities: An [ARRAY] data type. Damage to all entities in the array will be registered by the detector.
Outputs
- Damage: The amount of damage received instantaneously.
- Attacker: The player/entity that caused the damage.
- Victim: The entity that received damage. This is especially useful when "Include Constrained Props" is selected.
- Victims: A table listing the entity IDs of the props that took damage, along with the amount of damage that was inflicted.
- Position: The location of the damage being dealt, given as a global position vector.
- Force: The impact force, given as a vector
- Type: The type of damage that was dealt, given as a string. The detector will handle the following damage types: Explosive, Bullet, Melee, Fall, Crush
When damage is detected, the detector's outputs will update in the following order:
- Attacker
- Victim
- Victims
- Position
- Force
- Type
- Damage
Since Damage is triggered last, when wiring to multiple outputs it makes sense to perform operations after Damage has updated, as then it will be guaranteed that the other outputs have had a chance to update.
Variables
- Include Constrained props: If this is not selected, the detector will only register damage on the entity/entities it is directly linked to, or receives through the inputs. If this option is selected, then damage will be detected on any linked entities and every prop constrained to them (e.g. with welds, nocollides). This is so damage can be registered on entire contraptions with only one detector.
Useful hints
Use this to simulate damage on your contraptions! Use a damage detector to see if the total damage goes above a certain amount, and have them go out of control or break down gradually as they become more damaged.
Alternatively, use damage detectors to automatically find out who is firing at your contraptions with the "Attacker" output.
If an "Entity" or "Entities" input is sent to the detector, it will overwrite any previous links it had. For example, if you link a detector to a prop with secondary fire, then send entity data to its "Entity" input, the detector will only detect damage on the entity received through the wire input.
Note that the damage detector registers damage instantaneously. This means that damage will immediately reset to 0, so if wiring it to an E2 gate, make sure it executes when the input changes.