{
  "name": "Bosskills",
  "author": "Mad",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "v0.0.21",
  "versions": [
    {
      "tag": "1.0.1",
      "description": "Provides automated rewards and announcements upon the killing of specific boss entities in the game.\n\n  ## Key Functionality\n\n  * **Boss Kill Detection:** The module monitors game server logs for events indicating the death of designated boss entities.\n  * **Player Identification:** It extracts the name of the player who killed the boss.\n  * **Currency Rewards:** Configurable amounts of in-game currency are automatically awarded to the player who killed the boss.\n  * **Chat Announcements:** Customizable messages are broadcast to the server chat, congratulating the player on the kill and announcing the reward.\n  * **Boss-Specific Configuration:** Rewards and announcements can be configured independently for different boss types.\n\n  ## How to Use\n\n  1.  **Configuration:**\n      * `coinAmountDevourer`, `coinAmountMiniBoss`, `coinAmountBoss`, `coinAmountTinyBoss`:  Define the amount of currency to award for killing different categories of bosses.\n      * `announceDevourer`, `announceGargul`, `announceBear`, `announceBitch`, `announceBurningFlesh`, `announceCholera`, `announceBull`, `announceShocker`, `announceVeteran`, `announceCarrier`, `announceOstiarius`:  Customize the messages that are broadcast to the chat when a specific boss is killed. Use `{pname}` as a placeholder for the player's name and `{amount}` for the currency amount.\n  2.  **Module Operation:**\n      * The module automatically monitors the server logs for boss kill events. No manual commands are required.\n\n  ## Important Considerations\n\n  * **Log Format:** This module relies on a specific format for the game server's log messages. Ensure that the log output contains the necessary information (e.g., player name, killed entity type) in a parsable format.\n  * **Boss Names:** Correctly configure the module with the exact entity names used by the game server logs.\n  * **Currency System:** This module assumes that your server has a functional currency system that can be accessed and modified via API calls.\n  * **Performance:** Log processing can potentially impact server performance, especially with high activity. Monitor server resources and adjust module settings if necessary.\n",
      "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[\"coinAmountDevourer\"],\"additionalProperties\":false,\"properties\":{\"coinAmountDevourer\":{\"title\":\"coinAmountDevourer\",\"description\":\"Amoint of Coin to award\",\"default\":0,\"type\":\"number\"},\"announceDevourer\":{\"title\":\"announceDevourer\",\"description\":\"Post in chat Boss Kill\",\"type\":\"string\"}}}",
      "uiSchema": "{}",
      "commands": [],
      "hooks": [
        {
          "name": "Devourer",
          "eventType": "log",
          "description": "Hook for log events",
          "regex": null,
          "function": "// Hook function for detecting boss kills and sending congratulatory PM\nimport { data, takaro } from '@takaro/helpers';\n\nasync function main() {\n    const { gameServerId, eventData } = data;\n\n    // Check if eventData exists and contains the message\n    if (!eventData || !eventData.msg) {\n        console.log(\"Error: Expected log message not found in data structure\");\n        return;\n    }\n\n    // Get the log message from the correct path in the data object\n    const logLine = eventData.msg;\n    console.log(\"Processing log line:\", logLine);\n\n    // Check if this is a bossDevourer kill line\n    if (!logLine.includes(\"killed animal bossDevourer\")) {\n        console.log(\"Not a bossDevourer kill\");\n        return;\n    }\n\n    // Extract player name using regex \n    // Format: [CSMM_Patrons]entityKilled: Mad (Steam_76561198041959712) killed animal bossDevourer with Dev: Instant Death Pistol\n    const playerMatch = logLine.match(/entityKilled: (\\w+) \\(Steam_/);\n\n    if (!playerMatch || !playerMatch[1]) {\n        console.log(\"Could not extract player name from kill log\");\n        return;\n    }\n\n    const playerName = playerMatch[1];\n    console.log(\"Extracted player name:\", playerName);\n\n    try {\n        // Search for players with this name\n        const playerSearch = await takaro.player.playerControllerSearch({\n            filters: {\n                name: [playerName]\n            }\n        });\n\n        console.log(`Found ${playerSearch.data.data.length} players matching name ${playerName}`);\n\n        if (playerSearch.data.data.length === 0) {\n            console.log(\"No player found with name:\", playerName);\n            return;\n        }\n\n        const playerId = playerSearch.data.data[0].id;\n\n        // Get the player on game server record\n        const pogSearch = await takaro.playerOnGameserver.playerOnGameServerControllerSearch({\n            filters: {\n                playerId: [playerId],\n                gameServerId: [gameServerId]\n            }\n        });\n\n        if (pogSearch.data.data.length === 0) {\n            console.log(\"Player not found on this game server\");\n            return;\n        }\n\n        // This is what you need - get the player object from data\n        // Send PM directly without any parameters\n        const pog = pogSearch.data.data[0];\n        console.log(`${pog.playerId} pog object found`)\n\n        // Send a message to everyone\n        await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {\n            message: `\"${playerId}\" Good kill on that animal bossDevourer!`\n        });\n\n        // Get a proper player object that has the pm method\n        const pname = await takaro.player.playerControllerGetOne(playerId);\n\n        // Send PM to the specific player\n        await pname.data.data.pm(`TEST!!! ${pname.data.data.name}`);\n\n        console.log(\"Successfully sent PM to player:\", playerName);\n\n    } catch (error) {\n        console.log(\"Error:\", error.message);\n    }\n}\n\nawait main();"
        }
      ],
      "cronJobs": [],
      "functions": [],
      "permissions": []
    }
  ]
}