Page 1 of 2
custom weapon
Posted: Sat Jul 13, 2013 6:02 pm
by bongobeat
Hi there,
I need some help plz
how can I attach a custom sound to a custom weapon?
it's a modified weapon of the venom edge, but I would like that every time It shots, it plays a custom sound
I have tried onUse command , but it doesnt work
Code: Select all
onUse = function()
playSound("uraniumgun")
end,
Code: Select all
defineObject{
name = "uranium_gun",
class = "Item",
uiName = "Uranium Canon",
model = "assets/models/items/machine_part/machine_part_south.fbx",
gfxIndex = 99,
description = "Unknown weapon. One trigger on one extremity, two pipes on the other",
-- skill = "missile_weapons",
-- requiredLevel = 0,
attackPower = 100,
coolDownTime = 0.5,
attackMethod = "castWandSpell",
spell = "poison_bolt",
wandPower = 150,
charges = 5,
-- attackMethod = "rangedAttack",
-- attackSound = "uraniumgun",
-- rangedWeapon = true,
-- ammo = "uranium_bullet",
impactSound = "impact_blade",
weight = 2.0,
emptyItem = "damaged_uranium_gun",
onUse = function()
playSound("uraniumgun")
end,
}
I tried to switch it as a ranged weapon, now the custom sound works, but I prefer a weapon with some charges.
Any idea?
Re: custom weapon
Posted: Sat Jul 13, 2013 7:59 pm
by LordGarth
Put this code into your weapon code.
attackSound = "swipe",
Chand swipe with whatever sound you have.
LordGarth
Re: custom weapon
Posted: Sat Jul 13, 2013 8:05 pm
by bongobeat
that's what i did in the beginning
attackSound = "uraniumgun",
(because there was already a attack sound with the object.)
it worked, but because it was a ranged weapon
then after changing attackMethod = "rangedweapon" into "castWandSpell", with poison bolt spell, the poison bolt sound comes in priority, and I didnt hear the other sound.
Re: custom weapon
Posted: Sat Jul 13, 2013 8:14 pm
by LordGarth
That is probably because it is not attacking so no there is no attack sound it is only launch the spell until it runs out of charges.
I have a way to make melee weapons do there normal physical damage and a magic spell with it if you want.
G
Re: custom weapon
Posted: Sat Jul 13, 2013 8:41 pm
by bongobeat
mhh, but that will not be a mellee weapon,
it's some kind of canon,
that's why i use a castWandSpell in attack, because it should act like a rands weapon, but without ammo, and with a limited number of charge.
Is there a way to modify the launch sour of the poison bolt?
like creating a new poson bolt spell and change the sound?
LordGarth wrote:That is probably because it is not attacking so no there is no attack sound it is only launch the spell until it runs out of charges.
I have a way to make melee weapons do there normal physical damage and a magic spell with it if you want.
G
Yes please, I want to see yours, maybe it can helps me on this one, or it can be useful for other weapon.
Re: custom weapon
Posted: Sat Jul 13, 2013 8:45 pm
by LordGarth
You could copy and paste the posion bolt code from the LOG assets and just change the name to poison bolt 1 and change the name of the launch sound.
LG
Re: custom weapon
Posted: Sat Jul 13, 2013 10:29 pm
by bongobeat
here is what i ve done (what i have done?!)
the new spell
Code: Select all
defineSpell{
name = "ugun",
uiName = "U Shoot",
skill = "spellcraft",
runes = nil,
level = 0,
manaCost = 0,
onCast = function(caster, x, y, direction, skill)
local dx,dy = getForward(party.facing)
local x,y = party.x + dx, party.y + dy
spawn("poison_bolt_hi", party.level, x, y, party.facing)
end
}
and the new object spawned
Code: Select all
defineObject{
name = "poison_bolt_hi",
class = "ProjectileSpell",
particleSystem = "poison_bolt",
hitParticleEffect = "poison_bolt_hit",
lightColor = vec(0.25, 0.9, 0.2),
lightBrightness = 4,
lightRange = 4,
lightHitBrightness = 4,
lightHitRange = 5,
launchSound = "uraniumgun",
projectileSound = "poison_bolt",
hitSound = "poison_bolt_hit",
screenEffect = "poison_bolt_screen",
projectileSpeed = 10.5,
attackPower = 200,
damageType = "physical",
cameraShake = true,
tags = { "spell" },
}
all works
spells, sounds combined with a weapon
just a minor issue, when I kill a monster with it, I don't have any xp
Please can you help for this?
Re: custom weapon
Posted: Sun Jul 14, 2013 2:44 am
by LordGarth
I think there is an ongoing problem with splash damage not giving xp. This is for Almost Human to fix. I would guess that your spell's damage is falling under splash damage category.
LordGarth
Re: custom weapon
Posted: Sun Jul 14, 2013 7:55 pm
by bongobeat
arhghh
You were talking about another way to do a melee weapon? Can you please explain it?
Re: custom weapon
Posted: Sun Jul 14, 2013 9:34 pm
by LordGarth
This is the code I use. venom_edge can be replaced with any weapon name and poison_bolt1 can be replaced with any spell and when the weapon is used it will do physical damage and the spell will be launched as well.
The splash damage problem will most likely still be there though.
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onAttack = function(champ, weapon)
if (weapon ~= nil) and (weapon.name == "venom_edge") then
if party.facing == 0 then
spawn("poison_bolt1", party.level, party.x, party.y-1, party.facing)
end
if party.facing == 1 then
spawn("poison_bolt1", party.level, party.x+1, party.y, party.facing)
end
if party.facing == 2 then
spawn("poison_bolt1", party.level, party.x, party.y+1, party.facing)
end
if party.facing == 3 then
spawn("poison_bolt1", party.level, party.x-1, party.y, party.facing)
end
end
end
}
LordGarth