Skip to content

Commit 81018d3

Browse files
docs: explain SafeScripts limits when changing hit damage
1 parent 994b530 commit 81018d3

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎Code/ValueSystem/PropertySystem/ReferencePropertyRegistry.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static void Initialize()
324324
Register<DamageHandlerBase, NumberValue>(
325325
"damage",
326326
h => new NumberValue((decimal)((h as StandardDamageHandler)?.Damage ?? -1)),
327-
"Damage amount, -1 if not applicable. Can be changed for standard damage handlers.",
327+
"Damage amount, -1 if not applicable. To change a standard hit in a Hurting script, disable SafeScripts and set this before any pause.",
328328
(h, value) =>
329329
{
330330
if (h is not StandardDamageHandler standard)

‎docs/guides/flags-events-and-commands.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ server.
9797

9898
:::
9999

100+
### Change a hit's damage
101+
102+
In a `Hurting` script, change the damage amount to keep the hit's original
103+
attacker:
104+
105+
```ser
106+
!-- OnEvent Hurting
107+
-- require *evDamageHandler
108+
109+
*evDamageHandler -> damage = 25
110+
```
111+
112+
:::warning SafeScripts and hit damage
113+
114+
This changes the current hit only with SafeScripts disabled and before any
115+
`Wait` or other pause. With SafeScripts enabled, the hit continues before the
116+
script can change it. Keep SafeScripts enabled for general scripts; turn it off
117+
only after checking every active script for loops that can freeze the server.
118+
119+
:::
120+
121+
Only standard damage handlers have a damage amount to change. Other handlers
122+
return an error if you try to set this property.
123+
100124
## ProjectMER events
101125

102126
When ProjectMER is installed:

0 commit comments

Comments
 (0)