Can you associate weapons with armour?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
fazzasx
Posts: 104
Joined: Mon May 27, 2013 12:35 am

Can you associate weapons with armour?

Post 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
Zastaph
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Can you associate weapons with armour?

Post 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
User avatar
fazzasx
Posts: 104
Joined: Mon May 27, 2013 12:35 am

Re: Can you associate weapons with armour?

Post 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,
Zastaph
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Can you associate weapons with armour?

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Can you associate weapons with armour?

Post 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.
Post Reply