Spell – rune order

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Spell – rune order

Post by akroma222 »

Isaac wrote:
akroma222 wrote:Its almost tempting to make players collect the Rune stones to place in their Runestone collection (bag :lol: ) ... but probably not worth the hassle!
Have you played Arx Fatalis? (That is exactly what they did.)
I havent even heard of it (will do a search and check it out ;) )
Ultima Underworld 1 & 2 also did exactly this :D :mrgreen:
(you were limited by which runestones you had and casting spells of lvl = 3x character lvl)
.rhavin wrote:First having to unlock the runes is already a configurable feature ;)
BOOM 8-) :P
.rhavin wrote:....once Petri read my bugreport and hopefully has some spiced wine
We all live in hope :roll: ... havent heard much from AH lately :|
User avatar
.rhavin
Posts: 25
Joined: Fri Oct 13, 2017 1:10 pm
Location: Berlin
Contact:

Re: Spell – rune order

Post by .rhavin »

Just updated the sourcecode to show off some configurable parameters and added slighly more doku.

http://doc.rhavin.de/dmf/spelltome_demo.zip

Two platforms, one showing DM-style, the other GR-style.

Lets say I want to connect this to bare hands or to a book, both on rightclick… how do i do this and how can I get the coordinates of the castings character area? I remember I've seen somewhere a video of a weapon-attack-selector like in DM but I cant find it :D
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Spell – rune order

Post by minmay »

For drawing it and handling input you'll want to use the PartyComponent.onDrawAttackPanel hook. It gives you the position of the champion's attack panel, and even handles gui scaling for you.

As far as binding it to an item, you'll probably want to use ItemActionComponent with an onAttack hook that toggles the spellcasting panel on. You'll need to prevent the champion from doing anything else with their hands whlie the panel is on; you can mostly prevent that by simply returning false from PartyComponent.onAttack, but that hook doesn't get called for unarmed attacks (or bare hand spell casts) which is a problem.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3175
Joined: Fri Mar 02, 2012 10:02 pm

Re: Spell – rune order

Post by Isaac »

akroma222 wrote:Ultima Underworld 1 & 2 also did exactly this :D :mrgreen:
Arx Fatalis was originally intended to be an Underworld sequel, made by Arkane; the studio that later made 'Dishonored' ; but it didn't get licensed. It's available on GoG.
SpoilerShow
The player collects runes as they explore the world; merchants do sell some of them.
Image
As with Grimrock II the player draws a line with the mouse... but in Arx, the player draws the runes with the mouse, as if in the air in front of the caster. What's really neat is that the symbol meanings in some cases allow the player to deduce undocumented spells that are not mentioned in the game, and never appear in the spellbook... but they are fully supported with animations and effect.
Image
minmay wrote:...but that hook doesn't get called for unarmed attacks (or bare hand spell casts) which is a problem.
A problem I've been tangling with myself. Once I started looking into this, I couldn't help tinkering with one of my own —but it's different enough (unrelated in appearance and behavior—aside from casting spells), and it's not based on other scripts. The plan (at least for now) is that it does not replace the standard rune panel, so both could be used at the same time by different characters (of different casting skill).
SpoilerShow
Image
User avatar
.rhavin
Posts: 25
Joined: Fri Oct 13, 2017 1:10 pm
Location: Berlin
Contact:

Re: Spell – rune order

Post by .rhavin »

Can someone please provide a simple codefragment how to set up an item that calls

ItemActionComponent.onAttack()?

If tried it like this in my defineObject…

Code: Select all

	{
		class = "ItemAction",
		onAttack = function(self, champion, slot, chainIndex)
			hudPrint(champion:getName().." eats a book.")
		end
	},
… but it dies not get called.

Basically, i need it to behave different when a rightclick occurs while it is in inventory or in hand.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Spell – rune order

Post by minmay »

When you click on an item in the attack panel, it uses the item's primaryAction. The ItemActionComponent needs to be set as the primaryAction of the ItemComponent. So:

Code: Select all

{
   class = "Item",
   primaryAction = "bookattack",
},
{
   class = "ItemAction",
   name = "bookattack",
   onAttack = function(self, champion, slot, chainIndex)
      [stuff]
   end,
},
For doing something when the item is clicked in the inventory, use UsableItemComponent:

Code: Select all

{
   class = "UsableItem",
   onUseItem = function(self, champion)
      hudPrint(champion:getName().." eats a book.")
   end,
}
Both together in a full definition:

Code: Select all

defineObject{
	name = "booooook",
	baseObject = "bread",
	components = {
		{
			class = "Item",
			uiName = "Book",
			gfxIndex = 275,
			weight = 1.0,
			primaryAction = "itemaction",
		},
		{
			class = "UsableItem",
			onUseItem = function(self, champion)
				hudPrint(champion:getName().." eats a book.")
			end,
		},
		{
			class = "ItemAction",
			cooldown = 1,
			onAttack = function(self, champion, slot, chainIndex)
				hudPrint(champion:getName().." attacks with a book. It's not very effective...")
			end,
		},
	},
}
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Spell – rune order

Post by akroma222 »

Hey hey .rhavin!

Wondering if you are still working on this feature??

Akroma
Post Reply