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!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Looks like the UV map for your bushes goes from the bottom of the texture to the very top. This is causing the texture to wrap around slightly when viewed at some angles from some distances. You can fix this by changing the textureAddressMode of the material to clamp on that axis. For example, the blue_beam material in the standard assets uses textureAddressMode = "WrapU_ClampV_ClampW".
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.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Thanks minmay the textureadressmode fixed my problem.
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 »

Khollik wrote:Hello

I'm looking for a way to not make the health bar appear during a boss fight (so the fight would be more stressful...). Does anyone know how to do it? Until now, I didn't find out :roll:

Thanks
Khollik
What makes a boss fight a boss fight?

Without the health bar, it's just the bossName and music.
When all monsters are dead, or when you go to another level, the bossName disappears and the music stops playing.
User avatar
Khollik
Posts: 171
Joined: Tue Aug 29, 2017 6:44 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by Khollik »

Hello Zo Kath Ra

Thanks for your answer. I suppose, indeed that I could do without launching a bossfight, but precisely I like the idea of changing the music during the fight and I didn't figure out yet how to change the music track in a dungeon whithout using the bossfight. Besides, I didn't find anything in the bossfight asset that could help me understand how it works.

Code: Select all

defineObject{
	name = "boss_fight",
	components = {
		{
			class = "BossFight",
		},
		{
			class = "Controller",
			onActivate = function(self)
				self.go.bossfight:activate()
			end,
			onDeactivate = function(self)
				self.go.bossfight:deactivate()
			end,
		},
	},
	placement = "floor",
	tags = { "scripting" },
	editorIcon = 280,
}

So one question leading to another one, is it something hardcoded or is there a way to change the ambient track directly?

Cheers
Khollik
lostsol
Posts: 86
Joined: Mon Apr 02, 2018 4:51 pm

Re: Ask a simple question, get a simple answer

Post by lostsol »


So one question leading to another one, is it something hardcoded or is there a way to change the ambient track directly?

Cheers
Khollik
GameMode.playStream(name)
User avatar
Khollik
Posts: 171
Joined: Tue Aug 29, 2017 6:44 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by Khollik »

Great, thanks a lot Iostsol!! :P
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Ask a simple question, get a simple answer

Post by Mysterious »

Hi all.

There is a problem with: GameMode.setEnableControls(false) . If you activate this function while sleeping eg: pressing the movement keys it stops the rest cycle but you still cannot move or use the mouse until you do this: GameMode.setEnableControls(true).

When the rest cycle is stopped you can see daylight or night but your still resting until you use the above function again.

What im trying to do is make a bed when clicked on player goes into the rest function and it plays a snoring sound. I don't want the player to move or unrest till the sound has finished. The sound runs for 7 seconds. It all works but when you click on the bed and rest it goes dark but, if you hit any of the movement keys you wake up and you can see the daylight but, you still see the zzzzzz's like your still resting.

Code: Select all

defineObject{
	name = "grim_bed_2",
	baseObject = "base_obstacle",
	tags = { "furniture" },
	components = {
		{
			class = "Model",
			model = "mod_assets/grim_assets/grim_bed_2.fbx",
			staticShadow = true,
		},
		{
			class = "Clickable",
			offset = vec(0, 0, 0), --0,1.375,0
			size = vec(2.5, 1, 1), ---0.5,0.2,0.2
			maxDistance = 1,
			debugDraw = true,
			onClick = function(self)
			GameMode.setEnableControls(false)
			delayedCall("miscel_script", 6, "sleep1")
				playSound("snor1")
					party.party:rest()
			end,
			},
		}
	}
Script in Mod:

Code: Select all

function sleep1()
GameMode.setEnableControls(true)
end
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 »

I don't know if you can prevent the player from waking up the party.
But you can make it so that waking up always re-enables the controls.

Connect a button to sleepStart.
Connect timer_1 to counter_1.
Connect counter_1 to sleepEnd.

You wanted the party to sleep for 7 seconds.
Time runs faster while you're sleeping, so you'll have to experiment with timerInterval and counter value.

edit:
This code only prevents the player from waking up with mouse clicks.

Code: Select all

function initParty()
	party.party:addConnector("onWakeUp", self.go.id, "partyWakeUp")
end

function sleepStart()
	GameMode.setEnableControls(false)
	party.party:rest()
	
	counter_1.counter:reset()
	timer_1.timer:start()
end

function sleepEnd()
	party.party:wakeUp(false)
end

function partyWakeUp()
	timer_1.timer:stop()
	GameMode.setEnableControls(true)
	hudPrint("The party has woken up!")
end

initParty()
User avatar
Curunir
Posts: 332
Joined: Fri Mar 30, 2012 11:19 pm

Re: Ask a simple question, get a simple answer

Post by Curunir »

How would I go about checking to see if the party is within a certain range of map coordinates (let's say a 4x4 grid at x16-19 and y16-19, one tile away from a fountain model) and if they are, execute a script?

The purpose is to have something similar to how the horn works, but have Action X trigger Y when party is in a looser, simply "close proximity" to an object in the world.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Curunir wrote:How would I go about checking to see if the party is within a certain range of map coordinates (let's say a 4x4 grid at x16-19 and y16-19, one tile away from a fountain model) and if they are, execute a script?
One way is to place party-only activated floor-triggers in every tile in the region; tiles that all connect to the same script. You can inspect the the triggers to learn the exact location, if useful to you.

An alternative scripted method:

Code: Select all

--Place script_entity at top left of region.
--Set values of regionX, and regionY to the number of columns & rows to check 


party.party:addConnector('onMove', self.go.id, "positionCheck")
region_active = true
regionX, regionY = 7,7 

function positionCheck() 
	if region_active then
		local width, height = party.x +regionX, party.y +regionY
	
		if (party.x >= self.go.x and party.x <= width) and (party.y >= self.go.y and party.y <= height)
		 then
			--=======================================[ triggered actions ]
			
			
			print('Party is in region.')
			party:spawn("shockburst").tiledamager:setAttackPower(1)
			
			
			--============================================================
		end
	end
end

function setActive(self, bool)
	if type(bool)=="boolean" then region_active = bool return end
	if type(self)=="boolean" then region_active = self return end
	region_active = not region_active
end
Last edited by Isaac on Fri Apr 20, 2018 7:14 am, edited 1 time in total.
Post Reply