[SOLVED] Teleporters that don't conserve momentum?

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

[SOLVED] Teleporters that don't conserve momentum?

Post by Zo Kath Ra »

I've made a simple test dungeon with a 4-sided teleporter.
Depending on what direction you enter the teleporter from, it takes you to one of four possbile destinations (done with floor triggers and scripts that change the teleporter destination).

When you fall into the teleporter from above, it takes you to a 5th destination.
Problem: teleporters conserve momentum.

There are a few solutions in this thread, but they aren't exactly what I'm looking for:
http://grimrock.net/forum/viewtopic.php?f=14&t=8406

Is there any way to make a teleporter not conserve momentum?
Last edited by Zo Kath Ra on Thu May 28, 2015 3:13 pm, edited 1 time in total.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Teleporters that don't conserve momentum?

Post by minmay »

Use party.gravity:setFallingSpeed() to remove their vertical momentum.
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
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Teleporters that don't conserve momentum?

Post by Zo Kath Ra »

minmay wrote:Use party.gravity:setFallingSpeed() to remove their vertical momentum.
I've put a floor trigger under the teleporter.
The floor trigger is linked to a script that calls party.gravity:setFallingSpeed(0)
This solution doesn't work, because the floor trigger doesn't get activated (teleporter has a higher priority).
It doesn't matter if I walk into the teleporter from the same elevation, or if I fall into it from above.

Then I put a floor trigger on the destination square.
The floor trigger does get activated, but only after the party takes falling damage.

Since there are no "onEnterTeleporter" or "onLeaveTeleporter" hooks, I guess I'll just have to put a water tile at the destination.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Teleporters that don't conserve momentum?

Post by minmay »

Put floor triggers in the air squares above the teleporter that the party can walk into, and check the party's position every frame after they are triggered.
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
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Teleporters that don't conserve momentum?

Post by Zo Kath Ra »

Place a script entity called "script_entity_1" in a level and put this code in it:

Code: Select all

function timerTick()
	local level, x, y, elevation = teleporter_1.teleporter:getTeleportTarget()
	
	if ((party.level == level) and (party.x == x) and (party.y == y) and (party.elevation == elevation)) then
		party.gravity:setFallingSpeed(0)
		timer_1.timer:disable()
	end
end
Place a timer called "timer_1" in the same level, and
- disable its timer component
- set its timerInterval to 0
- set its onActivate connector to script_entity_1 / timerTick

Place a teleporter called "teleporter_1" in the level at h=0.
The teleporter_1's destination should be at ground level.

Place a floor trigger called "floor_trigger_1" above teleporter_1, and set its onActivate connector to timer_1 / start

When you walk onto floor_trigger_1 (from a tile that has the same elevation), you will fall into teleporter_1, and emerge at its destination without taking falling damage.
Post Reply