Page 1 of 2

any way to make a forcefield block only like a door?

Posted: Mon Mar 02, 2015 12:42 am
by bongobeat
Is there any way to make a forcefield to block as a door, but allow passage perpendiculary, behind the blocage, in the square where the forcefield is?
Don't know how to explain that: I mean to make a forcefield act as a blocage in 2 dimensions, and let the 3rd dimension free of move.

I have define a forcefield with a model that show a picture:
SpoilerShow
Image
and I use this as a door. The only problem, is that if you are behind this door, you can't go on the square, where the forcefield is.


by the way:
for those who use the castle wallset, there is an interesting model of a window in the asset pack which is not used in the game:
/models/env/castle_window_01.model
it shows some white rays/box.
pay attention that if you use it on a 2 ceilings level, like in this picture, there is a small gap when you come under the window, but you can hide it with a castle_wall_arch
SpoilerShow
Image
there is also another model of a high window, castle_window_high_01.model

Re: anyway to make a forcefield block only like a door?

Posted: Mon Mar 02, 2015 12:53 am
by minmay
Very easy, actually! Just copy the force_field definition from assets/scripts/spells/force_field.lua, change the placement to "wall", replace the ForceFieldComponent with a DoorComponent, and remove the ProjectileColliderComponent. Make sure your model's root node is named "gate" and based at 0,0,0 so the console doesn't complain and position and collisions are handled correctly.

Like this:

Code: Select all

defineObject{
	name = "force_field",
	components = {
		{
			class = "Model",
			-- Change this to your own model that has a node named "gate".
			model = "assets/models/effects/force_field.fbx",
			offset = vec(0, 0.05, 0),
		},
		{
			class = "Light",
			offset = vec(0, 1.75, 0),
			range = 6,
			color = vec(0.2, 0.5, 1),
			brightness = 20,
			castShadow = false,
			fillLight = true,
		},
		{
			class = "Particle",
			particleSystem = "force_field",
		},
		{
			class = "Sound",
			sound = "force_field_ambient",
		},
		{
			class = "Door",
			hitSound = "impact_blunt",
		},
		{
			class = "Clickable",
			offset = vec(0, 1.5, 0),
			size = vec(2.75,3,2.75),
			maxDistance = 1,
			--debugDraw = true,
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.clickable:enable()
			end,
			onInitialDeactivate = function(self)
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0)
				self.go.sound:fadeOut(0)
				self.go.light:fadeOut(0)
				self.go.clickable:disable()
			end,
			onActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.particle:fadeIn(0.1)
				self.go.sound:fadeIn(0.25)
				self.go.light:fadeIn(0.1)
				self.go.clickable:enable()
				--self.go:playSound("force_field_cast")
			end,
			onDeactivate = function(self)
				if self.go.model:isEnabled() then
					self.go:playSound("force_field_cast")
				end
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0.1)
				self.go.sound:fadeOut(0.5)
				self.go.light:fadeOut(0.5)
				self.go.clickable:disable()
			end,
			onToggle = function(self)
				if self.go.door:isEnabled() then
					self:deactivate()
				else
					self:activate()
				end
			end,
		},
	},
	placement = "wall",
	editorIcon = 272,
	tags = { "obstacle" },
}

Re: anyway to make a forcefield block only like a door?

Posted: Mon Mar 02, 2015 10:39 am
by bongobeat
thanks,

I forgot to precise, to do that without gate node. But as you explain on how to do a gate node! very nice! :D

---> trying

Re: anyway to make a forcefield block only like a door?

Posted: Mon Mar 02, 2015 1:33 pm
by Granamir
where did u take those walls and windows and so on?

Re: anyway to make a forcefield block only like a door?

Posted: Mon Mar 02, 2015 11:35 pm
by bongobeat
this work well, thanks again! :D

here is the final code with the door components:
by the way, I tried to add a pullchain, but it work only for opening the door, not to close it. Strange!
SpoilerShow

Code: Select all

