Page 1 of 1

Viewpos and mapping

Posted: June 29th, 2011, 10:02 am
by Opel
Hey guys, i am wondering if there is a much better way to get sizes of walls, etc rather than using viewpos. I am trying to recreate a Sp map and wondering if there is a different way. I just don't feel im doing it right with viewpos. Should i be taking into consideration player sizes when using it ? any help is appreciated, thanks.

Re: Viewpos and mapping

Posted: June 29th, 2011, 4:40 pm
by Opel
I guess you could do it with mod. Do mods work in singleplayer? I guess to calculate it, it would be something along the lines of

Code: Select all


self.firstorigin = self getorigin();
wait 1;
self.secondOrigin = self getOrigin();

size = self.firstOrigin[0] - self.secondOrigin[0];

iprintlnBold( size );

And also x,y,z are 0,1,2 when in an array?

Re: Viewpos and mapping

Posted: June 30th, 2011, 9:28 pm
by Opel
Hmm, i may have a go at recreating that. I guess i would have to use bulletraces and i just can't get my head around on how to use them.

Re: Viewpos and mapping

Posted: June 30th, 2011, 9:59 pm
by Drofder2004
It really isn't hard, It is simply a collection of positions marked with bullettraces and the use of 2D distance.
If I were to recreate the mod, it would be a lot more practical than how I had it.

Re: Viewpos and mapping

Posted: June 30th, 2011, 10:11 pm
by F |Madness| U
On the subject of bullet traces, how do you return the origin of a bullet trace? Ie. a bullet trade directly down from point A, to point B (point B being the first thing the bullet trace hits), and so it returns the origin of point B?

Re: Viewpos and mapping

Posted: July 1st, 2011, 2:29 am
by megazor
yes.

Re: Viewpos and mapping

Posted: July 3rd, 2011, 10:06 am
by Opel
I believe i've got it. It's not the best way or best coding but it seems to work.

Code: Select all

 
checks()
{
        self endon( "disconnect" );
        
        self.pressed = false;
 
        for(;;)
        {
                if( self attackButtonPressed())
                {
                        self thread checks2();
                        self thread trace1();
                        self iPrintLn("true");
                        self.pressed = true;      
                }
                wait 0.05;
        }
        wait 0.05;
}
        
 
 
checks2()
{
        self endon( "disconnect" );
 
        for(;;)
        {
                if(self.pressed && self useButtonPressed())
                {
                        self thread trace2();
                        self iPrintLn("true2");
                        self.pressed = false;
                }
                wait 0.05;
        }
        wait 0.05;
}
 
 
trace1()
{
        angles = self getPlayerAngles();
        start = ( self getEye() + ( 0, 0, 20 ) );
        end = ( start + vectorscale( anglesToForward( angles ), 4096 ));
 
        trace = bulletTrace( start, end, false, undefined );
        
        self.point = trace["position"];
 
        self iPrintLn( self.point );
}
 
trace2()
{
        angles = self getPlayerAngles();
        start = ( self getEye() + ( 0, 0, 20 ) );
        end = ( start + vectorscale( anglesToForward( angles ), 4096 ));
 
        trace = bulletTrace( start, end, false, undefined );
        
        self.point2 = trace["position"];
 
        self iPrintLn( self.point2 );
 
        self thread pos();
}
 
pos()
{
        x = ( self.point[0] - self.point2[0] );
        y = ( self.point[1] - self.point2[1] );
        z = ( self.point[2] - self.point2[2] );
 
        self iPrintLnBold( "x - " + x );
        self iPrintLnBold( "y - " + y );
        self iPrintLnBold( "z - " + z );
 
        self iPrintLnBold( "(" + x + " ),(" + y + "),(" + z + ")" );
}
 
 

Re: Viewpos and mapping

Posted: July 3rd, 2011, 4:51 pm
by Drofder2004
Its not the best code, but if it works, then it works...