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

Members Online

»
0 Active | 6 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: playerLinkToDelta MP
-
General Member
Since: Apr 16, 2012
Posts: 3
Last: Apr 17, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Apr. 16, 2012 04:42 pm
So... I'm trying to create some kind of script that would link player to a script model and limit the player angles like playerLinkToDelta function...

This is how I tried to limit player angles but it fails when the script model reaces yaw of 0...

Code:

playerLinkAC( player, target, pitch_max, pitch_min, yaw_max, yaw_min )
{
	// THIS WILL "FAIL" @ ANGLE OF 0...
	// PLAYER WILL ROTATE 360...
	level endon( "unlink_angles" );	
	
	while( 1 )
	{
		player.x = player getPlayerAngles();
	
		pitch = player.x[0];
		yaw = player.x[1];
		roll = player.x[2];
		
		yaw_a = ( target.angles[1] );
		yaw_b = ( player.angles[1] );
		
		dif = player angle_dif( yaw_a, yaw_b );
			
		wait( 0.05 );
			
		if( pitch < pitch_min )	
		{
			player setPlayerAngles( ( ( pitch + 0.20 ), player.x[1], player.x[2] ) );
		}
			
		if( pitch > pitch_max )
		{		
			player setPlayerAngles( ( ( pitch - 0.20 ), player.x[1], player.x[2] ) );
		}
			
		if( dif <= yaw_max )
		{
			player setPlayerAngles( ( player.x[0], ( yaw + 0.20 ), player.x[2] ) );
		}
		
		if( dif >= yaw_min )
		{
			player setPlayerAngles( ( player.x[0], ( yaw - 0.20 ), player.x[2] ) );
		}
	}
}

// ORIGINAL SCRIPT IN COMMON_SCRIPTS\UTILITY.GSC
angle_dif( oldangle, newangle )
{	
	// returns the difference between two yaws
	if( oldangle == newangle )
		return 0;
		
	oldangle += 30;
	newangle += 30;
	
	while (newangle > 360)
		newangle -=360;
	
	while (newangle < 0)
		newangle +=360;
	
	while (oldangle > 360)
		oldangle -=360;
	
	while (oldangle < 0)
		oldangle +=360;
	
	olddif = undefined;
	newdif = undefined;
	
	if (newangle > 180)
		newdif = 360 - newangle;
	else
		newdif = newangle;
	
	if (oldangle > 180)
		olddif = 360 - oldangle;
	else
		olddif = oldangle;
	
	outerdif = newdif + olddif;
	innerdif = 0;
	
	//if (newangle > oldangle)
		innerdif = newangle - oldangle;
	//else
		//innerdif = oldangle - newangle;
	
	if (innerdif < outerdif)
		return innerdif;
	else
		return outerdif;
}


And the script is called from _ac130.gsc ( custom script, not the SP one )

Code:
self thread playerLinkAC( self, level.ac130, 55, 20, -30, 30 );


If anyone knows a better solution to this I would really appreciate if you would share it with us. [thumbs_up]

EDIT:

I have tried to spawn a turret and link it to player but the problem is that the limited angles of turret won't rotate with the AC-130 and thus the player can only look to one direction.

The AC-130 is linked to a script origin at map center and the script origin is rotated.

Main()

