• 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++ /atrr skills

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
hello folks, as the title says I'm requesting a function in c++ that set the spawn positions, I need it to handle with some world changes ...
to be possible to create monsters by scripts and set their spawn positions to them spawn normal as the others monsters...
also I need a function that set skills in items...
exemple:
/attr skillname, value
I have some code for exemple..
Lua:
function onSay(player, words, param)

    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local t = param:split(" ", 1)
    local attr = t[1]
    local value = (t[2])

    local position = player:getPosition()
    position:getNextPosition(player:getDirection())

    local tile = position:getTile()
    if not tile then
        player:sendCancelMessage("Object not found.")
        return false
    end

    local thing = tile:getTopVisibleThing(player)
    if not thing then
        player:sendCancelMessage("Thing not found.")
        return false
    end

    if thing:isItem() then
        if attr == "skillfist" then
            thing:setAttribute('skillfist', value)
        else
            player:sendCancelMessage("Bad Attribute.")
            return true
        end
    end

    position:sendMagicEffect(CONST_ME_MAGIC_RED)
    return false
end
 
Last edited by a moderator:
Solution
Okay I didn't run the check spawn procedure

Code:
int LuaScriptInterface::luaMonsterSetSpawnPosition(lua_State* L)
{
    // monster:setSpawnPosition()
    Monster* monster = getUserdata<Monster>(L, 1);
    if (!monster) {
        lua_pushnil(L);
        return 1;
    }

    const Position& pos = monster->getPosition();
    monster->setMasterPos(pos);

    g_game.map.spawns.getSpawnList().emplace_front(pos, 5);
    Spawn& spawn = g_game.map.spawns.getSpawnList().front();
    spawn.addMonster(monster->mType->name, pos, DIRECTION_NORTH, 60000);
    spawn.startSpawnCheck();

    pushBoolean(L, true);
    return 1;
}

Code:
    local monster = Game.createMonster('Dwarf', Position(95, 127, 7))
    monster:setSpawnPosition(Position(95, 130...
Back
Top