Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,128 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Old school A6 user needs help with fps code #403622
06/22/12 18:13
06/22/12 18:13
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Hello,

I'm about 80% done with my game. I'm implementing AI and shooting code but cannot get my head around creating a decent fps simple movement code. There's always some issue that doesn't quite work. I've downloaded all the templates but none of them seem complete.

I would use A7/A8 but I'm using A6 so c-script is needed.

My code sends the player rising upwards when near walls so I used my_friction. This isn't really a problem as now if you jump when close to a wall you eventually go through it.

I'm at the point of giving up, been working on this for months and so my final act is to ask if there are any old school c-script programmers who would be kind enough to provide a simple fps movement code that includes jump. I would prefer c_move as I am using footsteps which compliment this.

thanks,

Rob

Re: Old school A6 user needs help with fps code [Re: robertbruce] #403624
06/22/12 18:46
06/22/12 18:46
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I don't know, but the only thing I could advice you to use free version of A8 for now, and if you'll succeed, then just update to COM version, which isn't really expensive. I don't know a thing about A6 c-script, I used the A7 version, which was a little bit different as far as I know (ent_move <-> c_move etc).
EDIT: if you do so, I can advice you to take a look at my website, I've made an example of movement, with smooth gravity and crawling, but I didn't implement jumping in it. Anyway, if you'll try to use it, PM me and I'll show how to implement a simple jumping part in it.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Old school A6 user needs help with fps code [Re: 3run] #403639
06/22/12 21:37
06/22/12 21:37
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Maybe this old A5 template helps. It always worked well even in A6.
Code:
// BLOCKED __WHEELS MODE cause of FLAG1-camera-noflag1 stuff
// Template file v5.202 (02/20/02)
//
////////////////////////////////////////////////////////////////////////
// File: move.wdl
//		WDL prefabs for player movement
////////////////////////////////////////////////////////////////////////
// Use:
//		Include AFTER "movment.wdl"
//
//]- Created: 06/15/01 DCP
//]-
//]- Mod Date: 07/27/01 DCP
//]-		wade_gravity(): Updated wading forces to reflect my_height_passable
//]-
//]- Mod Date: 08/08/01 DCP
//]-		player_move: Fixed '1 frame swim to wade' problem when entering
//]-			water.
//]-
//]- Mod Date: 12/18/01
//]-		Added WED 'uses' comments to all WED editable fields
//
// Mod Date: 02/12/02 DCP
//			player_move(): Increased distance (by 3) that entity must be "above"
//		a passable surface to not swim.
//
// Mod Date: 02/20/02 DCP
//			move_gravity(): Improved jumping code (no longer frame rate dependent)
//
// Mod Date: 04/22/02 DCP
//			changed player_move & client_move
//			added _player_rotate
//       Changes made to reduce latency on multiplayer games. Rotation is
//		handled on the client and the resulting rotation is sent to the server
//		(along with the forces).
//
// Mod Date: 09/19/02 JCL
//    changed _player_rotate, player_move2, client_move
//    Fixed a bug with the pan angle jittering, and added tilt in multiplayer


//@ Move Defines


//@ Move Vars

//@ Move Actions
//	Each of these three actions call 'player_move'
//		player_walk -	player walk (basic move) action
//		player_swim -	player swim action
//		player_drive -	player drive action


/////////////////////////////////////////////////////////////////////////
// Desc: player walk action
//
//]- Mod Date: 8/31/00 DCP
//]-		Scale the player by vec_scale
//
// no WED defined skills
// uses _WALKFRAMES, _RUNFRAMES, _WALKSOUND
ACTION player_walk
{
	MY._MOVEMODE = _MODE_WALKING;
	MY._FORCE = 0.75;
	MY._BANKING = -0.1;
	MY.__JUMP = ON;
	MY.__DUCK = ON;
	MY.__STRAFE = ON;
	MY.__BOB = ON;
	MY.__TRIGGER = ON;

	player_move();
}

/////////////////////////////////////////////////////////////////////////
// Desc: player swim action
//
// uses _WALKFRAMES, _RUNFRAMES, _WALKSOUND
ACTION player_swim
{
	MY._MOVEMODE = _MODE_SWIMMING;
	MY._FORCE = 0.75;
	MY._BANKING = 0;
	MY.__JUMP = ON;
	MY.__DUCK = ON;
	MY.__STRAFE = OFF;
	MY.__BOB = ON;

	player_move();

}

/////////////////////////////////////////////////////////////////////////
// Desc: player drive action
//
//]- Mod Date: 8/31/00 DCP
//]-		Scale the player by vec_scale
//
// uses _WALKFRAMES, _RUNFRAMES, _WALKSOUND
ACTION player_drive
{
	MY._MOVEMODE = _MODE_DRIVING;
	MY._FORCE = 1.5;
	MY._BANKING = 0.5;
	MY.__SLOPES = ON;
	MY.__TRIGGER = ON;

	player_move();
}



//@ Move Function Protypes
//ACTION player_move  - This is the main movement function, it handles the player movement
//@@ player_move helper functions
function move_gravity();	// handle movement on solids
function wade_gravity();	// handle movement while wading
function swim_gravity();	// handle movement in passables
function scan_floor();		// scan surface under ME entity, sets values (also called from actor_move)
function	fall_damage();		// return damage from falling
function _player_force();	// set the values for force and aforce

function client_move();	// handles client entity movement


function move_airborne();	// Airborne movement function


//@ Move Functions

// Desc: code to handle rotation of the player.
function	_player_rotate()
{
		// accelerate the angular speed, and change his angles
		temp = max(1-TIME*ang_fric,0);     // replaced min with max (to eliminate 'creep')
		MY._ASPEED_PAN  = (TIME * aforce.pan)  + (temp * MY._ASPEED_PAN);    // vp = ap * dt + max(1-(af*dt),0)  * vp
		MY._ASPEED_TILT = (TIME * aforce.tilt) + (temp * MY._ASPEED_TILT);
		MY._ASPEED_ROLL = (TIME * aforce.roll) + (temp * MY._ASPEED_ROLL);

  		temp = MY._ASPEED_PAN * MY._SPEED_X * 0.05;
#		if(MY.__WHEELS)
#		{
			// Turn only if moving ahead
#			my.pan += temp * time;
#		}
#		else
#		{
			my.pan += my._aspeed_pan * time; 


#		}
		my.roll += (temp * MY._BANKING + MY._ASPEED_ROLL) * time;

// set the camera tilt angle for the player
		head_angle.tilt += my._ASPEED_TILT * time;

// Limit the TILT value
		head_angle.tilt = ang(head_angle.tilt);
		if(head_angle.tilt > 80) { head_angle.tilt = 80; }
		if(head_angle.tilt < -80) { head_angle.tilt = -80; }
}

