Weapon ReCharging - Without replacing with new item
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Weapon ReCharging - Without replacing with new item
Has anyone figured out how to add charges to a weapon? (without replacing it with a new one with charges?)
I did read the posts regarding the dagger, but, basically, I want something similar, that costs hitpoints in exchange for recharges, but replacing it with a copy / clone version full of charges seems the long way round???
Thanks
UD
I did read the posts regarding the dagger, but, basically, I want something similar, that costs hitpoints in exchange for recharges, but replacing it with a copy / clone version full of charges seems the long way round???
Thanks
UD
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Weapon ReCharging - Without replacing with new item
Well, you have item:setCharges(amount). From there, everything (well, almost) is possible. I personnally would include the max number of charges within the name of the object, and from then, set charges until you reach that maximum. And you can always damage the champion, modify stats (health), etc...
A trip of a thousand leagues starts with a step.
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: Weapon ReCharging - Without replacing with new item
OK.. so I saw that... so.... (I dont know the charged object name off the top of my head atm...)
So above... how do code to say +1 to the existing charges?
Sorry, I am NOT a programmer... so any help/handholding is really valuable to me!!
Thanks,...
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "sword",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
onUseItem = function(self, champion)
champion:damage(25, "physical")
hudPrint(champion:getName().." pays the price.")
item:setCharges(
Sorry, I am NOT a programmer... so any help/handholding is really valuable to me!!
Thanks,...
Re: Weapon ReCharging - Without replacing with new item
item:setCharges(item:getCharges() + 1)
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: Weapon ReCharging - Without replacing with new item
Hmmm... that looks like something I can wrap my head around... AWESOME!
I will test this[=fix] tonight...
Hopefully what I have there makes some sort of sense to those with the skillz. Sorry if I have desecrated coding etiquette. I am pretty sure I cannot return true... or it will remove the item??

I will test this[=fix] tonight...
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "sword",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
onUseItem = function(self, champion)
champion:damage(25, "physical")
hudPrint(champion:getName().." pays the price.") then
if Item:getCharges(Item:getCharges() <10 )
item:setCharges(item:getCharges() + 1)
return false
else
champion:damage(5, "physical")
end
end
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: Weapon ReCharging - Without replacing with new item
Maybe I meant this:
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "sword",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
onUseItem = function(self, champion)
champion:damage(25, "physical")
hudPrint(champion:getName().." pays the price.")
if Item:getCharges(Item:getCharges() <10 ) then
item:setCharges(item:getCharges() + 1)
return false
else
champion:damage(5, "physical")
end
end
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Weapon ReCharging - Without replacing with new item
try this:
I hope it works, I didn't try it ingame.
You might want to warn the player that the item is "full".
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "sword",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
onUseItem = function(self, champion)
champion:damage(25, "physical")
hudPrint(champion:getName().." pays the price.")
local itemCharges = self:getCharges()
if itemCharges<10 then
self:setCharges(itemCharges + 1)
return false
else
champion:damage(5, "physical")
end
end,
}You might want to warn the player that the item is "full".
A trip of a thousand leagues starts with a step.
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: Weapon ReCharging - Without replacing with new item
Very Cool.. Thank You... I am considering that perhaps the damage/cost should be a percentage, so as the Champions grow stronger, the price doesn't become insignificant.
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "sword",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
onUseItem = function(self, champion)
champion:damage(champion:getStat(health) * .25, "physical")
hudPrint(champion:getName().." pays the price.")
local itemCharges = self:getCharges()
if itemCharges<10 then
self:setCharges(itemCharges + 1)
return false
else
champion:damage(5, "physical")
end
end,
}
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Weapon ReCharging - Without replacing with new item
("health"), not (health)
.
A trip of a thousand leagues starts with a step.
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: Weapon ReCharging - Without replacing with new item
So.. that Iwas able to get to work... but you can still "run out of charges" and it becomes the "empty" Item... so.. I thought... Evil Blade, would take from you, before it allowed itself to empty.
I am here, and don't know how to add that function / check, in....
I am here, and don't know how to add that function / check, in....
Code: Select all
cloneObject{
name = "MightyEvilBlade",
baseObject = "lightning_blade",
uiName = "Mighty Blade of Evil",
model = "assets/models/items/long_sword.fbx",
description = "This Powerful Blade sends an uncomfortable feeling into your arm.",
gameEffect = "The Blade speaks into your mind, Empower Me!",
weight = 0.8,
-- coolDownTime: = 4,
-- resistShock: = 5,
onUseItem = function(self, champion)
champion:damage(champion:getStat("health") * .5, "physical")
hudPrint(champion:getName().." pays the price.")
local itemCharges = self:getCharges()
if itemCharges < 10+1
then self:setCharges(itemCharges + 1)
elseif itemCharges = 0
then self:setCharges(itemCharges + 1)
champion:damage(champion:getStat("health") * .25, "physical")
return false
else
champion:damage(5, "physical")
end
end
end,
}