LoG Framework (dynamic hooks etc.)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

I took a brief look at my code and it really needs some optimization for onDraw-hooks. Currently it loops all party-hooks (not only onDraw-hooks) on every frame in vain, so if you have registered many party-hooks it could slow down the game. I will fix it soon, thanks for the bug-report.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

LoG Framework (dynamic hooks etc.)

Post by JKos »

Hello,

I finally got motivation to improve the performance of the framework, sorry for the long wait :(
Unnecesseary looping of tables has been removed and added a new method fw.setMonsterHooksActiveOnPartyLevelOnly(bool) which does what it says. So
calling fw.setMonsterHooksActiveOnPartyLevelOnly(true) makes monster:onMove and monster:onTurn-hooks to be active only if the monster is on the same level as the party.

But I hope that someone is willing to test this before I release a new version. Here is the updated fw.lua
https://drive.google.com/file/d/0B7cR7s ... sp=sharing


just replace the mod_assets/framework/modules/fw.lua with it.

I'm pretty sure that old save-games do not work with this, because I changed the fw.hooks-table structure.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: LoG Framework (dynamic hooks etc.)

Post by Isaac »

JKos wrote:...
If these are the same framework (as I believe), then Diarmuid has done some extensive optimizations for the ORRR2 mod, and you might talk to him about what was changed; though some of it was simply gutted as I understand it ~unneeded for our purposes, and for performance gains.
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Diarmuid »

What I did for the ORRR2 version of the framework is:

- disabled all non-monster dynamic hooks (if we need a hook on a particular item, we can put it in a definition)
- disabled all party hooks through the framework, and replaced it with a redirection to a hooks script-entity

+ fixed a few issues that these change created.

But as the monster hooks are still active in the fw, this new optimization will come in very handy. I'll upload the new mod_assets folder and then reapply the ORRR2 "disablings".

Thanks so much jKos!!!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

I believe that monster:onMove and monster:onTurn hooks are the most expensive ones, because those are called every time when any of the monsters moves, so you could get several hundred method-calls per second if you have a large dungeon.
Maybe I should set the monsterHooksActiveOnPartyLevel-flag to true by default, I can't think of any situation where those hooks should be active if party is on another level than the moving monster.

And it should be noticeably faster now because I changed the indexing method so that hooks are indexed by hookNamespace+methodName.hookIdentifier instead of hookNamespace+hooksIdentifier.methodName

For example: party.myHooksIdentifier.onMove method is now indexed in hooks-table like this:
hooks['party.onMove']['myHooksIdentifier'] = function(){...}

before it was like this:
hooks['party']['myHooksIdentifier']['onMove'] = function(){...}

Which means that the framework had to loop all defined identifiers and check if they had the called hook-method defined every time when any of the hooks was called, and that was just stupid, sorry about that. Now only one if-clause is enough to tell if there is any hooks defined.
So I'm pretty sure that enabling party, items and other hooks should not affect to the performance much anymore. Maybe I should join to the ORRR2 so I could test this in action, I see that there is couple of free rooms, but you guys have made so amazing stuff that I'm afraid to join :)
for example: A MULTITILE DRAGON, WTF? is that even possible?
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Diarmuid »

Ah, that's all great news.

Oh yes, you should SOOOO join the ORRR2. :P Right now, room 12 is totally free to take (the OP in the thread is off, Krazzikk never made a room).

There are contributions of all "levels" in there, some rooms featuring very complex scripting and engine exploits, other rooms featuring much more basic puzzles. The variety of it is what makes the beauty of the project. And I'm sure you of all people on this forum shouldn't be afraid of submitting something, considering your work powers the majority of mods here, hehe! ;)

Right now, we were trying to get all rooms in to start testing by the first weeks of november. Do you think you could cook up a small room in a two weeks timeframe?

If you wish, you can PM me your email and I'll add you to the dropbox, that way you'll be able to download the latest version, see what we have done (including this dragon) for yourself.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

Ok, I take the room 12 and try to pull off something in 2 weeks. PM is coming.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
Post Reply