Making magical melee weapons

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Making magical melee weapons

Post by LordGarth »

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

}
Dungeon Master and DOOM will live forever.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Making magical melee weapons

Post by Xanathar »

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):

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
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Making magical melee weapons

Post by LordGarth »

The game crashes with no error report when unarmed attack.

LG
Dungeon Master and DOOM will live forever.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Making magical melee weapons

Post by Xanathar »

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
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Making magical melee weapons

Post by LordGarth »

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
Dungeon Master and DOOM will live forever.
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Making magical melee weapons

Post by LordGarth »

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
Dungeon Master and DOOM will live forever.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Making magical melee weapons

Post by akroma222 »

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):
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,
}
I have pasted this script into init.lua.....
Is there anything I am doing different/incorrect??
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Making magical melee weapons

Post by Decayer »

akroma222 wrote:I have pasted this script into init.lua.....
Is there anything I am doing different/incorrect??
You need to replace "fblong_sword" with "ice_sabre" (and you might want to put it in objects.lua for clarity's sake).
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Making magical melee weapons

Post by LordGarth »

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,



}
Dungeon Master and DOOM will live forever.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Making magical melee weapons

Post by akroma222 »

Oh dear, I can not believe I overlooked changing fblong sword to my weapon (terrible!!!!) ... I think it might be time for some sleep :oops:
Thanks for replying guys
Post Reply