Weapon ReCharging - Without replacing with new item

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Weapon ReCharging - Without replacing with new item

Post 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
User avatar
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

Post 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...
A trip of a thousand leagues starts with a step.
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: Weapon ReCharging - Without replacing with new item

Post 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,...
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Weapon ReCharging - Without replacing with new item

Post by Decayer »

item:setCharges(item:getCharges() + 1)
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: Weapon ReCharging - Without replacing with new item

Post 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??


:)
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: Weapon ReCharging - Without replacing with new item

Post 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
User avatar
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

Post 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".
A trip of a thousand leagues starts with a step.
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: Weapon ReCharging - Without replacing with new item

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

User avatar
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

Post by cromcrom »

("health"), not (health) :-).
A trip of a thousand leagues starts with a step.
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: Weapon ReCharging - Without replacing with new item

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