Author Topic: CreateObject and terrain height (z axis)  (Read 387 times)

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
CreateObject and terrain height (z axis)
« on: February 08, 2012, 08:28:09 pm »


               so, i've got a script and all it does is read from a mysql database for parameters to a CreateObject function each heartbeat.  i use a webform to populate this mysql db with creatures and other placeables.

the in-game function is very dumb - it relies upon the webform completely for the appropriate parameters to CreateObject (including the location vector).

the problem i've run into is this:  i don't know how to handle the z axis.  x and y are easy, since i've dumped the minimaps from the module and can calculate them from the mouse clicks on the bitmap.  but i don't have a way of figuring out the z axis, so i've just been using 0.

that worked fine for awhile, until i tried to spawn something on a hill.  actually, a creature object was still fine, since they kind of "fly" in from the sky and land on whatever hill is at the x,y location.

placeables, however, are a problem.  they are still spawned at 0 on the z axis, which means they're now inside the hills and whatnot.


now for the question:  is there a way to get my desired action?  that placeables show up on the "ground" of whatever x,y vector i give them?  can they just "fall down" and land on whatever z axis is there?  is there a way to calculate (in game) what the z axis of the ground will be?  or perhaps an even more clever solution?


thanks guys '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
CreateObject and terrain height (z axis)
« Reply #1 on: February 08, 2012, 08:36:44 pm »


               This one's been asked before. Do a search, you'll find both a nwnx solution and a vanilla nwn solution. If not, let us know, and I can link you when I have more time.

Funky
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
CreateObject and terrain height (z axis)
« Reply #2 on: February 08, 2012, 09:04:58 pm »


               my apologies, but my forum searching skills must be sub-par.  i was unable to find anything related.  :/
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
CreateObject and terrain height (z axis)
« Reply #3 on: February 08, 2012, 09:56:17 pm »


               The vanilla creation method involves spawning in an invisible creature, and using it to find the z point of the ground at that x/y point.  You'd need to delay the placeable creation a tiny bit to allow for the creature to "settle" to ground level.  Without NWNX that's the only method of accurately finding Z.
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
CreateObject and terrain height (z axis)
« Reply #4 on: February 09, 2012, 12:08:29 am »


               oh very clever!  i was so close to figuring it out when i saw that creatures worked fine.  i don't think i would have made that last step, though.