I've made some scripts for this kinda of stuff - in fact, to control any entity when I want to.
All those scripts must go in your animationscript file and choose which ones fits you better
1 - changeEntAnim
Force a specific entity, by its model name ("default name"), to go to a specific animation.
No check done, so the entity will stop anithing it is done to execute it (it only checks it the target is alive)
Warning: this works by brute force, so it will make ALL entities with the same name to execute the animation
C-like:
void changeEntAnim(char target_name, int Ani)
{// Make a specific entity to change to a desired animation
//Douglas Baldan - 2018.07.21
int i;
for (i = 0; i < openborvariant("count_entities"); ++i)
{
void ent = getentity(i);
if ( getentityproperty(ent, "exists") && !getentityproperty(ent, "dead"))
{
if ( getentityproperty(ent,"model") == target_name)
{
changeentityproperty(ent, "animation", openborconstant(Ani));
continue;
}
} else continue;
}
return;
}
Usage
@cmd changeEntAnim "dog" "ANI_FOLLOW1"
Will make the target entity to go to FOLLOW1 animation.
If you have two entities called "dog" but one has the alias "wolf", both will be affected.
*ps I am aware of the bad memory usage by not using openborconstant, I just don't have time to update my code as I write this
2 - changeEntAnim2
Does the same of above, but checking for an animation (it checks if the animation is different than a specific one. If you want to check if its the same of the specific one, just revert the logic from != to ==)
C-like:
void changeEntAnim2(char target_name, int Ani, int AniCheck)
{// Make a specific entity to change to a desired animation, with animation check
//Douglas Baldan - 2018.07.21
int i;
for (i = 0; i < openborvariant("count_entities"); ++i)
{
void ent = getentity(i);
if ( getentityproperty(ent, "exists") )
{
if ( getentityproperty(ent,"model") == target_name && getentityproperty(ent,"animation") != AniCheck)
{
changeentityproperty(ent, "animation", openborconstant(Ani));
continue;
}
} else continue;
}
return;
}
Usage
@cmd changeEntAnim "dog" "ANI_FOLLOW1" "ANI_IDLE"
Will make the target entity to go to FOLLOW1 animation, but only if it isn't on the IDLE animation.
If you have two entities called "dog" but one has the alias "wolf", both will be affected.
The next two does the same as above, but they check for the entity alias instead of its default name.
IOW, If you have two entities called "dog" but one has the alias "wolf", just the "wolf" will be affected
C-like:
void changeAliasAnim(char target_name, int Ani)
{// Make a specific entity to change to a desired animation
//Douglas Baldan - 2018.07.21
int i;
for (i = 0; i < openborvariant("count_entities"); ++i)
{
void ent = getentity(i);
if ( getentityproperty(ent, "exists") )
{
if ( getentityproperty(ent,"name") == target_name)
{
changeentityproperty(ent, "animation", openborconstant(Ani));
continue;
}
} else continue;
}
return;
}
void changeAliasAnim2(char target_name, int Ani, int AniCheck)
{// Make a specific entity to change to a desired animation, with animation check
//Douglas Baldan - 2018.07.21
int i;
for (i = 0; i < openborvariant("count_entities"); ++i)
{
void ent = getentity(i);
if ( getentityproperty(ent, "exists") )
{
if ( getentityproperty(ent,"name") == target_name && getentityproperty(ent,"animation") != AniCheck)
{
changeentityproperty(ent, "animation", openborconstant(Ani));
continue;
}
} else continue;
}
return;
}