Page 376 of 396

Re: Ask a simple question, get a simple answer

Posted: Sun Mar 28, 2021 4:49 pm
by bongobeat
Pls can someone help me to figure this?

I'm trying to do a new door, without real animation, and do a fake animation because of the firearms shots that are blocked around the real beach_master_gate.
SpoilerShow

Code: Select all

defineObject{
	name = "beach_master_gate_new",
	baseObject = "base_wall_decoration",
	components = {
		{
			class = "Model",
			model = "mod_assets/models/beach_master_gate_frame.fbx",
			rotation = vec(0, 180, 0),
			staticShadow = true,
		},
		{
			class = "Model",
			name = "door1",
			model = "mod_assets/models/beach_master_gate_left_door.fbx",
			offset = vec(1.5, 0, 0),
			staticShadow = true,
		},
		{
			class = "Model",
			name = "door2",
			model = "mod_assets/models/beach_master_gate_right_door.fbx",
			offset = vec(-1.5, 0, 0),

			staticShadow = true,
		},
		{
			class = "Timer",
			enabled = false,
			currentLevelOnly = true,
			timerInterval = 0,
--			DisableSelf = true,
			onActivate = function(self)
				local time = Time.currentTime()*128
	self.go.door1:setRotationAngles(0, time%360, 0)
	self.go.door1:setRotationAngles(0, time*1.4%360, 0)
			end,
		},
		{
			class = "Timer",
			enabled = false,
			name = "timer2",
			currentLevelOnly = true,
			timerInterval = 0,
--			DisableSelf = true,
			onActivate = function(self)
				local time = Time.currentTime()*128
	self.go.door2:setRotationAngles(0, -time%360, 0)
	self.go.door2:setRotationAngles(0, -time*1.4%360, 0)
			end,
		},
		{
			class = "Controller",
			onInitialActivate = function(self)
				self.go.timer:enable()
				self.go.timer2:enable()
--				playSound("master_gate_open")
			end,
			onInitialDeactivate = function(self)
				self.go.timer:disable()
				self.go.timer2:disable()
			end,
			onActivate = function(self)
				self.go.timer:enable()
				self.go.timer2:enable()
				playSound("master_gate_open")
			end,
			onDeactivate = function(self)
				self.go.timer:disable()
				self.go.timer2:disable()
			end,
			onToggle = function(self)
				self.go.timer:disable()
				self.go.timer2:disable()
			end,
		},

	},
	editorIcon = 92,
--	minimalSaveState = true,
}
It is a custom beach master gate that some of the models can be rotated according to the internal timers and script.
Problem is in this way, the fake door acts not nicely. I don't know how to work that formula with time and angle rotation.

The fake doors has to rotate 90° on z axis, in max 3 seconds (time for playing the master gate opening sound)

I have taken that formula from minmay's asset megapack (used for the prison walls).

Re: Ask a simple question, get a simple answer

Posted: Mon Mar 29, 2021 5:57 am
by minmay
May I suggest a slightly easier fix? Go back to the original beach_master_gate and just change the AnimationComponent like so:

Code: Select all

defineObject{
	name = "beach_master_gate",
	baseObject = "beach_master_gate",
	components = {
		{
			class = "Animation",
			animations = {
				open = "assets/animations/env/beach_master_gate_open.fbx",
			},
			onAnimationEvent = function(self, event)
				if event == "open" then
					self.go:removeComponent("door") -- only change: remove DoorComponent instead of just disabling it
				end
			end,
		},
	},
}

Re: Ask a simple question, get a simple answer

Posted: Tue Apr 06, 2021 11:28 am
by bongobeat
thanks for your answer

have trying this, but this does not resolve the firearms blocking completely, if you stand in front of the door, a few tile in the back, it is ok.

But if you take one step to the right or the left, and shoot in direction of the "frame" of the door, that bug is still there.

Seems that the "frame" of the door (the stone parts) got invisible blocker all around.

Actually what I managed is to set the door to "open" and place an invisible blocker behind that will be deactivated or destroyed when using the normal way to open the door, like a key or a floor trigger.

The only visible issue now, is that, when you pass between the opened wooden doors, the whole wooden doors disappears from the screen (not the stone parts), and come back if you look in a different direction.