////////////////////////////////////////////////////////////////////////
// Desc: main player movement action
//			called from 'player_walk', 'player_drive', & 'player_swim'
//
//]- Mod Date: 5/10/00 @ 973 Doug Poston
//]-           Added code to handle swimming
//]- Mod Date: 5/11/00 @ 097 Doug Poston
//]-           Added code to handle ducking and crawling
//]- Mod Date: 5/16/00  Doug Poston
//]-				 Modified underwater fog code
//]-				 Modified player MIN_Z (when getting in & out of water)
//]-				 Fixed so you can no longer crawl over water
//]- Mod Date: 5/16/00 Doug Poston
//]-				 Returned fog control back to the camera views
//]- Mod Date: 5/18/00 Doug Poston
//]-				 Removed MIN_Z modifications (too easy to get stuck in objects)
//]-Mod Date: 5/25/00 Doug Poston
//]-				 Using an 'offset sonar' (7 units) while swimming to check if
//]-				the player is ON_PASSABLE
//]-Mod Date: 5/29/00 Doug Poston
//]-				 Change 'offset sonar' from 7 to 16 units
//]-Mod Date: 6/5/00 Doug Poston
//]-				 Removed Sets
//]-Mod Date: 6/27/00 Doug Poston
//]-				 Replaced ACCEL
//]-Mod Date: 6/29/00 Doug Poston
//]-				Remove IN_PASSABLE check for wading (fixed in v4.193)
//]-Mod Date: 10/31/00 Doug Poston
//]-				Replaced min with max in ASPEED (to eliminate 'creep')
//]-Mod Date: 11/1/00 DCP
//]-				Replace SHOOT with trace() and VECROTATE with vec_rotate
//]-Mod Date: 11/10/00 DCP
//]-				Edited code dealing with swimming (collision info has changed)
//]-Mod Date: 02/09/01 DCP
//]-				If entering passable block stop falling (MY._SPEED_Z = 0)
//]-Mod Date: 02/11/01 DCP
//]-				Use "my_height_passable" for passable blocks (fixed wading)
//]-Mod Date: 05/30/01 DCP
//]-			  	Changed -MY.MIN_Z + 5 to -MY.MIN_Z + 6 in "swim check" to
//]-	      replace '<=' compare with '<' (do NOT use '<=', '>=', or '==' to compare
//]-	      non-int values).
//]-Mod Date: 05/31/01 DCP
//]-      	Use 'content()' to check for switch from wade to swim
//]-				No longer change from wade to swim if still over water
//]-
//]- Mod Date: 06/12/01 DCP
//]-				Move 'actor_anim()' call inside if(MY._MOVEMODE != _MODE_STILL)
//]-			block.
//]-
//]- Mod Date: 08/08/01 DCP
//]-				Added an offset by "my_height_passable" when checking to see if the
//]-			players is wading. Fixes '1 frame swim to wade' problem when entering
//]-			water.
//]-
//]- Mod Date: 02/12/02 DCP
//]-				Increased distance that entity must be "above" a passable surface
//]-			to not swim (previous vers allowed "Jesus Walk")
//
//	Mod Date: 04/16/02 DCP
//		player rotation is handle in a seperate funtion ("_player_rotate()")
//		player rotation is handled on the client, not the server
//
// uses _FORCE, _MOVEMODE, _BANKING, _WALKFRAMES, _RUNFRAMES, _WALKSOUND
// uses __FALL, __WHEELS, __SLOPES, __JUMP, __DUCK, __STRAFE, __BOB, __TRIGGER
var Letter;
ACTION player_move
{


	MY._TYPE = _TYPE_PLAYER;
	MY.ENABLE_SCAN = ON;	// so that enemies can detect me
	if((MY.TRIGGER_RANGE == 0) && (MY.__TRIGGER == ON)) { MY.TRIGGER_RANGE = 32; }

	if(MY._FORCE == 0) {  MY._FORCE = 1.5; }
	if(MY._MOVEMODE == 0) { MY._MOVEMODE = _MODE_WALKING; }
	if(MY._WALKFRAMES == 0) { MY._WALKFRAMES = DEFAULT_WALK; }
	if(MY._RUNFRAMES == 0) { MY._RUNFRAMES = DEFAULT_RUN; }
	if(MY._WALKSOUND == 0) { MY._WALKSOUND = _SOUND_WALKER; }

	anim_init();      // init old style animation
	perform_handle();	// react on pressing the handle key


	// while we are in a valid movemode
	while((MY._MOVEMODE > 0)&&(MY._MOVEMODE <= _MODE_STILL))
	{

		// if we are not in 'still' mode
		if(MY._MOVEMODE != _MODE_STILL)
		{
			// Get the angular and translation forces (set aforce & force values)
			_player_force();

			// is this movement "local"?
			if(client_moving == 0)
			{
				// rotate the player
				_player_rotate();
			}

			// find ground below (set my_height, my_floornormal, & my_floorspeed)
			scan_floor();

			// if they are on or in a passable block...
// AVOID PLAYING STICKING IN WALLS AND THEN FLY OR CROUCH AWAY ! mod in input.wdl too _insolid bla bla
IF(in_solid==1) { 
 _insolid=1;
 player.pan=bounce.pan;
 C_MOVE(ME, vector(20*time,0,0), nullvector, GLIDE|IGNORE_MODELS|IGNORE_SPRITES|IGNORE_ME); 
}
ELSE { _insolid=0;}
///////////////////////////////////////////////////
			if( ((ON_PASSABLE != 0) && (my_height_passable < (-MY.MIN_Z + 19)))    // upped from 16 to 19 (3q 'buffer')
				|| (IN_PASSABLE != 0) )
			{

				// if not already swimming or wading...
				if((MY._MOVEMODE != _MODE_SWIMMING) && (MY._MOVEMODE != _MODE_WADING))
				{
  					snd_play(splash,50,0);
  					MY._MOVEMODE = _MODE_SWIMMING;
//---					actor_anim_transition(anim_swim_str);	//!!!!!

					// stay on/near surface of water
					MY._SPEED_Z = 0;
  				}

				// if swimming...
  				if(MY._MOVEMODE == _MODE_SWIMMING) // swimming on/in a passable block
				{
					if(ON_PASSABLE == ON) // && (IN_PASSABLE != ON)) -> Not need with version 4.193+
					{
						// check for wading
						temp.X = MY.X;
    					temp.Y = MY.Y;
    		  			temp.Z = MY.Z + MY.MIN_Z - my_height_passable;	// can my feet touch? (mod: 080801)
						trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
						trace(MY.POS,temp);

						if(RESULT > 0)
						{
							// switch to wading
							MY._MOVEMODE = _MODE_WADING;
 				 			MY.TILT = 0;       // stop tilting
							my_height = RESULT + MY.MIN_Z;	// calculate wading height
//---							actor_anim_transition(anim_wade_str);	//!!!!!
						}

 					}

				}// END swimming on/in a passable block
				else
				{	// not swimming

					// if wading...
 					if(MY._MOVEMODE == _MODE_WADING) // wading on/in a passable block
					{
  						// if model center is in the water switch to swimming mode
						result = content(MY.POS);
						if (result == content_passable)
						{
							// switch to swimming
							MY._MOVEMODE = _MODE_SWIMMING;
						}
						else	// use SOLID surface for height (can't walk on water)
						{
  							// get height to solid underwater surface
							temp.X = MY.X;
    						temp.Y = MY.Y;
    						temp.Z = MY.Z - 1000;//-- + MY.MIN_Z;	// can my feet touch?

							trace_mode = IGNORE_SPRITES + IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
							result = trace(MY.POS,temp);
  							my_height = RESULT + MY.MIN_Z;    // calculate wading height
						}
					} // END wading on/in a passable block
				}



	 		} // END if they are on or in a passable block...

			else  // not in or on a passable block
			{
				// if wading or swimming while *not* on/in a passable block...
				if(   (MY._MOVEMODE == _MODE_SWIMMING)
					|| ( (ON_PASSABLE == 0) && (MY._MOVEMODE == _MODE_WADING) )
				  )
				{
					// get out of the water (go to walk mode)
					MY._MOVEMODE = _MODE_WALKING;
					MY.TILT = 0;       // stop tilting
				}
 			} // END not in or above water


  			// if he is on a slope, change his angles, and maybe let him slide down
			if(MY.__SLOPES == ON)
			{
				// Adapt the player angle to the floor slope
				MY_ANGLE.TILT = 0;
				MY_ANGLE.ROLL = 0;
				if((my_height < 10) && ((my_floornormal.X != 0) || (my_floornormal.Y != 0) ))
				{	// on a slope?
					// rotate the floor normal relative to the player
					MY_ANGLE.PAN = -MY.PAN;
					vec_rotate(my_floornormal,MY_ANGLE);
					// calculate the destination tilt and roll angles
					MY_ANGLE.TILT = -ASIN(my_floornormal.X);
					MY_ANGLE.ROLL = -ASIN(my_floornormal.Y);
				}
				// change the player angles towards the destination angles
				MY.TILT += 0.2 * ANG(MY_ANGLE.TILT-MY.TILT);
				MY.ROLL += 0.2 * ANG(MY_ANGLE.ROLL-MY.ROLL);
			}
			else
			{
				// If the ROLL angle was not equal to zero,
				// apply a ROLL force to set the angle back
				//jcl 07-08-00 fix loopings on < 3 fps systems
				MY.ROLL -= 0.2*ANG(MY.ROLL);
			}

/*
MOVED INTO function _player_rotate()!!!
// CODE for handling rotation
			// Now accelerate the angular speed, and change his angles
			temp = max(1-TIME*ang_fric,0);     // replaced min with max (to eliminate 'creep')
			MY._ASPEED_PAN  = (TIME * aforce.pan)  + (temp * MY._ASPEED_PAN);    // vp = ap * dt + max(1-(af*dt),0)  * vp
			MY._ASPEED_TILT = (TIME * aforce.tilt) + (temp * MY._ASPEED_TILT);
			MY._ASPEED_ROLL = (TIME * aforce.roll) + (temp * MY._ASPEED_ROLL);

  			temp = MY._ASPEED_PAN * MY._SPEED_X * 0.05;
			if(MY.__WHEELS)
			{	// Turn only if moving ahead
				//jcl 07-03-00 patch to fix movement
				MY.PAN += temp * TIME; 

			}
			else
			{
				MY.PAN += MY._ASPEED_PAN * TIME;

			}
			MY.ROLL += (temp * MY._BANKING + MY._ASPEED_ROLL) * TIME;

			// the head angle is only set on the player in a single player system.
			if (ME == player)
			{
				head_angle.TILT += MY._ASPEED_TILT * TIME;
				//jcl 07-03-00 end of patcht

				// Limit the TILT value
				head_angle.TILT = ang(head_angle.TILT);
				if(head_angle.TILT > 80) { head_angle.TILT = 80; }
				if(head_angle.TILT < -80) { head_angle.TILT = -80; }
			}
*/
			// disable strafing
			if(MY.__STRAFE == OFF)
			{
				force.Y = 0;	// no strafe
			}


			// if swimming...
			if(MY._MOVEMODE == _MODE_SWIMMING)
			{
 				// move in water
  				swim_gravity();
			}
			else // not swimming
			{
				// if wading...
				if(MY._MOVEMODE == _MODE_WADING)
				{
					wade_gravity();
				}
				else // not swimming or wading (not in water)
				{
					// Ducking or crawling...
					if((MY._MOVEMODE == _MODE_DUCKING) || (MY._MOVEMODE == _MODE_CRAWLING))
					{
						if(force.Z >= 0)
						{
							MY._MOVEMODE = _MODE_WALKING;
						}
						else	// still ducking
						{
							// reduce height by ducking value
							my_height += duck_height;
						}

					}
					else  // not ducking or crawling
					{
						// if we have a ducking force and are not already ducking or crawling...
						if((force.Z < 0) && (MY.__DUCK == ON))		// dcp 7/28/00 added __DUCK
						{
							// ...switch to ducking mode
							MY._MOVEMODE = _MODE_DUCKING;
							MY._ANIMDIST = 0;
							force.Z = 0;
						}
					}

					// Decide whether the actor can jump or not. He can't if he is in the air
					if((jump_height <= 0)
						|| (MY.__JUMP == OFF)
						|| (my_height > 4)
						|| (force.Z <= 0))
					{
						force.Z = 0;
					}

					// move on land
					move_gravity();
				}  // END (not in water)
			}// END not swimming

		} // END not in 'still' mode

//		if(MY._MOVEMODE != _MODE_TRANSITION)
//		{
		// animate the actor
		actor_anim();
//		}

		// If I'm the only player, draw the camera and weapon with ME
		if(client_moving == 0) { move_view(); }

		carry();		// action pointer used to carry items with the player (eg. a gun or sword)

		// Wait one tick, then repeat
		wait(1);
	}  // END while((MY._MOVEMODE > 0)&&(MY._MOVEMODE <= _MODE_STILL))
} // end ACTION player_move


