How to access thrown items 'carried' by monsters?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

How to access thrown items 'carried' by monsters?

Post by Grimwold »

For example if I throw an axe at a monster it will 'carry' it until it dies. Is there any way to access the items carried by monsters via script? I tried findEntity on the axe id, but it returns nil if the axe is being carried by a monster.

Alternatively... is there a way to stop items being carried by monsters when you throw them?
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: How to access thrown items 'carried' by monsters?

Post by Grimwold »

Grimwold wrote:Alternatively... is there a way to stop items being carried by monsters when you throw them?
ok to answer this part of my own question...

Code: Select all

sharpProjectile = false,
in item definition.
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: How to access thrown items 'carried' by monsters?

Post by Lark »

Grimwold wrote:Is there any way to access the items carried by monsters via script?
Did you ever get an answer to this question? I really need to find out what items a monster is carrying using a script.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: How to access thrown items 'carried' by monsters?

Post by Grimwold »

Lark wrote:
Grimwold wrote:Is there any way to access the items carried by monsters via script?
Did you ever get an answer to this question? I really need to find out what items a monster is carrying using a script.
Unfortunately not. I found a way round my problem by forcing the throwing axe not to get "absorbed".
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: How to access thrown items 'carried' by monsters?

Post by Lark »

Okay, thanks. I've circumvented my problem by killing the monster, seeing what items it drops, destroying the dropped items, creating the monster again, and adding the items back in. Crazy, but it almost works. Some monsters drop extra items like shields and spears, so those are getting doubled up, but at least I'm not losing other more interesting items they're carrying. And yes, this is for another over engineered script that I'll post soon. I suppose I can check the type of monster in the square and delete the double items. More over engineering... Thank you, -Lark
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: How to access thrown items 'carried' by monsters?

Post by Grimwold »

Thinking about the problem after replying to you, that was the solution I came up with too... although I was going to teleport the monster away before destroying it, and spawn a new one... my concern was that you would lose any damage done to the monster that way... but I was coming at it from the point of view of my returning throwing axe... where the monster would be right in front of the player when I wanted to access the items.

EDIT - so, without looking it up, it's possible to add items to monsters on-the-fly?? so completely random item drops are a possibility?
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: How to access thrown items 'carried' by monsters?

Post by Decayer »

Grimwold wrote:EDIT - so, without looking it up, it's possible to add items to monsters on-the-fly?? so completely random item drops are a possibility?
Monster:addItem(item) is a thing, yes.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: How to access thrown items 'carried' by monsters?

Post by Grimwold »

Decayer wrote:
Grimwold wrote:EDIT - so, without looking it up, it's possible to add items to monsters on-the-fly?? so completely random item drops are a possibility?
Monster:addItem(item) is a thing, yes.
Fantastic, thanks for taking the time to reply. It just never occurred to me until now.
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: How to access thrown items 'carried' by monsters?

Post by Lark »

Just to be clear, you need to use something like monster:additem(spawn("blueberry_pie")) to make it work. I wonder what would happen if I added the items back to the new monster that fell on the floor. Would this duplicate them or move their location to the monster? I'll have to try that tonight.

I hadn't really thought about the health issues. :o While I'd prefer the monster damage to be preserved, without the right query abilities, I'm happy with what I have because health isn't the big issue for what I'm doing... I was going to teleport the original monster away, work with the substitute, and then teleport the original back when needed, but I wasn't sure how to make the script really portable, yet have a hidden holding cell for the monster. It would solve the health and duplicate item problems very nicely, however... darn! :? This is a much better solution and I just got everything working as is!

I wish we could just have a routine that would return items carried and ones that set and queried monster health. This would kill 50 lines or more of code and eliminate the need to save the original!

Thank you, -Lark
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: How to access thrown items 'carried' by monsters?

Post by Komag »

Lark wrote:I wonder what would happen if I added the items back to the new monster that fell on the floor. Would this duplicate them or move their location to the monster?
Petri counseled not to do this sort of thing, but I don't really understand what happens under the hood. I know that it will not move their location, but will duplicate them, and I had taken the step to then destroy the originals on the floor. Here is that thread:
viewtopic.php?p=34191#p34191
Finished Dungeons - complete mods to play
Post Reply