Code:
main()
{
	self endon( "disconnect" );
	level endon( "ac130_stop" );
	
	self notify( "nvg_off" );
	self.nvgOn = false;
	self.irOn = false;
	self bear\_nvg::nvgView();
	
	self takeallweapons();
	self disableWeapons();
	
	self maps\mp\gametypes\_weapons::detach_all_weapons();
	
	self detachall();
	self setModel( "" );
	
	if( self hasPerk( "specialty_fastreload" ) )
		self unSetPerk( "specialty_fastreload" );
	
	if( self hasPerk( "specialty_rof" ) )
		self unSetPerk( "specialty_rof" );
	
	self.isAC130 = true;
	iPrintLnBold( self.name + " is flying an AC-130!" );
	
	level.center_link = spawn( "script_origin", level.mapCenter );
	
	level.ac130 = spawnplane( self, "script_model", self getOrigin() );
	level.ac130.origin = level.mapCenter + ( -3000, 0, 2000 );
	level.ac130 setModel( "bear_ac130" );
	level.ac130.angles = ( 45, 0, 0 );
	level.ac130.team = self.pers["team"];
	level.ac130.damage = 0;
	
	level.ac130.flares = false;
	level.ac130.smoke = false;
	
	self_link = spawn( "script_origin", level.ac130 getTagOrigin( "tag_player" ) );
	self.origin = level.ac130 getTagOrigin( "tag_player" );
	
	self_link linkTo( level.ac130 );
	level.ac130 linkTo( level.center_link );
	self setplayerangles ( level.ac130.angles );
	self linkTo( self_link );
	
	/*turret = spawnTurret( "misc_turret", self.origin + ( 0, 0, 0 ), "saw_bipod_crouch_mp" );
	turret.angles = ( self getPlayerAngles() - ( self getPlayerAngles()[0], 0, 0 ) );
	turret setleftarc( 89 );
	turret setrightarc( 89 );
 	turret settoparc( 89 );
	turret setbottomarc( 89 );
	turret setmodel( "weapon_minigun" );
	turret.weaponinfo = "saw_bipod_crouch_mp";
	turret.targetname = "test01";
	turret linkTo( self );
	trig = spawn( "trigger_use_touch", self getOrigin(), 0, 3000, 30 );
	trig.targetname = "test01";*/

	level.center_link rotateYaw( ( level.ac130_time * 2 ), level.ac130_time );
	
	//playerLinkAC( player, target, pitch_max, pitch_min, yaw_max, yaw_min );
	self thread playerLinkAC( self, level.ac130, 55, 20, -30, 30 );
	self thread controls();
	self thread ac_end_spectator();
	self thread ac_end_player();
	self thread ac_end_player_alt();
	self thread ac_end_world();
	self thread ac_end_quit();
	self thread ac_end_death();
	self thread ac_end_force();
	self thread ac_damage();
	self thread ac_fx();
	self thread ac_brightness();
	self thread ac_hud();
	self thread ac_shellshock();
	self thread sounds();
	self thread weapons();
	self thread switchWeapons();
	self thread switchVision();
	self thread ac_fire();
	self thread ac_tweaks();
	
	ambientStop( 3 );
	set_ambient( "ac130" );
	
	self enableWeapons();
	
	wait( level.ac130_time );
	
	level notify( "ac130_leave" );
}
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Monday, Apr. 16, 2012 06:00 pm
I have helped several people make AC130 scripts, and I always use the turret method. All other methods are doomed to use excessive code in order to do what a turret can do by default - limit a players angles.

The problem you mentioned with your attempt at using a turret is that the turret doesn't change it's angles - so why not just keep updating the turrets angles as you update the angles of the AC130 itself?

One important piece of code when linking a player to a turret is to make the turret use the player that is attached to it. You do that like this:

Code:
		if( isPlayer( player ) && player isTouching( self ) )
		{
			player linkTo( self, "tag_player", (0,0,-40), (0,0,0) );
			
			wait( 0.05 );

			self UseBy( player );
}


Where "self" is the turret, and "player" is the player. The useBy() function makes the turret behave properly when a player is linked to it.

BTW- I see in your script that you tried to spawn a trigger_use_touch.. But you cannot dynamically spawn any type of trigger other than a trigger_radius.
Share |
-
General Member
Since: Apr 16, 2012
Posts: 3
Last: Apr 17, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Apr. 16, 2012 06:32 pm
Thanks for the reply, I'll try it out tomorrow... [sleeping]

I'm thinking about replacing the weapons with script controlled projectiles as the player can't use the 25mm, 40mm or 105mm while he/she is using the turret... ( something like script models with some bullettrace thingys etc. )

I will also try to make a vid of the AC-130 as it is right now [cool]
Share |
-
General Member
Since: Apr 16, 2012
Posts: 3
Last: Apr 17, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Tuesday, Apr. 17, 2012 03:09 pm
Okay... I tried it and its working pretty well [thumbs_up]

This is how I did it...
Code:
//self playerLinkToDelta( self, level.ac130, 10, 40, 40, 0, "ccw" ); // THIS IS IN _AC130.GSC

playerLinkToDelta( player, target, r_arc, l_arc, t_arc, b_arc, dir )
{
	self.linker = spawnTurret( "misc_turret", player getOrigin(), "saw_bipod_crouch_mp" );
	//self.linker.angles = ( self getPlayerAngles() - ( self getPlayerAngles()[0], 0, 0 ) );
	self.linker setrightarc( r_arc );
	self.linker setleftarc( l_arc );
 	self.linker settoparc( t_arc );
	self.linker setbottomarc( b_arc );
	self.linker setmodel( "weapon_minigun" );
	self.linker.weaponinfo = "saw_bipod_crouch_mp";
	self.linker.targetname = "linker";
	self.linker.angles = target.angles;
	self.linker linkTo( target );
	
	player thread rotateLinker( r_arc, l_arc, player, dir );
	//player linkTo( self.linker, "tag_player", (0,0,-40), (0,0,0) );
}

rotateLinker( r_arc, l_arc, player, dir )
{
	//a = r_arc;
	//b = l_arc;
	while( !self useButtonPressed() )
	{
		/*if( dir == "cw" )
		{
			a = ( a + 0.1 );
			b = ( b - 0.1 );
		} else
		if( dir == "ccw" )
		{
			a = ( a - 0.1 );
			b = ( b + 0.1 );
		}
		self.linker setrightarc( a );
		self.linker setleftarc( b );*/
		wait( 0.05 );
		self.linker UseBy( player );
	}
}


The self.linker UseBy( player ); must be looped or else the player in turret won't rotate with AC-130... [ohwell]

You have done it another way Tally?
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 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

»