// Desc: advanced player movement function.
//			uses advanced blended animation
// Mod: 121102  Added 3rd person walking sound
function player_move2()
{
	var sound_dist;    // used to play walking noise

	if(MY.CLIENT == 0) { player = ME; } // created on the server?

	MY._TYPE = _TYPE_PLAYER;
	MY.ENABLE_SCAN = ON;	// so that enemies can detect me
	if((MY.TRIGGER_RANGE == 0) && (MY.__TRIGGER == ON)) { MY.TRIGGER_RANGE = 32; }

	if(MY._FORCE == 0) {  MY._FORCE = 1.5; }
	if(MY._MOVEMODE == 0) { MY._MOVEMODE = _MODE_WALKING; }
	if(MY._WALKFRAMES == 0) { MY._WALKFRAMES = DEFAULT_WALK; }
	if(MY._RUNFRAMES == 0) { MY._RUNFRAMES = DEFAULT_RUN; }
	if(MY._WALKSOUND == 0) { MY._WALKSOUND = _SOUND_WALKER; }

  //--	anim_init();      // init old style animation
	perform_handle();	// react on pressing the handle key

	actor_adv_anim2();	// use new animation style (with blending)


	// while we are in a valid movemode
	while((MY._MOVEMODE > 0)&&(MY._MOVEMODE <= _MODE_STILL))
	{
		// check signal from actor_adv_anim2() to see if we have finished a previous state...
		if(my._ANIMDIST == -99)
		{
			if(MY._MOVEMODE == _MODE_JUMPING)
			{
				// exit from jumping state
				my._ANIMDIST = 0;	// signal that we have recieved the flag
				MY._MOVEMODE = _MODE_WALKING;
			}

/* ducking/crawling is handled like stand/walk/run is
			if(MY._MOVEMODE == _MODE_DUCKING)
			{
				// exit from ducking state
				MY._MOVEMODE = _MODE_CRAWLING;;
			}
 */
		}// end check singal returned from actor_adv_anim2()


		// if we are not in 'still' mode
		if(MY._MOVEMODE != _MODE_STILL)
		{
			// Get the angular and translation forces (set aforce & force values)
			_player_force();

			// is this movement "local"?
			if(client_moving == 0)
			{
				// rotate the player
				_player_rotate();
			}

			// find ground below (set my_height, my_floornormal, & my_floorspeed)
			scan_floor();

			// if they are on or in a passable block...
			if( ((ON_PASSABLE != 0) && (my_height_passable < (-MY.MIN_Z + 19)))    // upped from 16 to 19 (3q 'buffer')
				|| (IN_PASSABLE != 0) )
			{

				// if not already swimming or wading...
				if((MY._MOVEMODE != _MODE_SWIMMING) && (MY._MOVEMODE != _MODE_WADING))
				{
  					snd_play(splash,50,0);
  					MY._MOVEMODE = _MODE_SWIMMING;

					// stay on/near surface of water
					MY._SPEED_Z = 0;
  				}

				// if swimming...
  				if(MY._MOVEMODE == _MODE_SWIMMING) // swimming on/in a passable block
				{
					if(ON_PASSABLE == ON) // && (IN_PASSABLE != ON)) -> Not need with version 4.193+
					{
						// check for wading
						temp.X = MY.X;
    					temp.Y = MY.Y;
    		  			temp.Z = MY.Z + MY.MIN_Z - my_height_passable;	// can my feet touch? (mod: 080801)
						trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
						trace(MY.POS,temp);

						if(RESULT > 0)
						{
							// switch to wading
							MY._MOVEMODE = _MODE_WADING;
 				 			MY.TILT = 0;       // stop tilting
							my_height = RESULT + MY.MIN_Z;	// calculate wading height
						}

 					}

				}// END swimming on/in a passable block
				else
				{	// not swimming

					// if wading...
 					if(MY._MOVEMODE == _MODE_WADING) // wading on/in a passable block
					{
  						// if model center is in the water switch to swimming mode
						result = content(MY.POS);
						if (result == content_passable)
						{
							// switch to swimming
							MY._MOVEMODE = _MODE_SWIMMING;
						}
						else	// use SOLID surface for height (can't walk on water)
						{
  							// get height to solid underwater surface
							temp.X = MY.X;
    						temp.Y = MY.Y;
    						temp.Z = MY.Z - 1000;//-- + MY.MIN_Z;	// can my feet touch?

							trace_mode = IGNORE_SPRITES + IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
							result = trace(MY.POS,temp);
  							my_height = RESULT + MY.MIN_Z;    // calculate wading height
						}
					} // END wading on/in a passable block
				}



	 		} // END if they are on or in a passable block...
			else  // not in or on a passable block
			{
				// if wading or swimming while *not* on/in a passable block...
				if(   (MY._MOVEMODE == _MODE_SWIMMING)
					|| ( (ON_PASSABLE == 0) && (MY._MOVEMODE == _MODE_WADING) )
				  )
				{
					// get out of the water (go to walk mode)
					MY._MOVEMODE = _MODE_WALKING;
					MY.TILT = 0;       // stop tilting
				}
 			} // END not in or above water


  			// if he is on a slope, change his angles, and maybe let him slide down
			if(MY.__SLOPES == ON)
			{
				// Adapt the player angle to the floor slope
				MY_ANGLE.TILT = 0;
				MY_ANGLE.ROLL = 0;
				if((my_height < 10) && ((my_floornormal.X != 0) || (my_floornormal.Y != 0) ))
				{	// on a slope?
					// rotate the floor normal relative to the player
					MY_ANGLE.PAN = -MY.PAN;
					vec_rotate(my_floornormal,MY_ANGLE);
					// calculate the destination tilt and roll angles
					MY_ANGLE.TILT = -ASIN(my_floornormal.X);
					MY_ANGLE.ROLL = -ASIN(my_floornormal.Y);
				}
				// change the player angles towards the destination angles
				MY.TILT += 0.2 * ANG(MY_ANGLE.TILT-MY.TILT);
				MY.ROLL += 0.2 * ANG(MY_ANGLE.ROLL-MY.ROLL);
			}
			else
			{
				// If the ROLL angle was not equal to zero,
				// apply a ROLL force to set the angle back
				//jcl 07-08-00 fix loopings on < 3 fps systems
				MY.ROLL -= 0.2*ANG(MY.ROLL);
			}
/*
MOVED INTO function _player_rotate()!!!
			// the head angle is only set on the player in a single player system.
			if (ME == player)
			{
				head_angle.TILT += MY._ASPEED_TILT * TIME;
				//jcl 07-03-00 end of patcht

				// Limit the TILT value
				head_angle.TILT = ang(head_angle.TILT);
				if(head_angle.TILT > 80) { head_angle.TILT = 80; }
				if(head_angle.TILT < -80) { head_angle.TILT = -80; }
			}
*/
			// disable strafing
			if(MY.__STRAFE == OFF)
			{
				force.Y = 0;	// no strafe
			}


			// if swimming...
			if(MY._MOVEMODE == _MODE_SWIMMING)
			{
 				// move in water
  				swim_gravity();
			}
			else // not swimming
			{
				// if wading...
				if(MY._MOVEMODE == _MODE_WADING)
				{
					wade_gravity();
				}
				else // not swimming or wading (not in water)
				{
					// Ducking or crawling...
					if((MY._MOVEMODE == _MODE_DUCKING) || (MY._MOVEMODE == _MODE_CRAWLING))
					{
  		 				temp2 = (frc(-MY._ADVANIM_DIST)<<10);// walk_or_run
   					// you can only duck at walking speeds or below.
						if((my_dist >= temp2*TIME*movement_scale)	// to fast to duck?
							|| (force.Z >= 0)) // player chooses to stand up
						{
							MY._MOVEMODE = _MODE_WALKING; // catch the walking mode below this one
 						}
						else	// still ducking
						{
							// reduce height by ducking value
							my_height += duck_height;
						}

					}
					else  // not ducking or crawling
					{
						// if we have a ducking force and are not already ducking or crawling...
						if((force.Z < 0) && (MY.__DUCK == ON))		// dcp 7/28/00 added __DUCK
						{
							// ...switch to ducking mode
							MY._MOVEMODE = _MODE_DUCKING;
						//--	MY._ANIMDIST = 0;
							force.Z = 0;
						}
					}

					// Decide whether the actor can jump or not. He can't if he is in the air
					if((jump_height <= 0)
						|| (MY.__JUMP == OFF)
						|| (my_height > 4)
						|| (force.Z <= 0))
					{
						force.Z = 0;
					}

					// move on land
					move_gravity();
				}  // END (not in water)
			}// END not swimming

		} // END not in 'still' mode

		// play walking sound as needed...
		if((person_3rd>0)  // using a 3rd person camera and..
			&& (my._MOVEMODE == _MODE_WALKING))  // walking
		{
			sound_dist += my_dist;
			if(sound_dist > 50)
			{ //schritte hier steps footsteps


				sound_dist = 0;
			}
		}

 		// set movment amount
		if(force.X < 0)
		{
			// moving backwards
			my._WALKDIST = -my_dist;	// my_dist is set in move_gravity, wade_gravity, or swim_gravity
		}
		else
		{
			// moving forward, sideways, or standing still
			my._WALKDIST = my_dist;		// my_dist is set in move_gravity, wade_gravity, or swim_gravity
		}
		// If I'm the only player, draw the camera and weapon with ME
		if(client_moving == 0) { move_view(); }



		carry();		// action pointer used to carry items with the player (eg. a gun or sword)

		// Wait one tick, then repeat
		wait(1);
	}  // END while((MY._MOVEMODE > 0)&&(MY._MOVEMODE <= _MODE_STILL))
} // end function player_move2



/////////////////////////////////////////////////////////////////////////
// Desc: on ground movement action
//			use when player is not swimming or wading
//
//]- Mod Date: 5/10/00 @ 942 by Doug Poston
//]-				Added code to switch to jumping mode when needed
//]- Mod Date: 5/25/00 by Doug Poston
//]-				Split MOVE into two, so my_dist is now a function of player
//]-			  movement only (ie. not effected by elevators or platforms)
//]- Mod Date: 6/19/00 by Doug Poston
//]-          Added falling damage.
//]-				_FALLTIME keeps track of the time spent falling
//]-				if __FALL is set, damage is taken when landing
//]- Mod Date: 6/27/00 Doug Poston
//]-				Replace ACCEL (x2)
//]- Mod Date: 7/3/00 JCL
//]-				quick patch to fix movement for Adeptus
//]- Mod Date: 7/3/00 DCP
//]-				Modified code so speed and distance are TIME dependent
//]- Mod Date: 7/18/00 DCP
//]-				Removed time dependence on forces
//]-				Changed slope gravity
//]- Mod Date: 7/19/00 DCP
//]-				Changed jumping code so player always jumps to the same height
//]- Mod Date: 8/10/00 JCL
//]-				Changed 'airborne' force values to prevent entities from 'sticking'
//]- Mod Date: 8/10/00 JCL
//]-      		"bring to ground level - only if slope not too steep"
//]- Mod Date: 8/10/00 DCP
//]-				Replace fall damge formula with call to 'fall_damage'
//]- Mod Date: 8/31/00 DCP
//]-				Scale dist and absdist by movement_scale before MOVE command
//]- Mod Date: 11/9/00 DCP
//]- 			Replaced the double MOVE with a single MOVE and a distance check
//]- Mod Date: 01/16/01 JCL
//]-				Removed absdist movement_scale because absdist is calculated from external forces
//]-				Apply movement_scale to jumping force only
//]- Mod Date: 06/08/01 DCP
//]-				Replace move() with ent_move()
//]- Mod Date: 08/22/01 DCP
//]-				Added a Check for ducking and crawling when adding to _FALLTIME
//]-
//]- Mod Date: 02/20/02 DCP
//]-				Improved jumping code (no longer frame dependent)
//]-
//]- Mod Date: 04/30/02 DCP
//]-				Removed animation setting from the beginning of the jump section
//]-				Fixed bug in forces when the player in ducking (caused player
//]-			to get 'stuck' while ducking).
// Mod Date: 10/01/02  DCP
//			Modified 'bring to ground level' code to be time corrected and bound.
function move_gravity()
{
	// Filter the forces and frictions dependent on the state of the actor,
	// and then apply them, and move him

	// First, decide whether the actor is standing on the floor or not
	if(my_height < 5)
	{
		// Calculate falling damage
 		if((MY.__FALL == ON) && (MY._FALLTIME > fall_time))
  		{
			MY._HEALTH -= fall_damage();		// take damage depending on fall_time
 		}
		MY._FALLTIME = 0; 	// reset falltime

		friction = gnd_fric;
		if(MY._MOVEMODE == _MODE_DRIVING)
		{
			// Driving - less friction, less force
			friction *= 0.3;
			force.X *= 0.3;
		}

		// reset absolute forces
		absforce.X = 0;
		absforce.Y = 0;
		absforce.Z = 0;

		// If on a slope, apply gravity to draw him downwards:
		if(my_floornormal.Z < 0.9)
		{
			// reduce ahead force because player force it is now deflected upwards
			force.x *= my_floornormal.z;
			force.y *= my_floornormal.z;
			// gravity draws him down the slope
			absforce.X = my_floornormal.x * gravity * slopefac;
			absforce.Y = my_floornormal.y * gravity * slopefac;
		}
	}
	else	// (my_height >= 5)
	{
		if((MY._MOVEMODE == _MODE_DUCKING) || (MY._MOVEMODE == _MODE_CRAWLING))
		{
			friction = gnd_fric;	// ducking and crawling are handled differently
		}
		else
		{
			// airborne - reduce all relative forces
			// to prevent him from jumping or further moving in the air
			friction = air_fric;
//			//jcl 10-08-00
			force.X *= 0.2; // don't set the force completely to zero, otherwise
			force.Y *= 0.2; // player could be stuck on top of a non-wmb entity
			force.Z = 0;
		}

		absforce.X = 0;
		absforce.Y = 0;
		// Add the world gravity force
		absforce.Z = -gravity;

		// only falling if moving downward (but not if ducking)
		if( (MY._SPEED_Z <= 0) && ((MY._MOVEMODE != _MODE_DUCKING) && (MY._MOVEMODE != _MODE_CRAWLING)) )
		{
			MY._FALLTIME += TIME;   // add falling time
		}
	}

	// accelerate the entity relative speed by the force
 	// replaced min with max (to eliminate 'creep')
	temp = max((1-TIME*friction),0);
	MY._SPEED_X = (TIME * force.x) + (temp * MY._SPEED_X);    // vx = ax*dt + max(1-f*dt,0) * vx
	MY._SPEED_Y = (TIME * force.y) + (temp * MY._SPEED_Y);    // vy = ay*dt + max(1-f*dt,0) * vy
	MY._SPEED_Z = (TIME * absforce.z) + (temp * MY._SPEED_Z);

	// calculate relative distances to move
	dist.x = MY._SPEED_X * TIME;  	// dx = vx * dt
	dist.y = MY._SPEED_Y * TIME;     // dy = vy * dt
	dist.z = 0;                      // dz = 0  (only gravity and jumping)

	// calculate absolute distance to move
	// NOTE: changed absforce from d=f*dt^2 to d=f*dt because the absforce calculated
	//from the slope is not an 'actual' force.
	absdist.x = absforce.x * TIME;// * TIME;   // dx = ax*dt^2
	absdist.y = absforce.y * TIME;// * TIME;   // dy = ay*dt^2
	absdist.z = MY._SPEED_Z * TIME;         // dz = vz*dt

	// Add the speed given by the ground elasticity and the jumping force
	if(my_height < 5)
	{
		// bring to ground level - only if slope not too steep
		//jcl 10-08-00
  		if(my_floornormal.Z > slopefac/4)
		{
			//absdist.z = -max(my_height,-10);    // replaced with time corrected and bound version 10/01/02
			absdist.z = -max(my_height,-10*time);
			if((my_height + absdist.z) > 6) // allow a maximum of 6 quant penetration
			{ absdist.z = -my_height -6; }
		}

		// if we have a jumping force...
		if(force.Z > 0)
		{
			MY._JUMPTARGET = jump_height - my_height;	// calculate jump delta

			// ...switch to jumping mode
			MY._MOVEMODE = _MODE_JUMPING;
//--			MY._ANIMDIST = 0;
		}

		// If the actor is standing on a moving platform, add it's horizontal displacement
		absdist.X += my_floorspeed.X;
		absdist.Y += my_floorspeed.Y;
	}

	// if we are still 'jumping'
	if(MY._JUMPTARGET > 0)
	{
		// calculate velocity

		// predict the current speed required to reach the jump height
 		MY._SPEED_Z = sqrt((MY._JUMPTARGET)*2*gravity);

		// scale distance from jump (absdist.z) by movement_scale
		absdist.z = MY._SPEED_Z * TIME * movement_scale;
		MY._JUMPTARGET -= absdist.z;
	}

	// Restrict the vertical distance to the maximum jumping height
	// (scale jump_height by movement_scale)
	if((MY.__JUMP == ON) && (absdist.z > 0) && (absdist.z + my_height > (jump_height * movement_scale)))
	{
		absdist.z = max((jump_height * movement_scale)- my_height,0);
	}

	// Now move ME by the relative and the absolute speed
	YOU = NULL;	// YOU entity is considered passable by MOVE

	vec_scale(dist,movement_scale);	// scale distance by movement_scale
	// jcl: removed absdist scaling because absdist is calculated from external forces
	//--- vec_scale(absdist,movement_scale);	// scale absolute distance by movement_scale


	// Replaced the double MOVE with a single MOVE and a distance check
  IF(ME != PLAYER) { //mod. fette mod. verbessert pathki.wdl deutlich
	move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide+ignore_models+ignore_sprites+ignore_me;
  }
  ELSE{	move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide; }
	result = ent_move(dist,absdist);
	if(result > 0)
	{
		// only use the relative distance traveled (for animation)
		my_dist = vec_length(dist);
	}
	else
	{
		// player is not moving, do not animate
		my_dist = 0;
	}

	// Store the distance for player 1st person head bobbing
	// (only for single player system)
	if(ME == player)
	{
		player_dist += SQRT(dist.X*dist.X + dist.Y*dist.Y)/2;
	}

}


