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!
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

@Sutekh Oooooh I think I might have misunderstood what Hyperbog was asking for from the beginning :?. I thought he wanted the party to rotate after using stairs that are placed in opposite directions, like they usually are, but he was talking about stairs that are only rotated by 90°? Like so:
SpoilerShow
Image
I feel a bit silly now, but in any case, I thank you for helping solve a problem of my own. I do use customTargets for my stairs, because personally, I disagree with the way they work in the main campaign, and sometimes there is enough space to have an extra square in front of the square that the party ends up on, like so:
SpoilerShow
Image
But sometimes, I simply don't have the space, and that makes the party end up with a wall in front of them, which just doesn't look very nice, IMO:
SpoilerShow
Image
So yeah thanks for sort of helping two different peoples somewhat different problems in one post :D
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

New question now. As I said in the post above, I don't like having the party appear in the staircase, but I'm actually not entirely happy with placing the party one square in front either. What I actually want, if I'm allowed to dream, is to have the party appear in the staircase, but automatically move out of it. Basically I want an walking-out-of-stairs-animation, just like there actually is a walking-in-to-stairs-animation.

Is it possible through scripts to force player movement? Can't find anything about it in the Scripting Reference, and can't find any similar question on the forums.

I've also made a new post about something else regarding player movement, that I didn't feel would fit into in a simple-questions-simple-answers thread :P

EDIT: Okay, so I just found out about this link in another thread, and found that I can use party.party:move(0 to 3) and party.party:turn(-1 or 1) to force movement/rotation. Just gotta figure out how to use them properly.

EDIT2: I have managed to figure out how to simulate walking out of stairs now, although I have a feeling that I might have overcomplicated it... Oh well, if it works, it works.
Last edited by Slicyr on Wed Feb 03, 2016 1:03 am, edited 1 time in total.
Hyperbog
Posts: 13
Joined: Tue Jan 26, 2016 3:24 am

Re: Ask a simple question, get a simple answer

Post by Hyperbog »

@Sutekh Thanks so much once again for taking them time to help out. It worked perfectly, and I was able to manipulate the spikes script to work around the whole room. I know at this point I'm going to be full of questions, but this kind of help lets me see how it's done while keeping me motivated to move forward. The assistance is much appreciated.
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

Would be cool to have something like a sarcophagus that acts like a secret door, but instead of going up or down, it moves back one square. openingDirection doesn't seem to accept anything other than "up" and "down". Anyone know how to accomplish this?
User avatar
Skuggasveinn
Posts: 562
Joined: Wed Sep 26, 2012 5:28 pm

Re: Ask a simple question, get a simple answer

Post by Skuggasveinn »

Slicyr wrote:Would be cool to have something like a sarcophagus that acts like a secret door, but instead of going up or down, it moves back one square. openingDirection doesn't seem to accept anything other than "up" and "down". Anyone know how to accomplish this?
This can be done with an object that has the Sarcophagus as a model component and a door component that moves an invisible model (up and down :D ). The invisible door component will simply acts as a blocker, preventing the player to move through it if the door is closed, and the model component of the sarcophagus will be the visuals for the door and has no collision in the game world.

If you want a very simple animation for the sarcophagus like moving it backwards one tile then that can probably be done with a script that changes its offset every frame until its in place, scripting is not my strong suit ;),(so here is hoping someone will jump in with a good model offset move example)

I always go with option B , creating an animation for the model using Blender and then set the object up with several classes that work together, the advantage of doing it with an animation is that you can have subtle movements of different parts within the model. (door knob movement like the door that comes with the winter tileset)

