void main()
{ /*
* Caskey, Damon V.
* 2022-01-26
*
* Example function to enumerate the entity
* collection and take action on each
* if they meet specific conditions.
*/
void self = getlocalvar("self");
float time = openborvariant("elapsed_time")/10;
if(getglobalvar("alarmRate"+self) == NULL()){setglobalvar("alarmRate"+self, time);}
if(time > getglobalvar("alarmRate"+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")){
continue;
}
/* Take your actions here. Slowdown, disable attacks, etc. */
int lifespan = getentityproperty(self, "lifespancountdown");
//THIS IS THE ANIMATION THAT WILL ACTIVATE THE SLOWDOWN AND DISABLE ATTACK EFFECT
if(lifespan > 5){
float spd = getentityproperty(target, "speed"); //GET THE CURRENT SPEED
changeentityproperty(target, "speed", spd*0.25); //APPLY SPEED REDUCTION
changeentityproperty(target, "running", spd*0.50); //APPLY RUNNING REDUCTION
changeentityproperty(target, "jumpspeed", spd*0.25); //APPLY JUMP SPEED REDUCTION
changeentityproperty(target, "edelay", 1, 2, 1, 100, 1, 100); //INCREASE DELAY VALUE
changeentityproperty(self, "attackthrottle", 9999999999); //SET A HIGH VALUE TO DISABLE ATTACKS
changeentityproperty(self, "attackthrottletime", 9999999999); //SET A HIGH VALUE TO DISABLE ATTACKS
else
{
int dead = getentityproperty(entity_cursor, "dead");
if(!dead){
setidle(entity_cursor, openborconstant("ANI_IDLE"));
}
}
}
setglobalvar("alarmRate"+self, time);
}
}