/////////////////////////////////////////////////////////////////////////
// Desc: wading movement action
//       this action should be called when the player is wading (_MODE_WADING)
//
//]- Mod Date: 5/18/00 by Doug Poston
//]-				Created
//]- Mod Date: 5/25/00 by Doug Poston
//]-				Adjusted ground elasticity (so it doesn't force player to swim)
//]- Mod Date: 5/25/00 by Doug Poston
//]-				Adjust player force by water depth (slower the deeper the player is wading)
//]- Mod Date: 5/29/00 Doug Poston
//]-				 Change 'offset sonar' from 7 to 16 units
//]- Mod Date: 6/19/00 Doug Poston
//]-				 Reset _FALLTIME (no falling damage is you land in water)
//]- Mod Date: 6/27/00 Doug Poston
//]-				Replaced ACCEL (x2)
//]- Mod Date: 7/3/00 Doug Poston
//]-				Fixed code so speed and distance are TIME dependent
//]- Mod Date: 8/31/00 DCP
//]-				Scaled dist and absdist by movement_scale before MOVE command
//]- Mod Date: 01/16/01 JCL
//]-				Removed absdist movement_scale because absdist is calculated from external forces
//]- Mod Date: 05/31/01 DCP
//]-				Add gravity to 'pull' player down to underwater surface
//]- Mod Date: 06/08/01 DCP
//]-				Replace move() with ent_move()
//]- Mod Date: 07/27/01 DCP
//]-				Updated wading forces to reflect my_height_passable
function wade_gravity()
{
	// basic friction
	friction = gnd_fric;

	MY._FALLTIME = 0;	// reset falltime (no falling damage in water)

	//adjust player force depending on depth of water
	temp = (my_height_passable / max(1,-MY.MIN_Z));	// MY.min_z can be 0!!
	if(temp < 0.1)	// minimum speed
	{
		temp = 0.1;
	}
	force.X *= temp;
	force.Y *= temp;
	force.Z *= temp;

	// reset absforce
	absforce.X = 0;
	absforce.Y = 0;
	absforce.Z = 0;

	// If on a slope, apply gravity to draw him downwards:
	if(my_floornormal.Z < 0.9)
	{
		// reduce ahead force because player force it is now deflected upwards
		force.x *= my_floornormal.z;
		force.y *= my_floornormal.z;
		// gravity draws him down the slope (but only at 1/4 of above water)
		absforce.X = my_floornormal.x * gravity * slopefac * 0.25;
		absforce.Y = my_floornormal.y * gravity * slopefac * 0.25;
	}

	// -old method- ACCEL	speed,force,friction;
 	// replaced min with max (to eliminate 'creep')
	temp = max((1-TIME*friction),0);
	MY._SPEED_X = (TIME * force.x) + (temp * MY._SPEED_X);    // vx = ax*dt + max(1-f*dt,0) * vx
	MY._SPEED_Y = (TIME * force.y) + (temp * MY._SPEED_Y);    // vy = ay*dt + max(1-f*dt,0) * vy
	MY._SPEED_Z = (TIME * absforce.z) + (temp * MY._SPEED_Z);


	// calculate relative distances
	dist.x = MY._SPEED_X * TIME; 		// dx = vx * dt
	dist.y = MY._SPEED_Y * TIME;     // dy = vy * dt
	dist.z = 0;                      // dz = 0

	// calculate absolute distances
	absdist.x = absforce.x * TIME;// * TIME; 		// dx = ax * dt^2
	absdist.y = absforce.y * TIME;// * TIME;     // dy = ay * dt^2
	absdist.z = 0; // NO JUMPING WHILE WADING

 	// Add the speed given by the ground elasticity
 	if(my_height < -5)
	{
		temp = my_height;
		if(temp < -10)  { temp = -10; }
 		absdist.Z -= (temp - 5);
	}
	else
	{
 		// Pull back down to the underwater surface
		absdist.Z = max(-my_height,-gravity);

	}

	// Now move ME by the relative and the absolute speed
	YOU = NULL;	// YOU entity is considered passable by MOVE
	vec_scale(dist,movement_scale);	// scale distance by movement_scale
	//--vec_scale(absdist,movement_scale);	// scale absolute distance by movement_scale
	move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide;
	result = ent_move(dist,absdist);

	// Store the distance covered, for animation
	my_dist = RESULT;
	// Store the distance for player 1st person head bobbing
	// (only for single player system)
	if(ME == player)
	{
		player_dist = my_dist;
	}
}


/////////////////////////////////////////////////////////////////////////
// Desc: gravity / buoyancy effect on the player in water (IN_PASSABLE)
//       this action should be called when the player is swimming (_MODE_SWIMMING)
//
//]- Created: 05/9/00 @ 863 by Doug Poston
//]-
//]- Mod Date: 5/10/00 @ 913 by Doug Poston
//]-				Added code to TILT the player (allowing them to dive and rise in water)
//]- Mod Date: 5/18/00 by Doug Poston
//]-				Added code to drop player to the surface of the water
//]- Mod Data: 5/24/00 Doug Poston
//]-				 Using an 'offset sonar' (7 units) to check if the player is ON_PASSABLE
//]- Mod Date: 5/29/00 Doug Poston
//]-				 Change 'offset sonar' from 7 to 16 units
//]- Mod Date: 6/19/00 Doug Poston
//]-				 Reset _FALLTIME (no falling damage is you land in water)
//]- Mod Date: 6/27/00 Doug Poston
//]-				Replaced ACCEL
//]- Mod Date: 6/28/00 Doug Poston
//]-				Modified gravity check to handle ON_PASSABLE while IN_PASSABLE
//]- Mod Date: 6/29/00 Doug Poston
//]-				Remove IN_PASSABLE check while ON_PASSABLE (6/28/00 mod) (fixed in v4.193)
//]- Mod Date: 7/3/00 Doug Poston
//]-				Fixed code so forces are now completely TIME dependent
//]- Mod Date: 7/22/00 JCL
//]-				Modified because of changes in scan_floor
//]- Mod Date: 8/31/00 DCP
//]-				Scale dist and absdist by movement_scale before MOVE
//]- Mod Date: 11/9/00 DCP
//]-				Change diving (player no longer rotates)
//]- Mod Date: 01/16/01 JCL
//]-				Removed absdist movement_scale because absdist is calculated from external forces
//]- Mod Date: 02/08/01 DCP
//]-				Changes to "scan_floor"  remove need to offset for hull
//]- Mod Date: 02/09/01 DCP
//]-				Added code to 'surface' section that allows the player to 'hop' out of the water.
//]- Mod Date: 02/11/01 DCP
//]-				Use "my_height_passable" in place of "my_height"
//]- Mod: 06/08/01 DCP
//]-				Replaced move() with ent_move() in "hop out of water" and move section
function swim_gravity()
{
	friction = water_fric;     // set friction to water friction

	MY._FALLTIME = 0;	// no falling damage in water

	// force.Z is used for diving/surfacing
	if(force.Z == 0)
	{
		// level out player
		if(MY.TILT < 0)
		{
			MY.TILT += 3 * TIME;
			if(MY.TILT > 0)
			{
				MY.TILT = 0;
			}
		}
		else
		{
			if(MY.TILT > 0)
			{
				MY.TILT -= 3 * TIME;
				if(MY.TILT < 0)
				{
					MY.TILT = 0;
				}
 			}
		}
	}
	else
	{
		// surface player
		if(force.Z > 0)
		{
			MY.TILT += 3 * TIME;
			if(MY.TILT > 30)
			{
				MY.TILT = 30;
			}
		}
  		else
		{
			// player diving
			MY.TILT -= 3 * TIME;
			if(MY.TILT < -30)
			{
				MY.TILT = -30;
			}
		}
	}

/*	NO absforce needed in this swim_gravity
	// reset absolute forces
  	absforce.X = 0;
	absforce.Y = 0;
	absforce.Z = 0;
*/
	// Swimming - rhythmic acceleration
	force.X *= 0.5 + (0.25*walkwave);
	force.Y *= 0.5;
	force.Z *= 0.025;   // surface/diving force


	// accelerate the entity relative speed by the force
	// replaced min with max (to eliminate 'creep')
	temp = max((1-TIME*friction),0);
	MY._SPEED_X = (TIME * force.x) + (temp * MY._SPEED_X);    // vx = ax*dt - min(f*dt,1) * vx
	MY._SPEED_Y = (TIME * force.y) + (temp * MY._SPEED_Y);    // vy = ay*dt - min(f*dt,1) * vy
	MY._SPEED_Z = (TIME * force.z) + (temp * MY._SPEED_Z);    // vz = az*dt - min(f*dt,1) * vz


	// calculate relative distances
	dist.x = MY._SPEED_X * TIME; 		// dx = vx * dt
	dist.y = MY._SPEED_Y * TIME;     // dy = vy * dt
	dist.z = MY._SPEED_Z * TIME;     // dz = vz * dt


//jcl 07-22-00  scan_floor changed
	if( (on_passable_ == ON) )
	{
		// reset absolute distance
		absdist.x = 0;
		absdist.y = 0;
		absdist.z = 0;

		// if MY center (use passable height) is greater than the surface level...
		if(((my_height_passable) > 5))// (MY.MIN_Z + 21)))   // 21 = 16 "hull" + 5 "float value"
		{
			 // pull down to the surface of the water
  			absdist.Z -= min(gravity,my_height_passable);
		}


		// restrict climbing rotation on surface and check for edge...
		if(MY.TILT > 5)
		{
			MY.TILT = 5;   // shallow climb


			// If the user is near a solid edge and trying to swim up try to hop out
			// scan ahead of ME
			vec_set(vecFrom,MY.X);
			vecFrom.X += (MY.MAX_X + 25) * cos(MY.PAN);
			vecFrom.Y += (MY.MAX_X + 25) * sin(MY.PAN);
			vec_set(vecTo,vecFrom);
			vecFrom.Z += MY.MAX_Z;		// adjust this to adjust height

			trace_mode = IGNORE_ME + IGNORE_SPRITES + IGNORE_PASSENTS + IGNORE_MODELS + IGNORE_PASSABLE;
			if( (trace(vecFrom,vecTo)) != 0)
			{
				// hop out of water
				temp.X = 0; temp.Y = 0; temp.Z = MY.MAX_Z;
				//--move(ME,temp,NULLSKILL);
				move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide;
				ent_move(temp,NULLSKILL); // move up ..

				temp.X = MY.MAX_X; temp.Z = 0;
				//--move(ME,temp,NULLSKILL);
				result = ent_move(temp,NULLSKILL);// ... and over

			}
		}

		// Now move ME by the relative and the absolute speed
		YOU = NULL;	// YOU entity is considered passable by MOVE
		vec_scale(dist,movement_scale);	// scale distance by movement_scale
		//	Removed absdist movement_scale because absdist is calculated from external forces
		//---vec_scale(absdist,movement_scale);	// scale absolute distance by movement_scale
		//--move(ME,dist,absdist);
		move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide;
		result = ent_move(dist,absdist);
	}
	else   // underwater
	{
 		// NOTE: this is where we would add buoyancy (using absforce)
		// right now we are assuming zero buoyancy

		// NOTE: this is where we could add the effect of currents (using absforce)

		// Now move ME by the relative and the absolute speed
		YOU = NULL;	// YOU entity is considered passable by MOVE
		vec_scale(dist,movement_scale);	// scale distance by movement_scale
	  //--	move(ME,dist,NULLSKILL);
		move_mode = ignore_you + ignore_passable + ignore_push + activate_trigger + glide;
		result = ent_move(dist,NULLSKILL);
	}



	// Store the distance covered, for animation
	my_dist = RESULT;
	// Store the distance for player 1st person head bobbing
	// (only for single player system)
	if(ME == player)
	{
		player_dist += MY._SPEED_X;//SQRT(speed.X*speed.X + speed.Y*speed.Y);
	}
}

