void main()
{ /*
* Caskey, Damon V.
* 2022-01-26
*
* Example function to enumerate the entity
* collection and take action on each
* if they meet specfifc conditions.
*/
void self = getlocalvar("self");
float time = openborvariant("elapsed_time")/10;
if(getglobalvar("vortexRate"+self) == NULL()){setglobalvar("vortexRate"+self, time);}
if(time > getglobalvar("vortexRate"+self)){
void entity_cursor = NULL();
int entity_count = openborvariant("count_entities");
int entity_index = 0;
int exists = 0;
/*
* This loop runs on every entity in play.
* It works by iterating from 0 to <entity count>.
* At each iteration it gets an entity using the
* index cursor, verifies its existence, and then
* runs some custom checks.
*
* If any check fails, the loop skips and
* moves on to the next iteration. If all the
* checks pass, it runs whatever action code
* you place inside of it. The best practice
* is to put your action code into another
* function and let the loop execute that.
*/
for(entity_index = 0; entity_index < entity_count; entity_index++){
/*
* Get target entity for this loop increment,
* verify it is a valid pointer, and make
* sure it exists in play. The last check
* appears redundant, but it's possible for
* an entity to be removed while its pointer
* is still valid.
*/
entity_cursor = getentity(entity_index);
if(!entity_cursor){
continue;
}
exists = getentityproperty(entity_cursor, "exists");
if(!exists){
continue;
}
/*
* Check for specific conditions to your module here.
* This example skips non-enemy types.
*/
if( getentityproperty(entity_cursor, "type") != openborconstant("TYPE_ENEMY")&&
getentityproperty(entity_cursor, "type") != openborconstant("TYPE_OBSTACLE")){
continue;
}
/* Take your actions here. Sucking in, doing damage, etc. */
int lifespan = getentityproperty(self, "lifespancountdown");
//THIS IS THE ANIMATION THAT WILL ACTIVATE THE SWIRL EFFECT, YOU CAN PUT ANY OTHER
if(lifespan > 5){
void tAni = getentityproperty(entity_cursor, "animationID");
float Px = getentityproperty(self, "x");
float Pz = getentityproperty(self, "z");
float Tx = getentityproperty(entity_cursor, "x");
float Tz = getentityproperty(entity_cursor, "z");
float xDir = getentityproperty(entity_cursor, "xdir");
float zDir = getentityproperty(entity_cursor, "zdir");
float xVel;
float zVel;
float range = 5;
if(Px > Tx){xVel = 0.04;}
if(Px < Tx){xVel = -0.04;}
if(Pz > Tz){zVel = 0.02;}
if(Pz < Tz){zVel = -0.02;}
if(tAni != openborconstant("ANI_IDLE") && !getentityproperty(entity_cursor, "dead")){
executeanimation(entity_cursor, openborconstant("ANI_IDLE"), 1);
}
changeentityproperty(entity_cursor, "velocity", xDir+xVel, zDir+zVel);
if(Px - Tx < range && Px - Tx > -range){changeentityproperty(entity_cursor, "velocity", 0, NULL());}
if(Pz - Tz < range && Pz - Tz > -range){changeentityproperty(entity_cursor, "velocity", NULL(), 0);}
}
else
{
int dead = getentityproperty(entity_cursor, "dead");
if(!dead){
changeentityproperty(entity_cursor, "velocity", 0, 0);
setidle(entity_cursor, openborconstant("ANI_IDLE"));
}
}
}
setglobalvar("vortexRate"+self, time);
}
}