Code: Select all
cloneObject {
name == "party",
baseObject = "party",
onDrawGui = function(ctx)
mdConversationList.onDraw(ctx)
end,
onAttack = function(champion, weapon)
return attackingWeaponScripts.specialWeaponAttacks(champion, weapon, skill)
end,
}
Code: Select all
function specialWeaponAttacks(champion, weapon, skill)
if (weapon ~= nil) and (weapon.name == "dm_wind_sword") then
return attackingWeaponScripts.burstSpellAttacks(champion,weapon,skill)
end
return true end
function burstSpellAttacks(champion, weapon, skill)
if (weapon ~= nil) and (weapon.name == "dm_wind_sword") then
if party.facing == 0 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 1 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 2 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 3 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
end
end
Code: Select all
function pushbackSpell(caster,x,y,direction,skill)
local dx,dy = getForward(direction)
if monsterThere(party.level,x+dx,y+dy)
then
-- hudPrint("Monster!")
if isValidTarget(party.level,x+2*dx,y+2*dy)
then
hudPrint("PUSH!!!!")
spawn("fx", party.level, x+dx, y+dy, direction, "push_smoke")
:setParticleSystem("push_spell")
:translate(0, 0.5, 0)
playSoundAt("fireball_launch",party.level,x+dx,y+dy)
spawn("teleporter", party.level, x+dx,y+dy,direction, "push_teleport")
:setTeleportTarget(x+2*dx,y+2*dy, direction)
:setTriggeredByParty(false)
:setTriggeredByMonster(true)
:setTriggeredByItem(false)
:setChangeFacing(true)
:setInvisible(true)
:setSilent(true)
:setHideLight(true)
:setScreenFlash(false)
spawn("timer",party.level,x,y,direction,"push_timer")
:setTimerInterval(0.1)
:addConnector("activate", "pushback_spell_script", "pushDestroy")
:activate()
else
hudPrint("The spell fails because there is something in the way.")
end
else
hudPrint("The spell fails because there is no monster to push")
end
end
In your burstSpellAttacks script you will need to define x,y and direction to pass to the pushback script. I think this normally comes from the onCast hook. It's been a long time since I wrote lua script, but I think there's a way to determine the party's co-ords... such as party.x party.y and party.facing.LocalFire wrote:Any ideas on what to do here?
Code: Select all
pushback_spell_script.pushbackSpell(caster,party.x,party.y,party.facing,skill)
Code: Select all
defineSpell{
name = "leap",
uiName = "leap",
skill = "fire",
level = 0,
runes = "F",
manaCost = 0,
onCast = function(caster, x, y, direction, skill)
local target_y = party.y
local target_x = party.x
if direction == 0 then
if not isWall(party.level, party.x, party.y - 1) then
target_y = party.y - 1
if not isWall(party.level, party.x, party.y - 2) then
target_y = party.y - 2
end
end
elseif direction == 1 then
if not isWall(party.level, party.x + 1, party.y) then
target_x = party.x + 1
if not isWall(party.level, party.x + 2, party.y) then
target_x = party.x + 2
end
end
elseif direction == 2 then
if not isWall(party.level, party.x, party.y + 1) then
target_y = party.y + 1
if not isWall(party.level, party.x, party.y + 2) then
target_y = party.y + 2
end
end
elseif direction == 3 then
if not isWall(party.level, party.x - 1, party.y) then
target_x = party.x - 1
if not isWall(party.level, party.x - 2, party.y) then
target_x = party.x - 2
end
end
end
party:setPosition(target_x, target_y, direction, party.level)
end
}
Definitions do not get placed in script_entities on the map. These are put in the init.lua script, in the scripts folder of your mod. Here they get loaded first, and create/define the various objects available to the user scripts.zzaxe wrote:For some reason it says "attempt to call global 'defineSpell' (a nil value)" and i don't know how to fix it. could anyone help?
Blichew wrote: ↑Fri Oct 05, 2012 10:01 pm Fan of Knives
Credits go to JohnWordsworth who had a problem with this one
spellcraft level and/or mana cost need to be adjustedSpoilerShowCode: Select all
defineSpell{ name = "knives", uiName = "Fan of Knives", skill = "spellcraft", level = 1, runes = "AC", 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.1 do shootProjectile("throwing_knife", party.level, x+modif, y, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 1, false, true) end else for modif = -0.5,0.5,0.1 do shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 1, false, true) end end end }