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
0 registered members (), 1,454 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
My enemy's shooting code don't work #332390
07/09/10 13:03
07/09/10 13:03
Joined: Oct 2009
Posts: 90
WickWoody Offline OP
Junior Member
WickWoody  Offline OP
Junior Member

Joined: Oct 2009
Posts: 90
Hi,
I'm trying to write a enemy code but I have a problem. Enemy must nearing to player and shoot. But enemy start to shooting, FPS decrease incredibly. I think reason shooting function running wrong. Thanks for your help. Enemy code below. Thanks again.

Information:
Shooting function: d_ates_et()

Code:
function mermi_sil2()
{
	wait (1);
	ent_create (patlama_pcx, my.x, patlama);
	set(my,PASSABLE);
	set(my,INVISIBLE);
	if(you == player)
	{
		player.o_saglik -= 5;
	}
	wait(-2);
	ent_remove (my);
}

function mermi_hareket2()
{
	VECTOR mermi_hiz2;
	my.emask |= ENABLE_IMPACT;
	my.emask |= ENABLE_ENTITY;
	my.emask |= ENABLE_BLOCK;
	my.event = mermi_sil2;
	vec_set(temp_d, player.x);
	vec_sub(temp_d, my.x);
	vec_to_angle(my.pan, temp_d);
	while(my != NULL)
	{
		c_move(me, vector(200 * time_step, 0, 0), nullvector, GLIDE);
		wait(1);
	}
}

function d_ates_et()
{
	proc_kill(4);
	while(my.d_saglik > 0)
	{
		vec_for_vertex(temp_d, my, 240);
		ent_create(mermi_mdl, temp_d, mermi_hareket2);
		snd_play(mermi_wav2, 100, 0);
		wait(-0.14);
	}
}

function dusman_event()
{
}

action dusman_action()
{
	
	my.emask |= EVENT_IMPACT;
	my.event = dusman_event;
	my.d_saglik = 25;
	
	vec_set(temp_d, player.x);
	vec_sub(temp_d, my.x);
	vec_to_angle(my.pan, temp_d);
	while(my.d_saglik > 0)
	{
		d_uzaklik = c_trace(my.x, player.x, IGNORE_ME | USE_BOX);
		if(d_uzaklik > 200)
		{
			ent_animate(me, "run", my.skill48, ANM_CYCLE);
			my.skill48 += 5 * time_step;
			c_move(me, vector(10*time_step, 0,0), nullvector, GLIDE);
		} else {
			d_ates_et();
			ent_animate(me, "StandShoot", my.skill48, ANM_CYCLE);
			my.skill48 += 5 * time_step;
			wait(-0.14);
		}
		wait(1);
	}
	
	//dusman olurse
	my.d_saglik = 0;
	my.skill48 = 0;
	snd_play(birini_indirdim, 100, 0);	
	set(my, PASSABLE);
	mermi += 30;
	while(my.skill48 < 90)
	{
		ent_animate(me, "DeathHeadshot", my.skill48, ANM_CYCLE);
		my.skill48 += 5 * time_step;
		wait(1);
	}
	
	ent_remove(me);
}



Last edited by WickWoody; 07/09/10 13:04.
Re: My enemy's shooting code don't work [Re: WickWoody] #332424
07/09/10 16:11
07/09/10 16:11
Joined: Oct 2009
Posts: 90
WickWoody Offline OP
Junior Member
WickWoody  Offline OP
Junior Member

Joined: Oct 2009
Posts: 90
Okay, I solved. I have used total_frames global variable. The code below:

Code:
function d_ates_et()
{
	proc_kill(4);
	while(my.d_saglik > 0)
	{
			if ((total_frames % 80) == 1) // fire a bullet each second
			{
				vec_for_vertex(temp_d, my, 240);
				ent_create(mermi_mdl, temp_d, mermi_hareket2);
				snd_play(mermi_wav2, 100, 0);
			}
		wait(1);
	}
}




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