Item that can be carried only by all party members?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
vidarfreyr
Posts: 71
Joined: Sat Oct 20, 2012 4:40 am

Item that can be carried only by all party members?

Post by vidarfreyr »

I want to make an item that is not only heavy, but difficult to carry around. It's easy enough to make the item 200+ Kg so that the party can't move with said item in inventory, but can still pick it up and read the description. Logically the party could still carry an item of 200Kg when they work together ;) So when picked up with mouse cursor it kinda works to that effect. Only the party can do most anything else when the item is in cursor (attack, cast spells..), which kind of ruins the illusion of the item being carried by all four.

Is there a way to:

1. Hinder spellcasting and attacking while said item is picked up in cursor?
2. Slow down movement of party (like encumbered) while item is in cursor?
3. Make the item only be carriable with 4 party members alive and enabled?
dasarby
Posts: 28
Joined: Sun Dec 30, 2012 10:46 pm

Re: Item that can be carried only by all party members?

Post by dasarby »

Seems like you might be able to get close with party hooks. lets see...
onUseItem: a hook which is called when an item is used by clicking on an attack icon, right clicking on an inventory item or clicking a champion’s portrait while holding a mouse item. The function gets the following parameters: the champion who uses the item, the item to use and the numeric inventory slot. The slot parameter is nil if the a champion portrait was clicked. If the function returns false, the action is cancelled.
onCastSpell: a hook which is called when a champion casts a spell. The function gets two parameters, the casting champion and the name of the spell. If the function returns false, the casting is cancelled.
Maybe you could use these in combination with getMouseItem()? Check the mouse item in those hooks, if it is your heavy thing, return false? maybe even print "you cant do that while carrying this big thing"

there's also
onPickUpItem: a hook which is called when an item is picked up. The function gets two parameters, the party itself and the item. If the function returns false, the pick up action is cancelled.
which you could use to set a flag to know when the thing is being held. The problem here is i cant figure out how to clear the flag when the item is dropped....

EDIT: your first point looks like it could be done with the first 2 hooks. and 3 is easy by checking if the party members are all alive in onPickUpItem and returning false if necessary. Not sure how to do the encumbered one though.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Item that can be carried only by all party members?

Post by Komag »

A crazy workaround might be to check these:
Champion:getLoad()
Returns the current load of the champion in kilograms.
Champion:getMaxLoad()
Returns the maximum carrying capacity of the champion in kilograms.

Then spawn an item in the inventory that will raise their load to something near the max load, maybe a note that says "you are burdened" or something, or a weight symbol, or a little pic of people carrying a load, or whatever. Then destroy the item if the heavy object is let go. You would need to define many preset weight objects, such as 50 of them, one for each Kg up to 50
Finished Dungeons - complete mods to play
User avatar
vidarfreyr
Posts: 71
Joined: Sat Oct 20, 2012 4:40 am

Re: Item that can be carried only by all party members?

Post by vidarfreyr »

Excellent advice!

There is also a onAttack hook. So the script would be something like this:

1. check if mouse item is heavy item with onPickUpItem hook
2. Calculate each individual champions max load minus current load, and fill inventory with similar item of that exact weight that would encumber him, not immobilize.
3. if champion attacks or casts spells cancel that action with return false and a message explaining why
4. Disable the above effects and remove items from inventory.

I can probably get a script like this together with some trial and error. But there are two things that come to mind that would make this even better:

1. Is there a way to set the walking speed of the party manually, so to make it even slower and cumbersome (impossible to run from enemies with it)?
2. Is there a way to temporarily replace all items held in all eight hands of champions with a dummy of the mouse inventory item? That would be best of all cause it would show that the party is busy holding something other than their weapons + it eliminates the need for code to disable spellcasting or attacking at the same time.

When putting heavy-item down again, replacing all handheld heavy-item-dummies with items previously held would be hard to do I imagine, but it would be just as good to put weapons and previously held items in inventory (holstering weapons) when the heavy item is picked up (or on floor if inventory is full). So they would need to be taken out manually again. The idea is you would not be carrying this around during combat anyways. But how to access the inventory slots for held items?
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Item that can be carried only by all party members?

Post by Komag »

Xanathar's scripts can steal away all the held items then restore them accurately after putting the object down. This would affect the weight carried so would have to be taken into account
Finished Dungeons - complete mods to play
dasarby
Posts: 28
Joined: Sun Dec 30, 2012 10:46 pm

Re: Item that can be carried only by all party members?

Post by dasarby »

Is max carry weight dependent on strength? If so, maybe you could use get/setStat to temporarily set everyone's strength to 0? Wouldn't work if there everyone has a min carry weight though...
Post Reply