Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → FirstThingInView == Wall
FirstThingInView == Wall
2001-05-25, 5:45 PM #1
Jah , i've beeen straining to do this but sense I don't have much experince with flags I can't do it , I hope Aglar or Hedeki can ..


Just like FirstThingInView , using face masks , but instaed I want it to serch for the closest wall to it self ....

Is that possible ?

If it's not it's back to the laggy way of firing projectiles
2001-05-25, 5:54 PM #2
Hmm, being that FirstThingInView searches for things, I can't imagine that it would be able to detect walls (since they are geometry, not things). I, of course, could be wrong, perhapes Hideki can confirm it.

------------------
Together we stand.
Divided we fall.
2001-05-25, 6:29 PM #3
Yeah I know

I tried the way

for(index=1; index<1000; index=index+1)
{
if(getsurfaceflags(index) == 0x4)
{
Bla bla
}
}

But that didn't work
2001-05-27, 1:37 AM #4
I hope this won't bog down PCs...

Code:
    dist = 10000;
    curPos = GetThingPos(bot);


   for(i=0; i<GetSurfaceCount(); i=i+1)
   {
      if(GetSurfaceFlags(i) & 0x4)
      {
         checker = VectorDist(curPos, SurfaceCenter(i));


         if(checker < dist)
         {
             dist = checker;
             closest = i;
         }
      }
   }


And btw this checks the center of the surfaces, so there could be another closer surface nearby sometimes.

If you only want to get the faced surfaces,
you should create a ghost thing in the middle of the surface and use ThingViewDot on it. If it returns more than 0, it's in sight.

------------------
http://millennium.massassi.net/ - Millennium

[This message has been edited by Hideki (edited May 27, 2001).]
2001-05-29, 12:21 AM #5
Hmm that didnt work to well , it may just be because of me getting all the ints , flexes and vectors messed up , Could you please write the cog out in full for me Hedeki ?
2001-05-29, 2:09 AM #6
"bot" is a thing (maybe this is not for rbot)
"dist" is a flex
"curPos" is a vector
"i" is an integer
"checker" is a flex
"closest" is an int

As the code above ends, the integer "closest" should have the surface reference that is closest to the "bot".

So if you use "PrintInt(closest);" I think it should return the integer reference, and you can do whatever after that.

Btw: I think you got my name wrong in your memory... it's Hideki, not "e". [http://forums.massassi.net/html/biggrin.gif]

------------------
http://millennium.massassi.net/ - Millennium
2001-05-29, 6:00 PM #7
Hmm i think that worked , but how would we turn that into a thing , so we could target it and do "thing" commands
2001-05-30, 12:25 PM #8
>Worked

Cool.

You didn't note what to do after you find the closest surface.

Do you want to target the wall?

You can just create a ghost thing in the center of the surface.

------------------
http://millennium.massassi.net/ - Millennium
2001-06-03, 8:57 PM #9
ahh yeah , sorry for not replying for a while.

It seems like creating a ghost on the surface can do the job , can you tell me the line of code that will do it , I tried CreateThing(ghost, GetSurfaceCentre(i)); but that didn't work.

Help Hedeki ?
2001-06-04, 1:23 AM #10
You know, his name isn't that hard to spell [http://forums.massassi.net/html/smile.gif]
2001-06-04, 4:39 AM #11
Hehe, sorry I didn't check this thread when it came up.

No, the name should be easy to spell.

Ok, that's because CreateThing is (template, thing) reference, if you want to use vector position to create a thing, use this.

CreateThingAtPos(ghost, GetSurfaceSector(closest), GetSurfaceCenter(closest), '0 0 0');

Also "centre" must be spelt in American way... [http://forums.massassi.net/html/smile.gif]

------------------
http://millennium.massassi.net/ - Millennium

↑ Up to the top!