Page 1 of 2

Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 9:18 pm
by undeaddemon
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

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 9:25 pm
by cromcrom
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...

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 9:39 pm
by undeaddemon
OK.. so I saw that... so.... (I dont know the charged object name off the top of my head atm...)

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(

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,...

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 9:52 pm
by Decayer
item:setCharges(item:getCharges() + 1)

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 10:22 pm
by undeaddemon
Hmmm... that looks like something I can wrap my head around... AWESOME!
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
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??


:)

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 10:31 pm
by undeaddemon
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

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 10:37 pm
by cromcrom
try 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.") 
       local itemCharges = self:getCharges()
       if itemCharges<10  then
          self:setCharges(itemCharges + 1)
          return false
      else
      champion:damage(5, "physical")
     end
end,
}
I hope it works, I didn't try it ingame.
You might want to warn the player that the item is "full".

Re: Weapon ReCharging - Without replacing with new item

Posted: Tue Nov 13, 2012 11:00 pm
by undeaddemon
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,
}


Re: Weapon ReCharging - Without replacing with new item

Posted: Wed Nov 14, 2012 12:13 am
by cromcrom
("health"), not (health) :-).

Re: Weapon ReCharging - Without replacing with new item

Posted: Wed Nov 14, 2012 2:49 pm
by undeaddemon
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....

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,
}