Results 1 to 4 of 4

Thread: Drop a model

  1. #1
    Private
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    13
    Thanked 4 Times in 3 Posts

    Drop a model

    Hello

    i would like to know how to drop a model, i mean:
    i get a sentry from shop and this sentry must be in my vision and it moves only if i move my vision and i have to press f to drop the model. Mhm idk how to say, i hope you understand, i have already seen it in a few servers and i would like to have it too.

    i tried somethings with 'self geteye()' but it do not work.

    ORDI

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    To get the position your player is looking to, try this:

    https://github.com/kungfooman/cod2_s...utils.gsc#L203

    PHP Code:

    getRealEye
    ()
    {
        
    player self;

        
    stance player getStance();
        
        
    offset 0;
        switch (
    stance)
        {
            case 
    "stand"offset =  20; break;
            case  
    "duck"offset =   0; break;
            case   
    "lie"offset = -30; break;
            
    //default: offset = getcvarint("offset");
        
    }

        
    realEye player getEye() + (0,0,offset);
        return 
    realEye;
    }

    lookAtRaw()
    {
        
    player self;
        
        
    originStart player getRealEye();
        
    //originStart = player getTagOrigin("j_head");
        //originStart = player getTagOrigin("tag_aim");

        
    angles player getPlayerAngles();
        
    forward anglesToForward(angles);

        
    originEnd originStart vectorScale(forward100000);

        
    trace bullettrace(originStartoriginEndfalseundefined);

        if (
    trace["fraction"] == 1)
            return 
    undefined;

        return 
    trace;

    The getStance() function needs libcod though.

    You still need to add a distance check, like replacing

    PHP Code:
        originEnd originStart vectorScale(forward100000); 
    with

    PHP Code:
        originEnd originStart vectorScale(forward100); 
    If you can't run libcod, replace getRealEye() with getEye().
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    Mitch (31st May 2015)

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    GetStance() for normal COD2:

    Code:
    GetStance()
    {
    	trace = bulletTrace( self.origin, self.origin + ( 0, 0, 80 ), false, undefined );
    	top = trace["position"] + ( 0, 0, -1); //find the ceiling, if it's lower than 80
    
    	bottom = self.origin + ( 0, 0, -12 );
    	forwardangle = maps\mp\_utility::vectorScale( anglesToForward( self.angles ), 12 );
    
    	leftangle = ( -1 * forwardangle[1], forwardangle[0], 0 );//a lateral vector
    
    	//now do traces at different sample points
    	//there are 9 sample points, forming a 3x3 grid centered on player's origin
    	//and oriented with the player facing forward
    	trace = bulletTrace( top + forwardangle, bottom + forwardangle, true, undefined );
    	height1 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top - forwardangle, bottom - forwardangle, true, undefined );
    	height2 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top + leftangle, bottom + leftangle, true, undefined );
    	height3 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top - leftangle, bottom - leftangle, true, undefined );
    	height4 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top + leftangle + forwardangle, bottom + leftangle + forwardangle, true, undefined );
    	height5 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top - leftangle + forwardangle, bottom - leftangle + forwardangle, true, undefined );
    	height6 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top + leftangle - forwardangle, bottom + leftangle - forwardangle, true, undefined );
    	height7 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top - leftangle - forwardangle, bottom - leftangle - forwardangle, true, undefined );
    	height8 = trace["position"][2] - self.origin[2];
    
    	trace = bulletTrace( top, bottom, true, undefined );
    	height9 = trace["position"][2] - self.origin[2];
    
    	//find the maximum of the height samples
    	heighta = getMax( height1, height2, height3, height4 );
    	heightb = getMax( height5, height6, height7, height8 );
    	maxheight = getMax( heighta, heightb, height9, 0 );
    
    	//categorize stance based on height
    	if( maxheight < 33 )
    		stance = "lie";
    	else if( maxheight < 52 )
    		stance = "duck";
    	else
    		stance = "stand";
    
    	return( stance );
    }

  5. The Following User Says Thank You to Tally For This Useful Post:

    kung foo man (31st May 2015)

  6. #4
    Private
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    13
    Thanked 4 Times in 3 Posts
    mhm where is the problem ? i would like every 0.1 second, the model move according to my vision.

    PHP Code:
    sentry()
    {
        
    self endon("disconnect");
        
    self endon("killed_player");
        
        
    self iprintlnbold("^7Press ^3[^7F^3] ^7to Place a sentry");
        
    sentry spawn("script_model",self geteye()+(0,0,-40));
        
    sentry setmodel("xmodel/ordi_sentrygun");
        
    s1 undefined;
        
        for(;;)
        {
            
    wait 0.1;
            
    trace bullettrace(self getEye()+(0,0,-40), self getEye()+(0,0,-40)+maps\mp\_utility::vectorScale(anglesToForward(self getPlayerAngles()), 100000), falseundefined);
            
            if(
    trace["fraction"]!=1)
            {
                if(
    isdefined(trace["entity"]))
                {
                    if(
    isplayer(trace["entity"]))
                    {
                        
    s1=trace["entity"];
                        
    sentry.origin s1.origin;
                        
    s1 linkto(sentry);
                    }
                }
            }
            
            if(
    self usebuttonpressed())
            {
                
    sentry unlink();
                
    s1=undefined;
                
    self iprintln("Sentry placed!");
                
    self thread activation_sentry();
                break;
            }
        }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •