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
Zo Kath Ra
Posts: 932
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Eleven Warrior wrote:Hi all.

In the main game you start in a cage errrr (No shit) lol. How does it work when you hit the cage door with the stick, you see the animation of the cage door open. How is this done, I'm sure it simple. I tried it in my Mod but I don't see the door open at all.
Use this method to see how it was done in LoG2:
viewtopic.php?f=22&t=8404

If you don't want to do that:
1) Put a prison_cage on your map
The cage must be facing in the direction of the door (which you add in step 2).
2) Put a prison_cage_door_breakable where you want the door to open
3) Put a prison_cage_door on each of the other sides of the cage
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Cool it works thxs for that :)

Is there a way to get the door to open without hitting eg: The animation event to activate via script or floor trigger?

EDIT: Got it :)

Code: Select all

function cagetest()
prison_cage_1.animation:play("open")
end
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all.

I have tried everything I know but it's not working :( I want to change the sound of the pushable_block to my custom sound. So no matter what direction it's clicked on I need it to play my sound.

Is the sound hard coded for the pushable_block and pushable_block_floor

Code: Select all

defineObject{
	name = "pushable_block",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Model",
			model = "assets/models/env/pushable_block_01.fbx",
		},
		{
			class = "ProjectileCollider",
		},
		{
			class = "Obstacle",
			hitSound = "$weapon",
		},
		{
			class = "DynamicObstacle",
		},
		{
			class = "PushableBlock",
		},
		{
			class = "Clickable",
			name = "clickNorth",
			offset = vec(0, 1.15, 1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+2) % 4 then
					self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickEast",
			offset = vec(1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+3) % 4 then
					self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickSouth",
			offset = vec(0, 1.15, -1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == self.go.facing then
					self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickWest",
			offset = vec(-1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+1) % 4 then
					self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Light",
			name = "lightNorth",
			offset = vec(0,1.2,1.2),
			range = 1.2,
			color = vec(5,2,2,0.3),
			brightness = 2,
			fadeOut = 0,
			fillLight = true,
		},
		{
			class = "Light",
			name = "lightEast",
			offset = vec(1.2,1.2,0),
			range = 1.2,
			color = vec(5,2,2,0.3),
			brightness = 2,
			fadeOut = 0,
			fillLight = true,
		},
		{
			class = "Light",
			name = "lightSouth",
			offset = vec(0,1.2,-1.2),
			range = 1.2,
			color = vec(5,2,2,0.3),
			brightness = 2,
			fadeOut = 0,
			fillLight = true,
		},
		{
			class = "Light",
			name = "lightWest",
			offset = vec(-1.2,1.2,0),
			range = 1.2,
			color = vec(5,2,2,0.3),
			brightness = 2,
			fadeOut = 0,
			fillLight = true,
		},		
		{
			class = "Sound",
			sound = "silent", [color=#FF8000]----------This wont work-------------[/color]
			offset = vec(0, 1.5, 0),
			enabled = false,
		},
	},
	editorIcon = 220,
}
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Option #1: (This replaces the pushblock sound ~globally.)

Code: Select all

defineSound{
	name = "pushable_block_push",
	filename = "assets/samples/weapons/gun_shot_small_01.wav",
	loop = false,
	volume = 0.75,
}
Option #2: (This adds a custom push sound option to the object's properties in the editor.)
SpoilerShow
Image
Editor project: https://www.dropbox.com/s/5w3eia2culfno ... d.zip?dl=0
Silence.wav: (Included in editor project) https://www.dropbox.com/s/v7juow1ccrq4h ... e.wav?dl=0

Updated code :!:

Code: Select all

defineSound{
	name = "pushable_block_push",
    filename = "mod_assets/sounds/silence.wav",
	loop = false,
	volume = 0.75,
}

defineSound{
	name = "pushable_block_default",
	filename = "assets/samples/env/pushable_block_push_01.wav",
	loop = false,
	volume = 0.5,
	minDistance = 2,
	maxDistance = 10,
	pitch = 5, --OPTIONAL
}

defineObject{
	name = "pushable_block",
	baseObject = "pushable_block",
	components = {
		{
			class = "Clickable",
			name = "clickNorth",
			offset = vec(0, 1.15, 1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+2) % 4 then
					self.go.pushableblock:push(party.facing)
					 local dX, dY = getForward(party.facing)
					 local loc = {self.go.x + dX, self.go.y + dY, self.go.elevation}
					 if not self.go.map:isObstacle(unpack(loc)) then
					 	return 
					 end
					 playSound(self.go.Custom_Sound:getSound())
				end
			end,
			
		},
		{
			class = "Clickable",
			name = "clickEast",
			offset = vec(1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+3) % 4 then
					 self.go.pushableblock:push(party.facing)
						 local dX, dY = getForward(party.facing)
					 local loc = {self.go.x + dX, self.go.y + dY, self.go.elevation}
					 if not self.go.map:isObstacle(unpack(loc)) then
					 	return 
					 end
					 playSound(self.go.Custom_Sound:getSound())
					
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickSouth",
			offset = vec(0, 1.15, -1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == self.go.facing then
					 self.go.pushableblock:push(party.facing) 
						 local dX, dY = getForward(party.facing)
					 local loc = {self.go.x + dX, self.go.y + dY, self.go.elevation}
					 if not self.go.map:isObstacle(unpack(loc)) then
					 	return 
					 end
					 playSound(self.go.Custom_Sound:getSound())
					
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickWest",
			offset = vec(-1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				if party.facing == (self.go.facing+1) % 4 then
					 self.go.pushableblock:push(party.facing) 
						 local dX, dY = getForward(party.facing)
					 local loc = {self.go.x + dX, self.go.y + dY, self.go.elevation}
					 if not self.go.map:isObstacle(unpack(loc)) then
					 	return 
					 end
					 playSound(self.go.Custom_Sound:getSound())
					
				end
			end,
		},
		{
			class = "Sound",
			name = "Custom_Sound",
			sound = "pushable_block_default",

		},
	},
}		
Last edited by Isaac on Sun May 08, 2016 7:21 am, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Thxs Isaac. Glad your here at this forum. Well I cannot believe it was that simple man :oops: Thxs again your totally awesome bro :)
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

There was a flaw in the script; it meant that the push sound played even when the pushblock couldn't move in the direction pushed.

*I wish that pushableblock:push(party.facing) returned true if succesful, but it does not, so I had to add a test to each click event.

** Does anyone know why the push block has four onClick events, instead of just one? While I haven't tried it yet, it does seem to me that one could enlarge the click region to match the mesh, and (since the player can only click the side the party is facing)... just push the block in the direction the party is facing when they click it.
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:(since the player can only click the side the party is facing)
This is false.
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: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

minmay wrote:
Isaac wrote:(since the player can only click the side the party is facing)
This is false.
Is it?

I'm inclined to believe you just on your word, though this is not something that I've been able to do in the game. I have only been able to click (and get a reaction from) the stone block face immediately in front of the party. When I click while facing sideways (as one might click the pull-chains from the left side and have the doors open up), I get nothing; the block doesn't move. :? This is why I asked.

** If you mean that an expanded click region [the size of the full model] would become clickable on the sides, I don't see how that would be a problem ~if it moved the block in the direction the party faced; even if clicked from the side.
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:When I click while facing sideways (as one might click the pull-chains from the left side and have the doors open up), I get nothing; the block doesn't move. :? This is why I asked.
I suppose in the specific case of objects with ObstacleComponents that always block the party, it might be true that clicks will always happen with the party facing the object. But since the onClick hooks in the standard pushable_block object verify the party's facing before moving the block, I wouldn't get rid of that check if I were you.
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
Vandalar
Posts: 31
Joined: Sun Jan 18, 2015 6:05 pm
Location: Montreal, Canada

Re: Ask a simple question, get a simple answer

Post by Vandalar »

Hello everyone,

I'm looking to define a new condition (with a new icon) that will prevent a champion of attacking/casting spell, like the paralyzed or petrified conditions.

I looked at the scripting reference or Jkos for the champion component, but I failed to find something appropriate (the setEnabled, well, disable the champion completely, which is not what I want). I hope the answer is simple enough (most likely something I overlooked). I know it's possible to "disable" the whole party with game flags, but I'm looking for only one champion.

Thanks in advance,

Vand
Post Reply