I think the code is wrong, i need to killentity if it is NOT in PAIN7Try this:
C:anim idle @script void self = getlocalvar("self"); void P1 = getplayerproperty(0, "entity"); if(frame==1 && P1){ void PAnim = getentityproperty(P1, "animationID"); if(PAnim==openborconstant("ANI_PAIN7")){ killentity(self); } } @end_script
Try this:
C:anim idle @script void self = getlocalvar("self"); void P1 = getplayerproperty(0, "entity"); if(frame==1 && P1){ void PAnim = getentityproperty(P1, "animationID"); if(PAnim==openborconstant("ANI_PAIN7")){ killentity(self); } } @end_script
Can I ask a follow up question?
While player is in animation Pain7 (player decides when the mash out of it, they can stay in Pain7 forever if they want)
all enemies stand 500 pixels away from player, face player, and stay in idle
or, if that is too complex, if player = in Pain7, all enemies turn invisible
I got the enumeration to work!This is an enumeration solve. I would place it in a player's update. This would be generally more efficient than each enemy checking the player's animation. As for the stop effect, you could force enemies to turn toward player, then disable AI control. That would leave them Idle.
Tutorial - Entity Enumeration
On several occasions I've fielded questions about taking actions that affect multiple entities at once. Damaging all enemies. Gathering information on multiple entities (ex. for a custom HUD). Instant kill all enemies with low hitpoints...www.chronocrash.com
DC
Can you teach me how to force enemies to turn toward player (preferably without changing their current animation) and how to disable AI control?
changeentityproperty(Entity, "noaicontrol", 1);
changeentityproperty(Entity, "velocity", 0, 0, 0);
anim fall7
fshadow 0
delay 3000
offset 800 640
@cmd dc_animation_bomb openborconstant("ANI_PAIN98")
frame data/chars/Aerisetta/fall203.png #0
offset 805 640
frame data/chars/Aerisetta/fall203.png #1
@Aerisetta I suggest trying to check what entity is grabbing the player and skip him in the entity enumeration script, I'm using this kind of check in SORX too.The issue I have is that the enemy that grabbed the player is ALSO entering PAIN98 animation.
I need the bomb to ignore the enemy that grabbed the player.
Any advice?
void self = getlocalvar("self");
void target = getentityproperty(self, "opponent");
void grabbing = getentityproperty(target, "grabbing");
//SKIPS THE ENEMY ENTITY THAT IS GRABBING YOU (PLAYER) IN THE ENUMERATOR
if(target != NULL() && grabbing == self)
{
continue;
}
@Aerisetta I suggest trying to check what entity is grabbing the player and skip him in the entity enumeration script, I'm using this kind of check in SORX too.
C:void self = getlocalvar("self"); void target = getentityproperty(self, "opponent"); void grabbing = getentityproperty(target, "grabbing"); //SKIPS THE ENEMY ENTITY THAT IS GRABBING YOU (PLAYER) IN THE ENUMERATOR if(target != NULL() && grabbing == self) { continue; }
void dc_animation_bomb(int animation_id)
{
int i = 0;
int entity_count = 0;
int can_damage = 0;
int entity_type = 0;
void acting_entity = NULL();
void target_entity = NULL();
void self = getlocalvar("self");
void target = getentityproperty(self, "opponent");
void grabbing = getentityproperty(target, "grabbing");
/* Get the entity that called function. */
acting_entity = getlocalvar("self");
/*
* We're going to be comparing caller's can damage to
* every other entity, so let's get that here.
*/
can_damage = getentityproperty(acting_entity, "candamage");
/*
* Now we want to check all active entities. OpenBOR assigns
* each active entity a sequential ID that we can use to get
* the entity's pointer. That means we can work with every
* entity in play using these steps:
*
* 1. Get a count of current active entities.
* 2. Loop from 0 to that count.
* 3. On each loop, we get the entity pointer
* using the number we're currently on.
* 4. Skip entites we don't want to act on
* by using some logic checks.
* 5. Apply desired changes to entity.
*/
entity_count = openborvariant("count_entities");
for (i = 0; i < entity_count; i++)
{
/*
* Get the entity pointer by using
* current loop cursor as the ID. Now
* we can work with the entity.
*/
target_entity = getentity(i);
/*
* Now we are going to check for several conditions.
* If they aren't met, then we use a command called
* "continue" that skips this loop without doing any
* more code, and moves on to the next iteration. This
* is how we decide which entities we're going to make
* dance.
* First, we do a safety check to make sure the entity
* really exists. It's possible for an ID to be assigned
* but the entity already removed for one or more reasons.
* If we tried to do anything with a non-existing entity, the
* engine would log an error and shut down. This check
* will catch that before it can happen.
*/
if (!getentityproperty(acting_entity, "exists"))
{
continue;
}
/* Get the entity's type. */
entity_type = getentityproperty(target_entity, "type");
/* We don't ever want obstacles to dance, right? */
if (entity_type == openborconstant("TYPE_OBSTACLE"))
{
continue;
}
//SKIPS THE ENEMY ENTITY THAT IS GRABBING YOU (PLAYER) IN THE ENUMERATOR
if(target != NULL() && grabbing == self)
{
continue;
}
/*
* This check looks a little weird. It's basically the
* same thing as the obstacle check above. This time though
* we are making sure our target's type is included in the
* list of entity types the caller can damage. So if the
* caller has "candamage obstacle enemy" but the target is
* an NPC, then we move on to the next loop iteration and
* leave this entity alone.
*
* The end result is we have a "smart check" that only targets
* entities the caller could hit with normal attacks.
*/
if (!(entity_type & can_damage))
{
continue;
}
/*
* If target doesn't have a dance animation, we can't
* make it dance.
*/
if (!getentityproperty(target_entity, "animvalid", animation_id))
{
continue;
}
/*
* If we made it all the way down here, we know we can make
* this entity dance. So let's do it! Put them into the
* dance animation!
*/
executeanimation(target_entity, animation_id);
}
}
Here's the code replacing the "grabbing" property with "opponent" same as we tested before.It's continuing to hit all enemies, including the one taht grabbed, can you see what's wrong?
Code:void dc_animation_bomb(int animation_id) { int i = 0; int entity_count = 0; int can_damage = 0; int entity_type = 0; void acting_entity = NULL(); void target_entity = NULL(); void self = getlocalvar("self"); void target = getentityproperty(self, "opponent"); void grabbing = getentityproperty(target, "grabbing"); /* Get the entity that called function. */ acting_entity = getlocalvar("self"); /* * We're going to be comparing caller's can damage to * every other entity, so let's get that here. */ can_damage = getentityproperty(acting_entity, "candamage"); /* * Now we want to check all active entities. OpenBOR assigns * each active entity a sequential ID that we can use to get * the entity's pointer. That means we can work with every * entity in play using these steps: * * 1. Get a count of current active entities. * 2. Loop from 0 to that count. * 3. On each loop, we get the entity pointer * using the number we're currently on. * 4. Skip entites we don't want to act on * by using some logic checks. * 5. Apply desired changes to entity. */ entity_count = openborvariant("count_entities"); for (i = 0; i < entity_count; i++) { /* * Get the entity pointer by using * current loop cursor as the ID. Now * we can work with the entity. */ target_entity = getentity(i); /* * Now we are going to check for several conditions. * If they aren't met, then we use a command called * "continue" that skips this loop without doing any * more code, and moves on to the next iteration. This * is how we decide which entities we're going to make * dance. * First, we do a safety check to make sure the entity * really exists. It's possible for an ID to be assigned * but the entity already removed for one or more reasons. * If we tried to do anything with a non-existing entity, the * engine would log an error and shut down. This check * will catch that before it can happen. */ if (!getentityproperty(acting_entity, "exists")) { continue; } /* Get the entity's type. */ entity_type = getentityproperty(target_entity, "type"); /* We don't ever want obstacles to dance, right? */ if (entity_type == openborconstant("TYPE_OBSTACLE")) { continue; } //SKIPS THE ENEMY ENTITY THAT IS GRABBING YOU (PLAYER) IN THE ENUMERATOR if(target != NULL() && grabbing == self) { continue; } /* * This check looks a little weird. It's basically the * same thing as the obstacle check above. This time though * we are making sure our target's type is included in the * list of entity types the caller can damage. So if the * caller has "candamage obstacle enemy" but the target is * an NPC, then we move on to the next loop iteration and * leave this entity alone. * * The end result is we have a "smart check" that only targets * entities the caller could hit with normal attacks. */ if (!(entity_type & can_damage)) { continue; } /* * If target doesn't have a dance animation, we can't * make it dance. */ if (!getentityproperty(target_entity, "animvalid", animation_id)) { continue; } /* * If we made it all the way down here, we know we can make * this entity dance. So let's do it! Put them into the * dance animation! */ executeanimation(target_entity, animation_id); } }
void dc_animation_bomb(int animation_id)
{
int i = 0;
int entity_count = 0;
int can_damage = 0;
int entity_type = 0;
void acting_entity = NULL();
void target_entity = NULL();
void grabbing = NULL();
/* Get the entity that called function. */
acting_entity = getlocalvar("self");
/*
* We're going to be comparing caller's can damage to
* every other entity, so let's get that here.
*/
can_damage = getentityproperty(acting_entity, "candamage");
/*
* Now we want to check all active entities. OpenBOR assigns
* each active entity a sequential ID that we can use to get
* the entity's pointer. That means we can work with every
* entity in play using these steps:
*
* 1. Get a count of current active entities.
* 2. Loop from 0 to that count.
* 3. On each loop, we get the entity pointer
* using the number we're currently on.
* 4. Skip entites we don't want to act on
* by using some logic checks.
* 5. Apply desired changes to entity.
*/
entity_count = openborvariant("count_entities");
for (i = 0; i < entity_count; i++)
{
/*
* Get the entity pointer by using
* current loop cursor as the ID. Now
* we can work with the entity.
*/
target_entity = getentity(i);
/*
* Now we are going to check for several conditions.
* If they aren't met, then we use a command called
* "continue" that skips this loop without doing any
* more code, and moves on to the next iteration. This
* is how we decide which entities we're going to make
* dance.
* First, we do a safety check to make sure the entity
* really exists. It's possible for an ID to be assigned
* but the entity already removed for one or more reasons.
* If we tried to do anything with a non-existing entity, the
* engine would log an error and shut down. This check
* will catch that before it can happen.
*/
if (!getentityproperty(target_entity, "exists"))
{
continue;
}
if (target_entity == acting_entity)
{
continue;
}
/* Get the entity's type. */
entity_type = getentityproperty(target_entity, "type");
/* We don't ever want obstacles to dance, right? */
if (entity_type == openborconstant("TYPE_OBSTACLE"))
{
continue;
}
grabbing = getentityproperty(target_entity, "opponent");
//SKIPS THE ENEMY ENTITY THAT IS GRABBING YOU (PLAYER) IN THE ENUMERATOR
if(grabbing == acting_entity)
{
continue;
}
/*
* This check looks a little weird. It's basically the
* same thing as the obstacle check above. This time though
* we are making sure our target's type is included in the
* list of entity types the caller can damage. So if the
* caller has "candamage obstacle enemy" but the target is
* an NPC, then we move on to the next loop iteration and
* leave this entity alone.
*
* The end result is we have a "smart check" that only targets
* entities the caller could hit with normal attacks.
*/
if (!(entity_type & can_damage))
{
continue;
}
/*
* If target doesn't have a dance animation, we can't
* make it dance.
*/
if (!getentityproperty(target_entity, "animvalid", animation_id))
{
continue;
}
/*
* If we made it all the way down here, we know we can make
* this entity dance. So let's do it! Put them into the
* dance animation!
*/
executeanimation(target_entity, animation_id);
}
}