count Nº of entities on screen

jonsilva

New member
Hello

i remember one time i was reading some posts on the forum...
and i think i saw a script that could count the nº of enemies/npcs/entities on screen and would keep spawning those entities if they re number was less than 3/4 or any number...

but ive been searching most posts and i couldnt find it !!!
does any one knows were this script might be ???
 
thanks bloodbane

i should be able to make the script with hese commands
do you know if i can add something like...
void name = getentityproperty(self,"name");

to the...
openborvariant("count_enemies")
to make it count only the enemies with this name?
 
It's Bloodbane's script 'lonely'

http://www.chronocrash.com/forum/index.php?topic=719.msg5894#msg5894

(Maybe this should be moved to scripting instead of tutorials.)

edit:
Code:
@script
    void self = getlocalvar("self");
    int Enemy = openborvariant("count_enemies");

    if(Enemy == 1){
      changeentityproperty(self, "velocity", 0, 0, 0); // Should be omitted if declared in IDLE
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
 
ive made this one...
this way seems to be working for me

void spawncount(void Name, float dx, float dy, float dz, float nr)
{ // Spawn and bind other entity
    void self = getlocalvar("self");
    int ene = openborvariant("count_enemies");
    void Spawn;
    if(ene < nr){
    Spawn = spawn01(Name, dx, dy, 0);
    }
}

i dont think i will need the entity "name"
i would need to change the count in the script for a diferent entity
"count_enemies"
"count_players"
"count_npcs

so it could work with barrels / bullets / etc...
 
Try this, it uses a Type to check

Code:
void spawncounttype(void Name, void vType, float dx, float dy, float dz, float nr)
{ // Spawn and bind other entity
     void self = getlocalvar("self");
     int ene = openborvariant(vType);
     void Spawn;
     if(ene < nr){
     Spawn = spawn01(Name, dx, dy, 0);
     }
}

@cmd spawncounttype "soldier" "count_enemies" 0 0 0 1
 
jonsilva said:
do you know if i can add something like...
void name = getentityproperty(self,"name");

to the...
openborvariant("count_enemies")
to make it count only the enemies with this name?

That would require extra work, you need to sort all active entities, find which ones have specified name and count them
 
That would require extra work, you need to sort all active entities, find which ones have specified name and count them

i tend forget things really quickly...
but... yesterday while i was trying to make the count work with the "name" i think i was trying to filter them by name...
like
void bio = getentityproperty(self,"name");
if (bio==Name && ene < nr)
making a script that counts all entities on screen doesnt seem right
there could be explosions/bullets and flashes happening all at the same time...
but the way Ilusionista mention separates them by type that way it should only count those...
but i dont know how to add the "name" to the if
 
Back
Top Bottom