• 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!

C++ [LUA] Need help, info, orientation, runOnHealth flag

lokolokio

Well-Known Member
Joined
Jan 7, 2009
Messages
201
Solutions
13
Reaction score
78
Location
Mexico
Hello OTLanders, the info I need to know is if there are function like this one?
Lua:
monsterType:setRunHealth()
or wath I need to do to make a monster run anytime I want, not like this function:
Lua:
monsterType:getRunHealth()
that function make monster run when his hp goes below certain health points, but I want to make monster run if he is surounded by many players, not just with hp below, ex:

Lua:
--Obviously is not a working function but is the example idea.

function onThink(cid)
    local m = Monster(cid)
    local attackers = Game.getSpectators(pos, -5, 5, -6, 6, true)
    local monster = MonsterType(m)
    local hp = m:getHealth()
    if attacker >= 6 then
        monster:setRunHealth(hp) -- Not importing the hp, I want to make a monster run if a 6 or more players surround him.
    end
end
 
Hello OTLanders, the info I need to know is if there are function like this one?
Lua:
monsterType:setRunHealth()
or wath I need to do to make a monster run anytime I want, not like this function:
Lua:
monsterType:getRunHealth()
that function make monster run when his hp goes below certain health points, but I want to make monster run if he is surounded by many players, not just with hp below, ex:

Lua:
--Obviously is not a working function but is the example idea.

function onThink(cid)
    local m = Monster(cid)
    local attackers = Game.getSpectators(pos, -5, 5, -6, 6, true)
    local monster = MonsterType(m)
    local hp = m:getHealth()
    if attacker >= 6 then
        monster:setRunHealth(hp) -- Not importing the hp, I want to make a monster run if a 6 or more players surround him.
    end
end
Lua:
creature:teleportTo(position[, pushMovement = false])
forgottenserver/luascript.cpp at c2434778432c8a0609529b89a81d2dcabf0bc8e5 · otland/forgottenserver · GitHub
 
the thing that I want is the function that make a monster run like a chicken when hp goes below X, not just teleport him, I want to make a monster run like a chicken if was surounded by X amount of players, or if only one player but this one are lvl 1500 and monster cant fight against the player, I want to create a behavior on my monster that checks if he is on disvantage against player(s), and if true, then run. IDK if I am clear. :/
 
There's a function on player.h (sources) that verifies if the nonster should run:

C++:
bool isFleeing() const {
            return !isSummon() && getHealth() <= mType->info.runAwayHealth;
}

If I were you, I'd create a boolean flag like "forceFlee" on player.h, a setter, modify the content of isFleeing to always return true if forceFlee is true, and make a function on luascript.cpp / luascript.h to make a lua function to change this flag.

I'm writing this on my phone, and I don't have easily access to a computer (I work / study, I don't stay in my house :/), but shouldn't be something difficult


Edit: you can also make a function like you said "setrunhealth" if you prefer
 
Last edited:
Back
Top