• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Get Entity to Kill Self if Player is NOT in Pain7

Aerisetta

Active member
Trying to write a script for an animation to check on Frame 1 if Player is currently in Pain7 (my game only has 1 player)

if Player not in pain7, entity should killself.

can anyone help me with this?
 
Last edited:
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
 
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
I think the code is wrong, i need to killentity if it is NOT in PAIN7

Edit: TIL != means not equal :)

Thanks!
 
Last edited:
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
 
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

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.


DC
 
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.


DC
I got the enumeration to work!

Can you teach me how to force enemies to turn toward player (preferably without changing their current animation) and how to disable AI control?
 
Can you teach me how to force enemies to turn toward player (preferably without changing their current animation) and how to disable AI control?

You'd need to compare each enemy's x coord with player's x then change facing direction based on that.
As for disabling AI control, this line should do it:
C:
        changeentityproperty(Entity, "noaicontrol", 1);

Entity is handle of enemy whose AI control to be disabled.
Doing this won't stop enemy's movement though so you'd need another line like this to do that:
C:
        changeentityproperty(Entity, "velocity", 0, 0, 0);
 
I have a question on this one

I used the exact enumeration script @DCurrent provided

My use case is a bit different.

When the enemy grabs the player, I want ALL OTHER enemies to enter Pain98.
I currently put the animation bomb script in the fall7 of the player (when the player gets grabbed, they enter fall7 animation)

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?

Code:
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
 
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?
@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;
}
 
@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;
}

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);
    }
}
 
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);
    }
}
Here's the code replacing the "grabbing" property with "opponent" same as we tested before.

C:
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);
    }
}
 
Back
Top Bottom