Dynamically Getting Creature ID in Eluna menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Bazzlaze's Avatar Member
    Reputation
    1
    Join Date
    Jun 2024
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamically Getting Creature ID in Eluna

    Hello everyone!
    I plan to implement a feature where a character gains experience when they deal damage to a creature (similar to Cabal Online), but I've encountered a problem where Eluna lacks the ability to get the creature's ID. Specifically, the RegisterCreatureEvent (9 = CREATURE_EVENT_ON_DAMAGE_TAKEN) requires specifying a specific NPC ID in advance. My question is: is it possible to get this information dynamically?
    I tried writing the following code.

    Code:
    local attackedNPCs = 0
    
    local function getXP(event, creature, player, damage)
        local experienceReward = math.random(damage / 2, damage)
        player:SendBroadcastMessage(damage)
        player:GiveXP(damage)
    end
    
    local function OnCreatureTakeDamage(event, player, enemy, damage)
        attackedNPCs = enemy:GetEntry()
        player:SendBroadcastMessage("You have attacked " .. enemy:GetName() .. ".")
        player:SendBroadcastMessage(attackedNPCs)
    end
    
    RegisterCreatureEvent(attackedNPCs, 9, getXP)
    RegisterPlayerEvent(33, OnCreatureTakeDamage)
    CLIENT: 3.3.5
    CORE: TRINITY 355 Repack

    Dynamically Getting Creature ID in Eluna
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1614
    Join Date
    Sep 2007
    Posts
    4,558
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Not the best use case for Lua, but something like this might work:

    Code:
    
    local function OnCreatureTakeDamage(event, creature, player, damage)
        local experienceReward = math.random(damage / 2, damage)
        player:GiveXP(experienceReward)
    end
    
    local function OnPlayerEnterCombat(event, player, enemy, damage)
        if not enemy or not player then
            return
        end
        if not enemy:GetData("event") then
            local id = RegisterUniqueCreatureEvent(enemy:GetGUID(), enemy:GetInstanceId(), 9, OnCreatureTakeDamage) 
            enemy:SetData("event", id)
        end
    end
    
    RegisterPlayerEvent(33, OnPlayerEnterCombat)

Similar Threads

  1. always get STV chest in the arena! only rogues,sorry!
    By thisistheend861 in forum World of Warcraft Guides
    Replies: 6
    Last Post: 01-29-2007, 08:34 PM
  2. How do you get money/rep in this site
    By crankd in forum World of Warcraft General
    Replies: 2
    Last Post: 01-22-2007, 05:36 PM
  3. Getting 15k armor in bear form
    By Cush in forum World of Warcraft Guides
    Replies: 6
    Last Post: 01-03-2007, 01:10 PM
  4. How to not get deserter debuff in a BG!
    By wicked_joe in forum World of Warcraft Exploits
    Replies: 12
    Last Post: 11-01-2006, 03:09 PM
  5. Tauren Druids: Get people killed in WPL - and 10% durablility loss!
    By Liania in forum World of Warcraft Exploits
    Replies: 16
    Last Post: 10-27-2006, 07:11 PM
All times are GMT -5. The time now is 04:24 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search