/////////////////////////////////////////////////////////////////////////
// Desc: scan for a surface below the ME entity
//       set my_floornormal vector to the normal of the surface
//			set my_height to the distance between ME.MIN_Z and the surface
//			set floorspeed to the X & Y speed of any platform ME is on.
//			set on_passable_, in_passable_, and in_solid_ to the 'offset SONAR'
//		values.
//
//]- Mod Date: 7/22/00 JCL
//]-       sets on_passable_, in_passable_, and in_solid_ values using the
//]-		"MY.Z += 16 SONAR" method.
//]-
//]- Mod Date: 11/9/00 DCP
//]-				Replaced sonars with trace()
//]-
//]- Mod Date: 02/08/01 DCP
//]-          Modified 'offset sonar' to calculate height when in water (no
//]-			longer uses the hull, assume swim animation is centered vertically).
function scan_floor()
{
	// -old- SONAR	ME,4000;
//jcl 1-14-01: forgotten IGNORE_SPRITES fixed
	trace_mode = IGNORE_SPRITES + IGNORE_PASSENTS + IGNORE_MODELS + USE_BOX + ACTIVATE_SONAR;
	vec_set(vecFrom,MY.x);
	vec_set(vecTo,MY.x);
	vecTo.z -= 4000;
	my_height = trace(vecFrom,vecTo);  // this is the same as SONAR MY,distance;

	// if the first sonar shows we are in_passable or on_passable...
	if((IN_PASSABLE == ON) || (ON_PASSABLE == ON))
	{ 
		// the entity can be completely or partially under water
//--		vecFrom.z += 16;		// displace me upwards by the hull size - now my hull is outside the water
		vecFrom.z += (MY.MAX_Z + MY.MIN_Z);// displace upwards by model's vertical center
		trace_mode = IGNORE_SPRITES + IGNORE_PASSENTS + IGNORE_MODELS;
		my_height_passable = trace(vecFrom,vecTo);

	}
	else
	{
		my_height_passable = 0;
	}

	// save SONAR values for later use
	on_passable_ = ON_PASSABLE;
	in_passable_ = IN_PASSABLE;
	in_solid_ = IN_SOLID;

	my_floornormal.X = NORMAL.X; 	// set my_floornormal to the normal of the surface
	my_floornormal.Y = NORMAL.Y;
	my_floornormal.Z = NORMAL.Z;
//	my_height = RESULT;       		// set my_height to the distance between entity's MIN_Z and surface

	my_floorspeed.X = 0; 			// reset floorspeed to zero
	my_floorspeed.Y = 0;

	// if the player is standing on a platform, move him with it
	if(YOU != NULL)
	{
		if(YOUR._TYPE == _TYPE_ELEVATOR)
		{
			my_floorspeed.X = YOUR._SPEED_X;
			my_floorspeed.Y = YOUR._SPEED_Y;
			// Z speed is not necessary - this is done by the height adaption
		}
	}
}



/////////////////////////////////////////////////////////////////////////
// Desc: calculate the damage taken by a fall
//
//	Param: fall_time and MY must be set before calling
//
// Note: override this function if you want to use a different formula
//
// Called from 'move_gravity()'
function	fall_damage()
{
	// calculate damage depending on _FALLTIME
 	return(10 + INT((MY._FALLTIME - fall_time) * 1.75));
}



/////////////////////////////////////////////////////////////////////////
// Desc: set force and aforce values
//			these values come from _player_intentions (single player)
//		  or from the client (multiplayer)
//
//	Calls: _player_intentions
//
//	Called From: player_move()
//
//]- Mod Date: 6/9/00 Doug Poston
//]-				changed to function
function _player_force()
{
	// If the camera does not move itself
	if (_camera == 0)
	{
		// multiplayer mode
		if(connection > 0) // if (client_moving) does not work on a stand-alone server
		{
			// get forces from server
			vec_set(force,MY._FORCE_X);
			vec_set(aforce,MY._AFORCE_PAN);
		}
		else
		{
			// get forces from user input (local)
			_player_intentions();
		}

		vec_scale(aforce,MY._FORCE);
		vec_scale(force,MY._FORCE);
	}
	else
	{ // player is controlling camera - set actor forces to zero
		vec_set(aforce,nullvector);
		vec_set(force,nullvector);
	}
}




/////////////////////////////////////////////////////////////////////////
// Desc: used in multiplayer (client/server) games
//			set client_moving var to 1
//			take user input use that to adjust the 'player' forces
//			SEND player forces to the server
//       move the camera
//
// Mod: 04/18/02 rotation is now calculated on the client and sent to the server
//
// Call: _player_intentions
//			move_view

define SEND_RATE,4;
define SEND_UNRELIABLE,8;


function client_move()
{
	client_moving = 1;
	while(1)
	{
		// player created on the client?
		if(player)
		{
			_player_intentions();	// user key/mouse input sets force and aforce values

// we are setting the player's angles directly on the client,
// and are sending them to the server, rather than sending a keyboard
// force. This eliminates network latency on rotation.
// However the player entity will receive the angles back from the
// server at random intervals, and we have to prevent that they
// overwrite our directly set angles. For this we store the angles
// in the aforce skills.
			vec_set(player.PAN,player._AFORCE_PAN);	// retrieve angles
			my = player;
			_player_rotate();			// rotate on client
			send_skill(player.pan,SEND_VEC+SEND_UNRELIABLE+SEND_RATE); 	// send angles to server
			vec_set(player._AFORCE_PAN,player.PAN); // store angles

// we can't do the same with translation, due to collision detection.
// so set player forces to forces entered in _player_intentions()
			vec_set(player._FORCE_X,force);
// and then send player forces to server, for moving the player there
			send_skill(player._FORCE_X,SEND_VEC+SEND_UNRELIABLE+SEND_RATE);

			// move the camera
			move_view();
		}
		wait(1);
	}
}




