Viewpos and mapping

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Viewpos and mapping

Post by Opel » June 29th, 2011, 10:02 am

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.

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Viewpos and mapping

Post by Opel » June 29th, 2011, 4:40 pm

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?
Last edited by Opel on June 29th, 2011, 7:54 pm, edited 1 time in total.

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Viewpos and mapping

Post by Opel » June 30th, 2011, 9:28 pm

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.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Viewpos and mapping

Post by Drofder2004 » June 30th, 2011, 9:59 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Viewpos and mapping

Post by F |Madness| U » June 30th, 2011, 10:11 pm

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?
-

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Viewpos and mapping

Post by megazor » July 1st, 2011, 2:29 am

yes.

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Viewpos and mapping

Post by Opel » July 3rd, 2011, 10:06 am

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 + ")" );
}
 
 

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Viewpos and mapping

Post by Drofder2004 » July 3rd, 2011, 4:51 pm

Its not the best code, but if it works, then it works...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests