Author Topic: GetDistanceBetween onExit possible?  (Read 349 times)

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
GetDistanceBetween onExit possible?
« on: January 20, 2015, 06:26:34 pm »


               

I'm trying to discourage players from outrunning their pack animals and would like to do a GetDistanceBetween check when the PC exits an area.  If they are > 30.0 then it drops their henchman (pack animal) and floats text that they have lost their animal.


 


They can then go back to the previous area and tame it again.


 


Problem is when I add this onExit


 


object oExiting = GetExitingObject();


object oHench = GetHenchman(oExiting);

 

    if (GetDistanceBetween(oHench, oExiting) > 30.0)//Checks distance, if too far, will not follow

    {

        AssignCommand(oHench, ClearAllActions());

        RemoveHenchman(oExiting, oHench);

        DelayCommand(4.5, FloatingTextStringOnCreature("<cÍÍ >You have lost your pack animal</c>", oExiting));

    }

 


my conditions always fire as if I am always 30.0 distance away even if the animal is right behind me, so I lose the animal.  I fear the check isn't going off until I transition and it's true regardless of distance.


 


Any suggestions would be great!


 


 



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
GetDistanceBetween onExit possible?
« Reply #1 on: January 20, 2015, 06:46:35 pm »


               

no not possible OnExit


 


but you can code this in OnAreaTransition script (default area transition script thats fired when there is no custom script is nw_g0_transition)



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
GetDistanceBetween onExit possible?
« Reply #2 on: January 20, 2015, 07:03:11 pm »


               

I'll be alright with doing that if it's going to apply to every standard transition.


 


I was trying to avoid having to have a custom script on every single area transition.  Instead just a blanket check.


 


Thanks Shadooow



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
GetDistanceBetween onExit possible?
« Reply #3 on: January 20, 2015, 07:11:24 pm »


               

I would like to restrict my henchmen (pack animals) just like horses and have a hitching post in town that they jump to when you enter the 3_NO_HORSES areas.  


 


How would I go about assuring this?  My pack animals have the henchmen script sets on them, how do I define them as a horse so they are picked up by that variable?


 


EDIT: ended up finding my solution in the OnAreaTransition