lua sleep() for multiple fireballs
lua sleep() for multiple fireballs
Hi all,
I've tried to create a new spell - based on the original fireball spell - that cast a fireball every few milliseconds. The number of fireballs depends of caster's skill. The simplest way was to use a sleep(300) commande in lua spell object, but it not seems to work.
Is it possible?
To achieve my goal, I've created a script hook that temporary spawn a spawner, a counter and a timer, but in this case fireballs are spawn from the center of the square in front of the party.
How can I spawn a "real fireball", created from behind the screen on caster's side, with the same effects?
In other words, what is the equivalent script command to the "fireball" command in the original fireball spell's object?
Thanks,
Lex
I've tried to create a new spell - based on the original fireball spell - that cast a fireball every few milliseconds. The number of fireballs depends of caster's skill. The simplest way was to use a sleep(300) commande in lua spell object, but it not seems to work.
Is it possible?
To achieve my goal, I've created a script hook that temporary spawn a spawner, a counter and a timer, but in this case fireballs are spawn from the center of the square in front of the party.
How can I spawn a "real fireball", created from behind the screen on caster's side, with the same effects?
In other words, what is the equivalent script command to the "fireball" command in the original fireball spell's object?
Thanks,
Lex
Re: lua sleep() for multiple fireballs
OnCast hook, get champion and then use offset (take care of party direction). Smth like this:
[/color]
Code: Select all
-- projectile config for champions on left and right side of cell
if facing == 0 or facing == 3 then
offsetX = {-0.6,0.6,-0.6,0.6}
offsetZ = {-0.6,0.6,-0.6,0.6}
else
offsetX = {0.6,-0.6,0.6,-0.6}
offsetZ = {0.6,-0.6,0.6,-0.6}
end
...
shootProjectile("sh_bolter_bolt_projectile", party.level, party.x, party.y, party.facing, 25, 0, 0, offsetX[champ_num], 0, offsetZ[champ_num], 20, party, true, champ_num)
...
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore
Re: lua sleep() for multiple fireballs
Thank you for your reply Leki!
However, the shootProjectile("any spell object",...) doesn't work and stop the running party on the editor.
It works with physical objects, but not with magic objects (such as "fireball" or other spell's objects).
Any idea?
Lex
However, the shootProjectile("any spell object",...) doesn't work and stop the running party on the editor.
It works with physical objects, but not with magic objects (such as "fireball" or other spell's objects).
Any idea?
Lex
Re: lua sleep() for multiple fireballs
Not tested and there is typos etc - but it shows how to do it.
You need custom spell "Leveled Fireball", in OnCast hook, do what you need - see script for inspiration, imho the best way is to ignore timers etc and spawn firebals in one moment, but you can change their speed and change main offset a liitle bit- so it will look good, and no timer/party move during casting sequence issues etc. You also need to spawn your "invisible_leveled_fireball" to solve on hit, lighting and sound effects. It's without particle, so it can be spawned in the centre of the cell etc... It's a little bit chaotic, but hope you understand what you have to do...
-- or use smth like
You also need invisible fireball spell, to get light and on hit effect
defineObject{
name = "invisible_leveled_fireball",
class = "ProjectileSpell",
particleSystem = "invisible_fireball", -- here use your custom "null particle", so spell will fly, but without tracks - find particle definitions and clone them
hitParticleEffect = "fireball_hit",
lightColor = vec(1, 0.5, 0.25),
lightBrightness = 15,
lightRange = 7,
lightHitBrightness = 40,
lightHitRange = 10,
castShadow = true,
launchSound = "fireball_launch",
projectileSound = "fireball",
hitSound = "fireball_hit",
screenEffect = "fireball_screen",
projectileSpeed = 7.5,
attackPower = 30,
damageType = "fire",
tags = { "spell" },
}
You need custom spell "Leveled Fireball", in OnCast hook, do what you need - see script for inspiration, imho the best way is to ignore timers etc and spawn firebals in one moment, but you can change their speed and change main offset a liitle bit- so it will look good, and no timer/party move during casting sequence issues etc. You also need to spawn your "invisible_leveled_fireball" to solve on hit, lighting and sound effects. It's without particle, so it can be spawned in the centre of the cell etc... It's a little bit chaotic, but hope you understand what you have to do...
Code: Select all
defineSpell{
name = "leveled_fireball",
uiName = "leveled Firebal",
skill = "fire_magic",
level = 0,
runes = "ABCDE",
manaCost = 0,
onCast = function (champ, x, y, facing, skill)
champ_num = champ:getOrdinal()
champ_level = champ:getLevel() -- or use fire magic skill if you wish
-- projectile config for champions on left and right side of cell
-- single shot
if facing == 0 or facing == 3 then
offsetX = {-0.6,0.6,-0.6,0.6}
offsetZ = {-0.6,0.6,-0.6,0.6}
else
offsetX = {0.6,-0.6,0.6,-0.6}
offsetZ = {0.6,-0.6,0.6,-0.6}
end
-- spawn projectile
if champ_level < 2 then
shootProjectile("spell_projectile", party.level, party.x, party.y, party.facing, 25, 0, 0, offsetX[champ_num], 0, offsetZ[champ_num], 20, party, true, champ_num)
elseif champ_level > 2 and champ_level < 4 then
shootProjectile("spell_projectile", party.level, party.x, party.y, party.facing, 25, 0, 0, offsetX[champ_num]+0.1, 0, offsetZ[champ_num]+0.1, 20, party, true, champ_num)
shootProjectile("spell_projectile", party.level, party.x, party.y, party.facing, 20, 0, 0, offsetX[champ_num], 0, offsetZ[champ_num], 20, party, true, champ_num)
end
Code: Select all
for i = 0,champ_level step 3 do
spd = math.random()*30
offs = math.random()*30/100
pwr = math.random()*(champ_level * 10)
shootProjectile("spell_projectile", party.level, party.x, party.y, party.facing, 25, 0, 0, offsetX[champ_num], 0, offsetZ[champ_num], 20-pwr, party, true, champ_num)
-- here spawn your invisible_leveled_fireball
-- you can set up damage in invisible_leveled_fireball spell or in projectile
end
end,
}[/color]defineObject{
name = "invisible_leveled_fireball",
class = "ProjectileSpell",
particleSystem = "invisible_fireball", -- here use your custom "null particle", so spell will fly, but without tracks - find particle definitions and clone them
hitParticleEffect = "fireball_hit",
lightColor = vec(1, 0.5, 0.25),
lightBrightness = 15,
lightRange = 7,
lightHitBrightness = 40,
lightHitRange = 10,
castShadow = true,
launchSound = "fireball_launch",
projectileSound = "fireball",
hitSound = "fireball_hit",
screenEffect = "fireball_screen",
projectileSpeed = 7.5,
attackPower = 30,
damageType = "fire",
tags = { "spell" },
}
Last edited by Leki on Sun Jan 12, 2014 4:11 pm, edited 3 times in total.
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore
Re: lua sleep() for multiple fireballs
Yes, I understand: as far as the shootProjectile() can't be used to shoot ProjectileSpell object, I have to create a new visual projectile item object that can be shooted with the shootProjectile() when cast. And for damages, I just spawn as I did an invisible ProjectileSpell object to make damages.
Thank you very much for your help Leki.

Thank you very much for your help Leki.
Re: lua sleep() for multiple fireballs
Yes.
If you use spell for damage, it will manage exp as well etc. If you wanna use projectile, you have to take care about championOrdinal:
More in Moding/Scripting reference: http://www.grimrock.net/modding/scripting-reference/
If you use spell for damage, it will manage exp as well etc. If you wanna use projectile, you have to take care about championOrdinal:
shootProjectile(projectile, level, x, y, direction, speed, gravity, velocityUp, offsetX, offsetY, offsetZ, attackPower, ignoreEntity, fragile, championOrdinal)
Shoots a projectile item. The parameters are:
projectile: the name of the item to shoot.
level,x,y: the initial position of the projectile in a level.
direction: the shooting direction (0=north, 1=east, 2=south, 3=west).
speed: the speed of the projectile (metres/second). Typical values around 10.
gravity: the gravity force in y-direction. Typical values around 0.
velocityUp: the initial velocity in y-direction. Typically set to 0.
offsetX,offsetY,offsetZ: 3D offset in world space from the center of cell.
attackPower: attack power of the projectile.
ignoreEntity: the entity to be ignored for collisions (or nil if the entity should not ignore any collisions).
fragile: a boolean flag, if set the projectile is destroyed on impact.
championOrdinal: a champion ordinal number, used for dealing experience points. This parameter is optional.
More in Moding/Scripting reference: http://www.grimrock.net/modding/scripting-reference/
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore
Re: lua sleep() for multiple fireballs
I defined a new object with the red orb model and used the function you gave me previously to test it.
It works great with the right offsets.
Do you know if it is possible to add un bunring aspect on the orb?
Adding a fireball particleSystem to the object doesn't work...
To display fireball_hit on impact, we can add bombType = "fire" but I'm not sure this is the right way to do it, as far as the bomb damages supersede the shootprojectile damages.
Any idea?
It works great with the right offsets.
Code: Select all
defineObject{
name = "dm_orb_of_fire",
class = "Item",
uiName = "Orb of fire",
model = "mod_assets/models/items/orb_of_fire.fbx",
gfxIndex = 157,
particleSystem = "orb_of_fire",
attackPower = 1,
stackable = false,
sharpProjectile = false,
projectileRotationY = 0,
weight = 0,
}
Code: Select all
defineSpell{
name = "orb_of_fire",
uiName = "Orbs of fire",
skill = "fire_magic",
level = 2,
runes = "ABC",
manaCost = 5,
onCast = function(caster, x, y, direction, skill)
if direction == 0 or direction == 3 then
offsetX = {-0.6,0.6,-0.6,0.6}
offsetZ = {-0.6,0.6,-0.6,0.6}
else
offsetX = {0.6,-0.6,0.6,-0.6}
offsetZ = {0.6,-0.6,0.6,-0.6}
end
shootProjectile("dm_orb_of_fire", party.level, x, y, direction, 25, 0, 0, offsetX[champ_num], 0, offsetZ[champ_num], 2*skill, party, true, caster:getOrdinal())
end,
}
Adding a fireball particleSystem to the object doesn't work...
To display fireball_hit on impact, we can add bombType = "fire" but I'm not sure this is the right way to do it, as far as the bomb damages supersede the shootprojectile damages.
Any idea?
Re: lua sleep() for multiple fireballs
Add into yours projectile definition line particleEffect = "fireball", as you can see here:
Code: Select all
defineObject{
name = "dm_orb_of_fire",
class = "Item",
uiName = "Orb of fire",
model = "mod_assets/models/items/orb_of_fire.fbx",
gfxIndex = 109,
attackPower = 2,
stackable = false,
sharpProjectile = false,
projectileRotationY = 0,
weight = 0,
particleEffect = "fireball",
}Code: Select all
defineObject{
name = "fireball",
class = "ProjectileSpell",
particleSystem = "fireball", -- this one replace with smth like "fireball_null_particle"
hitParticleEffect = "fireball_hit",
lightColor = vec(1, 0.5, 0.25),
lightBrightness = 15,
lightRange = 7,
lightHitBrightness = 40,
lightHitRange = 10,
castShadow = true,
launchSound = "fireball_launch",
projectileSound = "fireball",
hitSound = "fireball_hit",
screenEffect = "fireball_screen",
projectileSpeed = 7.5,
attackPower = 30,
damageType = "fire",
--cameraShake = true,
tags = { "spell" },
}Code: Select all
defineParticleSystem{
name = "fireball_null_particle",
emitters = {
-- 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 = {1000000, 1000000},
colorAnimation = false,
color0 = {0.3, 0.13, 0.06},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.1,
size = {1.5, 1.5},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
}
}
}[/color]
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore
Re: lua sleep() for multiple fireballs
Fireball speed is 7.5Leki wrote:
Dont forget to synchronize projectile speed with the spell - it's 10 if I'm not wrong.
Re: lua sleep() for multiple fireballs
Hehe, so 10 is lighting ball I guessDiarmuid wrote:Fireball speed is 7.5Leki wrote:
Dont forget to synchronize projectile speed with the spell - it's 10 if I'm not wrong.
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore