2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2017-08-08 17:23:52 -04:00
|
|
|
-- func: setmobflags <flags> <optional MobID>
|
2016-08-09 19:05:15 -04:00
|
|
|
-- desc: Used to manipulate a mob's nameflags for testing.
|
2016-01-16 01:26:33 -05:00
|
|
|
-- MUST either target a mob first or else specify a Mob ID.
|
2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2016-01-16 01:26:33 -05:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'si'
|
2020-02-19 21:40:57 -08:00
|
|
|
}
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
local function error(player, msg)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(msg)
|
|
|
|
|
player:printToPlayer('!setmobflags <flags> (mob ID)')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-08 17:23:52 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, flags, target)
|
2017-08-08 17:23:52 -04:00
|
|
|
-- validate flags
|
2021-05-02 14:33:02 -04:00
|
|
|
if flags ~= nil and tonumber(flags) ~= nil then
|
|
|
|
|
flags = tonumber(flags)
|
|
|
|
|
else
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must supply a flags value.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
|
2017-08-08 17:23:52 -04:00
|
|
|
-- validate target
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
2021-05-02 14:33:02 -04:00
|
|
|
if target == nil then
|
2020-02-19 21:40:57 -08:00
|
|
|
targ = player:getCursorTarget()
|
2022-11-04 10:44:34 -04:00
|
|
|
if targ == nil or not targ:isMob() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must either supply a mob ID or target a mob.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-08 17:23:52 -04:00
|
|
|
end
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2020-02-19 21:40:57 -08:00
|
|
|
targ = GetMobByID(target)
|
2021-05-02 14:33:02 -04:00
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid mob ID.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-08 17:23:52 -04:00
|
|
|
end
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2017-08-08 17:23:52 -04:00
|
|
|
|
|
|
|
|
-- set flags
|
2024-08-25 12:01:53 -04:00
|
|
|
---@diagnostic disable-next-line param-type-mismatch
|
2020-02-19 21:40:57 -08:00
|
|
|
player:setMobFlags(flags, targ:getID())
|
2023-08-28 21:02:28 -04:00
|
|
|
local hex = '0x' .. string.format('%08x', flags)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Set %s %i flags to %s (%i).', targ:getName(), targ:getID(), hex, flags))
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|