Moving scenery items with NPC

XanMag
04 Jun 2016, 20:17I'm sure this is a dumb question, but, hey, what else am I good for?
I'll try to keep the description simple:
I have certain times of day in my game that are based on number of turns taken. After every 15 turns, an attribute switches from morning to noon, from noon to afternoon, etc. I have different NPC's that come and go and events that happen when the time of day changes. So far so good.
My question is this:
I have an NPC (a Juju Man) that has some interesting articles he carries with him - a staff and his outfit. I want the player to be able to look at each of those because there are clues hidden within their description. So, when the Juju Man moves from his shack to the cemetery, for example, I want those items to move with him. I realize I could make the Juju a container, but then when he is looked at, I would have an awkward "on which there is" response (I know I can change that to whatever) or a "He is a Juju Man (who is carrying a staff and an outfit) - or something like that. Right? I don't want that awkwardness.
So, my current set-up is to create two separate objects that I script to move with him when he goes from place to place. When the time of day changes, I move Juju Man, outfit, and staff to needed location. On the outfit and staff description, I have an 'If' script that checks to see if the Juju man is visible first. Is there a problem with this and is there a better solution? I have multiple NPCs I need to set up.
Thanks in advance.

I'll try to keep the description simple:
I have certain times of day in my game that are based on number of turns taken. After every 15 turns, an attribute switches from morning to noon, from noon to afternoon, etc. I have different NPC's that come and go and events that happen when the time of day changes. So far so good.
My question is this:
I have an NPC (a Juju Man) that has some interesting articles he carries with him - a staff and his outfit. I want the player to be able to look at each of those because there are clues hidden within their description. So, when the Juju Man moves from his shack to the cemetery, for example, I want those items to move with him. I realize I could make the Juju a container, but then when he is looked at, I would have an awkward "on which there is" response (I know I can change that to whatever) or a "He is a Juju Man (who is carrying a staff and an outfit) - or something like that. Right? I don't want that awkwardness.
So, my current set-up is to create two separate objects that I script to move with him when he goes from place to place. When the time of day changes, I move Juju Man, outfit, and staff to needed location. On the outfit and staff description, I have an 'If' script that checks to see if the Juju man is visible first. Is there a problem with this and is there a better solution? I have multiple NPCs I need to set up.
Thanks in advance.
The Pixie
04 Jun 2016, 21:01Have you looked at all the options for containers? There is quite a bit of flexibility, though whether it will do what you want I do not know.
If it was me, I would probably set up an attribute on the staff and clothes called "carriedby" and set them to the juju man. You turn script could then go through every object in the world, check if it has a "carriedby" attribute, and if it does, put the object in the same room as the object indicated by the attribute.
For any other NPC, give their belongs a "carriedby" attribute, and set it to that NPC.
If the NPC drops the item, or the player gets it or whatever, you must set "carriedby" to null.
If it was me, I would probably set up an attribute on the staff and clothes called "carriedby" and set them to the juju man. You turn script could then go through every object in the world, check if it has a "carriedby" attribute, and if it does, put the object in the same room as the object indicated by the attribute.
foreach(o, AllObjects()) {
if (HasAttribute (o, "carriedby")) {
o.parent = o.carriedby.parent
}
}
For any other NPC, give their belongs a "carriedby" attribute, and set it to that NPC.
If the NPC drops the item, or the player gets it or whatever, you must set "carriedby" to null.

XanMag
04 Jun 2016, 21:14Sounds simple enough. Perfect! Thanks!
HegemonKhan
04 Jun 2016, 23:35the manual method (Pixie's is global method, which is much better - less work you got to do, lol), would be:
for each of your Objects, you'd add this setup using the special 'changed' Script, something like this, an example:
when your npc1 moves to room2, it has changed its 'parent' Object Attribute's Value, and thus the 'changedparent' Script is run, moving 'hat1' and 'shirt1' to the same location as 'npc1' (which is now room2).
for each of your Objects, you'd add this setup using the special 'changed' Script, something like this, an example:
<object name="room">
<object name="npc1">
</object>
<object name="hat1">
<attr name="scenery" type="boolean">true</attr>
</object>
<object name="shirt1">
<attr name="scenery" type="boolean">true</attr>
</object>
<object name="npc2">
</object>
<object name="hat2">
<attr name="scenery" type="boolean">true</attr>
</object>
<object name="shirt2">
<attr name="scenery" type="boolean">true</attr>
</object>
</object>
<object name="room2">
</object>
<object name="npc1">
<attr name="changedparent" type="script">
hat1.parent = npc1.parent
shirt1.parent = npc1.parent
</attr>
</object>
<object name="npc2">
<attr name="changedparent" type="script">
hat2.parent = npc2.parent
shirt2.parent = npc2.parent
</attr>
</object>
when your npc1 moves to room2, it has changed its 'parent' Object Attribute's Value, and thus the 'changedparent' Script is run, moving 'hat1' and 'shirt1' to the same location as 'npc1' (which is now room2).