Ask a simple question, get a simple answer

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!
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

That makes sense! And I think that is also the correct explanation...
Okay thanks! Question is "fin(n)ished" :)
Sorry for my poor english... hope you understand what i try to say! :)
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

I have a question about the rat swarm. What component lets it move through a grating/porticulus ? Is it the rat swarm brain.
I have a wall with a hole in it on the bottem that is the size of a green slime. I want to green slime to move through it. the wall has a gate node, so it functions as a grating. ... what should I add to the slime so that it can move towards the player and not get stuck ?

Or is there another way to make this work ?

If I make it a normal base wall.. it wont stop the player from walking through the wall
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Just make a simple function connected to a floor trigger.
So for example when you enter the room and have vision of the hole in the wall, the slime moves out the wall to attack you.

green_slime_1.brain:enable()

As for the wall. Simply use any object with an obstacle component on the square behind the wall where the slime is.
And keep it as a base wall.
Disable the model in case you can look through the hole.
A monster can move out of an obstacle, but not back in.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

thanks pompidom. That was the solution I was looking for.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Code: Select all

swarm = true,
in the MonsterComponent is what allows rat swarms to move through sparse doors (and through the party and other monsters).
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
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

defineSpell -> onCast(champion, x, y, direction, elevation, skillLevel)

Does it make any difference if I return true, false or nothing from this function?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

No, the return value is ignored. If you want to prevent a spell from being cast you want the PartyComponent.onCastSpell hook.
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.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Not so simple question.

Blood Moon will completely eliminate default spells "cast by hand/wand" is disabled and the mage class will simply have naked physical hands just like a fighter. The mod will only feature 3 classes: fighter, mage, rogue. The only difference between these classes will be their health/energy pool and 1 unique passive. + strength / + willpower / + critical respectively.
It will also eliminate "resting" Pressing R to fully regenerate your party makes little sense in this mod.

The mod features magic wands with dual functionality.
For example a staff of fire will have fireburst as primary action (leftclick) and shoot custom fireballs as secondary action (rightclick) of the character.
Therefor these wands cannot be used to cast the default spells and the runepanel is therefor unavailable.

I'm transforming Blood Moon into a Dark Souls experience. Disable any form of health and energy regeneration.
(utility magic wands will be available with a healing spell at the cost of energy/charges) or expensive potions.
Rest at a bonfire to resurrect dead heroes and regenerate health and energy at the cost of reviving every single enemy.

This also adds the possibility to "kindle" a bonfire upgrading a bonfire so that all monsters around you become stronger making them drop better loot.

Melee weapons will consume energy like in log1
As for wands, I was looking into charges.

Now the issue I have is that I need to come up with a way that touching this bonfire (big invisible button) will also recharge all items in inventories + equipped wands.

The best I can come up with is installing a recharging station that simply destroys the wand and instantly gives an identical wand with full charges back. Manually recharging every single wand by dropping it on the recharging station surface is tedious and kinda ruins the gameplay flow with a long script where I need to add every single item with charges manually.

The other possibility is simply forget about charges and rely entirely on energy, balancing the magic wands so that they use little energy so a mage character doesn't run out of energy after defeating 2 monsters.

Any possible solutions/suggestions?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You can recharge an item without destroying it by using CastSpellComponent:recharge(). Take a look at the Crystal Shard of Recharging item in the standard assets.

This recharges all items in the party's inventory:

Code: Select all

function rechargeAllItems()
	local function rechargeItem(item)
		for _,c in item.go:componentIterator() do
			if c:getClass() == "CastSpellComponent" and c:getCharges() then -- don't recharge items with nil (unlimited) charges
				c:recharge()
			end
		end
	end
	local function searchContainer(c)
		for index=1,c:getCapacity() do
			local item = c:getItem(index)
			if item then
				for _,c in item.go:componentIterator() do
					if c:getClass() == "ContainerItemComponent" then
						searchContainer(c)
					end
				end
				rechargeItem(item)
			end
		end
	end
	for i=1,4 do
		local champion = party.party:getChampion(i)
		for slt,item in champion:carriedItems() do
			for _,c in item.go:componentIterator() do
				if c:getClass() == "ContainerItemComponent" then
					searchContainer(c)
				end
			end
			rechargeItem(item)
		end
	end
	if getMouseItem() then rechargeItem(getMouseItem()) end
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
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

ItemComponent:throwItem(dir, power)

This makes the party throw something.
But it's not like throwing an object manually, because there's no auto-pickup when you walk over it.

Has anyone else encountered this problem, and what was your solution?
Other than ignoring the problem, or re-implementing auto-pickup from scratch.
Post Reply