/////////////////////////////////////////////////////////////////////
// Desc: aitborne movement function
function move_airborne()
{

	MY._POWER += 0.1*force.Z;
	if(MY._POWER < 0) { MY._POWER = 0; }
	if(MY._POWER > power_max) { MY._POWER = power_max; }
	absforce.X = 0;
	absforce.Y = 0;
	absforce.Z = 0;

	friction = air_fric;
	force.X = 0;
	force.Y = 0;
	force.Z = 0;
}




Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Old school A6 user needs help with fps code [Re: rayp] #403641
06/22/12 22:08
06/22/12 22:08
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'll try to convert this template into lite-c laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Old school A6 user needs help with fps code [Re: 3run] #403644
06/22/12 22:56
06/22/12 22:56
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
have fun grin
heres the rest...
Code:
// MOD : blocked __WHEEL cause of FLAG1-camera-noflag1 stuff
//
// Template file v5.202 (02/20/02)
////////////////////////////////////////////////////////////////////////
// Last Mod: 02/11/01
////////////////////////////////////////////////////////////////////////
// File: movement.wdl
//		WDL prefabs for entity movement
////////////////////////////////////////////////////////////////////////
//]- Mod Date: 6/5/00
//]- Added code to handle new animation
//]- Player can now stand, walk, run, duck, jump, crawl, swim, and wade
//]-
//]- Mod Date: 6/8/00
//]- Converted code to 4.187 format (removed SETs and CALLs)
//]-
//]- Mod Date: 6/19/00
//]- Added __FALL (FLAG1) and _FALLTIME (SKILL31)
//]- If __FALL is ON, player takes damage from falls
//]- _FALLTIME contains the amount of time spent falling (calculated in move_gravity)
//]-
//]- Mod Date: 7/18/00
//]-	Changed slope gravity (added var 'slopefac')
//]-
//]- Mod Date: 7/19/00
//]- Added code to adjust my_height while ducking and crawling
//]-		- Add var 'duck_height'
//]-		- modified var 'eye_height_duck' to equal 'eye_height_up'
//]-
//]- Mod Date: 7/28/00
//]- Added __DUCK flag as flag #8 (replaces __SOUND flag)
//]- Player can only duck if the __DUCK flag is set to ON
//]- NOTE: __SOUND flag is still used for "old style" animation!
//]-
//]- Mod Date: 8/28/00 DCP
//]-	Removed Actions 'player_heli' and 'player_fly' (experimental code)
//]-	Added MODEs _MODE_PLANE &  _MODE_CHOPPER
//]-	Expanded var 'camera_dist' & 'temp_cdist' into vectors (X,Y,Z fields)
//]- Modified 'move_view_3rd' FUNCTION to take advantage of 'camera_dist' vector
//]- Replaced min with max (to eliminate 'creep') in 'gravity' functions
//]-
//]- Mod Date: 8/31/00 DCP
//]-	Added movement_scale and actor_scale to scale movement and models (to make world appear larger or smaller)
//]- Modified "swim_gravity" to scale dist and absdist by movement_scale before MOVE
//]- Modified "wade_gravity" to scale dist and absdist by movement_scale before MOVE
//]- Modified "move_gravity" to scale dist and absdist by movement_scale before MOVE
//]- Modified function "anim_init" to use actor_scale to scale the entity that calls it.
//]- Modified 'walk_or_run' by 'movement_scale' in function "actor_anim"
//]-
//]- Mod Date: 9/2/00 DCP
//]-	Modified 'move_view_3rd' to set camera_dist.Z to player.MAX_Z if zero
//]-
//]- Mod Date: 10/31/00 DCP
//]-	Modified 'player_move':	Replaced min with max in ASPEED (to eliminate 'creep')
//]-	Changed to 4.30 format
//]-
//]- Mod Date: 11/8/00 DCP
//]-	Modified 'camera_move':	Replace move_view with a simple vec_add()
//]- Modified 'actor_anim': Replace set_frame and set_cycle with ent_frame and ent_cycle
//]-
//]- Mod Date: 11/9/00 DCP
//]-	Modified 'move_shadow': Replaced sonar with trace()
//]- Modified 'scan_floor': Replaced sonar with trace()
//]- Modified 'move_gravity': Replaced the double MOVE with a single MOVE and a distance check
//]- Modified 'swim_gravity': Change diving (player no longer rotates)
//]-
//]- Mod Date: 11/13/00 DCP
//]-	Added 'mouse_to_level': uses trace() and vec_for_screen() to set TARGET
//]-								to the nearest point under the cursor.
//]- Modified 'move_view_1st': Headwave only when 'on_passable_' && swimming
//]-
//]- Mod Date: 01/16/01 JCL
//]-	"swim_gravity", "wade_gravity", & "move_gravity"
//]-	Removed absdist movement_scale because absdist is calculated from external forces
//]-
//]- Mod Date: 02/02/01 JCL
//]-	Added function 'attach_entity': attaches an entity that has the same origin and the same frame cycles
//]-
//]- Mod Date: 02/07/01 DCP
//]- "move_view_1st": Check camera 'content' for swimming headbob (don't bob if
//]-			          underwater, do if swimming on top)
//]-				 		  Removed swimming 'eye_height_down' value
//]-				 		  Change formating, grouped like actions together
//]- "move_view_3rd": Adjusted eye height
//]- 					  Don't tilt camera if swimming
//]-
//]- Replace 'eye_height_down' with 'eye_height_swim'
//]-
//]- Mod Date: 02/08/01 DCP
//]- "scan_floor": Modified 'offset sonar' to calculate height when in water (no
//]-			longer uses the hull, assume swim animation is centered vertically).
//]-
//]- Mod Date: 02/09/01 DCP
//]-	"swim_gravity": Added code to 'surface' section that allows the player to 'hop' out of the water.
//]-	"player_move":	If entering passable block stop falling (MY._SPEED_Z = 0)
//]-
//]- Mod Date: 02/11/01 DCP
//]-	Added new var "my_height_passable".  This is the height of the player model's center
//]- above any passable surface. It is only valid is the player model is in or on a passable surface.
//]- It is set in "scan_floor" and used in "player_move" & "swim_gravity".
//]-
//]- Mod Date: 04/17/01 DCP
//]-	Added '_test_arrow' test code. make object passable and remove after 128 ticks
//]-	(CREATE(<ARROW.PCX>,gun_source,_test_arrow);)
//]-
//]- Mod Date: 05/30/01 DCP
//]-		player_move():	Changed -MY.MIN_Z + 5 to -MY.MIN_Z + 6 in "swim check" to
//]-	replace '<=' compare with '<' (do NOT use '<=', '>=', or '==' to compare
//]-	non-int values).
//]-
//]- Mod Date: 05/31/01 DCP
//]-	player_move() & wade_gravity(): Changed 'wading' behavior so player
//]-	no longer 'stutters' from wade-to-swim when entering/exiting the water.
//]-
//]- Mod Date: 06/08/01 DCP
//]-		swim_gravity(), wade_gravity(), & move_gravity() : Replaced move() with ent_move()
//]-
//]- Mod Date: 06/11/01 DCP
//]-		Add function "actor_anim_old_style_anim()", removed code from "actor_anim"
//]-		Add function "actor_anim_transition()"
//]-		**NOTE** actor_anim_transition is still a work in progress.
//]-
//]- Mod Date: 06/13/01 DCP
//]-		Moved all code dealing with camera movement into its own WDL (camera.wdl)
//]-
//]- Mod Date: 06/14/01 DCP
//]-		Moved all code dealing with animation into its own WDL (animate.wdl)
//]-		Moved all code dealing with input into its own WDL (input.wdl)
//]-
//]- Mod Date: 06/15/01 DCP
//]-		Moved all code dealing with moving into its own WDL (move.wdl)
//]-
//]- Mod Date: 06/21/01 DCP
//]-		Replace SYNONYMs with pointers

////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////


//@ Defines
// Change them by re-defining them in your main wdl script
// BEFORE the include, and adding DEFINE MOVE_DEFS;
IFNDEF MOVE_DEFS;
	SOUND  thud = <tap.wav>;
	SOUND  robo_thud = <tap.wav>;  //??
	SOUND  splash = <splash.wav>;
	STRING shadowsprite = <shadow.tga>;
	STRING shadowflat = <shadflat.pcx>;
	DEFINE DEFAULT_WALK,13.040;
	DEFINE DEFAULT_RUN,5.060;
ENDIF;


////////////////////////////////////////////////////////////////////////
// User modifiable global skill definitions
// Duplicate them in your wdl script AFTER the include
// to give them new values
// NOTE: in most cases it is a good idea to make actor_scale == movement_scale
var movement_scale = 1;  // used to scale the movement
var actor_scale = 1;	// used to scale the size of actors

var gnd_fric = 0.5;		// ground friction
var air_fric = 0.03; 	// air friction
var water_fric = 0.75;	// water friction
var ang_fric = 0.6;		// angular friction

var gravity = 4; 			// gravity force 6
var elasticity = 0.1; 	// of the floor

// dcp: 10/02/02 changed from 2 to 0.5 to fit with constant slope force change in move
var slopefac = 0.5; // gravity on slopes, determines the max angle to climb

var strength[3] = 7,5,30;	// default ahead, side, jump strength   (7,5,25)
//var strength[3] = 10,9,50;
var astrength[3] = 7,5,2;	// default pan, tilt, roll strength

var jump_height = 30; 	// maximum jump height above ground
var fall_time = 10;		// max fall time before health is reduced
var duck_height = 10;	// distance to adjust my_height while ducking

var power_max = 1; 		// maximum engine power for aircraft


// values set in scan_floor
var on_passable_;
var in_passable_;
var in_solid_;



///////////////////////////////////////////////////////////////////////
// Entity skill & flag definitions
// some definitions here are also needed for ACTORS.WDL and WAR.WDL
DEFINE _WALKFRAMES,SKILL1;	// non-zero for old style animation
DEFINE _RUNFRAMES,SKILL2;
DEFINE _ATTACKFRAMES,SKILL3;
DEFINE _DIEFRAMES,SKILL4;

// 'advanced animation' style
DEFINE _ADVANIM_TICK,SKILL1;	// 'tick' related animation
DEFINE _ADVANIM_DIST,SKILL2;  // 'dist' related animation


DEFINE _WALKDIST,SKILL27;	// distance per walk cycle
DEFINE _RUNDIST,SKILL28;	// distance per run cycle


DEFINE _FORCE,SKILL5;		// determines speed
DEFINE _ENTFORCE,SKILL5;
DEFINE _BANKING,SKILL6;		// banking - for player only
DEFINE _PENDOLINO,SKILL6;	// banking - for player only
DEFINE _HITMODE,SKILL6;		// for actors
DEFINE _MOVEMODE,SKILL7;
DEFINE _FIREMODE,SKILL8;	// for actors


//mod FLAG1

#DEFINE __WHEELS,FLAG2;	// block turns without moving
DEFINE __FALL,FLAG2;		// take damage from falls

DEFINE __SLOPES,FLAG3;	// adapt the tilt and roll angle to slopes
DEFINE __JUMP,FLAG4;		// be able to jump
DEFINE __BOB,FLAG5;   	// head wave
DEFINE __STRAFE,FLAG6;	// be able to move sidewards
DEFINE __TRIGGER,FLAG7;	// be able to trigger doors automatically

DEFINE __DUCK, FLAG8;	// be able to duck

DEFINE __SOUND,FLAG8;	// internal flag

///////////////////////////////////////////////////////////////////////
DEFINE _HEALTH,SKILL9;
DEFINE _ARMOR,SKILL10;

DEFINE _SPEED,SKILL11;		// speed
DEFINE _SPEED_X,SKILL11;
DEFINE _SPEED_Y,SKILL12;
DEFINE _POWER,SKILL12;		// engine power for aircraft models
DEFINE _SPEED_Z,SKILL13;
DEFINE _ASPEED,SKILL14;		// angular speed
DEFINE _ASPEED_PAN,SKILL14;
DEFINE _ASPEED_TILT,SKILL15;
DEFINE _ASPEED_ROLL,SKILL16;

// for actor entities, and for doors and platforms
DEFINE _TARGET_X,SKILL17;
DEFINE _TARGET_Y,SKILL18;
DEFINE _TARGET_Z,SKILL19;
DEFINE _TARGET_PAN,SKILL20;
DEFINE _TARGET_TILT,SKILL21;
DEFINE _TARGET_ROLL,SKILL22;

// for player entities
DEFINE _FORCE_X,SKILL17;
DEFINE _FORCE_Y,SKILL18;
DEFINE _FORCE_Z,SKILL19;
DEFINE _AFORCE_PAN,SKILL20;
DEFINE _AFORCE_TILT,SKILL21;
DEFINE _AFORCE_ROLL,SKILL22;

DEFINE _WALKSOUND,SKILL23;	// walking sound
DEFINE _SIGNAL,SKILL24;		// communication for actions or client->server
DEFINE _COUNTER,SKILL25;	// internal counter
DEFINE _STATE,SKILL26;		// the state it is in (walk, attack, escape etc.)

DEFINE _ANIMDIST,SKILL28;	// time for standing, jumping, and ducking animations

DEFINE _JUMPTARGET,SKILL29;// target height to jump to

DEFINE _TYPE,SKILL30;		// the type of the entity - door, key, etc.

DEFINE _FALLTIME,SKILL31;	// amount of time spent falling

// Skills up to 32 are reserved for future template actions
// Skills 33-40 can be used freely

//@@ Vector Vars
// Force Vars
var force[3];		// cartesian force, entity coordinates
var absforce[3];	// cartesian force, world coordinates
var aforce[3];		// angular force

//@@ Distance Vars
var abspeed[3] = 0,0,0;	// cartesian speed, world coordinates
var dist[3];
var absdist[3];	// distances used for MOVE

//@@ Camera Vars
var person_3rd	= 0;		// 0: 1st person mode; 0.5: 3rd person mode

var eye_height_up = 0.85;//0.75	// eye position factor for walking, driving
var eye_height_swim = 0.4;	// first person camera offset for swimming
var eye_height_duck = 0.5; // first person camera offset for ducking (7/19/00: same as eye_height_up since ducking is controlled by my_height)

//@@ Multiplayer Vars
var client_moving = 0; 	// multiplayer mode


//@@ Mics Vars
var p[3];
var friction;
var limit[3];
var covered_dist;
var anim_dist;

var head_angle[3] = 0,0,0;	// separated from other values
var headwave = 0;
var walkwave = 0;
var my_dist;			// distance for actor anim
var player_dist;		// distance for head bobbing
var scan_sector;
var my_height;
var my_height_passable;	// height above passable surface (valid only if on passable surface)
var my_floornormal[3];
var my_floorspeed[3];
var temp_cdist[3] = 120,0,0;   // current camera distance in 3rd p view
//-var debugskill;

// temp values used to replace sonar with trace (DCP-11/9/00)
var vecFrom[3];
var vecTo[3];

var temp2[3];	// another temp var


//SYNONYM player { TYPE ENTITY; }
//SYNONYM temp_ent { TYPE ENTITY; }
//SYNONYM carry { TYPE ACTION; }
entity*	player;	// pointer to player entity
entity*	temp_ent;
action*	carry;

