Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, AndrewAMD), 1,640 guests, and 13 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Brauche dringend Hilfe! Player-Script #298491
11/15/09 15:50
11/15/09 15:50
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
Hallo Leute,
ich versuche gerade von C-Script auf Lite-C überzuwechseln :-)
ich habe ein problem, dass ich einfach nicht verstehen kann. ich schaffe es in keinem meiner Projekte ein player.script zum laufen zu kriegen. Es gibt keine Fehlermeldung oder ähnliches, aber wenn ich das spiel per run starte kann ich nur die standard kamera bewegen (wenn man "0" drück kann man sie bewegen), nicht aber meinen player... ich frage mich, ob ich vielleicht ieine einstellung falsch habe?
ich benutze den player-code aus der neusten Aum (playercar.c), welches in dem aum-level wunderbar funktioniert.
Ich bin wirklich so langsam am verzweifeln!

Last edited by CD_saber; 11/16/09 00:42.

Ja, lach du nur du haariges Pelzvieh!
Re: Brauche dringend Hilfe! Player-Script [Re: CD_saber] #298563
11/16/09 00:44
11/16/09 00:44
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
Hier ist noch ein ausschnitt aus dem player script, damit ihr wisst welchen code ich meine


Code:
////////////////////////////////////////////////////////////////////////////////////////////

var movement_speed = 0.9;
var rotation_speed = 0.2;
var engine_freq = 0;
var player_in_car = 0;
var players_health = 100;

VECTOR player_dist;
VECTOR player_pos;

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

SOUND* plengine_wav = "plengine.wav"; // player's engine sound
SOUND* health_wav = "health.wav";

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

ENTITY* pcar; // player's car

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

function player_hit()
{
	if (you.skill30 == 1) // the player was hit by an enemy bullet?
	{
		players_health -= 5; // then subtract 5 points from its health
	}
}

action players_action() // attach this action to your player
{
	while (!pcar) {wait (1);} // wait until the car model is loaded
	if (my.skill99 == 1) // the player was recreated by car's action?
	{
		my.pan = pcar.pan; // then it should inherit car's pan angle!
	}
	while (key_space) {wait (1);} // wait if the player just got out of the car
	var movement_speed = 20; // movement speed
	VECTOR temp;
	my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY); // the player is sensitive to impact with other entities
	my.event = player_hit; // and runs this function if it is hit by another entity
	set (my, INVISIBLE); // 1st person player
	player = my; // I'm the player
	while (players_health > 0)
	{
		my.pan -= 7 * mouse_force.x * time_step;
		camera.x = my.x;
		camera.y = my.y;
		camera.z = my.z + 50 + 1.1 * sin(my.skill44); // play with 50 and 1.1
		camera.pan = my.pan;
		camera.tilt += 3.5 * mouse_force.y * time_step;
		vec_set (temp.x, my.x); // trace 10,000 quants below the player
		temp.z -= 10000;
		temp.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - 2; // play with 2
		temp.x = movement_speed * (key_w - key_s) * time_step;
		temp.y = movement_speed * (key_a - key_d) * 0.6 * time_step;
		c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);

		// the player is close to the car and the "space" key was pressed
		if ((vec_dist (player.x, pcar.x) < 100) && (key_space)) 
		{
			while (key_space) {wait (1);} // then wait until "space" is released
			set (player, PASSABLE); // make the player model passable (allow the car to drive without being hindered by the player)
			player_in_car = 1; // this variable tells us that the player is driving
		}
		while (player_in_car == 1)
		{
			wait (1); // don't do anything for now -> allow the car to move the player
		}
		wait (1);
	}
	camera.tilt = 35; // the player is dead here
	camera.roll = 40; // so set some weird angles for the camera
}

function car_collides() // the event function for our car
{
	if (player_in_car == 0) {return;} // the player isn't using the car? Then don't decrease its health by shooting at the car!
	if (you.skill30 == 1) // the car was hit by a bullet?
	{
		players_health -= 5; // then decrease player's health
	}
}