a door like this (from log1 but the same principle applies)
https://www.youtube.com/watch?v=IffbYjzYJDw
Has a code that looks something like this (I added descriptions to try to explain what's going on)

Code: Select all

defineObject{
	name = "urban_town_door_wooden",
	components = {
		{
			-- This is the model of the door that has the animation
			class = "Model",
			model = "mod_assets/ext/sx_urban_town/models/sx_house01_door.fbx",
		},
		{
			-- This is the invisible model that acts as a blocker/unblocker depending on the door state
			-- that model has one node that's called "gate"
			class = "Model",
			name = "door_logic",
			model = "mod_assets/ext/sx_urban_town/models/sx_blocker.fbx",  -- sx_blocker.fbx is a door model that is invisible
		},
		{
			-- Here I define the 2 animations that I created, one that swings the door open, and another that closes it
			class = "Animation",
			currentLevelOnly = true,
			animations = {
				opendoor = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
				closedoor = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
			},
			-- I also create animation events so that I can disable and enable both the controller 
			-- and the clickable component the reason for this is that I don't want the player to 
			-- be able to change the state during an animation event.
			-- so if you click the door is starts to open, and will not be clickable again until the open animation has finished.
			onAnimationEvent = function(self, event)
				if event == "dooropening" then
					self.go.clickable:disable()
					self.go.controller:disable()
					--print("opening")
				elseif event == "doorclosing" then
					self.go.clickable:disable()
					self.go.controller:disable()
					--print("closing")
				elseif event == "doorisclosed" then
					self.go.clickable:enable()
					self.go.controller:enable()
					--print("isclosed")
				elseif event == "doorisopen" then
					self.go.clickable:enable()
					self.go.controller:enable()
					--print("isopen")

					end
			end

		},
		{
			-- this is the door class itself, I have created sounds that are silent so the "fake" door 
			-- will not play the default stone sliding sound when opening and closing
			class = "Door",
			sparse = false,
			killPillars = false,
			openVelocity = 10,	-- change this to match the length of the animation, so the player can not pass if the door is not fully open
			closeVelocity = 0,
			closeAcceleration = -10, -- I just slam the door shut right away
			openSound = "sx_silent",
			closeSound = "sx_silent",
			lockSound = "sx_silent"
		},
		{
			-- this allows the player to click on the door to trigger the opening of it
			class = "Clickable",
			maxDistance = 0,
			-- offset vector is the point where the clickable box begins
			offset = vec(0,1.3,0),
			-- size is the size of our clickable box
			size = vec(2.0,2.0,0.3),
			--debugDraw = true,
			onClick = function(self)
				if self.go.door:isClosed() then
					self.go.controller:open()
				else
					self.go.controller:close()
				end
			end
		},
		{
			-- if its possible to place objects on the floor around the door so they will go into
			-- the model you need ItemConstrainBoxes to prevent item placement in those areas.
			class = "ItemConstrainBox",
			name = "cbox1",
			size = vec(0.8, 3, 0.7),
			offset = vec(-1.3, 1.5, 0),
			--debugDraw = true,
		},
		{
			class = "ItemConstrainBox",
			name = "cbox2",
			size = vec(0.8, 3, 0.7),
			offset = vec(1.3, 1.5, 0),
			--debugDraw = true,
		},
		{
			class = "Controller",
			onOpen = function(self)
				self.go.door:open() -- this opens the invisible door, so the player can pass.
				playSound("sx_door") --The sound to play when the door opens
				self.go.animation:play("opendoor") -- here I play the animation of the visual door, swining it open 
			end,
			onClose = function(self)
				self.go.door:close() -- here we close the invisible door so the player can't pass
				playSound("sx_door") --The sound to play when the door closes
				self.go.animation:play("closedoor") -- here I play the animation of the visual door, swining it close
			end,
			onToggle = function(self)
				if self.go.door:isClosed() then
					self.go.controller:open()
				else
					self.go.controller:close()
				end
			end,
		},
	},
	placement = "wall",
	editorIcon = 16,
	automapIcon = 84,
	tags = { "sx_doors" },
}

defineAnimationEvent{
	-- here we create an event called dooropening that starts on frame 1 of the opening animation
	animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
	event = "dooropening",
	frame = 1,
}

defineAnimationEvent{
	-- here on frame 44 the door has come to a stop, creating the event doorisopen
	animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
	event = "doorisopen",
	frame = 44,
}

defineAnimationEvent{
	-- here we create an event on frame 1 thats called doorclosing
	animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
	event = "doorclosing",
	frame = 1,
}

defineAnimationEvent{
	-- and event when the door has come to a stop closed
	animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
	event = "doorisclosed",
	frame = 44,
}
you can download the winter tileset , it has animated doors for LoG2 if you want to see this in action inside the editor.
http://www.nexusmods.com/legendofgrimrock2/mods/29/?

Hope that helps.
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: Ask a simple question, get a simple answer

Post by Dr.Disaster »

AndakRainor wrote:Is it allowed to base a mod on Isle of Nex ?
i.e. like a Master Quest or "The Mountain"? I'm pretty sure that won't be an issue.
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

@Skuggasveiin Thanks, gonna see if I can accomplish anything in Blender.
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

I want to make a weapon that scales with willpower instead of dex/str, and I can't figure it out on my own. Anyone know?
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Just enter "willpower" for the baseDamageStat instead of "strength" or "dexterity"...
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.
Post Reply