DEFINE _MODE_NONE,0;		// no movement (i.e. player dead)
DEFINE _MODE_WALKING,1;		// covers standing,walking, and running (speed dependent)
DEFINE _MODE_DRIVING,2;
DEFINE _MODE_SWIMMING,3;
DEFINE _MODE_DIVING,4;
DEFINE _MODE_WADING,5;
DEFINE _MODE_HELICOPTER,6;	// very primitive helicopter mode
DEFINE _MODE_ROCKETEER,7;
DEFINE _MODE_DUCKING,8;		// ducking
DEFINE _MODE_JUMPING,9;		// jumping
DEFINE _MODE_CRAWLING,10;	// crawling
DEFINE _MODE_TRANSITION,14; // transitioning between modes
DEFINE _MODE_STILL,15;

DEFINE _MODE_PLANE,16;
DEFINE _MODE_CHOPPER,17;


// modes 20 and above are handled by a different wdl
DEFINE _MODE_ATTACK,20;

DEFINE _SOUND_WALKER,1;
DEFINE _SOUND_ROBOT,2;

DEFINE _TYPE_PLAYER,1;
DEFINE _TYPE_ACTOR,2;
DEFINE _TYPE_FOE,3;
DEFINE _TYPE_DOOR,10;
DEFINE _TYPE_GATE,11;
DEFINE _TYPE_ELEVATOR,12;
DEFINE _TYPE_GUN,20;
DEFINE _TYPE_AMMO,21;
DEFINE _TYPE_ARMOR,22;
DEFINE _TYPE_HEALTH,23;

DEFINE _FOG_UNDERWATER,2;	// fog color 2 is used for underwater fog

SOUND beep_sound,<beep.wav>;
//SYNONYM debugsyn { TYPE ENTITY; }



/////////////////////////////////////////////////////////////////////////
//@ MISC movement functions


/////////////////////////////////////////////////////////////////////////
//@ animate.wdl function prototype
function	actor_anim_transition(str_anim_target,trans_ticks);

var	q_anim_trans_use = 0;


/////////////////////////////////////////////////////////////////////////
// Desc: player tips over, can be used for death
function player_tip()
{
	MY._MOVEMODE = 0;	// suspend normal movement action
	eye_height_up.Z = eye_height_up;	// store original eye height
	while(MY.ROLL < 80)
	{
		MY.ROLL += 8 * TIME;
		MY.TILT += 2 * TIME;
		if(eye_height_up > 0.15)
		{
			eye_height_up -= 0.1 * TIME;
		}

		if(client_moving==0) { move_view(); }
		wait(1);
	}
	MY.ROLL = 80;
	MY.TILT = 20;
	eye_height_up = eye_height_up.Z;	// restore original eye height
}



////////////////////////////////////////////////////////////////////////
// Desc: event action to indicate any event by resetting the event flag
//
//]- Mod Date: 6/9/00 Doug Poston
//]-				changed to function
function _setback()
{
	if(EVENT_TYPE == EVENT_BLOCK) { MY.ENABLE_BLOCK = OFF; }
	if(EVENT_TYPE == EVENT_ENTITY) { MY.ENABLE_ENTITY = OFF; }
	if(EVENT_TYPE == EVENT_STUCK) { MY.ENABLE_STUCK = OFF; }

	if(EVENT_TYPE == EVENT_PUSH) { MY.ENABLE_PUSH = OFF; }
	if(EVENT_TYPE == EVENT_IMPACT) { MY.ENABLE_IMPACT = OFF; }

	if(EVENT_TYPE == EVENT_DETECT) { MY.ENABLE_DETECT = OFF; }
	if(EVENT_TYPE == EVENT_SCAN) { MY.ENABLE_SCAN = OFF; }
	if(EVENT_TYPE == EVENT_SHOOT) { MY.ENABLE_SHOOT = OFF; }
	if(EVENT_TYPE == EVENT_TRIGGER) { MY.ENABLE_TRIGGER = OFF; }

	if(EVENT_TYPE == EVENT_TOUCH) { MY.ENABLE_TOUCH = OFF; }
	if(EVENT_TYPE == EVENT_RELEASE) { MY.ENABLE_RELEASE = OFF; }
	if(EVENT_TYPE == EVENT_CLICK) { MY.ENABLE_CLICK = OFF; }
}



// Mod Date: 6/9/00 Doug Poston
//				changed to function
function _beep() { BEEP; }

// Desc: play some kinds of foot sound
//
//]- Mod Date: 6/9/00 Doug Poston
//]-				changed to function
function _play_walksound() //when update here make an update in camera.wdl too
{

	if((ME == player) && (person_3rd == 0)) { return; }	// don't play entity sounds for 1st person player
#	if(MY._WALKSOUND == _SOUND_WALKER) { ent_playsound(ME,thud,25); }
vec_set(temp, camera.x);
temp.z-=500;
c_trace (camera.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|SCAN_TEXTURE|USE_BOX);
IF(YOU==NULL) {
 IF (str_cmpi(tex_name, "carpetfloor001a")==1) {IF(Random(10)>5){MY._WALKSOUND=ent_playsound(ME,Snd_WalkSound_Concrete,60);}ELSE{MY._WALKSOUND=ent_playsound(Me,Snd_WalkSound_Concrete2,60);}GOTO Knowed_Ground; }
 IF (str_cmpi(tex_name, "woodfloor1")==1)      {IF(Random(10)>5){MY._WALKSOUND=ent_playsound(ME,Snd_WalkSound_Wood,60);}ELSE{MY._WALKSOUND=ent_playsound(ME,Snd_WalkSound_Wood2,60);}GOTO Knowed_Ground; }
 IF (str_cmpi(tex_name, "floor21")==1)         {IF(Random(10)>5){MY._WALKSOUND=ent_playsound(ME,Snd_WalkSound_Tile,60);}ELSE{MY._WALKSOUND=ent_playsound(ME,Snd_WalkSound_Tile2,60);}GOTO Knowed_Ground; }
}
ELSE { //...or entity
 IF(YOU.SKILL17==17) { //walking on swamp terrain?
  IF(Random(10)>5) {my._walksound=ent_playsound(me,Snd_WalkSound_Swamp, 55);}ELSE {my._walksound=ent_Playsound(me,Snd_WalkSound_Swamp2, 55); }
 }
}
MY._WALKSOUND=ent_playsound(me,thud,55); //unkown ground so use std sound
Knowed_Ground:


}


// Desc: test code. make object passable and remove after 128 ticks
function _test_arrow()
{
	MY.PASSABLE = ON;
	MY.alpha = 25;
	MY.transparent = ON;
	MY.SCALE_X = 0.45;
	MY.SCALE_Y = 0.45;
	waitt(32);//(128);
	ent_remove(ME);
}




// INCLUDED CODE (originally part of movement.wdl
include <move.wdl>;
include <camera.wdl>;	// handle camera movement
include <animate.wdl>;  // handle animation
include <input.wdl>;    // handle user input (mouse, keyboard, joystick, ..)



oh and the input.wdl

Code:
// modded to WASD movement ohh yeah !
// Template file v5.202 (02/20/02)
////////////////////////////////////////////////////////////////////////
// File: input.wdl
//		WDL prefabs for user input (mouse, keyboard, joystick, ..)
////////////////////////////////////////////////////////////////////////
// Use:
//		Include AFTER "move.wdl"
//



//@ Input Defines
DEFINE _HANDLE,1;		// SCAN via space key
DEFINE _EXPLODE,2;	// SCAN by an explosion
DEFINE _GUNFIRE,3;	// SHOOT fired by a gun
DEFINE _WATCH,4;		// looking for an enemy
DEFINE _DETECTED,5;	// detected by an enemy
DEFINE _SHOOT1,6;		// shoot key pressed (not used yet)


//@ Input Vars
var indicator = 0;


var mouseview = 0.5;  		// mouse factor, set 0 to disable mouse



//@ Input Function Protypes

function _player_intentions();	// core function handling input from the player

function do_handle();		// Handle action, calls 'scan_handle'
function scan_handle();		// scan a cone using '_HANDLE' indicator
function perform_handle();	// checks for receiving a handle signal
function send_handle();		// send a handle signal (player._SIGNAL = _HANDLE;)

function mouse_to_level();	// set TARGET to a point in the level under mouse pointer, return distance


//@ Input Functions

/////////////////////////////////////////////////////////////////////////
// Desc: Get key input from the player
//
// Set aforce & force values using player input (keyboard/mouse/joystick)
// Make sure these values are within limit
//
function _player_intentions()
{
// Set the angular forces according to the player intentions
	aforce.PAN = -astrength.PAN*(KEY_FORCE+JOY_FORCE.X);
	aforce.TILT = astrength.TILT*(KEY_PGUP-KEY_PGDN);//pgup-.._pgdn
	if(MOUSE_MODE == 0)
	{	// Mouse switched off?
		 aforce.PAN += -astrength.PAN*MOUSE_FORCE.X*mouseview*(2+KEY_SHIFT);
		 aforce.TILT += astrength.TILT*MOUSE_FORCE.Y*mouseview*(2+KEY_SHIFT);
	}

	aforce.ROLL = 0;
// Set ROLL force if ALT was pressed
	if(KEY_ALT != 0)
	{
		aforce.ROLL = aforce.PAN;
		aforce.PAN = 0;
	}
// Double the forces in case the player pressed SHIFT
/*--	if(KEY_SHIFT != 0)
	{
		aforce.PAN += aforce.PAN;
		aforce.TILT += aforce.TILT;
		aforce.ROLL += aforce.ROLL;
	}--*/
// Limit the forces in case the player
// pressed buttons, mouse and joystick simultaneously
	limit.PAN = 2*astrength.PAN;
	limit.TILT = 2*astrength.TILT;
	limit.ROLL = 2*astrength.ROLL;

	if(aforce.PAN > limit.PAN) {  aforce.PAN = limit.PAN; }
	if(aforce.PAN < -limit.PAN) {  aforce.PAN = -limit.PAN; }
	if(aforce.TILT > limit.TILT) {  aforce.TILT = limit.TILT; }
	if(aforce.TILT < -limit.TILT) {  aforce.TILT = -limit.TILT; }
	if(aforce.ROLL > limit.ROLL) {  aforce.ROLL = limit.ROLL; }
	if(aforce.ROLL < -limit.ROLL) {  aforce.ROLL = -limit.ROLL; }

// Set the cartesian forces according to the player intentions //force.Y
//IF (KEY_W == 1) {
	force.X = strength.X*(KEY_W-KEY_S);// } // forward/back +joy_force.y
//IF (KEY_S ==1) { 
//strength.X*(KEY_S-KEY_w); //}
	force.Y = strength.Y*(KEY_A-KEY_D);     // COMMA PERIOD
IF(_insolid==0){	force.Z = strength.Z*(MOUSE_RIGHT-KEY_C);}#(KEY_HOME-KEY_END);         // up and down
/*	if(MOUSE_MODE == 0)
	{	// Mouse switched off?
		force.X += strength.X*MOUSE_RIGHT*mouseview;
	}*/

// Double the forces in case the player pressed SHIFT
/*--	if(KEY_SHIFT != 0)
	{
		force.X += force.X;
		force.Y += force.Y;
		force.Z += force.Z;
	}--*/

// Limit the forces in case the player tried to cheat by
// operating buttons, mouse and joystick simultaneously

	limit.X = 2*strength.X;
	limit.Y = 2*strength.Y;
	limit.Z = 2*strength.Z;

	if(force.X > limit.X) {  force.X = limit.X; }
	if(force.X < -limit.X) { force.X = -limit.X; }
	if(force.Y > limit.Y) {  force.Y = limit.Y; }
	if(force.Y < -limit.Y) { force.Y = -limit.Y; }
	if(force.Z > limit.Z) {  force.Z = limit.Z; }
	if(force.Z < -limit.Z) { force.Z = -limit.Z; }
}



