-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move raid system to globalevents #1813
Conversation
Great job, but is it even necessary to have a seprate event for raid? We could just use onThink or onTime. If they wish and just create a raid library in lua. It should be possible? |
|
testraid.lua should use Position() constructor instead of the table constructor with x,y,z-fields. |
True that, I will fix it to use the Position constructor later. I will also patch the addSpawn function to allow another parameter, but I see it as removing clutter from the raid (explicit) to move to a lib function (implicit). |
actually this entire thing should be handled completly in lua by coroutines and a simple addEvent timer at startup, could get rid of all c code then and we wouldn't hit server performence. |
@EvilHero90 I agree with handling completely on Lua, but I couldn't figure how to use coroutines. Could you give me sample code for how you see raids? |
I can do that on monday, I'm busy with work the entire weekend |
|
||
-- Single spawns | ||
addEvent(Game.createMonster, 15000, Position(93, 123, 7)) | ||
addEvent(Game.createMonster, 30000, Position(98, 125, 7)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing monster name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my eyes failed me. Fixed
This PR is (almost) on it's final form. I added a generic interface to search and force execute global events. I couldn't find an use to force execute startup, shutdown or record events, so they are ignored. Also, it means it's possible to force trigger a server save on the Lua side. Edit: actually I'll just reuse the previous |
@ranisalt since seems he doesn't got time yet i made an example with coroutines. addEvent(checkRaids, 15000)
local inProgress = false
function ratPlague()
local pos = Position(146, 388, 7)
broadcastMessage("Rat plague in city!", MESSAGE_STATUS_WARNING)
Game.createMonster("Rat", pos)
coroutine.yield()
inProgress = false
end
function checkRaids()
print(coroutine.status(start))
if not inProgress then
if math.random(1, 1) == 1 then
inProgress = true
coroutine.resume(start)
end
end
addEvent(checkRaids, 15000)
end
start = coroutine.create(ratPlague) to make this a real raid system with coroutines would needed a lib as big as npcs is, i personally don't know performence impact with this tho, in my opinion coroutines are just a complicated way to call functions. |
If that is, I don't know how much better this is than |
i don't see the point also, if is needed to call a addEvent it becomes a complicated way to call functions, tho im curious to see how he would do that. |
e888bf7
to
18ca598
Compare
Rebased against master. |
593e6d8
to
e3e1bb2
Compare
I still intend to keep it up to date and merge when possible. This alone shaves 20 seconds off the build time 😄 besides -800 line delta. |
e3e1bb2
to
0d8f326
Compare
Only thing I can think you should "add" is a converter XML -> Lua |
@WibbenZ working on it! Check the new stuff under tools/ 😄 |
1043391
to
ed3911c
Compare
let's go?! |
@MillhioreBT your change request is blocking this PR |
- Move raids to globalevents, create Lua interface - Move force raid command to talkaction - Create example raid as globalevent - Add Lua interface to execute timed GlobalEvents Co-authored-by: Evil Puncker <EPuncker@users.noreply.github.com>
d697519
to
857c07c
Compare
Ready to merge, right? |
This should have been added years ago, we really need this! 🥹 |
I can't believe what my eyes are looking at |
2023/12/12, a milestone! OMG 🎉 🎉 🎉 |
This effectively nukes the raid system in favor of global events, which permit better management for raids. It's easier to define raids on interval, on exact times, force execution, force scheduling, add monsters on different delays and randomized amounts and positions... and also gets rid of a command.
I added a lib with helper functions to add monsters to a raid. The event is calledkeep readingonRaid
and there is an example bundled pretty equivalent to the previous XML raid example.