Page 1 of 1

magic door

Posted: Thu Dec 25, 2014 8:53 pm
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

Re: magic door

Posted: Thu Dec 25, 2014 9:21 pm
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" },
}

Re: magic door

Posted: Thu Dec 25, 2014 11:41 pm
by Isaac
IRRC, Diarmuid had assets for a magic door in the ORRR2 dungeon.

Re: magic door

Posted: Fri Dec 26, 2014 4:24 pm
by bongobeat
thanks I ve got a look at it.
it's a transparent moving door, nice work!

Re: magic door

Posted: Mon Dec 29, 2014 1:57 am
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