Closed GesiIvy128 closed 8 months ago
It's rare to see someone use Lua engine with TrinityCore. Do you use some Eluna fork?
I can say for sure that player:IsInGroup()
won't work with bots, you'll need something like group:IsMember()
. Sorry, I don't use any Lua engine, but if you provide a link to the repository I think I will be able to give you a better advice.
It's rare to see someone use Lua engine with TrinityCore. Do you use some Eluna fork?
I can say for sure that
player:IsInGroup()
won't work with bots, you'll need something likegroup:IsMember()
. Sorry, I don't use any Lua engine, but if you provide a link to the repository I think I will be able to give you a better advice.
Thank you for your reply! In fact, I have already solved this problem. I am using your Azerothcore with the Eluna module (https://www.azerothcore.org/pages/eluna/index.html) for the AC server. My script is as follows:
-- kill Elite and Boss give honor
local PLAYER_EVENT_ON_KILL_CREATURE = 7
local HONOR_FACTOR_1 = 0.064
local HONOR_FACTOR_2 = 10
math.randomseed(os.time())
function OnKill(event,player,creature)
local player_level=player:GetLevel()
local creature_level=creature:GetLevel()
local is_elite=creature:IsElite()
local is_boss=creature:IsWorldBoss()
local base_value=math.ceil(creature_level*0.5)
if player_level>19 then
if is_elite then
if is_boss then
local honor_num_2=math.ceil((math.random(1,base_value)+base_value)*HONOR_FACTOR_2)
player:ModifyHonorPoints(honor_num_2)
else
local honor_num_1=math.ceil((math.random(1,base_value)+base_value)*HONOR_FACTOR_1)
player:ModifyHonorPoints(honor_num_1)
end
end
end
end
RegisterPlayerEvent(PLAYER_EVENT_ON_KILL_CREATURE,OnKill,0)
print(">>Script: KillGetHonor. ...Ready")
The real test result in the game is that both robots and my kills will increase honor.
But I am only playing in the single-player version. If it is a server, I think I should change part of the code like this:
To check if the killer is in a group (using player:IsInGroup()
) and then increase honor for each member.
But I didn't have a chance to test it...
Because I am just a World of Warcraft enthusiast. Due to the servers in China have been closed, so I looked for simulators.
Your MOD is really excellent! Thank you once again.
By the way, this script no longer gives money when killing guards, but gives honor when killing elites.
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Description
I would like to write a Lua script that gives me money when a robot in the team kills a guard. Should I consider the robots as players or NPCs in this case? Or, can I use
player:IsInGroup()
in Lua for the robots? Thanks.TrinityCore or AzerothCore
TrinityCore
Core rev. hash/commit
No response
Operating system
No response