Page 1 of 2
How to access thrown items 'carried' by monsters?
Posted: Mon Oct 15, 2012 5:01 pm
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?
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 15, 2012 5:05 pm
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...
in item definition.
Re: How to access thrown items 'carried' by monsters?
Posted: Sun Oct 21, 2012 11:51 pm
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.
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 12:54 am
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".
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 5:10 am
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
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 1:29 pm
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?
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 1:43 pm
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.
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 2:14 pm
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.
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 4:23 pm
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.

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
Re: How to access thrown items 'carried' by monsters?
Posted: Mon Oct 22, 2012 4:43 pm
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