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 2 spells)

Post by JKos »

Thanks, I made those spells because I knew that you use this framework in your mod :) (Any chance to get in credits list ;) ) And yes I can do more EOB spells, I can use this http://www.freegameempire.com/games/Eye ... der/manual as reference.
- 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 2 spells)

Post by djoldgames »

Yes of course, you'll be credited in exported mod.

Now one more request from me, for the Illusion walls again ;-)
We need to extend hooks to check some sort of Array of possible Illusion_wall objects somewhere outside of framework file. For now I always add names in framework sript like this:

Code: Select all

if (e.name == 'dungeon_illusion_wall' or e.name == 'eob_sewers_illusion_wall' or e.name == 'eob_sewers_illusion_wall_rune')...
and in doTheMagic function:

Code: Select all

if not findEntity(wall.id.."_fake") then
     spawn(wall.name.."_fake", wall.level, wall.x, wall.y, wall.facing, wall.id.."_fake")
end
... hmm and little idea - if party pass through the illusion wall first time (since this tile is marked in automap as explored) we don't need to close the door nevermore. Illusion Walls would be "throwable"...
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (update: spell-hook support and 2 spells)

Post by JKos »

Ok, uploaded a new version which supports different types of illusion walls.
All types of illusion walls must be named so that the suffix of the name is illusion_wall, and the "fake-wall" must have sufix illusion_wall_fake

Also added flag which controls if doors stay open forever after party has passed through them.
illusion_walls.stayOpenAfterPartyPass = true
default value is true
- 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 2 spells)

Post by JKos »

Added 2 new eob-spells to demo-dungeon. (spells are not in framework.lua yet, because the magic system is under heavy development)
- Burning hands: just deals some fire damage to front of party.
- Shield: This was pretty tough. But now it works almost like in EoB.
It deflects magic missiles completely and reduces damage of missile and throwing weapons(throwing weapon damage is reduced more than missile).
- Improved magic missile so that it shoots from the tile where party is.
- Also refactored magic-related code so that it's more reusable, there is now fw_magic script entity(for general magic-related functions) and eob_spell script entity(for EoB spells only)
- added champion-specific hooks (only onProjectileHit currently) Shield spell uses this. Hook-namespaces for champions are champion_1,champion_2,champion_3,champion_4. The number is ordinal number of a champion.
- added a scroll which enables or disables turn based combat :) So you can choose if you wan't to use it or not. Scroll is spawned automatically to 1st champions inventory if turn_based module is activated.
- added 2 pressure plates to 1st room for testing purposes. Other shoot arrows and other magic-missiles. You can test shield-spell with it.

New spell definitions:

Code: Select all

createSpell{
	   name = "burning_hands",
	   uiName = "Burning hands",
	   skill = "fire_magic",
	   level = 0,
	   runes = "B",
	   manaCost = 10,
	}

createSpell{
	   name = "shield",
	   uiName = "Shield",
	   skill = "fire_magic",
	   level = 0,
	   runes = "D",
	   manaCost = 10,
	}
eob_spells script entity

Code: Select all

settings = {}
settings.useCasterLevelAsModifier = false
settings.hold_monster = {}
settings.hold_monster.duration = 5 --seconds + (skill/2)	
settings.hold_monster.immune= {
	skeleton_archer=true,
	skeleton_warrior=true
}

settings.magic_missile = {}
settings.magic_missile.damage = 5 -- damage * (skill / 2)

settings.shield = {}
settings.shield.duration = 5 --seconds + (skill/2)
settings.shield.missiles = 6 -- how many damagepoints are subtracted (max value)
settings.shield.throwing = 8 -- how many damagepoints are subtracted (max value)

settings.burning_hands = {}
settings.burning_hands.damage = 3 -- damage+skill*2

function activate()
	fw_magic.addSpell('hold_monster',holdMonster)
	fw_magic.addSpell('magic_missile',magicMissile)
	fw_magic.addSpell('burning_hands',burningHands)
	fw_magic.addSpell('shield',shield)
end

-- BURNING HANDS --

function burningHands(caster, x, y, direction, skill)
	if (useCasterLevelAsModifier) then skill = caster:getLevel() end
	local dx,dy = getForward(direction)
	playSoundAt("fireburst",party.level,x,y)
	damageTile(party.level, x+dx, y+dy, direction, 0, 'fire', settings.burning_hands.damage+skill*2)
end

-- SHIELD --

function shield(caster, x, y, direction, skill)
	if (useCasterLevelAsModifier and caster.getLevel) then skill = caster:getLevel() end
	
	local timerId = fw_magic.createSpellTimer(caster,settings.shield.duration+skill/2,{'eob_spells','shieldDestructor'})
	playSoundAt("fireball_launch",party.level,x,y)
	
	fw.addHooks(fw.getId(caster),timerId,{
		onProjectileHit = function(champion,projectile,damage,damageType)
			if projectile.name == 'magic_missile'  then
				hudPrint('Magic missile deflected')
				return false
			end
			if help.isEntityType(projectile,'item_missileweapon') then
				champion:damage(damage - math.random(settings.shield.missiles), damageType)
				hudPrint('Shield spell deflected some damage')
				champion:playDamageSound()
				return false
			end
			if help.isEntityType(projectile,'item_throwingweapon') then
				champion:damage(damage - math.random(settings.shield.throwing), damageType)
				hudPrint('Shield spell deflected some damage')
				champion:playDamageSound()
				return false
			end			
		
		end
	}
	)
