how to gain xp with an attack spell created?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
FrEEsiD

how to gain xp with an attack spell created?

Post by FrEEsiD »

hello all,
Here I create a new attack spell (black_bolt) but when I kill a monster I have no xp gain.
I look at the forum but I do not understand how?
A little help would be welcome ... ;)
And i want to make a "party: shakecamera" when the missile hits monster, decor and party, is it possible?
thank you in advance

defineSpell{
name = "blackbolt",
uiName = "blackbolt",
skill = "spellcraft",
level = 1,
runes = "ABCD",
manaCost = 1,
onCast = function(caster, x, y, direction, skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
spawn("blackbolt", party.level, x, y, party.facing)
--caster:damage(1, "physical")
--caster:damage(1, "poison")
--caster:modifyFood(-100)
end
}


Ps: it is possible to decrease energy of caster ?
flatline

Re: how to gain xp with an attack spell created?

Post by flatline »

You need to define the black bolt that you spawn as a particle too, so that when you cast the spell, it knows what particle to spawn.
Look at the original spells to see what you need.

Like this (it is a modified version of the basic shockburst):

Code: Select all

defineObject{
	name = "blackbolt",
	class = "ProjectileSpell",
	particleSystem = "shockburst",
	lightColor = vec(1, 0.5, 0.1),
	lightBrightness = -40,
	lightRange = 4,
	sound = "shockburst",
	attackPower = 27,
	damageType = "shock",
	tags = { "spell" },
	cameraShake = true,
}
Regarding the energy, if you don't simply want to increase the cost with manaCost you can add
caster:modifyStat("energy", -10) to the spell description to lower energy by 10.

Regarding the shaking effect, just add Party:shakeCamera(intensity, duration) when your spell is cast.

Code: Select all

defineSpell{
name = "blackbolt",
uiName = "blackbolt",
skill = "spellcraft",
level = 1,
runes = "ABCD",
manaCost = 1,
onCast = function(caster, x, y, direction, skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
spawn("blackbolt", party.level, x, y, party.facing)
Party:shakeCamera(0.2, 2)
caster:modifyStat("energy", -10)
--caster:damage(1, "physical")
--caster:damage(1, "poison")
--caster:modifyFood(-100)
end
}
FrEEsiD

Re: how to gain xp with an attack spell created?

Post by FrEEsiD »

thanks Flatline,

Ok for the cast ... it is shame;)
And to lower the energy of all the champions when the spell caster launches ?

Otherwise my fate works very well with a particle system of its own, but it gives no xp death monsters...

For "camerashake = true" in objets definition it has no effect for me ?!?

Thanks
FrEEsiD

Re: how to gain xp with an attack spell created?

Post by FrEEsiD »

I used the healing spell of grimwold (thanks Grimwold) ... for Decrease health and energy of party ;)

This is probably not very good for a coder but it works for me ;)

it remains to solve the xp gain and the "party: camerashake" when the spell hit (wall, party and monster)

defineSpell{
name = "blackbolt",
uiName = "blackbolt",
skill = "spellcraft",
level = 1,
runes = "ABCD",
manaCost = 1,
onCast = function(caster, x, y, direction, skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
spawn("blackbolt", party.level, x, y, party.facing)
caster:damage(1, "physical")
caster:damage(1, "poison")
caster:modifyFood(-100)
party:shakeCamera(0.2, 1.7)

local heal_amount = math.random(6,8)/4*skill
for i=1,4 do
party:getChampion(i):modifyStat("health", -30)
party:getChampion(i):modifyStat("energy", -30)
end
playSound("blackbolt_launch")
party:playScreenEffect("black_screen")
hudPrint(caster:getName() .. " blackbolt damage the group has 30 points of health and energy ...This powerful spell is to use sparingly ...")
end,
}
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: how to gain xp with an attack spell created?

Post by Grimwold »

Currently the only way to provide a link between the caster and the damage dealt to a monster, and hence solve the XP problem, is by using the damageTile() function as well as the projectile spell... this means you have to trigger damageTile when the projectile hits it's target!

JKos did a tutorial based on his magic missile spell, which you can find here:
viewtopic.php?f=14&t=3910&hilit=magic+missile
FrEEsiD

Re: how to gain xp with an attack spell created?

Post by FrEEsiD »

thanks Grimwold, i test now ;)

My problem now is to shake the camera when my projectilspell hit: a monster, a wall and a party ... is this possible ?

Ah yes, so it is possible to create a cloud on my spell hit as poison_bolt_greater ?
FrEEsiD

Re: how to gain xp with an attack spell created?

Post by FrEEsiD »

it work for xp gain with created spell, but just for caster ....
i haved make a bad error ?
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: how to gain xp with an attack spell created?

Post by Grimwold »

FrEEsiD wrote:it work for xp gain with created spell, but just for caster ....
i haved make a bad error ?
The way XP in Grimrock works is that every champion who deals damage to the monster gets full XP... otherwise they get half XP... so the spell is working as it should to credit the caster with full XP... the other champions will need to hit the monster too, in order to get full XP.

IF you wanted all party memebers to get full XP from the one spell... you could run damageTile() 4 times with the 4 different ordinal values 1 - 4.. you'd need to tone down the damage done by each one though!!!
flatline

Re: how to gain xp with an attack spell created?

Post by flatline »

Grimwold wrote:
FrEEsiD wrote:it work for xp gain with created spell, but just for caster ....
i haved make a bad error ?
The way XP in Grimrock works is that every champion who deals damage to the monster gets full XP... otherwise they get half XP... so the spell is working as it should to credit the caster with full XP... the other champions will need to hit the monster too, in order to get full XP.

IF you wanted all party memebers to get full XP from the one spell... you could run damageTile() 4 times with the 4 different ordinal values 1 - 4.. you'd need to tone down the damage done by each one though!!!
Correct me if I'm wrong but isn't it possible (and easier) to use the "flags" field of damageTile?
From the reference:

damageTile(level, x, y, direction, flags, damageType, power)
flags is a numeric bit field:
bit 0: monsters recoil from the impact
bit 1: ongoing damage such as poison cloud
bit 2: damage originated from champion with ordinal index 1
bit 3: damage originated from champion with ordinal index 2
bit 4: damage originated from champion with ordinal index 3
bit 5: damage originated from champion with ordinal index 4
bit 6: ignore immunities
bit 7: halve damage of back row party members
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to gain xp with an attack spell created?

Post by Komag »

That sounds right to me, but that bitfield is something none of us has ever gotten good at, hard to understand. Maybe what we need is a list of common combinations and their corresponding values
Finished Dungeons - complete mods to play
Post Reply