I am new to modding and I am not that high level in lua scripting, although I learned already a bit about scripting.
Now to my problem.
I successfully created a Zo-spell to open doors in Grimrock 2.
I am already able to open with it a special named door with the id "zo".
But I want to be able to open doors with more than one "zo"-id. I want to open doors with id-numbers from 1 to 500 (so on projectile hit, one door with the id zo_1 or zo_2 or zo_3 etc. shall open).
That's because I need many ids to place up to 500 doors with a "zo"-id in my custom dungeon which are openable by my spell.
The problematic spript part is written in yellow and I need it modified to my needs.
Please help!
Here is my script.
My Zo Spell:
defineSpell{
name = "zo_spell",
uiName = "Zo Spell",
skill = "concentration",
gesture = 8,
manaCost = 20,
icon = 100,
spellIcon = 20,
requirements = { "concentration", 1 },
description = "A bolt of magical negative energy which can open a door from a distance.",
onCast = function(champion, x, y, direction, elevation, skillLevel)
local s = spawn("zo_spell",party.level,party.x,party.y,party.facing)
s.projectile:setIgnoreEntity(party)
s.projectile:setAttackPower(0)
end
}
defineObject{
name = "zo_spell",
baseObject = "base_spell",
components = {
{
class = "Particle",
particleSystem = "zo_spell",
},
{
class = "Light",
color = vec(0.6, 0.6, 0.6),
brightness = 10,
range = 4,
castShadow = true,
},
{
class = "Projectile",
spawnOffsetY = 1.35,
velocity = 10,
radius = 0.1,
hitEffect = "zo_spell_blast",
onProjectileHit = function(self, what, entity)
self.go:playSound("zo_spell_hit")
if what == "entity" and entity.id == "zo" then
entity.door:toggle()
end
end,
},
{
class = "Sound",
sound = "blob",
},
{
class = "Sound",
name = "launchSound",
sound = "silence",
},
},
}
defineObject{
name = "zo_spell_blast",
baseObject = "base_spell",
components = {
{
class = "Particle",
particleSystem = "zo_spell_hit",
destroyObject = false,
},
{
class = "Light",
color = vec(0.6, 0.6, 0.6),
brightness = 12,
range = 7,
fadeOut = 0.5,
disableSelf = true,
},
{
class = "TileDamager",
attackPower = 0,
damageType = "shock",
sound = "blob_hit",
},
},
}
defineSound{
name = "blob",
filename = "assets/samples/magic/blob_01.wav",
loop = true,
volume = 0.1,
minDistance = 1,
maxDistance = 10,
}
defineSound{
name = "silence",
filename = "assets/samples/magic/dark_bolt_launch_01.wav",
loop = false,
volume = 1,
minDistance = 1,
maxDistance = 10,
}
defineSound{
name = "zo_spell_hit",
filename = "assets/samples/magic/dark_bolt_hit_01.wav",
loop = false,
volume = 1,
minDistance = 2,
maxDistance = 10,
}
defineParticleSystem{
name = "zo_spell",
emitters = {
{
emissionRate = 15,
emissionTime = 0,
maxParticles = 1000,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
objectSpace = true,
texture = "mod_assets/dmcsb_pack/textures/particles/exsp_zo_spell.tga",
frameRate = 4,
frameSize = 256,
frameCount = 4,
lifetime = {0.1,0.3},
color0 = {1.5,1.5,1.5},
opacity = 0.1,
fadeIn = 0.1,
fadeOut = 0.1,
size = {0.125, 0.5},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = 1,
blendMode = "Additive",
},
-- core
{
emissionRate = 10,
emissionTime = 0,
maxParticles = 1000,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
objectSpace = true,
texture = "mod_assets/dmcsb_pack/textures/particles/exsp_zo_spell.tga",
frameRate = 4,
frameSize = 256,
frameCount = 4,
lifetime = {0.1,0.3},
color0 = {1.5,1.5,1.5},
opacity = 0.8,
fadeIn = 0.1,
fadeOut = 0.1,
size = {0.15, 0.6},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = 1,
blendMode = "Additive",
},
-- glow
{
spawnBurst = true,
emissionRate = 1,
emissionTime = 0,
maxParticles = 1,
boxMin = {0,0,0.0},
boxMax = {0,0,0.0},
sprayAngle = {0,30},
velocity = {0,0},
texture = "assets/textures/particles/glow.tga",
lifetime = {1000000, 1000000},
colorAnimation = true,
color0 = {1,0.5,0.5},
color1 = {0.5,1.,0.5},
color2 = {0.5,0.5,0.1},
color3 = {1,1,0.5},
opacity = 0.1,
fadeIn = 0.1,
fadeOut = 0.1,
size = {0.4, 0.6},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
}
}
}
defineParticleSystem{
name = "zo_spell_hit",
emitters = {
-- sparks
{
emissionRate = 80,
emissionTime = 0.3,
maxParticles = 30,
boxMin = {-0.5, -0.5, -0.5},
boxMax = { 0.5, 0.5, 0.5},
sprayAngle = {0,360},
velocity = {0,0},
objectSpace = false,
texture = "mod_assets/dmcsb_pack/textures/particles/exsp_zo_spell.tga",
frameRate = 4,
frameSize = 256,
frameCount = 4,
lifetime = {0.2,0.5},
color0 = {2.5,2.5,2.5},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {0.3, 1.4},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 0,
blendMode = "Additive",
},
-- glow
{
spawnBurst = true,
emissionRate = 1,
emissionTime = 0,
maxParticles = 1,
boxMin = {0,0,-0.1},
boxMax = {0,0,-0.1},
sprayAngle = {0,30},
velocity = {0,0},
texture = "assets/textures/particles/glow.tga",
lifetime = {0.5, 0.5},
colorAnimation = false,
color0 = {1, 1, 1},
opacity = 0.5,
fadeIn = 0.01,
fadeOut = 0.5,
size = {1, 1},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
}
}
}