|
Re: 144655 entities instead of 5 entities...
[Re: zwecklos]
#185573
02/26/08 07:40
02/26/08 07:40
|
Joined: Mar 2007
Posts: 151
JokeSpeaker
OP
Member
|
OP
Member
Joined: Mar 2007
Posts: 151
|
Quote:
For your 2. question, use my.skill. For example: Code:
define ent_id;
action { id_counter += 1; my.ent_id = id_counter; }
thx, but which code can now looking to the for example ent_id == 2? Should I write all enemies a pointer called enemy and then for example: if(enemy.ent_id == 2) {ent_remove(enemy);} This code is only an example. That I need this way, because the friends should looking at the enemies and per random through the ids. I hope, I write it understandable.
@Xarthor: with = 0;
|
|
|
Re: 144655 entities instead of 5 entities...
[Re: JokeSpeaker]
#185574
02/26/08 08:50
02/26/08 08:50
|
Joined: Aug 2005
Posts: 312 Sweden
tindust
Senior Member
|
Senior Member
Joined: Aug 2005
Posts: 312
Sweden
|
Suggested code based on your original script: Code:
// Global definitions: define enemy_number, SKILL51; var max_enemy_count = 5; //max_enemy_count = 5 or whatever, can be changed in script var enemy_count = 0; // Actions: action enemy_creator { my.passable = on; my.invisible = on; while(1) { if(enemy_count < max_enemy_count) { //get a randomized position here before creation if you want ent_create("speeder.mdl",my.x,enemy_flight); } wait(5); } } action enemy_flight { enemy_count += 1; my.enemy_number = enemy_count; while(1) { // set this entities enemy_number to 0 whenever you want it to die if(my.enemy_number == 0) { ent_remove(me); enemy_count -= 1; // break; // automatic when enemy entity is removed } wait(1); } }
cheers
|
|
|
Re: 144655 entities instead of 5 entities...
[Re: tindust]
#185575
02/26/08 17:07
02/26/08 17:07
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
bad code tindust. At least that enemy_flight action. Better imho: Code:
action enemy_flight { enemy_count += 1; my.enemy_number = enemy_count; while(my.enemy_number) { // set this entities enemy_number to 0 whenever you want it to die // do whatever you want wait(1); } wait(1); ent_remove(me); //remove it }
|
|
|
Re: 144655 entities instead of 5 entities...
[Re: tindust]
#185578
02/27/08 03:38
02/27/08 03:38
|
Joined: Sep 2005
Posts: 274 Switzerland - Zurich
zwecklos
Member
|
Member
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
|
Hi there, Again, Its late, and Im not sure if this gonna help you but is it a collision that causes the enemies death? If yes, you could use an event to use the "you" pointer. In the momemt, where a enemy dies trough a collision, the "you" pointer is set to that enemies id. That means you can directly access the enemy's attribut with an event. Code:
define ent_id, skill54; var id_counter;
function check_death_id() { if(event_type == EVENT_IMPACT) { if(you.ent_id == 1) && (you.health <= 0)//enemy dies trough a collision { id_counter = 0; enemy_count -= 1; ptr_remove(you); } if(you.ent_id == 2) && (you.health <= 0) { id_counter = 1; enemy_count -= 1; ptr_remove(you); } if(you.ent_id == 3) && (you.health <= 0) { id_counter = 2; enemy_count -= 1; ptr_remove(you); } if(you.ent_id == 4) && (you.health <= 0) { id_counter = 3; enemy_count -= 1; ptr_remove(you); } if(you.ent_id == 5) && (you.health <= 0) { id_counter = 4; enemy_count -= 1; ptr_remove(you); } } }
action enemy_creator() { ... check_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 and everyone is alive { break; }
wait(5); } goto check_if_I_have_to_create;
}
action enemy_flight() { id_counter += 1; my.ent_id = id_counter;
my.ENABLE_IMPACT = ON; // sensible for push collision my.emask |= ENABLE_IMPACT; my.event = check_death_id; ...
}
This code is not tested, maybe you can use the logical process behind it... Important is, that you make sure that the "you" pointer is the hitten entity. You can control this by using the impact-event(my.ENABLE_IMPACT = ON;) in the right action (for example on an action for a bullet or a player that hit the enemy). cheers zwecklos
Last edited by zwecklos; 02/27/08 03:47.
|
|
|
Re: 144655 entities instead of 5 entities...
[Re: zwecklos]
#185579
02/27/08 07:51
02/27/08 07:51
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Just theory, but similar works: entity linked lists Code:
define nunsI, 0; define ratsI, 1;
function eCreate(_str, _index, _count) { if (_str == 0 || _count < 1 || _index < 0) { // ops not optimized in C-Script return(0); } // assumes ent_create does not fail? while (elCount(_index) < _count) { if (elAdd(_index, ent_create(_str, pos, fn)) == 0) { break; } } return(elCount(_index)); } // ... // 5 nuns eCreate("nun.mdl", nunsI, 5); // 2 rats eCreate("rat.mdl", ratsI, 2); // ... entity* e0; // can use directly without pointer also e0 = NULL; // give me nun 3 e0 = eGet(nunsI, 3-1); // give me 1st rat e0 = eGet(ratsI, 1-1);
Assign values to locals. http://testdummy93.tripod.comErrors here?, Makes sense?, 'get it', use it or don't. I don't have the time.
|
|
|
Re: 144655 entities instead of 5 entities...
[Re: testDummy]
#185580
02/27/08 11:47
02/27/08 11:47
|
Joined: Mar 2007
Posts: 151
JokeSpeaker
OP
Member
|
OP
Member
Joined: Mar 2007
Posts: 151
|
I see, I explained it bad, sry.
First I explain it in german then in english. Maybe someone can translate it better as I.
German: Ich will eine Raumschlacht erstellen, in der der Player (Raumschiff) mit 4 computergesteuerte freundliche Raumschiffe gegen 5 computergesteuerte Feinde kämpft. Wenn ein Feind zerstört ist, wird sofort ein neuer erstellt. Die Feinde können nur durch Schüsse vernichtet werden. Sie haben ent_move, allerdings gehen sie nicht durch Kollision kaputt. Und die Freunde suchen sich per random() zufällig einen Feind aus, Fliegen nur in dessen Richtung und schießen. DAZU brauche ich Pointer. Das erstellen klappt gut, allerdings brauchen die Feinde je auch einen Pointer.
English: I want create a space-battle, in that the player fly a spaceship and he has 4 no-player-controlled (NPC) friendly spaceships. And they must fight with 5 enemies. If an enemy is destroyed, a new will be created. The enemies can be only destroyed by shots. They have ent_move but they don't get destroyed if they collide. And the friends search per random() an enemy and fly only to him and shoot. FOR IT I need pointers. The creating runs good, but the enemies needs all a pointer.
Short: I need only the script, in that the pointers will be set. All other I have.
Last edited by JokeSpeaker; 02/27/08 11:50.
|
|
|
|