////////////////////////////////////////////////////////////////////////
// Desc: Handle action. Set to SPACE by default.
// Will operate doors or items within 200 quants.
//
function do_handle()
{
	if(player != NULL)
	{
		MY_POS.X = player.X;
		MY_POS.Y = player.Y;
		MY_POS.Z = player.Z;
		MY_ANGLE.PAN = player.PAN;
	}
	else
	{
		MY_POS.X = CAMERA.X;
		MY_POS.Y = CAMERA.Y;
		MY_POS.Z = CAMERA.Z;
		MY_ANGLE.PAN = CAMERA.PAN;
	}
	MY_ANGLE.TILT = CAMERA.TILT;
	scan_handle();
}


/////////////////////////////////////////////////////////////////////////
// Desc: scan a wide cone of 200 quants range
function scan_handle()
{
	temp.PAN = 120;
	temp.TILT = 180;
	temp.Z = 100;//200 mod
	indicator = _HANDLE;
	c_scan(MY_POS,MY_ANGLE,temp,SCAN_ENTS|SCAN_LIMIT);
}



/////////////////////////////////////////////////////////////////////////
// Desc: This action can be run by a player entity on the server
// 		It checks for receiving a handle signal, then performs a scan
function perform_handle()
{
	while(1)
	{
		if(MY._SIGNAL == _HANDLE)
		{	// client has pressed handle key
			my._SIGNAL = 0;				// reset it
			vec_set(my_pos,my.x);
			vec_set(my_angle,my.pan);
			scan_handle();
		}
		wait(1);
	}
}

/////////////////////////////////////////////////////////////////////////
// Desc: send a '_HANDLE' signal
function send_handle()
{
	if(player != NULL)
	{
		player._SIGNAL = _HANDLE;	// send command to perform a scan
		send(player._SIGNAL);
	}
}


/////////////////////////////////////////////////////////////////////
// Desc: set TARGET to a point in the map that appears under the mouse pointer
//			returns the distance to that point
//
// Modifies: vecTo, vecFrom, TARGET, NORMAL, YOU, TEX_NAME, TEX_LIGHT
// Returns: distance to TARGET (or 0 if NULL)
function mouse_to_level()
{
	vecFrom.X = MOUSE_POS.X;
	vecFrom.Y = MOUSE_POS.Y;
	vecFrom.Z = 10;
	vec_set(vecTo,vecFrom);
	vec_for_screen(vecFrom,CAMERA); // near point

	vecTo.Z = 5000;
	vec_for_screen(vecTo,CAMERA);   // far point

	return(trace(vecFrom,vecTo));  // trace a line between the two points
}





/////////////////////////////////////////////////////////////////////
//jcl (key assignments always at the end)
ON_SPACE send_handle;



Last edited by rayp; 06/22/12 23:08.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Old school A6 user needs help with fps code [Re: rayp] #403649
06/23/12 07:48
06/23/12 07:48
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Thanks for your replies and code.

Unfortunately I cannot use the A5 template as the skill definitions clash and there are not enough to go around.

As far as using A7/8 goes I would have to convert the entire code to lite-c.

I have placed the players code below. Perhaps there is something obvious I have left out.





define jump = skill91;
define health,skill22;
define foot_step_distance skill11; // use skill11 to store the covered distance that will trigger the foot step sound
define state,skill50;//used for player and enemy states eg running, combat etc


var cam_pan_speed = 8;
var cam_tilt_speed = 6;
var eyespot[3];
var jump = 0;
var jump_height = 10;
var checkuptemp[3];
var state_fps=150;
var curmid;
var max_dist = 10000;
var bulb_brightness = 200;



function gravity(){

vec_set(temp, my.x);
temp.z = -999999;
trace_mode = ignore_me + use_box + ignore_models + ignore_sprites;
-trace(my.x, temp);

if(result > 20){my.skill3 -= 2 * time;}
else{my.skill3 = -trace(my.x, temp) * 0.25;}

}

function the_camera(){

vec_for_vertex(eyespot,player,25);//middle of the eyes
proc_late();
camera.genius = me;
//camera.diameter = 180;
//camera.arc = 75;
camera.x = eyespot.x;
camera.y = eyespot.y;
camera.z = eyespot.z;
my.pan -= cam_pan_speed * (mouse_force.x) * time;
camera.pan = my.pan;
camera.tilt += cam_tilt_speed * (mouse_force.y) * time;
camera.tilt = clamp(camera.tilt, -65, 90);
my.pan%=360;

}






action ent_player
{
if (my.foot_step_distance == 0) {my.foot_step_distance = 128;} // default foot step distance = 59
player = my;
my.shadow = on;
my.narrow = on;
my.fat = off;
my.polygon=on;
my.enable_impact=on;
my.enable_entity=on;
my.enable_block=on;
//my.event=event_player;
my.skill88=0;
my.invisible=on;
my.health = 100;
c_setminmax(my);
wait(2);
my.state=state_fps;
//init_weapons();
//while(weapons_initiated!=3){wait(1);}

my.skill99=0;
while(my.health>0)
{
//if(my.skill99==1){show_playerhit();my.skill99=0;}
//if(my.state==state_cutscene){my.passable=off;}
wait(1);

if(my.state==state_fps)
{
gravity();
the_camera();

//handle_plweapons();
if(key_ctrl)
{ //hold breath
ent_cycle("stand", my.skill6);
my.skill6 += 2 * time;my.skill6%=100;
}
else
{
//stand
ent_cycle("alert", my.skill6);
my.skill6 += 0.3 * time;my.skill6%=100;
}

move_friction = 1; // strong friction
my.skill47 += c_move(me, my.skill1, nullvector,IGNORE_PASSABLE+GLIDE+USE_AABB);


if (my.skill47 > my.foot_step_distance) // adjust my.foot_step_distance (by default, we've got a step sound every 59 quants)
{
//snd_play(step_wav, 20, 0); // then play the foot step sound
my.skill47 = 0; // reset the distance (increase the precission)
}

if(key_shift==0)
{

my.skill1 = 15 * (key_w - key_s) * time;
my.skill2 = 10 * (key_a - key_d) * time;
}
else
{
my.skill1 = 20 * (key_w - key_s) * time;
my.skill2 = 14 * (key_a - key_d) * time;
}

if(my.skill1 != 0)
{
my.skill4 += my.skill1/2;my.skill4%=100;
}
if(my.skill2 != 0)
{
my.skill5 += my.skill2/2;my.skill5%=100;
}

while(key_alt)
{
wait(1);//crouch

gravity();
the_camera();

my.skill1 = 6 * (key_w - key_s) * time;
my.skill2 = 6 * (key_a - key_d) * time;

if(my.skill8 < 85)
{
ent_cycle("standcrouch", my.skill8);
my.skill8 += 5;
}

c_move(me, my.skill1, nullvector, glide);

}
if(key_alt == 0){my.skill8 = 0;}


vec_set(temp, my.x);
temp.z = -999999;
trace_mode = use_box + ignore_passable;
-trace(my.x, temp);

if(key_space && my.jump==0&&result<5&&my.skill88==0)
{
//JUMP
my.skill3 += jump_height;
my.jump = 1;
while(my.jump == 1)&&(my.skill88==0)
{
wait(1);

the_camera();

if(key_shift==0)
{
my.skill1 = 20 * (key_w - key_s) * time;
my.skill2 = 20 * (key_a - key_d) * time;
}else{
my.skill1 = 12 * (key_w - key_s) * time;
my.skill2 = 12 * (key_a - key_d) * time;
}

ent_cycle("jump", my.skill7);

if(my.skill7 < 100)
{
my.skill7 += 20;
}
else
{
gravity();
}

vec_set(temp, my.x);
temp.z = -999999;
trace_mode = use_box + ignore_me + ignore_passable;
-trace(my.x, temp);
if((my.skill7 >= 90) && (result < 7)){my.jump=0;}
move_mode = ignore_passable+glide;
c_move(me,my.skill1,nullvector, glide + ignore_models + ignore_sprites);
vec_set(checkuptemp,vector(0,0,35));
vec_rotate(checkuptemp,my.pan);
vec_add(checkuptemp,my.x);
result = trace(my.x,checkuptemp);
IF (result != 0) {gravity();my.skill3 = -2;}

}
my.skill7 = 0;

}
}//end state fps


}//end health

beep();
}

Re: Old school A6 user needs help with fps code [Re: robertbruce] #403650
06/23/12 09:12
06/23/12 09:12
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
First of all, use "code" tags to post your script, for that switch to "Switch to Full Reply Screen", so your script will be more readable. Secondly, I'm not going to convert whole of your game into lite-c, and I don't really think anyone around will (for free), but I'll show you few of your errors you've made while you tried to convert your script into lite-c. So at the end, lets hope that you'll be able to convert whole of your game yourself (you know better how it works etc.), here it goes:
Code:
// WRONG!!
// skills:
define jump = skill91;
define health,skill22;
// vectors:
var eyespot[3];
// trace function:
trace(my.x, temp);
// flags:
my.shadow = on; 
my.polygon = on;
// events:
my.enable_impact=on;
my.enable_entity=on;
my.enable_block=on;
//my.event=event_player;
// action stuff:
action ent_player
{
}
// animations:
ent_cycle("stand", my.skill6);
my.skill6 += 2 * time;my.skill6%=100;

// other stuff:
proc_late();
test += 1 * time;


// CORRECT!!
// skills:
define jump skill91
define healths kill22
// vectors:
VECTOR eyespot;
(same for "temp" you need to defined that vector yourself)
// trace function:
trace_mode = IGNORE_PASSABLE;
c_trace(my.x, temp, trace_mode);
(same for all other "c_" functions, take a look at the manual)
// flags:
set(my, SHADOW | POLYGON);
(take a look at "set" and other flag stuff at the manual)
(plus, in skills, use "1" <-> "0" instead of old "ON" <-> "OFF")
// events:
my.emask |= (ENABLE_IMPACT | ENABLE_BLOCK | ENABLE_ENTITY);
//my.event=event_player;
// action stuff:
action ent_player()
{
}
// animations:
// ANM_CYCLE shows that this animations will loop
// in this case "my.skill6 %= 100;" isn't needed!
ent_animate(my, "stand", my.skill6, ANM_CYCLE); 
my.skill6 += 2 * time_step;

// other stuff:
proc_mode = PROC_LATE;
test += 1 * time_step;

If you'll fix all this stuff I've mentioned above, you'll be good to go I guess, but some more complex stuff will need you to rewrite it (remade) from scratch. Please, pay attention to capital letters when you write the code, cause lite-c is very secretive! For example:
Code:
IF(comparison){
}

This will cause crash, cause "IF" is written with capital letters!! But this:
Code:
if(comparison){
}

Will work without any problems! So from now on, if you want to switch to lite-c, create new ".c" file (lite-c) and convert all of your functions step by step (one by one) and each time you think that you've converted function, run it, to see does it crash or not, that will help you. And don't forget to save new converted code in ".c", cause ".wdl" will cause strange crashes grin

Good luck mate.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Old school A6 user needs help with fps code [Re: 3run] #404372
07/08/12 01:44
07/08/12 01:44
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Originally Posted By: 3run
Please, pay attention to capital letters when you write the code, cause lite-c is very secretive! For example:
Code:
IF(comparison){
}

This will cause crash, cause "IF" is written with capital letters!! But this:
Code:
if(comparison){
}

Will work without any problems!

Seriously? I thought Lite-C was case insensitive like standard C.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Old school A6 user needs help with fps code [Re: Redeemer] #404378
07/08/12 09:19
07/08/12 09:19
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Seriously? I have NEVER seen standard C to be case-INsensitive.

It gave me major learning troubles learning standard C when I first
started with it because I was migrating from 'commodore basic' and that WAS
case in-sensitive...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Old school A6 user needs help with fps code [Re: EvilSOB] #404625
07/11/12 23:20
07/11/12 23:20
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Originally Posted By: EvilSOB
Seriously? I have NEVER seen standard C to be case-INsensitive.

The only part of C that is case sensitive is identifiers (eg int foo =/= int FOO). Everything else is insensitive.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1