Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, 7th_zorro, TedMar, Ayumi), 800 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
144655 entities instead of 5 entities... #185563
02/25/08 15:02
02/25/08 15:02
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
hi, I use A6 extra and scripted following code:
Code:
action enemy_creator
{
my.passable = on;
my.invisible = on;
while(1)
{
if(enemy_count < max_enemy_count) //max_enemy_count = 5
{
ent_create("speeder.mdl",my.x,enemy_flight);
enemy_count += 1;
}
wait(5);
}
}
action enemy_flight
{
counter += 1;
}



The creator should create 5 entities. But when I run it, it creates 144655 entities (I see it at the var counter and at the many entities) and enemy_count is 5! What I make wrong?

Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185564
02/25/08 15:59
02/25/08 15:59
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
I dont know exactly why it doesnt stop when the counter reachs 5, but to solve the problem, try to leave the while after your counter reaches 5.

if(entity_counter >= 5)
{
break;
}

put this within your while loop should work for you.
Hope this helps.

cheers

Last edited by zwecklos; 02/25/08 16:00.
Re: 144655 entities instead of 5 entities... [Re: zwecklos] #185565
02/25/08 16:15
02/25/08 16:15
Joined: Feb 2006
Posts: 76
Mi
H
Havoc22 Offline
Junior Member
Havoc22  Offline
Junior Member
H

Joined: Feb 2006
Posts: 76
Mi
just to test it, remove max_enemy_count and replace it with 5 and see if that works. Maybe max_enemy_count is being changed somewhere, or not defined as 5. If you replace it with 5 and it still does it, that's weird.

Re: 144655 entities instead of 5 entities... [Re: Havoc22] #185566
02/25/08 16:40
02/25/08 16:40
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
@zwecklos: This must while endless because if the enemy_count lose a worth, a new enemy should be created.

@Havoc22: It run still not right.

The first enemy are created right, but when all have an ent_move with moving ahead of themselves, the 144654 other enemys are at one position with very very little distances and flying very low, because they collide with the others.

Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185567
02/25/08 17:47
02/25/08 17:47
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
the problem could be because you created them at the my.x position of the first box, try using a random value, like:

Code:

action enemy_creator
{
var pos_;
////////set the maximum distance from the spawn box
var max_x_ = 300;
var max_y_ = 300;
var max_z_ = 0;
my.passable = on;
my.invisible = on;
while(1)
{
while(enemy_count < 5) //max_enemy_count = 5
{
vec_set (pos_.x, my.x);
pos_.x += random (max_x_) - random (max_x_ *1.5);
pos_.y += random (max_y_) - random (max_y_ *1.5);
pos_.z += random (max_z_) - random (max_z_ *1.5);
ent_create("speeder.mdl",pos_,enemy_flight);
enemy_count += 1;
}
wait(5);
}
}



i also changed the "if" to a "while" so that it should stop, although if it doesn't it'll create millions more, also, have you tried making max_enemy_count a local var instead?

Last edited by mpdeveloper_B; 02/25/08 17:50.

- aka Manslayer101
Re: 144655 entities instead of 5 entities... [Re: mpdeveloper_B] #185568
02/25/08 19:28
02/25/08 19:28
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
It shouldn't stop, that always 5 enemys are here.
Yes, max_enemy_count is a local var.
Your random script functions, but now I have a very big swarm with 144566 enemys...

The script should always run, because I want endless 5 enemys. Enemy_count controls the count of the enemies and max_enemy_count controls the maximal count of enemies.

Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185569
02/25/08 19:33
02/25/08 19:33
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Quote:


Yes, max_enemy_count is a local var.





And where did you define it INSIDE the action? I cannot see it (must be blind ).

Code:

action enemy_creator
{
my.passable = on;
my.invisible = on;
while(1)
{
if(enemy_count < max_enemy_count) //max_enemy_count = 5
{
ent_create("speeder.mdl",my.x,enemy_flight);
enemy_count += 1;
}
wait(5);
}
}



Re: 144655 entities instead of 5 entities... [Re: Xarthor] #185570
02/25/08 19:41
02/25/08 19:41
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
Er, local is the definition outside of a function?

I meant max_entity_count is defined at start, not in function.

EDIT: Now are the models right, I don't know why Oo
But the var is 144655 and lose a worth if one enemy killed.

EDIT˛: How can I set, while the creating, the enemies the pointers enemy1,...enemy5? And it should set right, so that no pointer is double, thus I mean when enemy2 is killed, the creator should'nt create an enemy5, but enemy2.

Last edited by JokeSpeaker; 02/25/08 20:10.
Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185571
02/25/08 21:12
02/25/08 21:12
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
nope local means inside a function/action
global means outside of it.

How did you define that var enemy_count?
This way:
var enemy_count;

or:
var enemy_count = 0;

Re: 144655 entities instead of 5 entities... [Re: Xarthor] #185572
02/26/08 03:40
02/26/08 03:40
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Dont know, its late, but maybe this is what you are looking for

Code:

recheck_if_I_have_to_create:
while(1)
{

if(enemy_count < max_enemy_count) //No enemies created yet or there are dead ones
{
ent_create("speeder.mdl",my.x,enemy_flight);
enemy_count += 1;
}
else//there are 5 enemies created atm
{
break;
}

wait(5);
}
goto recheck_if_I_have_to_create;




Hope this helps...

For your 2. question, use my.skill.
For example:
Code:

define ent_id;

action
{
id_counter += 1;
my.ent_id = id_counter;
}



Last edited by zwecklos; 02/26/08 03:47.
Page 1 of 4 1 2 3 4

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