Author Topic: Queue/Stack of Objects - Possible in NwN?  (Read 958 times)

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #15 on: May 30, 2015, 02:45:30 pm »


               

Having given up on being able to get this working 100%, I decided that with all the work I had put into it, I would post it (including a warning about the mystery bug) anyway. Having decided this, I set about taking some screen shots. As I tried and failed to get all the placeables into a single picture, I enlarged the area and moved the PC's start position a little (~ 2 - 3 game meters) further away from the placeables. I first got my shot in the toolset. I then pressed F9 for an in-game shot. To cut a long story (of experimentation) short... Having left the debug code in place I discovered that it now appears to be working 100%. It would appear that either standing this close (see pic)


 


Too%20Close.gif


 


was the problem or the area was too small. In other words the blueprints are fine, and the script is ok as well. My guess is that there is something in the algorithm of the GetNearestObjectByTag function that was falling down. Has anyone else come across this before?


 


BTW, if you are interested in what this project is look in this thread.


 


TR



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #16 on: May 30, 2015, 03:32:32 pm »


               

Bear in mind that a script that creates objects can interfere with the indexing for looping through GetNearestObjectByTag().



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #17 on: May 30, 2015, 08:02:20 pm »


               

Which is why I used a pseudo stack and 3 separate loops for detection, destruction and creation. What you see above is only the detection part of the code, that stores the information on the pseudo stack.


 


TR



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #18 on: May 30, 2015, 11:32:02 pm »


               As a rule-of-thumb, I avoid distance functions if there is an alternative e.g. GetObjectByTag.


The only science behind this is that distance is miscalculated on entry (because creature position is null for an appreciable time) and slightly variable when creatures get bumped, so I can't explain your result.


Some will say that blanket avoidance is unnecessary, which is true if you have a memory for fine detail, but as a more conceptual thinker I prefer to keep it simple.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #19 on: May 31, 2015, 12:14:17 am »


               

The only thing GetNearestObjectByTag() would be efficient for is if you had different effects for the closest, next closest, etc.  If you are just looking for what is within a certain distance, then GetObjectByTag() accompanied by a distance check will be much more efficient processing-wise and does not run the risk of duplicating when an object is created.



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #20 on: May 31, 2015, 12:14:37 am »


               

I chose GetNearestObjectByTag  because it simplified the script due to it only getting matching objects in the current area.


 


TR



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #21 on: May 31, 2015, 08:12:20 pm »


               


 


The question is "What is causing the duplication on the 11th and 12th passes and why is the object with the resref of es_sg_window03e being missed? I cannot see any errors in the blueprints either. TBH I am stumped. Ideas anyone?

 

TR

 




 


I have another thought. How repeatable was this duplication and omission?  Could it be a rare occurrence when the two objects specified were the exact same distance from the PC's location?


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Queue/Stack of Objects - Possible in NwN?
« Reply #22 on: May 31, 2015, 11:31:25 pm »


               

That is my guess. But I have now finished with the project that it was for. I have learned some new techniques and if anyone comes across this problem in that project I will offer what help I can. Finally, if I have a similar project in the future I will avoid GetNearestObjectByTag  and use GetObjectByTag  even if it does mean I have another level of complexity in my code.


 


TR