Re: Ask a simple question, get a simple answer

Posted: Tue Apr 06, 2021 9:47 pm
by minmay
bongobeat wrote: Tue Apr 06, 2021 11:28 amBut if you take one step to the right or the left, and shoot in direction of the "frame" of the door, that bug is still there.

Seems that the "frame" of the door (the stone parts) got invisible blocker all around.
This should go away after the removeComponent() call. If you don't want this collision even when the door is closed, then it sounds like you don't want to use DoorComponent's automatic collision handling at all, and should get rid of the DoorComponent entirely, or use a separate object with a smaller gate node.
bongobeat wrote: Tue Apr 06, 2021 11:28 amThe only visible issue now, is that, when you pass between the opened wooden doors, the whole wooden doors disappears from the screen (not the stone parts), and come back if you look in a different direction.
That's because opening the DoorComponent offsets the bounding box for the model, which is why I removed the DoorComponent instead of just opening it.

Re: Ask a simple question, get a simple answer

Posted: Tue Jun 01, 2021 9:20 am
by Lorial
Is there a way to use "global" timers that count down reliably whether the player is on the respective level or not?

When I trigger an event with a timer object via script and leave the level, the time seems to run a lot slower and a 10 second timer activates roughly a minute later. Been using this method for monster and fish respawns (30 to 60 minutes), so these probably hardly every activated during a playthrough, I guess.

Re: Ask a simple question, get a simple answer

Posted: Tue Jun 01, 2021 11:55 am
by Zo Kath Ra
Lorial wrote: Tue Jun 01, 2021 9:20 am Is there a way to use "global" timers that count down reliably whether the player is on the respective level or not?
Yes, by attaching timers to the party.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 03, 2021 6:51 am
by Lorial
Zo Kath Ra wrote: Tue Jun 01, 2021 11:55 am Yes, by attaching timers to the party.
Yeah, that makes sense. However, I have never used any party hooks before, so I'm rather clueless. Do I have to define the party as an object first or how does that work? Mind giving an example on how to connect a timer or any trigger to the party?

On another note: Would one be able to check whether the party is submerged?
Thinking waterbreathing horn that only works underwater as aquatic-only is not an option. Perhaps with a limited underwater light spell as a search light on top of that (looking at you, murky swamp water).

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 03, 2021 9:50 am
by Zo Kath Ra
Lorial wrote: Thu Jun 03, 2021 6:51 am
Zo Kath Ra wrote: Tue Jun 01, 2021 11:55 am Yes, by attaching timers to the party.
Yeah, that makes sense. However, I have never used any party hooks before, so I'm rather clueless. Do I have to define the party as an object first or how does that work? Mind giving an example on how to connect a timer or any trigger to the party?
One way is to redefine the party object, by putting this code at the end of init.lua

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
			class = "Timer",
			name = "party_timer_1",
			onActivate = function(self)
				print(self:getName(), "onActivate", Time.currentTime())
			end,
			onInit = function(self)
				print(self:getName(), "onInit")
				self:setTimerInterval(0)
			end,
		},
	},
}
Or you can attach timers to the party dynamically:
http://www.grimrock.net/forum/viewtopic ... 23#p121823

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 03, 2021 5:04 pm
by Isaac
Lorial wrote: Thu Jun 03, 2021 6:51 am On another note: Would one be able to check whether the party is submerged?
The short answer is, "no"; however it is possible to check what tile type they are on, and that can be type 2 (water) ; and if their elevation is below zero, then they are probably submerged in it.

Code: Select all

party.map:getAutomapTile(party.x, party.y)

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 03, 2021 6:58 pm
by 7Soul
Lorial wrote: Thu Jun 03, 2021 6:51 am On another note: Would one be able to check whether the party is submerged?
Thinking waterbreathing horn that only works underwater as aquatic-only is not an option. Perhaps with a limited underwater light spell as a search light on top of that (looking at you, murky swamp water).
Pretty sure this still works:

Code: Select all

local waterLevel = -10
for entity in Dungeon.getMap(party.level):allEntities() do
	if entity and entity.watersurface then
		waterLevel = -0.6
	end
end

if party:getWorldPositionY() < waterLevel then
	-- party is underwater
end