end

function shieldDestructor(timer)
	fw_magic.spellTimerDestructor(timer)
	hudPrint('Effect of shield spell worn out.')
end

-- MAGIC MISSILE --

function magicMissile(caster, x, y, direction, skill)
	if (useCasterLevelAsModifier) then skill = champ:getLevel() end
	if caster and caster.getOrdinal then caster = party end
	playSoundAt("fireball_launch",party.level,x,y)
	shootProjectile('magic_missile', party.level, x, y, direction, 14, 0, 0, 0, 0, 0,
	 	settings.magic_missile.damage * (skill / 2), caster, true)
	
end

-- HOLD MONSTER --

function holdMonster(champ, x, y, direction, skill)
	if (useCasterLevelAsModifier) then skill = champ:getLevel() end
	
	local holdMonster = function() return false end
	
	local monster = help.nextEntityAheadOf(party,3,'monster')
	if not monster then return false end
	if settings.hold_monster.immune[monster.name] then return false end
	local timerId = fw_magic.createSpellTimer(monster,settings.hold_monster.duration+(skill/2))
	playSoundAt("frostbolt_launch",party.level,party.x,party.y)
	
	fw.debugPrint(monster.id..' held')
	
	--dynamically add hooks which prevents monster to attack or move	
	-- use spellId as hook-id so the hook can be removed on destructor
	fw.addHooks(monster.id,timerId,{
		onMove = holdMonster,
		onAttack = holdMonster,
		onRangedAttack = holdMonster,
		onTurn = holdMonster
	},
	1)
	return true
end
As you can see I added settings to the top of the eob_spells, so that the spell-properties can be altered in runtime. If you want to change the duration of shield, just set a new value in your own script entity.
eg.
eob_spells.settings.shield.duration = 10

edit: link
https://docs.google.com/open?id=0B7cR7s ... UN4SGZGNEk
- 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 4 EoB spel

Post by djoldgames »

Great update SpellMaster ;-)
You working fast and hi-quality. I don't catch up with all your updates. Now we are almoust finished with pre-generated EOB levels from original files.

EOB Levels for dungeon.lua: More maps and updates you can find on our project homepage (sorry for non English version)
Here you also find the "not-so-fully-cleaned" source code of my Eye of the Beholder Mod (link to google docs), you can look on all scripts ;) ...

Some credits: maps and objects generator is made by Bifrost (sk), and Tomek (pl) working on items and monsters...
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

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

Post by JKos »

@djoldgames: you guys are doing great work too, I will definitely check out your scripts when I have time.

New update: armor spell
At first I thought that it will be impossible to implement because there was no way to select a target for the spell, but now there is! It works exactly like in EoB.
So when you cast armor (rune F) a target selector (magic orb) is spawned as a mouse item, then when you left click a champion (or place selector on champions hand) the armor spell is casted on selected champion and selector is destroyed. I'm pretty proud of this one :)

Spell definition (copy pasted from EoB manual and modified for Grimrock)
With this spell the mage can surround a character with a magical field
that protects as chain mail (protection 6). The spell has no effect on
characters who already have protection 6 or greater and it does not have a
cumulative effect with the Shield spell. The spell lasts until the
character suffers 8 points + 1 per level of the caster of damage or a
Dispel Magic (this is not implemented yet) is cast.


I won't copy paste the script here just take a look at the demo dungeon sources if you are interested.
Also fixed couple of serialization problems (illusion_walls.isIllusionWall() and turn_based.scroll), and I'm pretty sure that this version is save game compatible, previous was not.

Updated this version to my google drive and also to steam workshop .
- 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
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

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

Post by Xanathar »

So when you cast armor (rune F) a target selector (magic orb) is spawned as a mouse item, then when you left click a champion (or place selector on champions hand) the armor spell is casted on selected champion and selector is destroyed. I'm pretty proud of this one
Terrific! The most clever idea I ever heard.

You are right to be proud!
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
SinusPi
Posts: 8
Joined: Fri Oct 19, 2012 11:57 am

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

Post by SinusPi »

Just a thought... Does the shield selector work when the target's inventory is full..? Since it's a fake item and all...
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

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

Post by JKos »

SinusPi wrote:Just a thought... Does the shield selector work when the target's inventory is full..? Since it's a fake item and all...
Good point, I have to test that. But I think that even if it doesn't work I can fix it by removing one item from inventory temporarily when spell is cast and put it back to inventory after the selector is destroyed.
- 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
SinusPi
Posts: 8
Joined: Fri Oct 19, 2012 11:57 am

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

Post by SinusPi »

I can fix it by removing one item from inventory temporarily
But, you don't know which character is going to be the target - and if you just remove items temporarily, and then the player runs around with the "healing sphere" on their mouse cursor, and happens to pick up dropped ammo... Mayhem will ensue.

Perhaps, as a total alternative, the spell itself could be adjusted to handle different targets? Like, if the runes are on the numpad, then let the 8956 squares decide the target, visually representing the party - so that, if the heal spell itself is something like 741, then 7418 would heal the front left, 7419 front right, etc.

Oh, if only we could get the Creators to supply us with simple Lua-driven interface creation tools... We could make a quick character picker dialog!

Although, yeah, a "target picker", picking a character or an item in the inventory or an item on the ground... That'd be simple and cool.
Post Reply