defineObject{
	name = "dwarf_force_field_door",
	components = {
		{
			class = "Model",
			model = "mod_assets/dwarf/models/forcefield_door.fbx",
			offset = vec(0, 0.05, 0),
		},
		{
			class = "Light",
			offset = vec(0, 1.75, 0),
			range = 6,
			color = vec(0, 0, 0),
			brightness = 30,
			castShadow = false,
			fillLight = true,
		},
		{
			class = "Particle",
			particleSystem = "dwarf_force_field",
		},
		{
			class = "Sound",
			sound = "force_field_ambient",
		},
		{
			class = "Door",
			openVelocity = 1000,
			closeVelocity = 1000,
			closeAcceleration = -100,
			--sparse = true,
			killPillars = true,
	--		pullchainObject = "dwarf_door_button",
			hitSound = "impact_blunt",
			openSound = "force_field_cast",
			closeSound = "force_field_cast",
			lockSound = "force_field_cast",
			maxHeight = 5.0,
		},
		{
			class = "Model",
			name = "frame",
			model = "mod_assets/dwarf/models/dwarf_door_frame.fbx",
			staticShadow = true,
		},
		{
			class = "ProjectileCollider",
		},
		{
			class = "Clickable",
			offset = vec(0, 1.5, 0),
			size = vec(2.75,3,2.75),
			maxDistance = 1,
			--debugDraw = true,
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.clickable:enable()
			end,
			onInitialDeactivate = function(self)
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0)
				self.go.sound:fadeOut(0)
				self.go.light:fadeOut(0)
				self.go.clickable:disable()
			end,
			onActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.particle:fadeIn(0.1)
				self.go.sound:fadeIn(0.25)
				self.go.light:fadeIn(0.1)
				self.go.clickable:enable()
				--self.go:playSound("force_field_cast")
			end,
			onDeactivate = function(self)
				if self.go.model:isEnabled() then
					self.go:playSound("force_field_cast")
				end
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0.1)
				self.go.sound:fadeOut(0.5)
				self.go.light:fadeOut(0.5)
				self.go.clickable:disable()
			end,
			onToggle = function(self)
				if self.go.door:isEnabled() then
					self:deactivate()
				else
					self:activate()
				end
			end,
		},
	},
	placement = "wall",
	editorIcon = 272,
	tags = { "obstacle" },
}
Granamir wrote:where did u take those walls and windows and so on?
It's a custom "dwarven castle" wallset.
All models are from the castle wallset, except for the gobelin and durin's door models, which is taken from the town wallset (it's simply a rectangular 2d model)

Re: anyway to make a forcefield block only like a door?

Posted: Tue Mar 03, 2015 1:58 am
by Eburt
by the way, I tried to add a pullchain, but it work only for opening the door, not to close it. Strange!
Probably because closeVelocity needs to be negative to work properly. The acceleration isn't really necessary with such a high velocity. Actually, the acceleration should make it work as is... after ~10 seconds. Did you give it some time? Either way, negative closeVelocity should fix your problem.

Re: anyway to make a forcefield block only like a door?

Posted: Tue Mar 03, 2015 3:50 am
by minmay
bongobeat wrote:this work well, thanks again! :D

here is the final code with the door components:
by the way, I tried to add a pullchain, but it work only for opening the door, not to close it. Strange!
SpoilerShow

Code: Select all

