Author Topic: scripts and updating pc's display  (Read 402 times)

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« on: May 16, 2015, 07:41:05 pm »


               

Hi folks. 


 


I've been seeing an issue with the PC's appearance not updating when it should. I've got a couple of scripting systems that tie equip/unequip events to changes in PC appearance. For example, modified version of DLA dynamic quivers and a hooded cloak system  where if  you unequip the cloak the hood gets unequipped as well.  By using short delays I can make these things work almost all the time. But sometimes the cloak is unequipped but the PC model still shows the cloak. Or the quiver is removed (and debug shows the neck part to be back to 1) but the quiver still shows on the screen.


 


Has anyone else seen this?


 


I can fix it by re-equipping the cloak and the removing it, or re-equipping the bow/arrows and then removing it.  But the player would have to do that.  I don't want to script a hack to do it twice every time.


 


Is there a way to force the game to re-draw the PC's avatar?


 


Any other thoughts?


 



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
scripts and updating pc's display
« Reply #1 on: May 16, 2015, 11:10:35 pm »


               

Assuming the character is not polymorphed (a check may need to be made), you could use SetCreatureAppearanceType(OBJECT_SELF, GetAppearanceType(OBJECT_SELF));



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« Reply #2 on: May 16, 2015, 11:59:20 pm »


               

Thanks WhiZard, that's a good idea. I'll give it a try.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« Reply #3 on: May 18, 2015, 02:56:11 pm »


               

Looks like I have two different issues.  I have not gotten to test the cloak staying visible while unquipped yet, but I've added the above as a chat debug command so when I get that to happen again I can see if that fixes it.


 


The quiver issue turns out to be different. It seems the armor somehow remembers the neck part that is set on the creature. So while wearing an armor (that normally has neck part 1) if I equip the quiver (by equipping arrows) the armor seems to get the quiver but the PC does report neck part 7 with getcreaturebodypart. If I then remove the armor (while keeping the arrows/quiver equipped) the quiver code runs again and detects the PC does not have the quiver (neck part reports 1) and re-adds it. So the neck part which was set to 7 reverted to 1 when the armor was removed.


 


If I then remove the arrows (quiver goes away and neck part reports 1) and re-equip the armor the quiver neck part returns, yet the PC still reports neck part 1. The quiver code does not think there is a quiver to remove and leaves the it there.  So the quiver seems to go with the armor but only partly.


 


There's some inconsistency here that does not quite make sense to me. Normally using getcreaturebodypart does not return the equipped armor part. But it looks like setting it sets the armor part as well in this case. I've added debug to dump the armor part numbers too so I'll do some more testing before I hack up the code to try to get around this oddness.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« Reply #4 on: May 19, 2015, 02:53:22 am »


               

That's what's happening. Seems to only happen to the neck part.  In summary:


 


SetCreatureBodyPart(CREATURE_PART_NECK, X, oPC)  changes both the PCs neck part _and_ the equipped armor's neck part.  When re-equipped armor now has the new neck part number but PC does not get that on creature part number.


 


That's somewhat obnoxious but can be coded around...



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
scripts and updating pc's display
« Reply #5 on: May 19, 2015, 04:38:43 pm »


               

Meaglyn, that is one reason why I moved to amethyst dragon's VFX quivers. Those neck parts are tricky.


 


I don't recall sleuthing it out like you have. So thanks for that. This is good information.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« Reply #6 on: May 19, 2015, 05:21:10 pm »


               

That could be better than hacking in code for this issue. Do you have a code snippet you can share or a pointer? If there is a better way to do this I'm all for it. I was just realizing that I'd have to not do the quiver if the armor used a specific neck part etc.


 


I suspect the neck part thing is left over from the earlier cloak implementation but that's before my time so is just a guess. 



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
scripts and updating pc's display
« Reply #7 on: May 19, 2015, 07:12:01 pm »


               

Nevermind Henesua, I found the package and managed to cobble together something that should work. Thanks for the suggestion (and thanks TAD for the content). Someday I may even let PCs pick their own quiver color. For now they can have any color they want as long as it's brown.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
scripts and updating pc's display
« Reply #8 on: May 19, 2015, 09:55:05 pm »


               

heh... that is the position i am currently at too. Brown quivers.