cube?

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!
Post Reply
ratman
Posts: 84
Joined: Fri Jan 10, 2020 1:13 am

cube?

Post by ratman » Thu Sep 24, 2020 7:22 pm

Has anyone imported the cube from LoG 1? if not can someone explain how to? thanks.

User avatar
Skuggasveinn
Posts: 548
Joined: Wed Sep 26, 2012 5:28 pm

Re: cube?

Post by Skuggasveinn » Fri Oct 09, 2020 3:27 pm

Hi.

It's not just a question of importing it, the brain of the Cube is missing in LoG2, so that part has to be rewritten or faked in someway to get it to function they way the cube functions in LoG1.

Brains, or AI behavior has never been part of the released asset packs, so I have never seen the code behind a brain.
Importing the Cube and assigning it a different brain that is available does not really work also, you will get monster that tries to make 90 degree turns (missing animation) and behaves differently then what you would expect from the Cube, not to mention weird animation resets, moving forward one tile for a normal monster is an animation that goes from one tile to another and resets, moving forward one tile for the cube is one flip of the cube, it needs to make 4 flips until it is again back in the same position since the sides of the cube look different, so there is something special going on that tracks which side he is on.

hope that helps explain why this "simply" hasn't been done yet ;)

kind regards.
Skuggasveinn.
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.

ratman
Posts: 84
Joined: Fri Jan 10, 2020 1:13 am

Re: cube?

Post by ratman » Sun Oct 11, 2020 4:32 pm

Okay, thanks. I don't think I'll be doing it anytime soon, since I cant even successfully import the animations for the cube :lol:

User avatar
Skuggasveinn
Posts: 548
Joined: Wed Sep 26, 2012 5:28 pm

Re: cube?

Post by Skuggasveinn » Mon Oct 12, 2020 3:22 am

Replying to this post got me thinking on how this could be faked, instead of importing the LoG1 Cube, what if one would recreate a new one, a cube that is the same on all sides to try to hide the animations skips.

I used the rat-swarm brain for behavior (that creates problems with projectiles that I haven't fixed) I then created single frame turning animations that I speed up to "hide" the 90 degrees turns, that worked out surprisingly well. Being a rat swarm brain the monster tries to move into the square of party and then "eat it", so the crush of the cube comes way way to late (the cube has landed over the party and then you die).

I was surprised that this wasn't nearly as bad as I thought at first, perhaps with more love and care and some scripting this could work out for a monster, but bringing the original cube that is different on all sides and has stopping, freezing, powering back up etc , I would not know where to begin with that.

The result is here.
https://youtu.be/WkBIytNvCGw

kind regards.
Skuggasveinn.
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.

minmay
Posts: 2657
Joined: Mon Sep 23, 2013 2:24 am

Re: cube?

Post by minmay » Mon Oct 12, 2020 8:30 am

I think you could implement the animations in a similar way to how Grimrock 1 does it. If you examine the cube's movement animation files from the Grimrock 1 asset pack, you'll find that it includes the movement of the cube's center and the animation of all the gears and buzzsaws and stuff inside, but doesn't rotate the whole cube; the rotation is done in the game code. And in Grimrock 2, we can control that rotation in our code too, with Component:setRotationAngles() on the ModelComponent!
You'll need to remove all the rotation keys from the root node when you port over the animations, using my modification to the Blender exporter. Otherwise the animation will just overwrite your rotation every frame.

To know how the cube should be rotated on any particular frame, you need to know two things: where the center of the cube is, and what orientation it was in when it started moving.
There's a nice little hack that makes it easy to get the position of the center every frame: you can get the position of any node in a monster mesh by using MonsterComponent:shootProjectile([projectile name], [height], [attackPower], [node]) with the node's name as the fourth argument, then getting the world position of the returned projectile.

Code: Select all

local projectile = ogre_1.monster:shootProjectile("blob",0,0,"capsule")
local capsulePosition = projectile:getWorldPosition()
projectile:destroy()
As for the initial orientation, you can just keep track of that in your AI code (you'll be pretty much writing it from scratch anyway).
Or you could the same shootProjectile() trick at the beginning of the move for one of the nodes that isn't at the center, and use that node's position relative to the center to determine which of the 24 possible orientations you're in. Inelegant and magic number-y, but it'd work.

I could go into how I think you could implement the knockback and crushing and assembling and disassembling the cube, but instead I'm going to poo-poo the whole idea a bit. The mechanical cube is the final and only boss of Legend of Grimrock and a major presence in the game's story. It's tied to the identity of the game in a way that cave ogres and wallsets and such are not. So as rich as this probably sounds coming from someone who ported a ton of Grimrock 1 stuff to Grimrock 2, I would urge you to rethink whether your mod really benefits from having the cube in it. Most of the Grimrock 1 mods that used it sure didn't.
I made the conscious decision not to port it myself, and not because it would have been too hard.
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
Skuggasveinn
Posts: 548
Joined: Wed Sep 26, 2012 5:28 pm

Re: cube?

Post by Skuggasveinn » Mon Oct 12, 2020 5:25 pm

I totally agree with you on the uniqueness of the Cube, that's way the idea of making a new Cube is more appealing to me, not that I'm actively working on any mod mind you :D , I just wanted to see how far I would go over the weekend.
The idea of multiple cubes is supported by the lore, one is buried on the island, and during the final cutscene you can see a full size cube next to one of the large bookshelf when the party enters the Nexus, clearly there are more then one.

I did notice in the original animations that It doesn't turn, and therefore the code is handling the rotation of the cube when its moving like you pointed out, even more interesting is when you directly convert the log1 animations into log2 and just throw the cube into the editor, it does rotate, meaning that something in the LoG2 code is also rotating it :o (I wonder what else is buried there ;) )

kind regards.
Skuggasveinn.
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.

ratman
Posts: 84
Joined: Fri Jan 10, 2020 1:13 am

Re: cube?

Post by ratman » Wed Oct 14, 2020 1:50 am

The result is here.
https://youtu.be/WkBIytNvCGw
:shock: That is amazing! I could not even begin to make something like that.(by the way, I would honestly much rather have that than the original cube)

@Minmay: Yes, I agree that the cube should be unique to grimrock 1. at first, my mod's whole storyline revolved around the cubes, but I decided to scrap that idea. (Though if anyone does manage to create their own, I would very much like it!)

Zo Kath Ra
Posts: 832
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: cube?

Post by Zo Kath Ra » Wed Oct 14, 2020 7:09 am

ratman wrote:
Wed Oct 14, 2020 1:50 am
:shock: That is amazing!
Everything Skuggasveinn makes is amazing.

Post Reply