logicHandler.CreateObjectsAtPlayer and logicHandler.CreateObjectAtLocation both take objectData table instead of plain refId. objectData can be built using added method BuildObjectData in dataTableBuilder.lua This way any amount of say gold can be spawned easily. For backwards compatibility it's possible to replace argument refId in either logicHandler.CreateObjectAtPlayer or logicHandler.CreateObjectAtLocation with dataTableBuilder.BuildObjectData(refId)
36 lines
900 B
Lua
36 lines
900 B
Lua
dataTableBuilder = {}
|
|
|
|
dataTableBuilder.BuildAIData = function(targetPid, targetUniqueIndex, action,
|
|
posX, posY, posZ, distance, duration, shouldRepeat)
|
|
|
|
local ai = {}
|
|
ai.action = action
|
|
ai.posX, ai.posY, ai.posZ = posX, posY, posZ
|
|
ai.distance = distance
|
|
ai.duration = duration
|
|
ai.shouldRepeat = shouldRepeat
|
|
|
|
if targetPid ~= nil then
|
|
ai.targetPlayer = Players[targetPid].accountName
|
|
else
|
|
ai.targetUniqueIndex = targetUniqueIndex
|
|
end
|
|
|
|
return ai
|
|
end
|
|
|
|
-- Use with logicHandler.CreateObject* functions
|
|
dataTableBuilder.BuildObjectData = function(refId, count, charge, enchantmentCharge, soul)
|
|
|
|
local objectData = {}
|
|
objectData.refId = refId
|
|
objectData.count = count or 1
|
|
objectData.charge = charge or -1
|
|
objectData.enchantmentCharge = enchantmentCharge or -1
|
|
objectData.soul = soul or ""
|
|
|
|
return objectData
|
|
end
|
|
|
|
return dataTableBuilder
|