Code:
//Theese functions put the enemies:
var Max_hordes=2;		//maximo numero de hordas
function reset_values() // reinicia los valores
{
	var i;
	vec_set(GMSA,vector(0,0,0));	vec_set(GMSB,vector(0,0,0));	vec_set(GMSC,vector(0,0,0));
	vec_set(GMSD,vector(0,0,0));	vec_set(GMSE,vector(0,0,0));
	for(i = 0; i < 20; i += 1)
	{
		GM_S_NE[i] = 0;
	}
}

function initialize_values(var h) // posicion de aparicion de los monstruos y numero maximo en total y de cada uno de ellos
{
	switch(h)
	{
		case 0:
			vec_add(GMSA,vector(0,0,0));				vec_add(GMSB,vector(1040,2720,180));			vec_add(GMSC,vector(780,2040,180));
			vec_add(GMSD,vector(1660,2840,180));	vec_add(GMSE,vector(1363,1567,180));
			GM_S_ME[0] = 5;	GM_S_ME[1] = 3;	GM_S_ME[2] = 4;	GM_S_ME[3] = 0;	GM_S_ME[4] = 0;
			GM_S_ME[5] = 0;	GM_S_ME[6] = 0;	GM_S_ME[7] = 0;	GM_S_ME[8] = 0;	GM_S_ME[9] = 0;
			break;
	}
}

function GM_S_CE(var cual_mostruo)
{
	var create_position;
	vec_set(GMSA, vector(1650,2150,0));
	vec_add(GMSA, vector(250 - random(500),250 - random(500),0));
	create_position = 0;
	create_position = integer(random(4));
	create_position %= 4;
	wait(-1);

	switch(cual_mostruo)
	{
		case 0:		ent_create("egg.mdl", GMSA, zombie);	break;
		case 1:		ent_create("egg.mdl", GMSA, zombie);	break;
		case 2:		ent_create("egg.mdl", GMSA, zombie);	break;
		case 3:		ent_create("chopper.mdl", GMSA, NULL);	break;
	}
	++GM_S_NE[cual_mostruo];
}

function Game_Mode_S(var Nhorde, var end_horde)
{
	var i, number_monsters, create_position, horde = 0;
	while(1)
	{
		wait(1);
		if(horde < Nhorde)//nNhorde
		{
			reset_values();	number_monsters = 0;
			initialize_values(horde);
			for(i = 0; i < 20; i ++){end_horde += GM_S_ME[i];}
			while(!player){wait(1);}
			while(number_monsters < end_horde)//End horde
			{
				for(i = 0; i < 20; i ++)
				{
					if(GM_S_NE[i] < GM_S_ME[i])
					{
						GM_S_CE(i);
						++number_monsters;
						wait(-2);
					}
				}
				wait(1);
			}
			++horde;
			//break_off();
			switch(horde)
			{
				case 0:
					//activa un evento X de acuerdo a la horda actual
					//muestra un mensaje
				break;
			}
			//crea municiones
			//crea curas
			wait(-15);
		}
		//muestra mensaje de victoria
		//cierra el nivel
		//muestra tabla de resultados
	}
}
// and this is the monster code:

function CCD()
{
	if(my.skill88 == 0)
	{
		my.skill88 = 1;
		wait(-5);
		my.skill92 = integer(random(2)) + 1;//camino o me quedo quieto?
		my.skill88 = 0;
	}
}

