SixNine
Active Member
- Joined
- Dec 12, 2018
- Messages
- 452
- Reaction score
- 41
TFS 1.2
How can i add teleport to x,y,z when players kill creature in this config. Tried doing myself but it was just one big failure
So i would like to add something like this in local config
How can i add teleport to x,y,z when players kill creature in this config. Tried doing myself but it was just one big failure
So i would like to add something like this in local config
Lua:
teleport = {x = 999, y = 999, z = 7},
Lua:
local config = {
['monstername'] = {needValue = 1, setValue = 2,
minimumDamagePercent = 0.06,
reward = {
addExperience = 50,
addItem = {{id = 1560, count = 1}}
},
}
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
local creatureName = creature:getName()
local config = config[creatureName:lower()]
if not config then
return true
end
local convinceCreature = nil
local creaturePosition = creature:getPosition()
if config.convinceCreature then
convinceCreature = Game.createMonster(config.convinceCreature, creaturePosition, true)
end
local summonMonsters = config.summonMonsters
if summonMonsters and next(summonMonsters) then
for k, monsterName in pairs(summonMonsters) do
local summonCreature = Creature(monsterName)
if convinceCreature ~= nil or not isMonster(summonCreature) then
local monster = Creature(Game.createMonster(monsterName, creaturePosition, true))
if monster ~= nil and convinceCreature ~= nil then
doConvinceCreature(convinceCreature, monster)
end
end
end
end
if config.minimumDamagePercent and config.minimumDamagePercent > 0 then
local monsterMaxHealth = creature:getMaxHealth()
local needDamage = monsterMaxHealth * config.minimumDamagePercent
for pid, info in pairs(creature:getDamageMap()) do
local player = Player(pid)
if player then
local currentSaga = player:getStorageValue(Storage.Saga)
if currentSaga == config.needValue and info.total >= needDamage then
if config.setValue then player:setStorageValue(Storage.Saga, config.setValue) end
if config.reward then player:takeReward(config.reward) end
end
local playerPercent = math.min(100, math.max(0, info.total / monsterMaxHealth * 100))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("[PRINT] dealt %.2f percents to %s.", playerPercent, creatureName))
end
end
end
return true
end