• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua [1.X] Boss checker

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,112
Solutions
26
Reaction score
596
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I have the following configuration for my bosses, they raid on startUp and if they die, a creaturescript sends an addEvent with time, that defines in how much time the boss will spawn again.

here's the globalevent that spawns the monster onStartUp
Lua:
local config = {
    ['Thursday'] = {
        position = Position(1418, 1016, 4),
        monsterName = "Ferumbras",
    }
}
function onStartup()
    local spawn = config[os.date('%A')]
    if spawn then
        local monster = Game.createMonster(spawn.monsterName, spawn.position, false, true)
        if monster then
            monster:setMasterPosition(spawn.position)
            addEvent(Game.broadcastMessage, 10000, "The seals on old cidatel are glowing. Ferumbras has returned once more, stop him before its too late.", MESSAGE_EVENT_ADVANCE)
        end
    end
    return true
end

and the creatureescript, if creature dies
Lua:
local function onRespawn(name, position)
    local monster = Game.createMonster(name, position, false, true)
    if monster then
        position:sendMagicEffect(CONST_ME_TELEPORT)
    end
end

function onDeath(monster, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    addEvent(onRespawn, 360 * 60 * 1000, monster:getName(), monster:getPosition())
    addEvent(Game.broadcastMessage, 1000, "Ferumbras has been defeated, the mage master will reveal himself in the Citadel in 6 hours.", MESSAGE_EVENT_ADVANCE)
    return true
end

The thing I need now, is a boss checker. This can be a talkaction, where you say !bosscheck and it should throw a list of avaible bosses on the map. Not sure which way is the best to achieve this:

a) Verify on the whole map if there's a creature with name "Ferumbras". Also do it for multiple monsters (Ghazbaran, Orshabaal, etc.).
b) Set a globalstorage on the globalevent and creaturescript, add it when the boss spawns, and remove it when the boss dies. Then call the storage via talkaction.


Both methods are actually suggestions, if u know any other better method please do it, I only need to achieve the boss checking. My actual boss list is Ghazbaran (Fridays and Saturdays), Orshabaal (Sundays and Mondays), and Ferumbras (Thursdays). If it also have the possibility of sending how much time is left to spawn, if the boss is killed, would be really amazing.
.
In advance, thanks a lot!
Regards :)
 
Solution
Worked on this over discord with him.

He said he'll post the solution here or somewhere else.

If somewhere else, I'll link to it in this comment.

--

Solution here

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,758
Solutions
24
Reaction score
475
Location
Sweden
To avoid scanning the tiles for monsters it would probably be best to go with b) and assign a unique global storage value to each monster
 
OP
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,112
Solutions
26
Reaction score
596
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
To avoid scanning the tiles for monsters it would probably be best to go with b) and assign a unique global storage value to each monster
Thanks for the reply! To set the global storage I should use something like this?

Or there's functions that TFS 1.5 already has for this? Also how do I merge the monster:setStorageValue in addEvent?
This references that the event will getName and getPosition after the time is ended right?
Lua:
addEvent(onRespawn, 360 * 60 * 1000, monster:getName(), monster:getPosition())

The thing is, how I can use the addEvent so the event will be during the time and not at the end...
Maybe i'm complaining it too much, i'm really bad coding

Regards!
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,175
Solutions
527
Reaction score
4,368
If this information doesn't need to be retained, just use a global table to record information about the monsters you want to track.

When you successfully create a creature, insert it's creatureId into the table.
Something like this.
Lua:
raidBossInformation = {
    --{creatureId = 0, creatureName = "Ferumbras", creatureSpawnPosition = Position(1418, 1016, 4)}
}

When the creature dies, just find it's creatureId in the table, reset it to 0 (so you know it's dead), and start your addEvent to respawn them.
(or use some other method of tracking time.)

The beauty of tables is that you can just throw endless information into them, to use with your talkaction.
When it was killed, when it'll respawn again, it's respawn timer, if the creature is currently alive, who it was last killed by.. et cetera

It's basically the exact same thing as your current config table, but making it global, and remembering that some/most of the variables aren't static.
 
OP
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,112
Solutions
26
Reaction score
596
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
If this information doesn't need to be retained, just use a global table to record information about the monsters you want to track.

When you successfully create a creature, insert it's creatureId into the table.
Something like this.
Lua:
raidBossInformation = {
    --{creatureId = 0, creatureName = "Ferumbras", creatureSpawnPosition = Position(1418, 1016, 4)}
}

When the creature dies, just find it's creatureId in the table, reset it to 0 (so you know it's dead), and start your addEvent to respawn them.
(or use some other method of tracking time.)

The beauty of tables is that you can just throw endless information into them, to use with your talkaction.
When it was killed, when it'll respawn again, it's respawn timer, if the creature is currently alive, who it was last killed by.. et cetera

It's basically the exact same thing as your current config table, but making it global, and remembering that some/most of the variables aren't static.

Hey thanks as always bro! My guess is that the creatureID should be placed on function onDeath, how do I exactly trigger that? Not sure what to do, I think the way that I could add that table is to merge the creaturescript and the globalevent in a revscriptsys, so it can be called from the same file in a local variable. But honestly, you know i'm not good doing this stuff. How could be an script outcome to achieve the system and make it work?

Regards!
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,175
Solutions
527
Reaction score
4,368
Worked on this over discord with him.

He said he'll post the solution here or somewhere else.

If somewhere else, I'll link to it in this comment.

--

Solution here

 
Last edited:
Solution
Top