• 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...
onspawn function and item attributes
what you mean ? on Spawn I already have on my sources.. I need setSpawn(position) to create monsters with lua scripts and then set their spawn to them born again.. understand ?
about the item attributes, I don't know how set the skills values, so I need that someone help me with that
 
you don't need any c++ edits for this.
But if you want to do all that in Lua then this will take quite some time, not sure how long it took me to do it, because have had this feature over a year.

Create a script in globalevents to spawn monsters.
make new monsterAI in creaturescripts onThink where they cast spells.

if you got those, all you need is 2 functions with which you register monster spawns and which add spells to monsters.
If you want each spawn have their own spells, well then you need to do some exceptional spawn script which loads spells on monster after its spawned.

However know that if you register spawns and spells while in game they wont last if you restart server. But you can always register spells and spawn positions trough database and then server restarts wont be problem either.
 
... friends, lets start again...
spawn function ...
usage:
step 1 - create monsters with lua scripts
Code:
for x = 1000, 2000 do
    for y = 1000, 2000 do
         local monster = Game.createMonster('monster', Position(x, y, 7))
         if monster then
              monster:setSpawnPosition(Position(x, y, 7))  -- this will make the monsters spawn again in this position when it die
         end
    end
end
step 2 - monster:setSpawnPosition(Position(x, y, 7)) -- this will make the monsters spawn again in this position when it die (please get the point)
step 3 - monsters will respawn as the ANOTHERS monsters at spawn.xml
now my request is more understandable?
I want make it to handle with the world changes that have different monsters in differents days

@whitevo who are talking about spells ? LOL
 
Last edited by a moderator:
ah my bad. though the skills you you said were in other words monster spells/attacks.

but well then its just less complicated.
Like I said make interval event in globaevents and let it spawn registered monsters from there periodically.
monster:setSpawnPos() will be a simple method to register the monster to global spawning table which the globalevent checks every now and then.
if you want to make it different monsters different days simply add some more variables inside the spawning table and let thee script decide shall it spawn or ignore it
 
ah my bad. though the skills you you said were in other words monster spells/attacks.

but well then its just less complicated.
Like I said make interval event in globaevents and let it spawn registered monsters from there periodically.
monster:setSpawnPos() will be a simple method to register the monster to global spawning table which the globalevent checks every now and then.
if you want to make it different monsters different days simply add some more variables inside the spawning table and let thee script decide shall it spawn or ignore it
yes, it could be done in this way, but my point, I want it on c++ also to be possible with handle with Game.loadMap(), also this globalevent could make my server heavy, I mean, waste RAM... so, if is possible do in c++ then someone should do it in c++
thank you very much

i'm wondering if my request seems more easy to understand after alots of comments, my bad english always fuc* almost of my threads
 
Last edited by a moderator:
yes, it could be done in this way, but my point, I want it on c++ also to be possible with handle with Game.loadMap(), also this globalevent could make my server heavy, I mean, waste RAM... so, if is possible do in c++ then someone should do it in c++
thank you very much
you rly need tens of thousands of custom spawns to even see difference..
why you need it to be in c++?
 
I did the setSpawnPosition function some time ago, but if I remember correctly, It doesn't respawn the monster later... :eek:
 
Not exactly sure what you want, but is it somewhat in the terms of creating a new spawn area that allows you to assign monsters to that spawn area?

btw, you should probably slit your requests as I didn't even notice what you meant with the item attribute thing to begin with. It would be easier to handle both of your requests (imo) by making another support thread where you specifically ask for that and separate the setspawnposition thing you want
 
Last edited:
you rly need tens of thousands of custom spawns to even see difference..
why you need it to be in c++?
to me is more easy to implement instead make 1928319381293 lines putting monsters to spawn but if you can show me the "lua way" I can change my mind about the place where code the function
Not exactly sure what you want, but is it somewhat in the terms of creating a new spawn area that allows you to assign monsters to that spawn area?

