Difference between revisions of "Combat Log"
(Add example damage message log which used llAdjustDamage) |
(→Example Messages: Latest damage/death event examples. Pos seem to be numbers now) |
||
Line 136: | Line 136: | ||
[ | [ | ||
{ | { | ||
"damage": | "damage": 100, | ||
"event": "DAMAGE", | "event": "DAMAGE", | ||
"initial": | "initial": 100, | ||
"owner": " | "owner": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca", | ||
"rezzer": " | "rezzer": "7061ebe8-6919-49fd-8d9e-06983ada3108", | ||
"source": " | "source": "4daf361b-5912-e8f6-455c-ea9cdf0f0422", | ||
"target": " | "target": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca", | ||
"type": | "type": 102 | ||
}, | }, | ||
{ | { | ||
"event": "DEATH", | "event": "DEATH", | ||
"owner": " | "owner": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca", | ||
"rezzer": " | "rezzer": "7061ebe8-6919-49fd-8d9e-06983ada3108", | ||
"source": " | "source": "4daf361b-5912-e8f6-455c-ea9cdf0f0422", | ||
"source_pos": [ | "source_pos": [ | ||
52.5, | |||
210.2584991455078, | |||
1001.904296875 | |||
], | ], | ||
"target": " | "target": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca", | ||
"target_pos": [ | "target_pos": [ | ||
52.88808059692383, | |||
210.6649627685547, | |||
1001.1831665039062 | |||
], | ], | ||
"type": | "type": 102 | ||
} | } | ||
] | ] | ||
Line 191: | Line 191: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Parsing Messages== | ==Parsing Messages== |
Revision as of 00:58, 11 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, e.g. llListen(COMBAT_CHANNEL, "", 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 damage target | |||||||||
"owner" | JSON_STRING | UUID key of damage source owner | |||||||||
"rezzer" | JSON_STRING | UUID key of damage source rezzer | |||||||||
"modifications" | JSON_ARRAY | Array of damage adjustments
|
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 damage target |
"target_pos" | JSON_ARRAY | Array representing the position of the damage target |
"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": 100,
"event": "DAMAGE",
"initial": 100,
"owner": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"rezzer": "7061ebe8-6919-49fd-8d9e-06983ada3108",
"source": "4daf361b-5912-e8f6-455c-ea9cdf0f0422",
"target": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"type": 102
},
{
"event": "DEATH",
"owner": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"rezzer": "7061ebe8-6919-49fd-8d9e-06983ada3108",
"source": "4daf361b-5912-e8f6-455c-ea9cdf0f0422",
"source_pos": [
52.5,
210.2584991455078,
1001.904296875
],
"target": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"target_pos": [
52.88808059692383,
210.6649627685547,
1001.1831665039062
],
"type": 102
}
]
A DAMAGE event which features a damage adjustment:
{
"damage": 15.000000953674316,
"event": "DAMAGE",
"initial": 25,
"modifications": [
{
"events": [
{
"new_damage": 15.000000953674316,
"script": "Damage Adjustment Testing"
}
],
"task_id": "9d980b7e-9c74-a790-001c-bb852f95c16e"
}
],
"owner": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"rezzer": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"source": "daf3a6cb-8a56-afa9-5ebf-2156272dde16",
"target": "75078730-ebc8-4a80-adb9-1cfd2d95b5ca",
"type": 102
}
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