action players_car()
{	
	pcar = my; // I'm player's car
	set (my, POLYGON);
	while (!player) {wait (1);} // wait until the player model is loaded
	// wait until the space key is released (don't allow the player to get in / out of the car several times in a row)
	while (key_space) {wait (1);} 
	var players_engine; // engine sound handle
	VECTOR player_speed, temp;
	ANGLE player_ang, temp_ang;
	var minimum_z;
	var temp2;
	my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY);
	my.event = car_collides;
	my.albedo = -100;
	players_engine = ent_playloop (my, plengine_wav, 50); // play the engine sound in a loop
	my.skill99 = 102;
	while (players_health > 0)
	{
		while (player_in_car == 0) // the player isn't driving? Then stop this loop until it does
		{
			wait (1);
		}
		player_speed.x = movement_speed * (key_cuu - 0.4 * key_cud); // backwards movement speed = 40%
		my.skill1 = player_speed.x * time_step + maxv (1 - time_step * 0.02, 0) * my.skill1; // compute speed
		player_dist.x = my.skill1 * time_step; // time correct the speed
		player_dist.y = 0;

		vec_set (temp.x, my.x); // trace 10,000 quants below the player
		temp.z -= 10000;
		
		player_dist.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - my.min_z - 10;
		
		temp_ang.tilt = 0; // adjust the tilt and roll angles of the car according to the slopes
		temp_ang.roll = 0;
		temp_ang.pan = -my.pan;
		vec_rotate(normal, temp_ang);
		temp_ang.tilt = -asin(normal.x);
		temp_ang.roll = -asin(normal.y);
		my.tilt += 0.1 * ang(temp_ang.tilt - my.tilt); // play with 0.1
		my.roll += 0.1 * ang(temp_ang.roll - my.roll); // play with 0.1
		
		my.skill2 = c_move (my, player_dist.x, nullvector, IGNORE_PASSABLE | GLIDE | IGNORE_PUSH); // now move the player

		player_ang.pan = rotation_speed * (key_cul - key_cur - joy_force.x) * my.skill2; // allow rotations only if the car is moving
		my.skill3 = time_step * player_ang.pan + maxv (1 - time_step * 0.7, 0) * my.skill3; // rotation speed
		my.pan += my.skill3 * time_step; // time corrected rotation
	
		my.skill4 = 100 + abs(5 * my.skill1); // play an engine sound at the minimum speed too (given by 100)
		snd_tune (players_engine, 50, my.skill4, 0); // tune the engine sound

		// place the player in the car at x = 15, y = -10, z = 15 in relation to the car origin
		vec_set (player.x, vector(15, -10, 15)); 
		vec_rotate (player.x, my.pan);
		vec_add (player.x, my.x);

		player.pan = my.pan;
		player.tilt = my.tilt;
		player.roll = my.roll;
		
		// place the camera at x = -13, y = -10, z = 15 in relation to the car model
		vec_set (camera.x, vector(-13, -10, 15));
		vec_rotate (camera.x, pcar.pan);
		vec_add (camera.x, pcar.x);

		camera.pan += 0.2 * ang (player.pan - camera.pan);
		camera.tilt = player.tilt;
		camera.roll = player.roll / 4; // don't allow camera.roll to change that much

		if (my.skill2 < 0.3) // the car has stopped for good? (or is almost stopped)
		{
			if (key_space) // if the player has pressed the "space" key
			{
				while (key_space) {wait (1);} // we wait until the "space" key is released
				player_in_car = 0; // the player isn't driving anymore
				player = NULL; // remove the "player" pointer -> it will be assigned to the newly created player
				// create a position that's 10 quants ahead on the x axis, 40 quants sideways 
				// and 55 quants upper in relation to the car model
				vec_set (player_pos.x, vector(10, -40, 55)); 
				vec_rotate (player_pos.x, pcar.pan);
				vec_add (player_pos.x, pcar.x);
				you = ent_create("guard.mdl", player_pos, players_action); // create a new player model at that position
				you.skill99 = 1; // tell the player to inherit car's pan angle
			}
		}
		wait(1);
	}
	camera.tilt = 35; // the player is dead here
	camera.roll = 40; // so let's set some weird angles for the camera
}

action health_pack()
{
	var scale_factor = 0.01;
	set (my, PASSABLE);
	while (!player) {wait (1);} // wait until the player is loaded
	while (vec_dist (player.x, my.x) > 100) // wait until the player comes close the the health pack
	{
		my.scale_x += scale_factor * time_step;
		if (my.scale_x > 1.2) // decrease the scale
		{
			scale_factor = -0.01;
		}
		if (my.scale_x < 0.8) // and then increase it, etc
		{
			scale_factor = 0.01;
		}		
		my.scale_y = my.scale_x;
		my.scale_z = my.scale_x;
		my.pan += 3 * time_step;
		wait (1);
	}
	players_health += 50; // add 50 points to player's health
	players_health = minv(100, players_health); // limit player's health value to 100 points
	snd_play (health_wav, 100, 0);
	set (my, INVISIBLE);
	wait (-2);
	ent_remove(my);
}




Ja, lach du nur du haariges Pelzvieh!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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