Legend of Grimrock
0 of 0

File information

Last updated

Original upload

Created by

Roman Adler

Uploaded by

Roman42

Virus scan

Safe to use

Documentation

Readme

View as plain text

Earth Goromorg v1.1
by Roman Adler in 2012
######################

Magic: Greater Poison Bolt, Poison Bolt, sometimes Poison Cloud (when near)

Immunity: Earth, Poison

HP: 600 (regular Goromorg 400)
XP: 1200 (1000)
Power 50 (40)

Magic Shield is working, thanks to Diarmuid's damageTracker script.

Changelog: 1.2
--------------
Added Diarmuid' latest Shield Script! No the shield is rendered on the Goromorg,
not on the tile on which he gets hit. It's a perfect Goromorg now.

Installation:
-------------
Drop the "earth_goromorg" folder into your "mod_assets" folder and add the
following lines to your init.lua:

import "mod_assets/earth_goromorg/monsters.lua"
import "mod_assets/earth_goromorg/materials.lua"

To make his magic shield work, you have to copy/paste the following LUA script_entity
somewhere to your dungeon map and name it "damageTracker":

---cut---

--[[
Diarmuid's Goromorg Shield script, Version 1.1

Changelog:
1.1 Shield visual effect now moves along if monster moves
Shield sound effect is now played at monster's location
Simplified monster properties table
1.0 Initial release

Readme:
Add the following hooks to your monster(s):
onDamage = function(self,damage,type)
return damageTracker.shield(self,damage)
end,

onMove = function(self, direction)
return damageTracker.createMoveTimer(self, direction)
end,

onDie = function(self)
return damageTracker.clear(self)
end,

Then define the monster(s) in monstersTable below using the following properties:

shield: sets how much damage the shield can take before breaking
immunity: "fire", "frost", "poison", "shock" or "none"
(If elemental, you will get a "0" over the monster, if "none", just the shield visual)
shieldVAlign: adjusts the shield effect vertical alignment. Positive values go upwards.
shieldSize: adjusts the size of the shield effect. Values below 1 = smaller, above 1 = larger.
moveSpeed: adjusts the speed at which the shield moves with monster. Values below 1 = slower, above 1 = faster.

]]

damageTable = {}

timersTable = {}

monstersTable = {
earth_goromorg = {
shield = 300,
immunity = "earth",
shieldVAlign = 0,
shieldSize = 1,
moveSpeed = 1,
},
}


function shield(monster, damage)
if damage > 0 then
local shieldActive = false
if damageTable[monster.id] == nil then
damageTable[monster.id] = damage
shieldActive = true
elseif damageTable[monster.id] < monstersTable[monster.name].shield then
damageTable[monster.id] = damageTable[monster.id] + damage
shieldActive = true
end
if shieldActive == true then

if monstersTable[monster.name].immunity ~= 'none' then
damageTile(monster.level, monster.x, monster.y, monster.facing, 0, monstersTable[monster.name].immunity,0)
end

local fxId = monster.id..".shield"
if findEntity(fxId) ~= nil then
findEntity(fxId):destroy()
end
spawn("fx", monster.level, monster.x, monster.y, monster.facing,fxId)
findEntity(fxId):setParticleSystem("shield_glow")
local dx,dy = getForward(party.facing)
local shieldSize = monstersTable[monster.name].shieldSize
local shieldVAlign = monstersTable[monster.name].shieldVAlign
findEntity(fxId):translate(-dx*0.6*shieldSize,shieldVAlign,dy*0.6*shieldSize)

local timerId = monster.id..'.moveTimer'
if findEntity(timerId) ~= nil then
local mx, my = getForward(timersTable[timerId].direction)
local moveSpeed = monstersTable[monster.name].moveSpeed
local x, y = unpack(timersTable[timerId].position)
findEntity(fxId):translate(mx*0.2*timersTable[timerId].tick*moveSpeed,0,-my*0.2*timersTable[timerId].tick*moveSpeed)
if x ~= monster.x or y ~= monster.y then
print("Translated")
findEntity(fxId):translate(-mx*3,0,my*3)
end
end
if damageTable[monster.id] < monstersTable[monster.name].shield then
playSoundAt("goromorg_shield_hit", monster.level, monster.x, monster.y)
else
playSoundAt("goromorg_shield_break", monster.level, monster.x, monster.y)
end

return false
end
return damage
end
end

function clear(monster)
damageTable[monster.id] = 0
local fxId = monster.id..".shield"
if findEntity(fxId) ~= nil then
findEntity(fxId):destroy()
end
end

function createMoveTimer(monster, direction)
local level, x, y = monster.level, monster.x, monster.y
local timerId = monster.id..'.moveTimer'
if findEntity(timerId) ~= nil then
findEntity(timerId):destroy()
end
local moveTimer = spawn('timer', level, x, y, 0, timerId)
moveTimer:addConnector('activate', 'damageTracker', 'moveTimer')
moveTimer:setTimerInterval(0.05)
moveTimer:activate()
timersTable[timerId] = {}
timersTable[timerId].id = monster.id
timersTable[timerId].direction = direction
timersTable[timerId].position = {x, y}
end

function moveTimer(self)
timerId = self.id
if timersTable[timerId].tick == nil then
timersTable[timerId].tick = 0
end
timersTable[timerId].tick = timersTable[timerId].tick + 1
fxId = timersTable[timerId].id..'.shield'
if findEntity(fxId) ~= nil then
local dx, dy = getForward(timersTable[timerId].direction)
local monster = findEntity(timersTable[timerId].id)
local moveSpeed = monstersTable[monster.name].moveSpeed
findEntity(fxId):translate(dx*0.2*moveSpeed,0,-dy*0.2*moveSpeed)
end
if timersTable[timerId].tick == 15 then
timersTable[timerId].tick = 0
self:destroy()
end
end

---cut---