LoG Framework (dynamic hooks etc.)

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

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by JKos »

I don't have to know which champion is going to the target, I just remove one item from all champions whose inventory is full. If you pick up an item the selector is destroyed and spell is cancelled.

Edit: Actually this could be easily extended to item picker too, thanks for the idea.
- 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:

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by JKos »

I tested it, and it doesn't work if inventory is full, but you can select the target by putting the selector to champions hand (even it's not empty). I guess that is good enough for now. Just remembered that I can't store items to lua-variables, because that will break save games. Of course i could store them to temporary container spawned to some champions inventory, but I think that's not worth the effort for now, I have more interesting things to do.
- 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:

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by JKos »

Ok, I tried to fix this, but there is no way to store items temporarily, because there is no container which supports both inserting and removing items. But I just changed spell selector uiName to "Select target by left clicking champions hand", I think that will do. Of course you can left click portrait too if inventory isn't full.
- 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
djoldgames
Posts: 107
Joined: Fri Mar 23, 2012 11:28 pm
Contact:

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by djoldgames »

JKos wrote:Ok, I tried to fix this, but there is no way to store items temporarily, because there is no container which supports both inserting and removing items. But I just changed spell selector uiName to "Select target by left clicking champions hand", I think that will do. Of course you can left click portrait too if inventory isn't full.
And what about using the ALCOVE as the "item container" for framework? ;-)
Somewhere in the LoGFramework object onOpen hook:

Code: Select all

spawn("dungeon_alcove", 1,1,1,0,"fwContainer")
-- load modules
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by JKos »

@djoldgames: That came in my mind too, but it doesn't work because items can't be removed from alcove, so when I tried to insert item back to champions inventory an error was thrown, something like: item is placed on dungeon already... but I think current solution is good enough.
- 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
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by Decayer »

I think fuel, charges, stack size, scroll text and scroll image is the only information unique to individual items, so you could store those values in local variables, destroy the item, spawn a new one where you want it and copy the values back; you now have a perfect copy of the old item. Unfortunaly there's no getScrollImage function, so that might be a problem.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (update: spell-hook support and 5 EoB spel

Post by JKos »

@Decayer, good idea. That could work, but IMO it works pretty nicely now and I have so much more in my mind.

Update: added Invisibility and invisibility 10' radius spells
AND experimental spell book. It's WIP state.

Purpose of the spell book is that you have to learn spells from it before you can cast them. I'd like to make the spell system to work like in EoB and other D&D games, and currently it looks like that it's possible.

Updated to google drive.
Try it, I have to go to sleep :)
- 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:

Re: LoG Framework (update: spell book(WIP) and 7 EoB spells)

Post by JKos »

- Spell system converted to EoB(D&D) style. You now have to learn spells from spell book, which is spawned automatically to every mages inventory. Spell book can't be moved or replaced.
- Also spell progression is converted to D&D style so that now you gain spell points on level up, and you can only learn so many spells than you have spell points. The amount of available spell points is show on spell books description. Progression table is copied from EoB manual.
- Spells can be learned by right clicking the desired spell scroll on book. When spell i learned the scroll opens(icon changes) and runes are shown. But you can't cast spells before you have learned them even if you know the runes.
- I added a button to the right of starting location which upgrades 4th champions level, so you can test the spell system easily.

Couple of screenshots here: https://docs.google.com/folder/d/0B7cR7 ... BSMjQ/edit

Also demo dungeon updated to Google drive and published to steam workshop. Any feedback is welcome.
- 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
djoldgames
Posts: 107
Joined: Fri Mar 23, 2012 11:28 pm
Contact:

Re: LoG Framework (update: spell book(WIP) and 7 EoB spells)

Post by djoldgames »

Very nice work, especially with the spellbook idea (books -> scrools -> notes).

Spellcasting items and monsters: we must to think out, how to make compatible these spells with items like scrolls (we have placeholders only for it yet), wands, etc. - without any restrictions to levels/points. Ant the same for monsters casting these spells...

Bugs:
  • Consumable items - don't add the food
  • Alcoves - we cannot add items to it
Maybe this problems is in overwriting default onInsertItem/onUseItem hooks, but I don't know how to fix it ;-(
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (update: spell book(WIP) and 7 EoB spells)

Post by JKos »

Update

- Added melf's acid arrow (strikes caster.level/3 times)
- added fw.repeatFunction(count,interval,callbackargs,callback,instant)
Thanks to Mebaru for the basic idea, I needed this for acid arrow so i implemented it. Enjoy :)
- fixed alcove:onInsertItem hook (there was an error in official documentation or bug in the LoG code, but alcove:onInsertItem must return true or else the alcove won't accept items)
- Custom projetile spells now give XP to caster!

@djoldgames: You can fix consumables by adding them to to consumable list
for example if you have consumable named rations put this code to the logfw_init.main function (or in some other function)
fw.lists.item.consumable['rations'] = true

Other way to fix it is to add a onUseItem-hook which returns true to your consumable. Consumables caused me some trouble because their hooks must return true by default but other item hooks must return nil, so I had to add a list of consumables to framework.lua so I could check if item is consumable in onUseItemHook (see framework.lua)

Here is the source for melf's acid arrow, It wasn't easy to implement

Code: Select all

 -- MELF'S ACID ARROW ***

function melfs_acid_arrow(caster, x, y, direction, skill)

	playSoundAt("fireball_launch",party.level,x,y)
	
	-- pass the caster.id to hook
	fw.setHookVars('monsters','eob_spells_acid_arrow','onProjectileHit',fw.getId(caster))
	
	fw.addHooks('monsters','eob_spells_acid_arrow',{
		onProjectileHit = function(monster,projectile,damage,damageType)
			if projectile.name == 'acid_arrow' then
			
				local caster = fw.getById(fw.getHookVars()) 

							
				local callback = function(caster_id,target_id)
					local target = fw.getById(target_id) 
					local caster = fw.getById(caster_id) 
					local originator = 2 ^ (caster:getOrdinal()+1) 
					local modifier = math.ceil(caster:getLevel()/2)
					local damage = math.random(2,eob_spells.settings.melfs_acid_arrow.damage)
									
					damageTile(target.level,target.x,target.y,(target.facing + 2)%4,originator+1, 'physical',8)
				end
				
				local attacks = math.ceil(caster:getLevel()/3)	
				
				fw.repeatFunction(attacks,1,{fw.getId(caster),fw.getId(monster)},callback,true)
	
				-- remove hook for performance reasons
				fw.removeHooks('monsters','eob_spells_acid_arrow')
				return false
			end
			
		end
	})
	
	shootProjectile('acid_arrow', party.level, x, y, direction, 14, 0, 0, 0, 0, 0,
	 	0, party, true)

end
Edit: damn, just noticed that there is upvalue (originator) in that callback function, I will fix it.
Edit2: upvalue fixed
- 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