Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Joey, flink, AndrewAMD), 1,226 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Spread bullets further apart. #235772
11/10/08 01:41
11/10/08 01:41
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
Hi, i have a gun that is shooting bullets like a machine gun. But it is WAY to rapid. I tried putting waits in many places, heres is the orig code.
Code:
function move_bullet()
{
set(my,FLAG2);
	while(my)
	{
		c_move(my,vector(10,0,0),nullvector,IGNORE_PASSABLE | IGNORE_FLAG2);
		wait(1);
	}
}

function standard_shoot()
{
	vec_for_vertex(bullet_pos1,ship,1231);
	bullet1 = ent_create("bullet.mdl",vector(bullet_pos1.x,bullet_pos1.y,bullet_pos1.z),move_bullet);


	bullet1.pan = ship.pan;

}
action player_action()
{
while(1)
{
if(key_space){standard_shoot();}
wait(1);
}
}


Right know it shoot like 300 bullets right when you hit the space bar but i would like them to be spaced out like 1 or 2 seconds apart, could any1 help me out? Thanks.

Re: Spread bullets further apart. [Re: upsidedownman] #235773
11/10/08 01:51
11/10/08 01:51
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Code:
var reload;
function standard_shoot()
{
    if(reload == 0)
    {
	vec_for_vertex(bullet_pos1,ship,1231);
	bullet1 = ent_create("bullet.mdl",vector(bullet_pos1.x,bullet_pos1.y,bullet_pos1.z),move_bullet);


	bullet1.pan = ship.pan;
        reload = 1;
    }
    wait(-1);
    reload = 0;

}





something like that?


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: Spread bullets further apart. [Re: heinekenbottle] #235774
11/10/08 02:07
11/10/08 02:07
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
Tried that already.But thanks.

Re: Spread bullets further apart. [Re: upsidedownman] #235777
11/10/08 02:28
11/10/08 02:28
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
perhaps we need to limit the number of times the function is called rather than limiting the number of times the bullet is created:
Code:
action player_action()
{
  var reload = 0;
  while(1)
  {
    if(key_space)
    {
      standard_shoot();
      reload = 10;
    }
    reload -= (reload > 0);
    wait(1);
}


Last edited by heinekenbottle; 11/10/08 02:29.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: Spread bullets further apart. [Re: heinekenbottle] #236180
11/12/08 16:11
11/12/08 16:11
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Replace the "wait(1)" in the player loop with "wait(-1)".
You should now have a break of one second after every bullet.
If this doesn't work, try to put a "wait(-1)" at the end of the "standard_shoot" function.

Oh, you've already tried that, I see. Sorry. blush


Last edited by the_clown; 11/12/08 16:13.

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