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

Re: Ask a simple question, get a simple answer

Post 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).
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

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

Re: Ask a simple question, get a simple answer

Post 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.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post 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.
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.
User avatar
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post 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.
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post 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.
User avatar
Lorial
Posts: 91
Joined: Sat Dec 29, 2018 12:27 pm

Re: Ask a simple question, get a simple answer

Post 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).
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post 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
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post 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)
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post 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
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
Post Reply