Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 97 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Flying in MP like spectator
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Nov. 27, 2009 03:14 pm
Hi, I wrote a code for flying in cod... Everything works, but I can't go lower than 0.075 in time in that while function. Simply u stop moving if u set value lower for example 0.05... Does anyone have an idea what is causing it?

plane()
{
while (1)
{
self hide();
startOrigin = self getEye();
forward = anglesToForward( self getplayerangles() );
forward = maps\mp\_utility::vectorScale( forward, 200 );
endOrigin = startOrigin + forward;

trace = bulletTrace( startOrigin, endOrigin, false, self );
angles = vectortoangles(vectornormalize(trace["normal"]));
model = spawn("script_model", trace["position"]);
model2 = spawn("script_model", self.origin);

self linkto (model2);

plane = spawn("script_model", self.origin+(0,0,70));
plane setmodel("xmodel/vehicle_stuka_flying");
plane.angles = (self.angles);

model2 moveto(model.origin, 0.2);


wait (0.075);

model delete();
model2 delete();
plane delete();

}

}

Problem is: Plane has jerky movement. (0.1-10fps;0.05-20fps;0.075-15fps) and 15 fps is rll low :(

edited on Nov. 27, 2009 10:19 am by Dutch77
Share |
COD4GRC
General Member
Since: Aug 12, 2007
Posts: 44
Last: Jan 30, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Nov. 27, 2009 03:32 pm
Your wait should have the same value as you moveto time. moveto time is .2 so wait has to be: wait .2;
Share |
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Nov. 27, 2009 08:43 pm
Nope problem stays :(
Share |
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Dec. 13, 2009 02:14 pm
So I made it... my finelly version of this. This is a plane that bombard on melee button :) I don't expect anynone would be clever at this code (I am honestly not and I am suprised that code even works). But if anyone want to bombard the map, here's the code xD :

Code:


plane()
{
self hide();
self disableWeapon();

destination1 = 0;
destination2 = 0;
destination3 = 0;
destination4 = 0;
destination5 = 0;
destination6 = 0;
destination7 = 0;
destination8 = 0;
destination9 = 0;
destination10 = 0;

bomb1 = 0;
bomb2 = 0;
bomb3 = 0;
bomb4 = 0;
bomb5 = 0;
bomb6 = 0;
bomb7 = 0;
bomb8 = 0;
bomb9 = 0;
bomb10 = 0;

bum1 = 0;
bum2 = 0;
bum3 = 0;
bum4 = 0;
bum5 = 0;
bum6 = 0;
bum7 = 0;
bum8 = 0;
bum9 = 0;
bum10 = 0;

cislo = 1;

self iprintln("^1Press F to delete plane");
self iprintln("^2Press Shift to bombard");

while (1) 
      {
      startOrigin = self getEye();
      forward = anglesToForward( self getplayerangles() );
      forward = maps\mp\_utility::vectorScale( forward, 200 );
      endOrigin = startOrigin + forward;
      
      trace = bulletTrace( startOrigin, endOrigin, false, self );
      angles = vectortoangles(vectornormalize(trace["normal"])); 
      model = spawn("script_model", trace["position"]);
      model2 = spawn("script_model", self.origin);
      
      self linkto (model2);
      
      plane = spawn("script_model", self.origin+(0,0,-30));
      plane setmodel("xmodel/vehicle_stuka_flying");
      plane.angles = (self.angles); 
      
      model2 moveto(model.origin, 0.2);
      

      wait (0.075);
      
      model delete();
      model2 delete();
      plane delete();
      
      if(self.health <= 0)  //player is dead
              {
              model delete();
              model2 delete();
              plane delete();
              self show();
              self enableWeapon();
              return(0);
              }
      if(self UseButtonPressed()) //delete plane
        {
        model delete();
        model2 delete();
        plane delete();
        self show();
        self enableWeapon();
        self iprintln("^1You have just left the plane");
        return(0);
        }
      if(cislo!=1 && cislo!=11 && cislo!=21 && cislo!=31 && cislo!=41 && cislo!=51 && cislo!=61 && cislo!=71 && cislo!=81 && cislo!=91) 
        {
        cislo++;
        }
      if (self MeleeButtonPressed()) //bombard
      {
        if (cislo == 91) 
        {
        bum10 = 1;
        bomb10 = spawn("script_model", self.origin );
    		bomb10 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination10 = spawn("script_model", trace["position"] );
        
        x = destination10.origin[0];
        y = destination10.origin[1];
        z = destination10.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        // counting vector, to calculate the time to impact
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
        
        // newton patern for square of number (v9=3)    
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000; //120000 is constant value 
      
        bomb10 moveto(destination10.origin, j); // move bomb to position
        cislo++; 
        }
        if (cislo == 81) 
        {
        bum9 = 1;
        bomb9 = spawn("script_model", self.origin );
    		bomb9 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination9 = spawn("script_model", trace["position"] );
        
        x = destination9.origin[0];
        y = destination9.origin[1];
        z = destination9.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb9 moveto(destination9.origin, j);
        cislo++; 
        }
        if (cislo == 71) 
        {
        bum8 = 1;
        bomb8 = spawn("script_model", self.origin );
    		bomb8 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination8 = spawn("script_model", trace["position"] );
        
        x = destination8.origin[0];
        y = destination8.origin[1];
        z = destination8.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb8 moveto(destination8.origin, j);
        cislo++; 
        }
        if (cislo == 61) 
        {
        bum7 = 1;
        bomb7 = spawn("script_model", self.origin );
    		bomb7 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination7 = spawn("script_model", trace["position"] );
        
        x = destination7.origin[0];
        y = destination7.origin[1];
        z = destination7.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb7 moveto(destination7.origin, j);
        cislo++; 
        }
        if (cislo == 51) 
        {
        bum6 = 1;
        bomb6 = spawn("script_model", self.origin );
    		bomb6 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination6 = spawn("script_model", trace["position"] );
        
        x = destination6.origin[0];
        y = destination6.origin[1];
        z = destination6.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb6 moveto(destination6.origin, j);
        cislo++; 
        }
        if (cislo == 41) 
        {
        bum5 = 1;
        bomb5 = spawn("script_model", self.origin );
    		bomb5 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination5 = spawn("script_model", trace["position"] );
        
        x = destination5.origin[0];
        y = destination5.origin[1];
        z = destination5.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb5 moveto(destination5.origin, j);
        cislo++; 
        }
        if (cislo == 31) 
        {
        bum4 = 1;
        bomb4 = spawn("script_model", self.origin );
    		bomb4 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination4 = spawn("script_model", trace["position"] );
        
        x = destination4.origin[0];
        y = destination4.origin[1];
        z = destination4.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb4 moveto(destination4.origin, j);
        cislo++; 
        }
        if (cislo == 21) 
        {
        bum3 = 1;
        bomb3 = spawn("script_model", self.origin );
    		bomb3 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination3 = spawn("script_model", trace["position"] );
        
        x = destination3.origin[0];
        y = destination3.origin[1];
        z = destination3.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb3 moveto(destination3.origin, j);
        cislo++; 
        }
        if (cislo == 11) 
        {
        bum2 = 1;
        bomb2 = spawn("script_model", self.origin );
    		bomb2 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination2 = spawn("script_model", trace["position"] );
        
        x = destination2.origin[0];
        y = destination2.origin[1];
        z = destination2.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb2 moveto(destination2.origin, j);
        cislo++; 
        }
        if (cislo == 1) 
        {
        bum1=1;
        bomb1 = spawn("script_model", self.origin );
    		bomb1 setmodel("xmodel/prop_mortar_ammunition");
        
        //bombarding 
        startOrigin = self.origin;
        down = anglesToForward( self.angles+(90,0,0) );
        down = maps\mp\_utility::vectorScale( down, 10000 );
        endOrigin = startOrigin + down;
      
        trace = bulletTrace( startOrigin, endOrigin, false, self );
        angles = vectortoangles(vectornormalize(trace["normal"]));
        
        destination1 = spawn("script_model", trace["position"] );
        
        x = destination1.origin[0];
        y = destination1.origin[1];
        z = destination1.origin[2];
      
        m = self.origin[0];
        n = self.origin[1];
        o = self.origin[2];
        
        i = ((x-m)*(x-m))+((y-n)*(y-n))+((z-o)*(z-o));
            
        a = 1;
        a = a-((a*a-i)/(2*a));
      
        j=a/120000;  
      
        bomb1 moveto(destination1.origin, j);
        cislo++; 
        }
        if (cislo >> 1 && cislo << 11)  
        {
        cislo++;
        }
        
      }
        if (bum1 == 1) //check if bomb reach destination, if y boom :)
        {
        if (destination1.origin == bomb1.origin) 
        {
        bomb1 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination1.origin);
	      destination1 playSound("flak88_explode");
        radiusDamage (destination1.origin+(0,0,30), 350, 150, 80);
        destination1 = 0;
        bomb1 = 0;
        bum1=0;
        }
        }
        
        if (bum2 == 1) 
        {
        if (destination2.origin == bomb2.origin) 
        {
        bomb2 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination2.origin);
	      destination2 playSound("flak88_explode");
        radiusDamage (destination2.origin+(0,0,30), 350, 150, 80);
        destination2 = 0;
        bomb2 = 0;
        bum2=0;
        }
        }
        
        if (bum3 == 1) 
        {
        if (destination3.origin == bomb3.origin) 
        {
        bomb3 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination3.origin);
	      destination3 playSound("flak88_explode");
        radiusDamage (destination3.origin+(0,0,30), 350, 150, 80);
        destination3 = 0;
        bomb3 = 0;
        bum3=0;
        }
        }
        
        if (bum4 == 1) 
        {
        if (destination4.origin == bomb4.origin) 
        {
        bomb4 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination4.origin);
	      destination4 playSound("flak88_explode");
        radiusDamage (destination4.origin+(0,0,30), 350, 150, 80);
        destination4 = 0;
        bomb4 = 0;
        bum4=0;
        }
        }
        
        if (bum5 == 1) 
        {
        if (destination5.origin == bomb5.origin) 
        {
        bomb5 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination5.origin);
	      destination5 playSound("flak88_explode");
        radiusDamage (destination5.origin+(0,0,30), 350, 150, 80);
        destination5 = 0;
        bomb5 = 0;
        bum5=0;
        }
        }
        
        if (bum6 == 1) 
        {
        if (destination6.origin == bomb6.origin) 
        {
        bomb6 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination6.origin);
	      destination6 playSound("flak88_explode");
        radiusDamage (destination6.origin+(0,0,30), 350, 150, 80);
        destination6 = 0;
        bomb6 = 0;
        bum6=0;
        }
        }
        
        if (bum7 == 1) 
        {
        if (destination7.origin == bomb7.origin) 
        {
        bomb7 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination7.origin);
	      destination7 playSound("flak88_explode");
        radiusDamage (destination7.origin+(0,0,30), 350, 150, 80);
        destination7 = 0;
        bomb7 = 0;
        bum7=0;
        }
        }
        
        if (bum8 == 1) 
        {
        if (destination8.origin == bomb8.origin) 
        {
        bomb8 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination8.origin);
	      destination8 playSound("flak88_explode");
        radiusDamage (destination8.origin+(0,0,30), 350, 150, 80);
        destination8 = 0;
        bomb8 = 0;
        bum8=0;
        }
        }
        
        if (bum9 == 1) 
        {
        if (destination9.origin == bomb9.origin) 
        {
        bomb9 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination9.origin);
	      destination9 playSound("flak88_explode");
        radiusDamage (destination9.origin+(0,0,30), 350, 150, 80);
        destination9 = 0;
        bomb9 = 0;
        bum9=0;
        }
        }
        
        if (bum10 == 1) 
        {
        if (destination10.origin == bomb10.origin) 
        {
        bomb10 delete();
        level._effect["mortexplosion"] = loadfx("fx/explosions/flak88_explosion.efx");
	      playfx(level._effect["mortexplosion"], destination10.origin);
	      destination10 playSound("flak88_explode");
        radiusDamage (destination10.origin+(0,0,30), 350, 150, 80);
        destination10 = 0;
        bomb10 = 0;
        bum10=0;
        }
        }
      
        if (cislo >= 91) // start at first bomb
        {
        cislo = 1;
        }
        
      }
            
}