defineObject{
	name = "dwarf_force_field_door",
	components = {
		{
			class = "Model",
			model = "mod_assets/dwarf/models/forcefield_door.fbx",
			offset = vec(0, 0.05, 0),
		},
		{
			class = "Light",
			offset = vec(0, 1.75, 0),
			range = 6,
			color = vec(0, 0, 0),
			brightness = 30,
			castShadow = false,
			fillLight = true,
		},
		{
			class = "Particle",
			particleSystem = "dwarf_force_field",
		},
		{
			class = "Sound",
			sound = "force_field_ambient",
		},
		{
			class = "Door",
			openVelocity = 1000,
			closeVelocity = 1000,
			closeAcceleration = -100,
			--sparse = true,
			killPillars = true,
	--		pullchainObject = "dwarf_door_button",
			hitSound = "impact_blunt",
			openSound = "force_field_cast",
			closeSound = "force_field_cast",
			lockSound = "force_field_cast",
			maxHeight = 5.0,
		},
		{
			class = "Model",
			name = "frame",
			model = "mod_assets/dwarf/models/dwarf_door_frame.fbx",
			staticShadow = true,
		},
		{
			class = "ProjectileCollider",
		},
		{
			class = "Clickable",
			offset = vec(0, 1.5, 0),
			size = vec(2.75,3,2.75),
			maxDistance = 1,
			--debugDraw = true,
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.clickable:enable()
			end,
			onInitialDeactivate = function(self)
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0)
				self.go.sound:fadeOut(0)
				self.go.light:fadeOut(0)
				self.go.clickable:disable()
			end,
			onActivate = function(self)
				self.go.model:enable()
				self.go.door:enable()
				self.go.particle:fadeIn(0.1)
				self.go.sound:fadeIn(0.25)
				self.go.light:fadeIn(0.1)
				self.go.clickable:enable()
				--self.go:playSound("force_field_cast")
			end,
			onDeactivate = function(self)
				if self.go.model:isEnabled() then
					self.go:playSound("force_field_cast")
				end
				self.go.model:disable()
				self.go.door:disable()
				self.go.particle:fadeOut(0.1)
				self.go.sound:fadeOut(0.5)
				self.go.light:fadeOut(0.5)
				self.go.clickable:disable()
			end,
			onToggle = function(self)
				if self.go.door:isEnabled() then
					self:deactivate()
				else
					self:activate()
				end
			end,
		},
	},
	placement = "wall",
	editorIcon = 272,
	tags = { "obstacle" },
}
You should not use a pullchain for this object. It will only open/close the door instead of properly activating/deactivating the controller. Use a custom button instead.

Re: anyway to make a forcefield block only like a door?

Posted: Tue Mar 03, 2015 12:51 pm
by Granamir
bongobeat wrote:
Granamir wrote:where did u take those walls and windows and so on?
It's a custom "dwarven castle" wallset.
All models are from the castle wallset, except for the gobelin and durin's door models, which is taken from the town wallset (it's simply a rectangular 2d model)
Ty, and is it downloadable somewere?

Re: any way to make a forcefield block only like a door?

Posted: Fri Mar 06, 2015 8:26 pm
by bongobeat
Eburt wrote:
by the way, I tried to add a pullchain, but it work only for opening the door, not to close it. Strange!
Probably because closeVelocity needs to be negative to work properly. The acceleration isn't really necessary with such a high velocity. Actually, the acceleration should make it work as is... after ~10 seconds. Did you give it some time? Either way, negative closeVelocity should fix your problem.
minmay wrote:You should not use a pullchain for this object. It will only open/close the door instead of properly activating/deactivating the controller. Use a custom button instead.
Thanks for your answers, I'm using some kind of custom buttons to open it.
Granamir wrote: Ty, and is it downloadable somewere?
no it is not:

I did not thought to share it as it is some kind of "bricolage" wallset (sorry don't know the word in english, google gives me a word that I dont think is the proper translation :oops: ). I dont have proper specular and normal textures for the 5 or 6 additional textures (diffuse) used in this wallset. Instead of that, I use castle or tomb specular and normal. Except for the blue brick wall, which Maneus did it for me. This is make specially to don't load too much textures, or only log2 textures. I dont intend to make any other proper normal or spec textures, because I have already too much textures in my mod. So this is not a clean wallset to be shared.

Anyway if you want to use the door, I can send you the texture file with definition.

Re: any way to make a forcefield block only like a door?

Posted: Fri Mar 06, 2015 11:58 pm
by Granamir
np i got it, we use bricolage too here in Italy.
i was interested in windows if possible, otherwise don't worry i will figure out a way to solve it
ty anyway