JohnWordsworth wrote:
It's easy to modify the 'fan of knives' so that you can pickup the knives afterwards, and so that it does more damage! In my spell compendium, I will be using the following parameters for shootProjectile,
The last parameter determines whether the projectile hangs around afters, and the 20 is the new damage. This feels about fair. I also made it ignore the party, as it would sometimes hit the party! In my version, I've changed modif so that there are only 5 blades too...Code: Select all
shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, false)
Code: Select all
for modif = -0.5,0.5,0.2 do
Code: Select all
defineSpell{
name = "knives",
uiName = "Fan of Knives",
skill = "earth_magic",
level = 1,
runes = "GFC",
manaCost = 5,
onCast = function(champ, x, y, direction, skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
if party.facing == 0 or party.facing == 2 then
for modif = -0.5,0.5,0.2 do
shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, true)
end
else
for modif = -0.5,0.5,0.2 do
shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 20, party, true)
end
end
end,
}
Code: Select all
defineSpell{
name = "blades",
uiName = "Blades",
skill = "earth_magic",
level = 15,
runes = "CFG",
manaCost = 50,
onCast = function(caster, x, y, direction, skill)
return mymod_spells.castBlades(caster,x,y,direction,skill)
end
}
Code: Select all
spellCaster = 0
----------------------Blades----------------------------------
function castBlades(caster,x,y,direction,skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
local originator = caster:getOrdinal()
local e = caster:getSkillLevel("earth_magic")
local c = findEntity("learnShrapnelBlastCounter")
playSound("blades_gear")
if e >= 40 then
if party.facing == 0 or party.facing == 2 then
for modif = -0.4,0.4,0.1 do
shootProjectile("blade_gear", party.level, x+modif, y, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 35, party, true, originator)
end
else
for modif = -0.4,0.4,0.1 do
shootProjectile("blade_gear", party.level, x, y+modif, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 35, party, true, originator)
end
end
for ent in entitiesAt(party.level, party.x, party.y) do
if ent.name == "blade_gear" then
fxScripts.addProjectileEffect(ent, "blades_knife", 9, "hit_flame")
end
end
if c and c:getValue() == 0 then
hudPrint("Blades has upgraded (Earth 40) to a new spell: Shapnel Blast!")
playSound("upgrade_spell")
c:destroy()
end
else
if party.facing == 0 or party.facing == 2 then
for modif = -0.4,0.4,0.1 do
shootProjectile("blade_knife", party.level, x+modif, y, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 15, party, true, originator)
end
else
for modif = -0.4,0.4,0.1 do
shootProjectile("blade_knife", party.level, x, y+modif, party.facing, 14+(modif*2), 0, 1, 0, 0, 0, 15, party, true, originator)
end
end
for ent in entitiesAt(party.level, party.x, party.y) do
if ent.name == "blade_knife" then
fxScripts.addProjectileEffect(ent, "blades_knife", 9, "hit_flame")
end
end
end
spellCaster = caster:getOrdinal()
return true
end
Code: Select all
defineObject{
name = "blade_gear",
class = "Item",
uiName = "Blade Gear",
model = "assets/models/items/machine_part/machine_part_junk4.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons5.tga",
gfxIndex = 103,
attackPower = 35,
particleEffect = "blades_knife",
attackSound = "swipe_special",
impactSound = "impact_blade",
projectileSpeed = 10,
projectileRotationSpeed = 10,
projectileRotationX = 0,
projectileRotationY = 0,
projectileRotationZ = -60,
weight = 10,
}
defineObject{
name = "blade_knife",
class = "Item",
uiName = "Blade Knife",
model = "assets/models/items/throwing_knife.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons3.tga",
gfxIndex = 42,
attackPower = 15,
particleEffect = "blades_knife",
attackSound = "swipe_special",
impactSound = "impact_blade",
projectileSpeed = 9,
projectileRotationSpeed = 10,
projectileRotationX = 0,
projectileRotationY = 0,
projectileRotationZ = -60,
weight = 1,
}
Code: Select all
allMonstersList = { "crab" , "spider" etc etc etc }
for i=1,# allMonstersList do
cloneObject{
name = allMonstersList[i],
baseObject = allMonstersList[i],
onProjectileHit = function(monster, projectile, damage, damageType)
return mymod_spells.customSpellOnProjectileHitHook(monster,projectile,damage, damageType)
end,
}
end
Code: Select all
projectileItems = {'blade_knife' , 'blade_gear' }
function isInTable(table, element)
for _,value in pairs(table) do
if value == element then
return true
end
end
return false
end
function customSpellOnProjectileHitHook(monster,projectile,damage,damageType)
local dx,dy = getForward(monster.facing)
if isInTable(projectileItems, projectile.name) then
if projectile.name == 'blade_knife' then
local originator = 2 ^ (spellCaster+1) -- calculate the originator of the spell
local damage = math.random(15,20) --
damageTile(monster.level,monster.x,monster.y,(monster.facing + 2)%4,originator+1, 'physical',damage)
playSoundAt("impact_blade",monster.level,monster.x,monster.y)
return false
elseif projectile.name == 'blade_gear' then
local originator = 2 ^ (spellCaster+1) -- calculate the originator of the spell
local damage = math.random(30,40) --
damageTile(monster.level,monster.x,monster.y,(monster.facing + 2)%4,originator+1, 'physical',35)
playSoundAt("impact_blade",monster.level,monster.x,monster.y)
return false
end
end
end
Code: Select all
projectiles = {}
function addProjectileEffect(projectile,effectName,speed,onHitEffectName)
local timer = spawn('timer',projectile.level,projectile.x,projectile.y,projectile.facing)
local effect = spawn('fx',projectile.level,projectile.x,projectile.y,projectile.facing)
projectiles[timer.id] = {}
projectiles[timer.id].projectile_id = projectile.id
projectiles[timer.id].effect_id = effect.id
projectiles[timer.id].level = projectile.level
projectiles[timer.id].x = 0
projectiles[timer.id].y = 0
projectiles[timer.id].facing = projectile.facing
projectiles[timer.id].onHitEffect= onHitEffectName
local dx,dy = getForward(projectile.facing)
dy = -1 * dy
projectiles[timer.id].x = dx * 0.5
projectiles[timer.id].y = dy * 0.5
timer:addConnector('activate','fxScripts','move_effect')
timer:setTimerInterval(0.5/speed)
local light = getLightPreset(effectName)
if light then
effect:setLight(unpack(light))
end
effect:translate(0.5*dx,1,0.5*dy)
effect:setParticleSystem(effectName)
timer:activate()
return effect
end
function addProjectileManualHit(caster, projectile, damageAmount, damageType, radius)
for key,value in pairs(projectiles) do
if value.projectile_id == projectile.id then
if caster then
projectiles[key].caster = caster:getOrdinal()
end
projectiles[key].damage = damageAmount
projectiles[key].damageType = damageType
projectiles[key].radius = radius
end
end
end
function getLightPreset(preset)
--FX:setLight(red, green, blue, brightness, range, time, castShadow)
local s = {}
s['fireball'] = {1, 0.5, 0.25,15,7,200,true}
s['fireball_hit'] = {1, 0.5, 0.25,40,7,1,true}
s['magic_missile'] = {1, 1, 1,15,7,200,true}
s['poison_bolt'] = {0.25, 0.6, 0.2,4,4,200,true}
s['lightning_bolt'] = {0.25, 0.5, 1,30,5,1,true}
s['lightning_bolt_hit'] = {0.25, 0.5, 1,100,5,0.5,true}
s['magic_missile_hit'] = {1, 1, 1,40,10,1,true}
s['wizards_fire'] = {1, 0.9, 0.5,40,10,1,true}
s['wizards_life_fire'] = {1, 1, 1,120,10,1,true}
s['wizards_fire_hit'] = {1, 1, 0.95, 150,10,0.6,true}
local l = s[preset]
if not l then
l = {0, 0, 0, 0, 0, 0, false}
end
return l
end
function move_effect(timer)
local e = projectiles[timer.id]
local p = findEntity(e.projectile_id)
local fx = findEntity(e.effect_id)
if not p then
if e.onHitEffect then
local ohfx = spawn('fx',e.level,e.px,e.py,e.facing)
ohfx:setParticleSystem(e.onHitEffect)
ohfx:translate(0, 1, 0)
local light = getLightPreset(e.onHitEffect)
if light then
ohfx:setLight(unpack(light))
end
end
projectiles[timer.id] = nil
timer:deactivate()
timer:destroy()
fx:destroy()
return
end
e.px = p.x
e.py = p.y
fx:translate(e.x,0,e.y)
end
Code: Select all
defineParticleSystem{
name = "blades_knife",
emitters = {
-- sparks
{
emissionRate = 30,
emissionTime = 0,
maxParticles = 100,
boxMin = {-0.015, 0.02, 0.015},
boxMax = { 0.015, 0.1, -0.015},
sprayAngle = {0,180},
velocity = {0.1, 2.4},
texture = "assets/textures/particles/glow.tga",
lifetime = {0.25, 0.85},
colorAnimation = false,
color0 = {1.5, 1.5, 1.5},
opacity = 0.8,
fadeIn = 0.15,
fadeOut = 0.3,
size = {0.01, 0.05},
gravity = {0,0,0},
airResistance = 1.0,
rotationSpeed = 1,
blendMode = "Additive",
depthBias = -0.0005,
objectSpace = true,
}
}
}
I did this once for a room I never used... a long time ago... I'm pretty sure you just add the following to the items.lua file.. (make sure you have the spell "push_monster" defined in lua as well). Then you can add the wand_push item in the editor. It basically looks like the lightning rod.LocalFire wrote:I've got a question, how can I add a spell effect to an item?
I want to add Grimwolds pushback spell to an item, so it casts when the item hits an enemy, I've tried onAttack and onUseItem but neither works, is this even possible to do?
Code: Select all
-- A wand that uses the Push Monster spell
defineObject{
name = "wand_push",
class = "Item",
description = "The wand pulses with a powerful energy.",
uiName = "Wand of Push Monster",
attackMethod = "castWandSpell",
spell = "push_monster",
wandPower = 25,
coolDownTime = 2,
model = "assets/models/items/lightning_rod.fbx",
gfxIndex = 222,
attackPower = 14,
accuracy = 0,
attackSwipe = "vertical",
attackSound = "swipe",
impactSound = "impact_blunt",
weight = 1.7,
}
Code: Select all
-- A wand that uses the Hold Monster spell
defineObject{
name = "wand_hold",
class = "Item",
uiName = "Wand of Hold Monster",
model = "assets/models/items/whitewood_wand.fbx",
description = "A hand crafted wooden wand",
skill = "spellcraft",
requiredLevel = 1,
gfxIndex = 56,
energy = 5,
wandPower = 25,
coolDownTime = 2,
attackMethod = "castWandSpell",
spell = "hold_monster",
impactSound = "impact_blunt",
weight = 3.5,
}