Scroll of Safe Teleport Home

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Eczarkun
Posts: 9
Joined: Sun Dec 09, 2012 6:48 pm
Location: FRANCE

Scroll of Safe Teleport Home

Post by Eczarkun » Mon Jan 21, 2013 10:51 pm

Hello everyone,
Sorry for my bad english and i'm really a newbie there.

One of my first work is a Safe Teleport Home, it's important to use the wonderfull LoG Framework from JKos with the use of the t.lua (with the lua object testpoint).
The idea is to propose the player on a dungeon something like a complete appartment where he can stack his goods, have safe rest, a cosy room from where he can get back to the dungeon (for now only by different teleporters to each level).

First, the definition of the scroll and the spell:
SpoilerShow
defineSpell{
name = "leomunds_secure_shelter",
uiName = "Leomund's Secure Shelter",
skill = "spellcraft",
level = 5,
runes = "ACGI",
manaCost = 20,
onCast = function(party)
testpoint_1.run(testpoint_1)
end,
}

defineObject{
name = "leomunds_secure_shelter_scroll",
class = "Item",
uiName = "Leomund's Secure Shelter Scroll",
model = "assets/models/items/scroll_spell.fbx",
gfxIndex = 113,
scroll = true,
spell = "leomunds_secure_shelter",
weight = 0.3,
}
then the function in the tespoint_1:
SpoilerShow
function run(testpoint)
if type(testpoint) ~= 'table' or testpoint.name ~= 'testpoint' then
print('Invalid testpoint')
return
end
t.to(testpoint)
if testpoint.activate then
testpoint.activate()
end
end
The next idea is to create "Leomund's Secure Return" spell, but i don't know how to script it yet... perhaps by dropping an object/casting a spell on the floor doing the same use as the testpoint, memorize the location of this object, and create the spell calling for these coordonates. ;)

User avatar
Ixnatifual
Posts: 731
Joined: Mon Apr 16, 2012 5:23 pm

Re: Scroll of Safe Teleport Home

Post by Ixnatifual » Tue Jan 22, 2013 8:04 am

That's a very good idea. Especially the storing of items.

User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Scroll of Safe Teleport Home

Post by crisman » Tue Jan 22, 2013 6:40 pm

You can memorize the coordinates in 4 variables (X, Y, F, L), when you cast the ReturnHome spell.
You just have to define them before a function, for example, in a script_entity you will have

Code: Select all

X = 0
Y = 0
L = 0
F = 0

function returnHome()
X = party.x,
Y = party.Y,
L = party.level,
F = party.facing,

party:setPosition(home coords)
end

function returnBack()

party:setPosition(X,Y,F,L)

end

User avatar
Eczarkun
Posts: 9
Joined: Sun Dec 09, 2012 6:48 pm
Location: FRANCE

Re: Scroll of Safe Teleport Home

Post by Eczarkun » Fri Jan 25, 2013 11:14 pm

Hi everyone and thanks to crisman,
It took me some times to understand how to launch your script because i was trying another way to do it and because i'm really a newbie. Anyway, here are the finals (i'm too lasy to put some FX on the spells):
On the same time your code do the same as the use as the t.lua with the original code, so it may be easyier to make it work for everyone.

here is an add to a lua file (spells.lua or specific lua file imported in the init.lua)
SpoilerShow
defineSpell{
name = "leomunds_secure_shelter", -- name = "abri_sur_de_leomund"
uiName = "Leomund's Secure Shelter", -- uiName "Abri sur de Leomund"
skill = "spellcraft",
level = 25,
runes = "ACGI",
manaCost = 20,
onCast = function()
returnScript.backPosition(party)
end,
}

defineObject{
name = "leomunds_secure_shelter_scroll", -- name = "parchemin_abri_sur_de_leomund"
class = "Item",
uiName = "Leomund's Secure Shelter Scroll", -- uiName "Parchemin d'arbi sur de Leomund"
model = "assets/models/items/scroll_spell.fbx",
gfxIndex = 113,
scroll = true,
spell = "leomunds_secure_shelter", -- spell = "abri_sur_de_leomund",
weight = 0.3,
}

defineSpell{
name = "leomunds_return_shelter", -- name = "retour_abri_de_leomund"
uiName = "Leomund's retun Shelter", -- uiName = "Retour de l'abri de Leomund"
skill = "spellcraft",
level = 25,
runes = "ACEGI",
manaCost = 20,
onCast = function()
returnScript.backReturn(party)
end,
}

defineObject{
name = "leomunds_return_shelter_scroll", -- name = "parchemin_retour_abri_de_leomund"
class = "Item",
uiName = "Leomund's return Shelter Scroll", -- uiName = "Parchemin de retour de l'abri de Leomund"
model = "assets/models/items/scroll_spell.fbx",
gfxIndex = 113,
scroll = true,
spell = "leomunds_return_shelter", -- spell = "retour_abri_de_leomund"
weight = 0.3,
}
You have to define a "script_entity" witch ID is "returnScript":
SpoilerShow
-- Define Locals from Home
Xhome = 16 -- X coord from Home
Yhome = 15 -- Y coord from Home
Lhome = 2 -- Level coord from Home
Fhome = 3 -- 0=South 1=Est 2=North 3=West %4 (modulo 4)

-- Initialize Locals from return
Xreturn = 0
Yreturn = 0
Lreturn = 0
Freturn = 0

function backPosition()
-- Memorization of the position
Xreturn = party.x
Yreturn = party.y
Lreturn = party.level
Freturn = party.facing

-- Testing hook
hudPrint("The Sorcerer draws a power cercle on the floor...")
-- hudPrint("Le Sorcier trace un cercle de pouvoir au sol...")

-- Teleportation to Home
party:setPosition(Xhome,Yhome,Fhome,Lhome)
end

function backReturn()
-- Teleportation from Home

-- Testing hook
hudPrint("You seems to be ready to face the danger again...")
-- hudPrint("Vous semblez etre prets a retourner affronter le danger...")

-- Teleportation to the dungeon
party:setPosition(Xreturn,Yreturn,Freturn,Lreturn)
end

Post Reply