Re: Useful scripts repository
Posted: Sun Sep 23, 2012 10:19 am
Updated my script so that it puts the display on a wall in the direction of the script entities' facing.
Official Legend of Grimrock Forums
http://almosthumangames.com/forum/
Code: Select all
function scareshake()
party:shakeCamera(1,1)
end
Code: Select all
playSound("earthquake")
Code: Select all
defineSound{
name = "earthquakestop",
filename = "assets/samples/env/earthquake_01.wav",
loop = false,
volume = 1,
minDistance = 1,
maxDistance = 6,
}
Code: Select all
spawn("fx", 1, 15, 15, 3, "dust")
dust:setParticleSystem("earthquake_dust")
Code: Select all
-- returns the name of a random living and not disabled champion
function getRandomLivingChamp()
local charnumber = ""
repeat charnumber = math.random(1,4)
until party:getChampion(charnumber):getEnabled() and party:getChampion(charnumber):isAlive()
return party:getChampion(charnumber):getName()
end
Code: Select all
-- returns how many characters are still alive and enabled
function checkLifeSigns()
local lifesigns = 0
for i=1,4 do
if party:getChampion(i):getEnabled() and party:getChampion(i):isAlive() then
lifesigns = lifesigns+1
end
end
return lifesigns
end
Code: Select all
-- lets two random champions talk with each other
-- if only one champion is alive, he will talk with himself
function champTalk(line1,line2,line3)
local firstTalker = getRandomLivingChamp()
local secondTalker = firstTalker
if line1 == nil then
return
else
hudPrint(firstTalker..": "..line1)
end
if line2 ~= nil then
if checkLifeSigns() > 1 then
repeat secondTalker = getRandomLivingChamp()
until secondTalker ~= firstTalker
end
hudPrint(secondTalker..": "..line2)
end
if line3 ~= nil then
hudPrint(firstTalker..": "..line3)
end
end
Code: Select all
function banter()
your_script_entity.champTalk("How are YOU doin'?", "Seriously? We're in the middle of a bloody dungeon!", "T'was worth a shot.")
end
Beware though: since the characters that talk are random, it might just be Mork chatting with SancsaronContar Stoneskull: How are YOU doin'?
Yennicka Whitefeather: Seriously? We're in the middle of a bloody dungeon!
Contar Stoneskull: Well... it was worth a shot.
Code: Select all
cloneObject{
name = "lock_high",
baseObject = "lock",
height = 1.743,
placement = "wall",
editorIcon = 20,
}
Code: Select all
function activate()
if counter_1:getValue() == 5 then -- Change the number to match how many text strings that you use.
--[[ Optional place to put code for a trap
spawner_1:activate()
spawner_2:activate()
--]]
counter_1:reset()
return
end
local Info = {"Stay off the plate!", "Stop That!", "You are going to regret this!", "One more time and it's Goodbye! You've been warned."}
dungeon_wall_text_1:setWallText(Info[counter_1:getValue()])
counter_1:increment()
end
Code: Select all
function activate()
for x = 1,4 do
local PCRace = party:getChampion(x):getRace()
local isLucid = party:getChampion(x):isAlive()
if PCRace == "Minotaur" and isLucid then
dungeon_wall_text_2:setWallText("The etherial wall is to the East.")
end
end
end
Code: Select all
function deactivated()
dungeon_wall_text_2:setWallText("This text is indecipherable")
end
Code: Select all
cloneObject{
name = "destructible_cave_in",
baseObject = "dungeon_cave_in", -- you might want to change this to temple_cave_in or the prison one
brokenModel = "assets/models/env/floor_dirt.fbx", -- if anyone can find a better standard model for this, give me a shout
health = 50, -- adjust this to your needs
evasion = -1000,
hitEffect = "hit_dust",
hitSound = "impact_generic",
onProjectileHit = function()
return false -- projectiles (arrows and such) shouldn't be able to destroy it
end,
onHit = false, -- this is used to negate the "indestructible" property
onDie = function(self)
-- when blockage is destroyed, spawn 2-5 rocks
rocks = math.random(1,4)+1
for i = 1,rocks do
spawn("rock", self.level, self.x, self.y, i%4)
end
end
}
Code: Select all
defineObject{
name = "dungeon_pillar_center",
class = "Blockage",
model = "assets/models/env/dungeon_pillar.fbx",
placement = "floor",
repelProjectiles = true,
hitSound = "impact_blade",
editorIcon = 100,
}
Code: Select all
defineObject{
name = "prison_pillar_center",
class = "Blockage",
model = "assets/models/env/prison_pillar.fbx",
placement = "floor",
repelProjectiles = true,
hitSound = "impact_blade",
editorIcon = 100,
}
Code: Select all
defineObject{
name = "temple_pillar_center",
class = "Blockage",
model = "assets/models/env/temple_pillar.fbx",
placement = "floor",
repelProjectiles = true,
hitSound = "impact_blade",
editorIcon = 100,
}
Code: Select all
function openport()
if
oddplate1:isUp() and
oddplate2:isUp() and
oddplate3:isUp() and
oddplate4:isUp() and
oddplate5:isUp() and
evenplate1:isDown() and
evenplate2:isDown() and
evenplate3:isDown() and
evenplate4:isDown()
then
checkeredport:open()
elseif
oddplate1:isDown() and
oddplate2:isDown() and
oddplate3:isDown() and
oddplate4:isDown() and
oddplate5:isDown() and
evenplate1:isUp() and
evenplate2:isUp() and
evenplate3:isUp() and
evenplate4:isUp()
then
checkeredport:open()
else
checkeredport:close()
end
end
Code: Select all
timecount = 1
function tick()
if timecount == 1 then
-- spawn object 1 here
elseif timecount == 2 then
-- spawn object 2 here
elseif timecount == 3 then
-- spawn object 3 here
elseif timecount == 4 then
-- spawn object 4 here
elseif timecount == 5 then
-- spawn object 5 here
elseif timecount == 6 then
-- spawn object 6 here and in this example it's the last object on our list)
cooltimer:deactivate()
-- so then we can loop back to the beginning here by uncommenting the next two lines if we want to:
-- timecount = 1
-- return
end
timecount = timecount + 1
end
Code: Select all
cloneObject{
name = "sacrificial_dagger",
baseObject = "dagger",
uiName = "Sacrificial Dagger",
gfxIndex = 142,
model = "assets/models/items/assassin_dagger.fbx",
description = "Dark energy emanates from this ritualistic blade",
gameEffect = "Place against a comrade's throat to complete the dark ritual",
weight = 1.0,
emptyItem = "sacrificial_dagger_used",
onUseItem = function(self, champion)
playSound("party_crushed")
champion:damage(10000, "physical")
hudPrint(champion:getName().." has been sacrificed.")
return true
end,
}
cloneObject{
name = "sacrificial_dagger_used",
baseObject = "dagger",
uiName = "Sacrificial Dagger",
gfxIndex = 142,
model = "assets/models/items/assassin_dagger.fbx",
description = "The essence of your comrade pulses within the blade",
attackPower = 10,
weight = 1.0,
}