Fine animation control

Want to discuss changes to the UOX3 source code? Got a code-snippet you'd like to post? Anything related to coding/programming goes here!
Post Reply
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Fine animation control

Post by Saint »

Is there a way to control player or NPC animations? Example, maybe have the animation freeze on specific frames for a certain amount of time in order to capture a certain pose or something.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

It might be possible to do an action with a really slow time frame, but not all are possible. But as far as that level of control goes, nope, the server doesn't tell the client that sort of detail.
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

Does this mean it's not really possible to make a character lay on the floor as if they are going to sleep?

I guess the only way to do that would be to make the player invisible, make a copy of the player at the player's location, then play the death animation on that copy of the player and leave that NPC dead. And when the player *wakes up* the copy is removed and the player is made visible again. m i rite
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Yeah, but you wouldn't have to make an actual copy of the player and kill him. Just make the player fall over - then make him invisible and add a corpse item looking just like him on the ground. Attach an onUse JS to the corpse, setup so the player will become visible again and regain his items (if transferred to the corpse earlier) when he double-clicks it.

Would also have to make sure that only that specific character could double-click it though :)
-= Ho Eyo He Hum =-
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

So corpse objects can be decorated as if they were players?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Yep. I've done that myself in a half-finished script I wrote to let characters sleep on beds. i.e. hide, freeze & mute the real character, add a corpse (renamed, of course) on the bed with the player character's physical features (skin color, hair, beard), transfer all items from character to corpse.
-= Ho Eyo He Hum =-
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

I've actually noticed that NPC's and PC's lose their hair and facial hair on death. And some items actually become unequipped from the corpse. Why? And can it be fixed?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

You're making the bold assumption that it is something that should be fixed :)

The events on death are handled in HandleDeath(), in pcmanage.cpp (around line 1000). You probably want to tinker with MoveItemsToCorpse(), which is around line 920. That basically shunts everything across to the corpse, except for trade containers, bank boxes, and the backpack (though contents of the backpack do get moved in). As long as it's not a spellbook, nor a newbie item, that is.
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

Looking through the script real quick, the first thing I've noticed is that objects are being manipulated with SetX, SetY and SetZ function. Can't really understand why? Does this represent the location in the container or something?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Yup, the xyz is either a location in the world, or a location within the container. Container's tend to like to be organised, I think the client treats certain cooardinates certain ways. But yup, it's to make sure they're within the proper bounds of the container so that someone can see them.
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

Maarc wrote:Yup, the xyz is either a location in the world, or a location within the container. Container's tend to like to be organised, I think the client treats certain cooardinates certain ways. But yup, it's to make sure they're within the proper bounds of the container so that someone can see them.
Ah, makes sense. If a container has multiple items but you know the exact location of a specific item you would be able to access them quickly in O(1) time without iterating through all the items, like a hash table.

I take it that on resurrection there is a script somewhere that searches for items called "Hair/Beard". Do Corpses have layers in the same way that players do? Maybe it's simply a matter of creating a copy of the player's hair and facial hair and putting them into the proper layers on the corpse?


Edit: I've also noticed that SetCont has no checks for elven hair styles. Wouldn't that result in a bug?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

No, corpses don't have layers, which is part of why all that logic has to be there. As for constant access, while we set it, we don't do location based lookups, we have a vector based list, so it'd be more O(n) really. But it was a damn sight better than it used to be in 0.7x, where it was stuffed into a global hash table, which means it also contained other containers and their items as well that you'd have to look through :)

Resurrection is handled through NpcResurrectTarget(), in targeting.cpp. It can call onResurrection script, yes. But as far hair/beard handling, actually, no, it doesn't look like there is. Interesting, I wonder what that really means.

And the SetCont thing is probably a bug, yes. We should probably not be checking against hard coded IDs anyway, but whether the item's layer property is IL_HAIR or IL_FACIALHAIR.
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

Maarc wrote:No, corpses don't have layers, which is part of why all that logic has to be there. As for constant access, while we set it, we don't do location based lookups, we have a vector based list, so it'd be more O(n) really. But it was a damn sight better than it used to be in 0.7x, where it was stuffed into a global hash table, which means it also contained other containers and their items as well that you'd have to look through :)

Resurrection is handled through NpcResurrectTarget(), in targeting.cpp. It can call onResurrection script, yes. But as far hair/beard handling, actually, no, it doesn't look like there is. Interesting, I wonder what that really means.
Interesting. I also wonder what it really means.

I wouldn't doubt that the hair and beard never actually leaves the player. Strangely enough, while messing around I noticed I can get hair to appear on a players paperdoll without appearing on the actual character. Most puzzling.
And the SetCont thing is probably a bug, yes. We should probably not be checking against hard coded IDs anyway, but whether the item's layer property is IL_HAIR or IL_FACIALHAIR.
Yea, but the IDs probably aren't going anywhere for a while. The missing ranges are 0x2FBF to 02FC2 and 0x2FCC to 0x2FD2
Saint
UOX3 Apprentice
Posts: 162
Joined: Sun Feb 11, 2007 6:05 pm
Has thanked: 0
Been thanked: 0

Post by Saint »

What really puzzles me is why the hair gets renamed to "Hair/Beard", I've searched but there are no files which even use that piece of information.


edit: Xuri: did your sleeping script find a way to transfer hair and beard features in java script?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Not sure why it's doing what it is with the hair, doesn't make a lot of sense to me. As far as IDs vs LayerTypes goes, it's just as easy to fix it to do the right thing by layer as to add the new IDs, and one's a lot more futureproof than the other :)
Post Reply