Difference between revisions of "Combat Log"
(Stub page about Combat Log) |
|||
Line 12: | Line 12: | ||
System generated messages can be delayed up to 1 second as the sim collects messages to send them in bulk at a time. | System generated messages can be delayed up to 1 second as the sim collects messages to send them in bulk at a time. | ||
Unless you want to intentionally listen to object generated messages it is recommended to set your listener to filter by [[COMBAT_LOG_ID]]. This is because your script may end up unnecessarily receiving and processing custom messages that it was not designed to handle and ends up ignoring. | |||
==Message Format== | |||
== Message Format == | |||
The format of the combat log message is a JSON array (<code>[]</code>) containing JSON objects (<code>[{},{},{}]</code>). There is always an "event" property present to describe the type of the message object for parsing. The schema of the different objects are as follows: | The format of the combat log message is a JSON array (<code>[]</code>) containing JSON objects (<code>[{},{},{}]</code>). There is always an "event" property present to describe the type of the message object for parsing. The schema of the different objects are as follows: | ||
{| {{Prettytable}} | |||
|+ JSON structure of a DAMAGE event | |||
|- {{Hl2}} | |||
! '''Key''' | |||
! '''Value''' | |||
! '''Description''' | |||
|- | |||
| "event" | |||
| "DAMAGE" | |||
| | |||
|- | |||
| "damage" | |||
| [[JSON_NUMBER]] | |||
| Float of final damage applied | |||
|- | |||
| "initial" | |||
| [[JSON_NUMBER]] | |||
| Float of initial damage before adjustment | |||
|- | |||
| "type" | |||
| [[JSON_NUMBER]] | |||
| [[:Template:LSL_Constants/Damage_Types|DAMAGE_TYPE_*]] or any number defined by the scripter of the damage source | |||
|- | |||
| "source" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source | |||
|- | |||
| "target" | |||
| [[JSON_STRING]] | |||
| UUID key of target source | |||
|- | |||
| "owner" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source owner | |||
|- | |||
| "rezzer" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source rezzer | |||
|- | |||
|} | |||
{| {{Prettytable}} | |||
|+ JSON structure of a DEATH event | |||
|- {{Hl2}} | |||
! '''Key''' | |||
! '''Value''' | |||
! '''Description''' | |||
|- | |||
| "event" | |||
| "DEATH" | |||
| | |||
|- | |||
| "type" | |||
| [[JSON_NUMBER]] | |||
| [[:Template:LSL_Constants/Damage_Types|DAMAGE_TYPE_*]] or any number defined by the scripter of the damage source | |||
|- | |||
| "source" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source | |||
|- | |||
| "source_pos" | |||
| [[JSON_ARRAY]] | |||
| Array representing the position of the damage source | |||
|- | |||
| "target" | |||
| [[JSON_STRING]] | |||
| UUID key of target source | |||
|- | |||
| "target_pos" | |||
| [[JSON_ARRAY]] | |||
| Array representing the position of the target source | |||
|- | |||
| "owner" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source owner | |||
|- | |||
| "rezzer" | |||
| [[JSON_STRING]] | |||
| UUID key of damage source rezzer | |||
|- | |||
|} | |||
<!-- | |||
(Table of a damage adjustment event) | (Table of a damage adjustment event) | ||
(Table of a death event) | (Table of a death event) | ||
--> | |||
==Example Messages== | ==Example Messages== | ||
Line 68: | Line 151: | ||
<syntaxhighlight lang="lsl2"> | <syntaxhighlight lang="lsl2"> | ||
// Script example with a listener and showing how to filter for death events | // Script example with a listener and showing how to filter for death events | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="lsl2"> | |||
// Script example with a listener and showing how to filter for damage events | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 13:11, 6 August 2024
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This article has been classified as a stub, you can help the Second Life Wiki by expanding this article and adding more information.
The Combat Log has been added as part of the Combat2 update which allows for auditing and useful usecases.
- Combat Log messages are sent region-wide on the channel: COMBAT_CHANNEL
- Records all damage events, damage adjustments and kills
- System generated messages by a specific ID that scripts may filter to: COMBAT_LOG_ID
- Scripts may write to this channel if not restricted by the region, check via: llGetEnv("restrict_combat_log")
System generated messages can be delayed up to 1 second as the sim collects messages to send them in bulk at a time.
Unless you want to intentionally listen to object generated messages it is recommended to set your listener to filter by COMBAT_LOG_ID. This is because your script may end up unnecessarily receiving and processing custom messages that it was not designed to handle and ends up ignoring.
Message Format
The format of the combat log message is a JSON array ([]
) containing JSON objects ([{},{},{}]
). There is always an "event" property present to describe the type of the message object for parsing. The schema of the different objects are as follows:
Key | Value | Description |
---|---|---|
"event" | "DAMAGE" | |
"damage" | JSON_NUMBER | Float of final damage applied |
"initial" | JSON_NUMBER | Float of initial damage before adjustment |
"type" | JSON_NUMBER | DAMAGE_TYPE_* or any number defined by the scripter of the damage source |
"source" | JSON_STRING | UUID key of damage source |
"target" | JSON_STRING | UUID key of target source |
"owner" | JSON_STRING | UUID key of damage source owner |
"rezzer" | JSON_STRING | UUID key of damage source rezzer |
Key | Value | Description |
---|---|---|
"event" | "DEATH" | |
"type" | JSON_NUMBER | DAMAGE_TYPE_* or any number defined by the scripter of the damage source |
"source" | JSON_STRING | UUID key of damage source |
"source_pos" | JSON_ARRAY | Array representing the position of the damage source |
"target" | JSON_STRING | UUID key of target source |
"target_pos" | JSON_ARRAY | Array representing the position of the target source |
"owner" | JSON_STRING | UUID key of damage source owner |
"rezzer" | JSON_STRING | UUID key of damage source rezzer |
Example Messages
Below is an example of a system generated combat log message, featuring a DAMAGE event following by a DEATH event:
[
{
"damage": 15,
"event": "DAMAGE",
"initial": 15,
"owner": "c5a07167-9bbe-4944-a7b0-a9677afa134d",
"rezzer": "c5a07167-9bbe-4944-a7b0-a9677afa134d",
"source": "02f42025-7c1f-9277-435d-f3b60d3250f1",
"target": "89574eed-53b1-4441-a85b-2b75d0facfd9",
"type": 1
},
{
"event": "DEATH",
"owner": "c5a07167-9bbe-4944-a7b0-a9677afa134d",
"rezzer": "c5a07167-9bbe-4944-a7b0-a9677afa134d",
"source": "02f42025-7c1f-9277-435d-f3b60d3250f1",
"source_pos": [
"154.5489501953125",
"146.957275390625",
"29.285243988037109"
],
"target": "89574eed-53b1-4441-a85b-2b75d0facfd9",
"target_pos": [
"156.97242736816406",
"141.52787780761719",
"25.638824462890625"
],
"type": 1
}
]
Parsing Messages
You can use JSON functions to help parse the messages:
// Script example with a listener and showing how to filter for death events
// Script example with a listener and showing how to filter for damage events