Page 1 of 1

Can you associate weapons with armour?

Posted: Sun Nov 22, 2015 8:00 pm
by fazzasx
Hi There,

I have searched the forum but I cant find the answer and it might not be possible...

Can you have for example an axe that can only be used with a certain pair of gauntlets? For example, I would like to make it so that you can only use an ancient axe and get good hit points if your wearing the gauntlets valor? You see what I mean?

So, if you locate a special axe, it can be used, but it wont score well until you combine it with the gauntlets valor?

Let me know, I am not sure where to begin, but then again I am not sure if I can even do it.

Thanks

Re: Can you associate weapons with armour?

Posted: Sun Nov 22, 2015 8:23 pm
by Zo Kath Ra
I would use:
ItemComponent.onEquipItem(self, champion, slot)
ItemComponent.onUnequipItem(self, champion, slot)
MeleeAttackComponent:getAttackPower()

When a champion equips the axe, check if the champion is wearing the gauntlets.
If he is, increase the axe's attack power.
When the champion un-equips the axe, reset the axe's attack power to normal.

When the champion equips the gauntlets, check if he's already wielding the axe.
If he is, increase the axe's attack power.
When the champion un-equips the gauntlets, check if he's wielding the axe.
If he is, reset the axe's attack power to normal.

When you check if the champion is wielding the axe, remember that it can be in one of these four slots:
ItemSlot.Weapon
ItemSlot.OffHand
ItemSlot.Weapon2
ItemSlot.OffHand2

Re: Can you associate weapons with armour?

Posted: Wed Nov 25, 2015 7:09 pm
by fazzasx
Zo Kath Ra wrote:I would use:
ItemComponent.onEquipItem(self, champion, slot)
ItemComponent.onUnequipItem(self, champion, slot)
MeleeAttackComponent:getAttackPower()

When a champion equips the axe, check if the champion is wearing the gauntlets.
If he is, increase the axe's attack power.
When the champion un-equips the axe, reset the axe's attack power to normal.

When the champion equips the gauntlets, check if he's already wielding the axe.
If he is, increase the axe's attack power.
When the champion un-equips the gauntlets, check if he's wielding the axe.
If he is, reset the axe's attack power to normal.

When you check if the champion is wielding the axe, remember that it can be in one of these four slots:
ItemSlot.Weapon
ItemSlot.OffHand
ItemSlot.Weapon2
ItemSlot.OffHand2

Thanks for this zo Kath Ra,

I have almost done it.. But for some reason the onequip function will give the axe its power even if you put it into the inventory. I think the onequip possibly means an item on your person no matter where it is?

Also, from reading around the forum you cant just give the axe the power by specifying it in Grimrock1, so you need to spawn a copy of it.. (please tell me if I am way off course here.. I am happy to take a corrective course :))

The code below works, but the only part I cant quite figure out is getting the axe to only get the power if the champion is actually wearing the gloves?


Code: Select all

cloneObject{
	name = "power_gauntlets",
	uiName = "Power Gauntlets",
	onEquipItem = function(self, champion, itemSlot)
	  local thisPlayer,itemSlot,currItem,champion
	  for thisPlayer = 1,4 do
	    champion = party:getChampion(thisPlayer)
	    for itemSlot = 7,8 do
	      if champion:getItem(itemSlot) ~= nil then
            currItem = champion:getItem(itemSlot)
              if currItem.name == "special_axe" then
                champion:removeItem(itemSlot)
                champion:insertItem(itemSlot,spawn("special_axe1"))
	          end
	      end
		end
	  end
	end,

Re: Can you associate weapons with armour?

Posted: Wed Nov 25, 2015 8:50 pm
by minmay
fazzasx wrote:Also, from reading around the forum you cant just give the axe the power by specifying it in Grimrock1, so you need to spawn a copy of it.. (please tell me if I am way off course here.. I am happy to take a corrective course :))
You're correct, Zo Kath Ra didn't read which subforum they were in.

The itemSlot parameter of onEquipItem is the slot the item was equipped to. You need to verify that itemSlot == 9 (gauntlets slot) for the gauntlets, and itemSlot == 7 (left hand) or itemSlot == 8 (right hand) for the axe. If itemSlot is 11 through 31, it's just in the inventory.

Re: Can you associate weapons with armour?

Posted: Wed Nov 25, 2015 10:32 pm
by Isaac
You might consider changing the UI icon of the Ax once it has the bonus, and reverting it when it loses that bonus. That way, perhaps it obviously glows, or develops runes, or ~something, if it's equipped when they chance to wear the gloves.