Author Topic: Testing Validity of a Vector  (Read 363 times)

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Testing Validity of a Vector
« on: February 01, 2016, 11:51:46 pm »


               

I am utterly clueless as to how I would go about coding this. Is there a way to test if a vector is in a valid location (I.E. three yards into the blackspace of a wall?)



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Testing Validity of a Vector
« Reply #1 on: February 02, 2016, 12:45:09 am »


               

well... option 1 is to create an invisible creature on those coords and then get her location and compare it - if it differs the vector is in nonwalkable spot.


 


option2 is nwnx it has GetSurfaceMaterial function which can be used to test this



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Testing Validity of a Vector
« Reply #2 on: February 04, 2016, 04:47:30 pm »


               

I use option 1 for my Rift System in my PW.


At random intervals, a random area is chosen (above ground, outdoors)

Then a random location is selected - 


I spawn an invisible creature, get its location then destroy the creature.


 


If the location's X and Y do not match the vector I targetted, then I know that the location was not valid.


The thing to remember about Z axes is that even a little bit of debris or change in elevation on the ground can affect the Z axes of the creatures standing location.

So you might want to disregard the Z part of the vector, or at the very least append some buffer to the z axes if you are planning on spawning anything in the air at that location.


Eg: I do : Z = creatureLocation.Z+4; or something like that.


Result is a rift system that spawns at always 'valid' locations. (Note - it can still spawn in inaccessible areas though)

Below is an early POC I did (before it was refined) - I was planning on using tilemagic to turn water in the area to lava when a fire rift spawned etc
Worlds_of_Rhun_0005a.jpg



               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Testing Validity of a Vector
« Reply #3 on: February 04, 2016, 07:26:59 pm »


               

Thanks guys, this was tremendously helpful. Option 2 was used, I believe.