2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2016-08-09 19:05:15 -04:00
|
|
|
-- func: mobhere <mobId>
|
2016-01-16 01:26:33 -05:00
|
|
|
-- desc: Spawns a MOB and then moves it to the current position, if in same zone.
|
2023-08-28 21:02:28 -04:00
|
|
|
-- Errors will despawn the MOB unless 'noDepop' was specified (any value works).
|
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 = 'is'
|
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('!mobhere (mobID) (noDepop)')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-06 12:44:08 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, mobId, noDepop)
|
2021-10-18 10:41:48 -05:00
|
|
|
local zone = player:getZone()
|
2024-08-25 12:01:53 -04:00
|
|
|
if not zone then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2023-08-15 12:40:21 -04:00
|
|
|
if zone:getTypeMask() == xi.zoneType.INSTANCED then
|
2021-10-18 10:41:48 -05:00
|
|
|
local instance = player:getInstance()
|
|
|
|
|
local targ
|
|
|
|
|
|
|
|
|
|
-- validate mobId
|
|
|
|
|
if mobId == nil then
|
|
|
|
|
targ = player:getCursorTarget()
|
|
|
|
|
if targ == nil or not targ:isMob() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must either provide a mobID or target a mob.')
|
2021-10-18 10:41:48 -05:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
targ = GetMobByID(mobId, instance)
|
|
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid mobID.')
|
2021-10-18 10:41:48 -05:00
|
|
|
return
|
|
|
|
|
end
|
2017-08-06 12:44:08 -04:00
|
|
|
end
|
2022-11-22 14:39:00 -05:00
|
|
|
|
2021-10-18 10:41:48 -05:00
|
|
|
if not targ:isSpawned() then
|
2021-10-19 21:53:27 -05:00
|
|
|
SpawnMob(mobId, instance)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('Mob state changed to: Spawned.')
|
2021-10-18 10:41:48 -05:00
|
|
|
end
|
2022-11-22 14:39:00 -05:00
|
|
|
|
2021-10-18 10:41:48 -05:00
|
|
|
targ:setPos(player:getXPos(), player:getYPos(), player:getZPos(), player:getRotPos())
|
2017-08-06 12:44:08 -04:00
|
|
|
else
|
2021-10-18 10:41:48 -05:00
|
|
|
-- validate mobId
|
|
|
|
|
local targ
|
|
|
|
|
if mobId == nil then
|
|
|
|
|
targ = player:getCursorTarget()
|
|
|
|
|
if targ == nil or not targ:isMob() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must either provide a mobID or target a mob.')
|
2021-10-18 10:41:48 -05:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
targ = GetMobByID(mobId)
|
|
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid mobID.')
|
2021-10-18 10:41:48 -05:00
|
|
|
return
|
|
|
|
|
end
|
2017-08-06 12:44:08 -04:00
|
|
|
end
|
2022-11-22 14:39:00 -05:00
|
|
|
|
2021-10-18 10:41:48 -05:00
|
|
|
mobId = targ:getID()
|
2020-03-19 18:41:42 -07:00
|
|
|
|
2021-10-18 10:41:48 -05:00
|
|
|
if not targ:isSpawned() then
|
2022-11-06 08:16:08 -05:00
|
|
|
SpawnMob(mobId)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('Mob state changed to: Spawned.')
|
2021-10-18 10:41:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if player:getZoneID() == targ:getZoneID() then
|
2022-11-06 08:16:08 -05:00
|
|
|
targ:setPos(player:getXPos(), player:getYPos(), player:getZPos(), player:getRotPos(), player:getZoneID())
|
2021-10-18 10:41:48 -05:00
|
|
|
else
|
2022-11-04 10:44:34 -04:00
|
|
|
if noDepop == nil or noDepop == 0 then
|
2022-11-06 08:16:08 -05:00
|
|
|
DespawnMob(mobId)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('Despawned the mob because of an error.')
|
2021-10-18 10:41:48 -05:00
|
|
|
end
|
2022-11-22 14:39:00 -05:00
|
|
|
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('Mob could not be moved to current pos - you are probably in the wrong zone.')
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
|
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|