• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Monster push player

ZiumZium

Member
Joined
Sep 27, 2024
Messages
106
Solutions
1
Reaction score
11
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:



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
 
Solution
I've been looking for information and apparently on TFS 1.4.2 there's no way to do it in .lua, you just have to make changes in src. Does anyone know how to do it? :D
I've been looking for information and apparently on TFS 1.4.2 there's no way to do it in .lua, you just have to make changes in src. Does anyone know how to do it? :D
 
Solution
Back
Top