action zombie()
{
	VECTOR* SPOTTEDP,C_speed, temp, temp2, IFOM, GGC; //IFOM= in front of my, MDTTF = my distance to the floor, GG = gravedad
	ANGLE temp_ang;
	my.skill89 = 35;
	my.health = 100;
	my.skill98 = 1000;
	my.skill97 = 250;
	my.skill94 = 0;
	
	my._id = _id_enemy;
	
	vec_set(temp2.x, nullvector);
	vec_set(temp.x, nullvector);
	vec_set(C_speed.x, nullvector);
	vec_set(IFOM.x, nullvector);
	vec_set(GGC.x, nullvector);
	my.skill92 = integer(random(2)) + 1;//camino o me quedo quieto?
	
	while (1)
	{
		while(my.health > 0)//no detecto nada
		{
			// si me hiero demasiado puedo morir
			if(my.health <= 0)
			{
				break;
			}
			//soy atraido por la gravedad, y me inclino de acuerdo al suelo
			temp2.z -= 100000;
			my.skill90 = c_trace(my.x, temp2.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE | IGNORE_PASSENTS);
			c_move(my, nullvector, GGC.x, IGNORE_PASSABLE | GLIDE);
			if(my.skill90 < (my.skill89 -3))
			{
				GGC.z += 0.05 * time_step;
			}
			else
			{
				if(my.skill90 > (my.skill89 +3))
				{
					GGC.z -= 3 * time_step;
				}
				else
				{
					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
				}
			} 
			
			//camino por ahi
			if(my.skill92 == 1)
			{
				vec_set(IFOM.x, vector(200,0,0));
				vec_add(IFOM.x, my.x);
				if(my.skill93 == 0)
				{
					vec_set(IFOM.x, vector(300,0,0));
					vec_rotate(IFOM.x, my.pan);
					vec_add(IFOM.x, my.x);
					
					my.skill91 = c_trace(my.x, IFOM.x, IGNORE_ME | IGNORE_PASSABLE);
					C_speed.x = 18 * time_step;
			  		my.skill22 += 18 * time_step; // 5 gives the "walk" animation speed
					c_move(my, C_speed.x, GGC.x, IGNORE_PASSABLE | GLIDE);
					ent_animate(my, "run", my.skill22, ANM_CYCLE);
					if(my.skill91 > 0)
					{
						my.skill93 = (random(360) * -1) + 180;
						while((my.skill93 < 70) && (my.skill93 > -70) && (my.skill93 < -140) && (my.skill93 > 140))
						{
							my.skill93 = (random(360) * -1) + 180;
							if(my.health <= 0)
							{
								break;
							}
							wait(1);
						}
						my.skill91 = 0;
					}
				}
				else
				{
		  			C_speed.x = 12 * time_step;
			  		my.skill22 += 17 * time_step; // 5 gives the "walk" animation speed
					c_move(my, C_speed.x, GGC.x, IGNORE_PASSABLE | GLIDE);
					ent_animate(my, "run", my.skill22, ANM_CYCLE);
					if((my.skill93 - ang(my.pan)) > 5)
					{
						my.pan += 7 * time_step;
					}
					else
					{
						if((my.skill93 - ang(my.pan)) < -5)
						{
							my.pan -= 7 * time_step;
						}
						else
						{
							my.skill92 = integer(random(2)) + 1;
							my.skill93 = 0;
						}
					}
				}
			}
			// me quedo quieto
			if(my.skill92 == 2)
			{
				c_move(my, nullvector, GGC.x, IGNORE_PASSABLE | GLIDE);
		  		my.skill22 += 2 * time_step; // 2 gives the "idle" animation speed
				ent_animate(my, "stand", my.skill22, ANM_CYCLE);
				if(my.skill22 > 150)
				{
					my.skill22 -= 150;
					CCD();
				}
			}
			if(my.skill92 == 3)
			{
				my.skill92 = 2;
			}
			//busco al jugador
				//¿lo oi?
					//enable_scan
				//¿lo veo?
			if (c_scan(my.x, my.pan, vector(120, 90, my.skill98), IGNORE_ME | IGNORE_PASSABLE | SCAN_ENTS) > 0) // detected the player?
			{
				if(you._id == _id_player)
				{
					if ((c_trace(my.x, you.x, IGNORE_ME | IGNORE_PASSABLE) > 0) && (you._id == _id_player))// and the spider can actually see the player?		
						my.skill94 = 1;
						break; // then get out of this loop!
				}	
			}
				//¿lo huelo?
			if (c_scan(my.x, my.pan, vector(120, 90, my.skill98), IGNORE_ME) > 0) // detected the player?
			{
				if(you._id == _id_player)
				{
					my.skill94 = 1;
					break; // then get out of this loop!
				}
			}
				//¿lo siento?
					//event_touch
			//
			wait (1);
		}
		while((my.health > 0) && (my.skill94 == 1))//detecto algo
		{
			c_scan(my.x, my.pan, vector(120, 90, (my.skill98 + 1000)), IGNORE_ME);// ver
			if(my.health <= 0)
			{
				break;
			}
			while(you != NULL)
			{
				if(my.health <= 0)
				{
					break;
				}
				if(you._id == _id_player)
				{
					c_scan(my.x, my.pan, vector(120, 90, (my.skill98 + 1000)), IGNORE_ME);// ver
					
					if(vec_dist(me.x, you.x) < my.skill98)
					{
						if(vec_dist(me.x, you.x) > my.skill97)
						{
							vec_set(temp, you.x);
							vec_sub(temp, my.x);
							vec_to_angle(my.pan, temp);
							
					  		C_speed.x = 24 * time_step;
					  		my.skill22 += 24 * time_step; // 5 gives the "walk" animation speed
							c_move(my, C_speed.x, GGC.x, IGNORE_PASSABLE | GLIDE);
							ent_animate(my, "run", my.skill22, ANM_CYCLE);
						}
						else
						{
							my.skill21 += 15 * time_step; // 5 gives the "walk" animation speed
							ent_animate(my, "attack", my.skill21, ANM_CYCLE);
						}
					}	
					else
					{
						my.skill92 = integer(random(2)) + 1;
						my.skill94 = 0;
						break;
					}
				}
				else
				{
					my.skill92 = integer(random(2)) + 1;
					my.skill94 = 0;
					break;
				}
				wait(1);
			}	
			wait(1);
		}
		ent_animate(me,NULL,0,0);	
		my.skill21 = 0;
		while((my.health <= 0))//he muerto
		{
			my.skill21 += 1 * time_step; // 5 gives the "walk" animation speed
			ent_animate(my, "death", my.skill21, NULL);
			wait (1);
			wait(-3);
			set(my,PASSABLE);
			set(my,INVISIBLE);
		}
		wait (1);
	}
}



Last edited by wdakfenixx; 02/14/12 03:18.

CAUTION :The content above could blow your mind