edited on Dec. 13, 2009 01:09 pm by Dutch77
Share |
COD4GRC
General Member
Since: Aug 12, 2007
Posts: 44
Last: Jan 30, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Dec. 13, 2009 08:22 pm
next time, try looping through a destination bomb and bum array. I see a lot of code duplication, which is bad :D
(no offense, just a tip)
Share |
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Dec. 13, 2009 09:02 pm
attachment: image(38.3Kb) image(39.9Kb) image(38.3Kb)
I know, but I didn't figure out any other method how to do it... even if its lot of code, it works with 5 players with plane and no lags (tested on 3 servers).

When u wanted drop one bomb, there was no problem, but when u wanted drop more bombs, then there was the problem.
Share |
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Dec. 27, 2009 05:02 pm
hi its me again. I've got another problem. As u can see when I'm in the plane I can see myself (when I have 3rd person active)... Is there any script that hide me even when I use 3rd person ?

self hide(); -> hide me from everyone except me :(
Look at the screens. Please help :/
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Sunday, Dec. 27, 2009 09:26 pm
hidepart maybe?

so basically hide what is connected to the plane's player tag (might be different than tag_player):

plane hidepart("tag_player");

not sure if that works, you may have to pass the player's model name as second argument to hidepart
Share |
Dutch77
General Member
Since: Oct 7, 2007
Posts: 48
Last: May 5, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Dec. 27, 2009 09:43 pm
nope, it doesn't work. Unknown func...

btw. when I tried to hide model, than game crashed with "model has more than 127bones".

... I've tried almost everything xD.... has anybody any idea?

Share |
PwN3R
General Member
Since: Jun 19, 2008
Posts: 96
Last: Mar 17, 2010
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Dec. 28, 2009 09:54 am
maybe u want this?

self detachall();

This delete all the models attached to your body(body,weapons,helmet etc..)

edited on Dec. 28, 2009 04:55 am by PwN3R
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»