magic door

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
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

magic door

Post by bongobeat »

I wanted a magic door so I try this:

I think that modifying the forcefield object will be better, but I did not find the forcefield definition in the asset pack:
so, I'm using 2 objects, a modified magic bridge which is named magic_door_particle and a door used to block the party:

the magic_door, it is always a plateform:
SpoilerShow

Code: Select all

defineObject{
	name = "magic_door",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Particle",
			particleSystem = "magic_door_part",
		},
		{
			class = "Light",
			color = vec(1.5,1.0,1.25),
			brightness = 5,
			range = 3,
			castShadow = false,
			offset = vec(0, -0.25, 0),
			fillLight = true,
			onUpdate = function(self)
				self:setBrightness((math.noise(Time.currentTime() + 12) * 0.5 + 0.5 + 0.1) * 15)
			end,
		},
		{
			class = "Platform",
		},
		{
			class = "Sound",
			sound = "magic_bridge_ambient"
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.platform:enable()
			end,
			onInitialDeactivate = function(self)
				self.go.platform:disable()
				self.go.particle:stop()
				self.go.light:fadeOut(0)
				self.go.sound:fadeOut(0)
			end,
			onActivate = function(self)
				self.go.platform:enable()
				self.go.particle:start()
				self.go.light:fadeIn(0.1)
				self.go.sound:fadeIn(0.1)
			end,
			onDeactivate = function(self)
				self.go.platform:disable()
				self.go.particle:stop()
				self.go.light:fadeOut(0.5)
				self.go.sound:fadeOut(0.1)
			end,
			onToggle = function(self)
				if self.go.platform:isEnabled() then
					self:deactivate()
				else
					self:activate()
				end
			end,
		},
	},
	editorIcon = 276,
}
the magic door particle:
SpoilerShow

Code: Select all

defineParticleSystem{
	name = "magic_door_part",
	emitters = {
		-- fog
		{
			emissionRate = 10,
			emissionTime = 0,
			maxParticles = 100,
			boxMin = {-1.5,0.0,1.5},
			boxMax = { 1.5,4.0,1.5},
			sprayAngle = {0,360},
			velocity = {0.1,0.4},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {3,3},
			color0 = {0.15, 0.1, 0.125},
			opacity = 0.2,
			fadeIn = 2,
			fadeOut = 2,
			size = {1, 2},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 0.3,
			blendMode = "Additive",
		},

		-- stars
		{
			emissionRate = 300,
			emissionTime = 0,
			maxParticles = 600,
			boxMin = {-1.5,0.0,1.5},
			boxMax = { 1.5,4.0,1.5},
			sprayAngle = {0,30},
			velocity = {0.0,0.1},
			objectSpace = true,
			texture = "assets/textures/particles/glitter_silver.tga",
			lifetime = {1,1.7},
			color0 = {1.5,1.0,1.25},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.5,
			size = {0.05, 0.15},
			gravity = {0,-0.5,0},
			airResistance = 0.1,
			rotationSpeed = 2,
			blendMode = "Additive",
		},

		-- stars
		{
			emissionRate = 400,
			emissionTime = 0,
			maxParticles = 400,
			boxMin = {-1.5,0.0,1.5},
			boxMax = { 1.5,4.0,1.5},
			sprayAngle = {0,30},
			velocity = {0.0,0.1},
			objectSpace = true,
			texture = "assets/textures/particles/glitter_silver.tga",
			lifetime = {1,1},
			color0 = {1.5*1.5, 1.0*1.5, 1.25*1.5},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.5,
			size = {0.05, 0.25},
			gravity = {0,-0.2,0},
			airResistance = 0.1,
			rotationSpeed = 2,
			blendMode = "Additive",
		},
	}
}
then the code for a door, which use a custom sound: the custom sound has to be blank, but at least some seconds long or it will make an error.
So when opening this door, you will hear no sound.
(the best way to do it is to open any sound in audacity, select the sound and use the amplification tool, in the effect tab, then set the amplification to the lowest value. This will reduce the sound volume to 0)
SpoilerShow

Code: Select all

defineObject{
	name = "magic_door_block",
	baseObject = "base_door",
	components = {
		{
			class = "Model",
			model = "assets/models/env/dungeon_door_wooden.fbx",
			staticShadow = true,
		},
		{
			class = "Model",
			name = "frame",
			model = "assets/models/env/dungeon_door_frame.fbx",
		},
		{
			class = "Door",
			openVelocity = 10,
			closeVelocity = 0,
			closeAcceleration = -20,
			sparse = true,
			openSound = "no_sound",
			closeSound = "no_sound",
			lockSound = "no_sound",
--			killPillars = true,
		},
	},
}
you have to place them both on the same square, by watching the correct orientation of the 2 objects.

set the magic_door_block as following in the editor:
unselect the frame and the model box

a screenshot:
SpoilerShow
Image
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: magic door

Post by bongobeat »

Lol!
I ve searched everywhere the forcefield, but not in the spell definitions... :roll:

here is another try more simple, with a forcefield:
SpoilerShow

Code: Select all

defineObject{
	name = "force_field_magic_door",
	components = {
		{
			class = "Particle",
			particleSystem = "magic_door_part",
		},
		{
			class = "Sound",
			sound = "magic_bridge_ambient",
		},
		{
			class = "ForceField",
			hitSound = "impact_blunt",
		},
		{
			class = "ProjectileCollider",
			size = vec(3, 3, 3),
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.forcefield:enable()
				self.go.projectilecollider:enable()
			end,
			onInitialDeactivate = function(self)
				self.go.forcefield:disable()
				self.go.particle:fadeOut(0)
				self.go.sound:fadeOut(0)
				self.go.projectilecollider:disable()
			end,
			onActivate = function(self)
				self.go.forcefield:enable()
				self.go.particle:fadeIn(0.1)
				self.go.sound:fadeIn(0.25)
				self.go.projectilecollider:enable()
			end,
			onDeactivate = function(self)
			playSound("force_field_cast")
				self.go.forcefield:disable()
				self.go.particle:fadeOut(0.1)
				self.go.sound:fadeOut(0.5)
				self.go.projectilecollider:disable()
			end,
			onToggle = function(self)
				if self.go.forcefield:isEnabled() then
					self:deactivate()
				else
					self:activate()
				end
			end,
		},
	},
	placement = "floor",
	editorIcon = 272,
	tags = { "obstacle" },
}
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: magic door

Post by Isaac »

IRRC, Diarmuid had assets for a magic door in the ORRR2 dungeon.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: magic door

Post by bongobeat »

thanks I ve got a look at it.
it's a transparent moving door, nice work!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: magic door

Post by QuintinStone »

bongobeat wrote:Lol!
I ve searched everywhere the forcefield, but not in the spell definitions... :roll:

here is another try more simple, with a forcefield:
The force field is defined in assets\scripts\spells\force_field.lua
Crypt of Zulfar
Post Reply