Isaac wrote:Code: Select all
-- replace <monsterId> and replace <dialog function> with the name of your called function in quotes.
<monster_Id>.monster:addConnector('onDie', self.go.id, <dialog function>)
Howl3r wrote:Code: Select all
<warden_1>.monster:addConnector('onDie', self.go.id, <"function die">)
Based on your example, this is how it should be:
Code: Select all
warden_1.monster:addConnector('onDie', self.go.id, "function die")
**BUT... this is only correct for LoG2; (my mistake in not spotting the thread section/title... I'm assuming you are using LoG1)
... and it doesn't work like that in LoG1.
[AFAIK] LoG1 monsters cannot have connectors, it has to be done with hooks in the definition.
So...
What you'll need to do is open the monsters.lua file in your project's scripts folder.
On Windows [Vista/7/+], this is typically found in your documents folder here:
*Try pasting the following into the file name field in your text editor (like Windows Notepad) address bar:
Code: Select all
"%systemdrive%\%userprofile%\documents\Almost Human\Legend of Grimrock\Dungeons"
, and then choose the folder with the same name as your project, then the mod_assets folder, then scripts; and open the Monsters.lua file.
Alternatively: In a text editor, choose to open a file, and navigate to your documents folder, then further into the 'Almost Human' folder; then into the 'Legend of Grimrock' folder, then dungeons; then the name of your map ~folder, then mod_assets, then ~finally the script's folder, where you select monsters.lua
Once you have the file open, paste this script into it, and save it.
Code: Select all
cloneObject{
name = "talkative_warden",
baseObject = "warden",
onDie = function(self) if lastWord then lastWord:speak()
end
local spawnPoints = {"sWarden_1", "sWarden_2"}
for c = 1, #spawnPoints do
local delay = spawn("timer", self.level, self.x, self.y, 0)
delay:setTimerInterval(math.random(2)+1)
delay:addConnector("activate", spawnPoints[c], "nSpawn")
delay:addConnector("activate", delay.id, "deactivate")
delay:activate()
end
end
}
Then place two script_entities where you want the two other wardens to appear. name them sWarden_1 and sWarden_2; face them appropriately.
In each script paste the following:
Code: Select all
--Place a copy of this script_entity where each Warden should spawn; and with correct facing.
default = "talkative_warden"
function nSpawn(caller, monsterName)
local monsterName = monsterName or default
if lastWord.next < #lastWord.statements then
spawn(monsterName, self.level, self.x, self.y, self.facing)
spawn("fx", self.level, self.x, self.y, self.facing):setParticleSystem("crystal")
playSoundAt("teleport", self.level, self.x, self.y)
end
end
Place the new asset 'talkative_warden' as your initial warden/boss enemy, and when it dies the other two will spawn. Each has a parting remark that you can customize in the next script.
Code: Select all
next = 1
statements = {
"You've got a lot to learn before you beat me, try again kiddo!",
"The Force is strong with this one.",
"Never tell me the odds!",
}
function speak(self)
if next <= #statements then
hudPrint(statements[next])
next = next + 1
end
end
Paste the above into a script_entity named lastWord
_________________________
The above script set is simplified version that only spawns two, and only supports three hudPrinted statements; but the one below, supports as many as one wants, and is designed to spawn a single warden randomly from among a set of spawn locations.
Code: Select all
cloneObject{
name = "talkitive_warden",
baseObject = "warden",
onDie = function(self) if lastWord then lastWord:speak()
end
local spawnPoints = {""}
local count = 0
for each in allEntities(self.level) do
if each.nSpawn then
count = count +1
spawnPoints[count] = each.id
end
end
local delay = spawn("timer", self.level, self.x, self.y, 0)
delay:setTimerInterval(math.random(2)+1)
delay:addConnector("activate", spawnPoints[math.random(#spawnPoints)], "nSpawn")
delay:addConnector("activate", delay.id, "deactivate")
delay:activate()
end
}
Code: Select all
--Place a copy of this script_entity everywhere a Warden should spawn; and with correct facing.
default = "talkitive_warden"
function nSpawn(caller, monsterName)
local monsterName = monsterName or default
if lastWord.next <= #lastWord.statements then
local cancel = false
for each in entitiesAt(self.level, self.x, self.y) do
if each.class == "monster" then
cancel = true
end
end
if not cancel then
spawn(monsterName, self.level, self.x, self.y, self.facing)
spawn("fx", self.level, self.x, self.y, self.facing):setParticleSystem("crystal")
playSoundAt("teleport", self.level, self.x, self.y)
end
end
end
Code: Select all
next = 1
statements = {
"You've got a lot to learn before you beat me, try again kiddo!",
"The Force is strong with this one.",
"Never tell me the odds!",
"We were not the droids you were looking for!",
"We seem to be made to suffer. Its our lot in life.",
}
function speak(self)
if next <= #statements then
hudPrint(statements[next])
next = next + 1
end
end