btw, you should probably slit your requests as I didn't even notice what you meant with the item attribute thing to begin with. It would be easier to handle both of your requests (imo) by making another support thread where you specifically ask for that and separate the setspawnposition thing you want
well, you understand the point about the setSpawnPosition(Position) :)
about the item attributes...
I just need a function that set attributes as skills in my items...
I'll give more one exemple:
using the command in the item in front of me (the item will be on the ground)
/attr skillaxe, 1
then the item should give me 1 skill of axe fighting, OFC I know about the movement tag to it give correctly the skill
so, the look of the item could be like this
Code:
00:32 You see a mastermind shield (Def:37, axe fighting +1).
It weighs 57.00 oz.
It's an enchanted shield.
you need creature:setSpawn(position,interval) function?
not really necessary the interval, all of the monsters will spawn in the regular time
 
I'm not sure
Code:
[LIST=1]
[*]["actionid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["action"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["aid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["description"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
[*]    ["desc"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
[*]    ["remove"] = { isActive = true, targetFunction = function (item, target) return item:remove() end },
[*]    ["decay"] = { isActive = true, targetFunction = function (item, target) return item:decay() end },
[*]    ["transform"] = { isActive = true, targetFunction = function (item, target) return item:transform(target) end },
[*]    ["clone"] = { isActive = true, targetFunction = function (item, target) return item:clone() end }
[/LIST]
also, in this doens't exist a function that set skill attributes to items
 
I'm not sure
Code:
[LIST=1]
[*]["actionid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["action"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["aid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
[*]    ["description"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
[*]    ["desc"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
[*]    ["remove"] = { isActive = true, targetFunction = function (item, target) return item:remove() end },
[*]    ["decay"] = { isActive = true, targetFunction = function (item, target) return item:decay() end },
[*]    ["transform"] = { isActive = true, targetFunction = function (item, target) return item:transform(target) end },
[*]    ["clone"] = { isActive = true, targetFunction = function (item, target) return item:clone() end }
[/LIST]
also, in this doens't exist a function that set skill attributes to items
it's pretty simple
all you do is make a new index and use item:setAttribute in the target function
lol

also the function you're asking for, i don't think you know exactly how it should be done
monster:setSpawnPosition won't do anything, a function like this would be expected to copy the monster's attributes and recreate it once it's dead, which is weird to do since you'll have to use onKill/onDeath for the monster and respawn it when it dies
a function that you should be asking for is something like Game.createMonsterSpawn(name, position)
you could do this in a globalevent like whitevo said and spawn monsters that way, the function would add a spawn position in some table so that next time the globalevent executes so that itll start spawning on a regular interval
 
it's pretty simple
all you do is make a new index and use item:setAttribute in the target function
lol

also the function you're asking for, i don't think you know exactly how it should be done
monster:setSpawnPosition won't do anything, a function like this would be expected to copy the monster's attributes and recreate it once it's dead, which is weird to do since you'll have to use onKill/onDeath for the monster and respawn it when it dies
a function that you should be asking for is something like Game.createMonsterSpawn(name, position)
you could do this in a globalevent like whitevo said and spawn monsters that way, the function would add a spawn position in some table so that next time the globalevent executes so that itll start spawning on a regular interval
could you give some exemple code? I tried alots and get nothing...
about the function of spawn...
Man, if I deal with this using globalvent it might kind of bug the time, for example, it runs or scaled every 2 minutes and players kill the monsters 1 second before the execution of the globalvent is as if a monster spawn again much fast... so I would like c ++ because with this I did not have to worry about running at intervals, it will happen automatically, and I also do not have to configure onKill or onDeath scripts, I'll do it myself in C ++ after I I'm going back here to report, but I'm pretty sure that i'll need help, I've never done anything like this before, and since I'm not an expert in c ++ it's going to be hard
 
Last edited:
Back
Top