Hello, TFS 1.4.2.
I tried to make one function but it doesn't work for me. Namely, if the boss wants to run to a certain target that it detects, and the player is in his way (and can be pushed) then the boss should push him into a free space.
Can something like that be done?
I tried like this:
I tried to make one function but it doesn't work for me. Namely, if the boss wants to run to a certain target that it detects, and the player is in his way (and can be pushed) then the boss should push him into a free space.
Can something like that be done?
I tried like this:
LUA:
l
pushPlayerAwayFromCorpse(creature, corpsePos)
if creature:getPosition():getDistance(corpsePos) <= 1 then
local tile = Tile(corpsePos)
if tile then
for _, item in ipairs(tile:getItems() or {}) do
if table.contains(config.corpseIds, item:getId()) then
item:remove()
creature:addHealth(config.healAmount)
creature:getPosition():sendMagicEffect(config.effect)
local currentBoost = bossBoosts[creatureId] or 0
currentBoost = currentBoost + config.baseDamageBoost
bossBoosts[creatureId] = currentBoost
local percent = math.floor(currentBoost * 100)
creature:say("Power increased! Total: +" .. percent .. "%", TALKTYPE_MONSTER_SAY)
break
end
end
end
creature:setDropLoot(true)
creature:setSkillLoss(true)
local originalTarget = Creature(originalTargetId)
if originalTarget and originalTarget:isPlayer() then
creature:setTarget(originalTarget)
creature:setFollowCreature(originalTarget)
end
bossStates[creatureId] = nil
return
end
local path = creature:getPathTo(corpsePos, 0, 1, true, true)
if path and #path > 0 then
creature:move(path[1])
addEvent(function()
moveToCorpse(creatureId, corpsePos, originalTargetId)
end, config.moveInterval)
else
bossStates[creatureId] = nil
end
end