|
144655 entities instead of 5 entities...
#185563
02/25/08 15:02
02/25/08 15:02
|
Joined: Mar 2007
Posts: 151
JokeSpeaker
OP
Member
|
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
Member
|
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: JokeSpeaker]
#185567
02/25/08 17:47
02/25/08 17:47
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
Expert
|
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: JokeSpeaker]
#185569
02/25/08 19:33
02/25/08 19:33
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
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
OP
Member
|
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: Xarthor]
#185572
02/26/08 03:40
02/26/08 03:40
|
Joined: Sep 2005
Posts: 274 Switzerland - Zurich
zwecklos
Member
|
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.
|
|
|
|