Bosskills

  • community
  • events
  • by Mad
  • Takaro v0.0.21
  • all
View export JSON

Provides automated rewards and announcements upon the killing of specific boss entities in the game.

Key Functionality

  • Boss Kill Detection: The module monitors game server logs for events indicating the death of designated boss entities.
  • Player Identification: It extracts the name of the player who killed the boss.
  • Currency Rewards: Configurable amounts of in-game currency are automatically awarded to the player who killed the boss.
  • Chat Announcements: Customizable messages are broadcast to the server chat, congratulating the player on the kill and announcing the reward.
  • Boss-Specific Configuration: Rewards and announcements can be configured independently for different boss types.

How to Use

  1. Configuration:
    • coinAmountDevourer, coinAmountMiniBoss, coinAmountBoss, coinAmountTinyBoss: Define the amount of currency to award for killing different categories of bosses.
    • 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.
  2. Module Operation:
    • The module automatically monitors the server logs for boss kill events. No manual commands are required.

Important Considerations

  • 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.
  • Boss Names: Correctly configure the module with the exact entity names used by the game server logs.
  • Currency System: This module assumes that your server has a functional currency system that can be accessed and modified via API calls.
  • Performance: Log processing can potentially impact server performance, especially with high activity. Monitor server resources and adjust module settings if necessary.

Configuration 2

Settings you fill in when installing the module on a server.

SettingTypeDefaultDescription
coinAmountDevourer required coinAmountDevourer number 0 Amoint of Coin to award
announceDevourer announceDevourer string Post in chat Boss Kill
Raw config schema
{
  "$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"
    }
  }
}
Raw UI schema
{}

Hooks 1

Code that runs in reaction to a game or Takaro event.

  • Devourer

    Hook for log events

    Hook source
    // Hook function for detecting boss kills and sending congratulatory PM
    import { data, takaro } from '@takaro/helpers';
    
    async function main() {
        const { gameServerId, eventData } = data;
    
        // Check if eventData exists and contains the message
        if (!eventData || !eventData.msg) {
            console.log("Error: Expected log message not found in data structure");
            return;
        }
    
        // Get the log message from the correct path in the data object
        const logLine = eventData.msg;
        console.log("Processing log line:", logLine);
    
        // Check if this is a bossDevourer kill line
        if (!logLine.includes("killed animal bossDevourer")) {
            console.log("Not a bossDevourer kill");
            return;
        }
    
        // Extract player name using regex 
        // Format: [CSMM_Patrons]entityKilled: Mad (Steam_76561198041959712) killed animal bossDevourer with Dev: Instant Death Pistol
        const playerMatch = logLine.match(/entityKilled: (\w+) \(Steam_/);
    
        if (!playerMatch || !playerMatch[1]) {
            console.log("Could not extract player name from kill log");
            return;
        }
    
        const playerName = playerMatch[1];
        console.log("Extracted player name:", playerName);
    
        try {
            // Search for players with this name
            const playerSearch = await takaro.player.playerControllerSearch({
                filters: {
                    name: [playerName]
                }
            });
    
            console.log(`Found ${playerSearch.data.data.length} players matching name ${playerName}`);
    
            if (playerSearch.data.data.length === 0) {
                console.log("No player found with name:", playerName);
                return;
            }
    
            const playerId = playerSearch.data.data[0].id;
    
            // Get the player on game server record
            const pogSearch = await takaro.playerOnGameserver.playerOnGameServerControllerSearch({
                filters: {
                    playerId: [playerId],
                    gameServerId: [gameServerId]
                }
            });
    
            if (pogSearch.data.data.length === 0) {
                console.log("Player not found on this game server");
                return;
            }
    
            // This is what you need - get the player object from data
            // Send PM directly without any parameters
            const pog = pogSearch.data.data[0];
            console.log(`${pog.playerId} pog object found`)
    
            // Send a message to everyone
            await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
                message: `"${playerId}" Good kill on that animal bossDevourer!`
            });
    
            // Get a proper player object that has the pm method
            const pname = await takaro.player.playerControllerGetOne(playerId);
    
            // Send PM to the specific player
            await pname.data.data.pm(`TEST!!! ${pname.data.data.name}`);
    
            console.log("Successfully sent PM to player:", playerName);
    
        } catch (error) {
            console.log("Error:", error.message);
        }
    }
    
    await main();