Making magical melee weapons
Making magical melee weapons
Hello all
Why does the champ spawn fireburst all the time with this code and not just with the fblong_sword?
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onAttack = function(champ, fblong_sword)
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
}
Why does the champ spawn fireburst all the time with this code and not just with the fblong_sword?
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onAttack = function(champ, fblong_sword)
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
}
Dungeon Master and DOOM will live forever.
Re: Making magical melee weapons
First of all, I would avoid using defineObject with party.. it's one of those cases where I would follow the cloneObject good-practice closely since party is not a trivial object.
That said, the "words" in the function declaration aren't "filters" are just symbolic names given to the parameters.
You have to do something like (not-tested):
That said, the "words" in the function declaration aren't "filters" are just symbolic names given to the parameters.
You have to do something like (not-tested):
Code: Select all
onAttack = function(champ, weapon)
if (weapon.name == "fblong_sword") then
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
end
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: Making magical melee weapons
The game crashes with no error report when unarmed attack.
LG
LG
Dungeon Master and DOOM will live forever.
Re: Making magical melee weapons
if (weapon ~= nil) and (weapon.name == "fblong_sword") then
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: Making magical melee weapons
Great now I can make lots of magical melee weapons that will do melee and magical damage at the same time. And I can make enchantment potions to turn regular melee weapons to magical ones.
The enchantment does not run out though. I wonder how to put in charges if that is possible.
Thx a bunch,
LG
The enchantment does not run out though. I wonder how to put in charges if that is possible.
Thx a bunch,
LG
Dungeon Master and DOOM will live forever.
Re: Making magical melee weapons
Great now the Ice longsword, Ice warhammer, Ice battleaxe cast frostburst on attack and the magma longsword, battleaxe and warhammer cast fireburst on attack.
Torch casts fireburst on attack as well.
LG
Torch casts fireburst on attack as well.
LG
Dungeon Master and DOOM will live forever.
Re: Making magical melee weapons
Hey guys,
I'm trying to get your code to work, but nothing happens when I swing 'ice_sabre' in any direction...
I have used this code (yours I think, if I pieced it together correctly):
I have pasted this script into init.lua.....
Is there anything I am doing different/incorrect??
I'm trying to get your code to work, but nothing happens when I swing 'ice_sabre' in any direction...
I have used this code (yours I think, if I pieced it together correctly):
SpoilerShow
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onAttack = function(champ, weapon)
if (weapon ~= nil) and (weapon.name == "fblong_sword") then
if party.facing == 0 then
spawn("frostburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("frostburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("frostburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("frostburst", party.level, party.x-1, party.y, party.facing)
end
end
end,
}
Is there anything I am doing different/incorrect??
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Making magical melee weapons
You need to replace "fblong_sword" with "ice_sabre" (and you might want to put it in objects.lua for clarity's sake).akroma222 wrote:I have pasted this script into init.lua.....
Is there anything I am doing different/incorrect??
Re: Making magical melee weapons
I put this into the items folder.
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onAttack = function(champ, weapon)
if (weapon ~= nil) and (weapon.name == "fblong_sword") then
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
if (weapon ~= nil) and (weapon.name == "torch") then
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
end
}
defineObject{
name = "fblong_sword",
class = "Item",
uiName = "Longsword of FireBurst",
model = "assets/models/items/long_sword.fbx",
skill = "swords",
gfxIndex = 84,
attackPower = 14,
accuracy = 0,
coolDownTime = 1.5,
attackMethod = "meleeAttack",
attackSwipe = "horizontal",
attackSound = "swipe",
impactSound = "impact_blade",
weight = 3.2,
}
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onAttack = function(champ, weapon)
if (weapon ~= nil) and (weapon.name == "fblong_sword") then
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
if (weapon ~= nil) and (weapon.name == "torch") then
if party.facing == 0 then
spawn("fireburst", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("fireburst", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("fireburst", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("fireburst", party.level, party.x-1, party.y, party.facing)
end
end
end
}
defineObject{
name = "fblong_sword",
class = "Item",
uiName = "Longsword of FireBurst",
model = "assets/models/items/long_sword.fbx",
skill = "swords",
gfxIndex = 84,
attackPower = 14,
accuracy = 0,
coolDownTime = 1.5,
attackMethod = "meleeAttack",
attackSwipe = "horizontal",
attackSound = "swipe",
impactSound = "impact_blade",
weight = 3.2,
}
Dungeon Master and DOOM will live forever.
Re: Making magical melee weapons
Oh dear, I can not believe I overlooked changing fblong sword to my weapon (terrible!!!!) ... I think it might be time for some sleep
Thanks for replying guys
Thanks for replying guys
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)