Enemies get items

betterbold

Active member
Hello. :D
I want to make enemies get items.
"hostile item" and "aimove chase" but it's not work ... Can't I do something ?
 
Thank you for your advice, O Ilusionista. :D
Sure, they have the get animation but not work ... because I set "nomove 1" to them.
It's "bonus game" stage.
R1cPQQL.png

Player and enemy have "nomove 1" then items go through.
Is there another way to stop them ?
 
Because of the "nomove" command, the enemy can not perform the get animation.

Although I may be wrong.

Here, most likely, you need to look for an alternative move. Without the "nomove"

 
I think this bonus game is simple so there's no need for enemy's get mechanics. You can just make new items entity which gives score if attacked. Yes, in this bonus game, player and enemy are attacking items to get the latter
Player's model should be simple and as for enemy, since it's using nomove 1, you can control his/her AI with his/her IDLE animation
 
Let's start by discussing the mechanics of bonus game first :)
Correct me if I'm wrong, player and enemy are sitting on a table while foods or items pass through ontop of table. I'm not sure about the winning condition here i.e is it only about getting highest score in limited time OR is it about getting higher score than the enemy?
Then about enemy's AI, is it a smart one which snatches any food passing through in front of him/her OR less smart one which sometimes misses some passing foods?
 
Hmm... that would require randomized attack or snatch. You could make an ATTACK animation for the enemy with a random script run in its first frame and another animation say FOLLOW animation. Both animations are item/food snatch animation but one has short delay while the other has long delay. The latter is for the misses snatch one
 
Try to insert this script into the animationscript of the enemy:
Code:
void finisher(void AniE, void Ani , int RxMin, int RxMax, int Rz, int Type, int Flag)
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");
    void vEntity;                                     
    int  iEntity;                                      
    int  iType;                                        
    int  iMax      = openborvariant("ent_max");        

    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 
      iType   = getentityproperty(vEntity, "type"); 

      if (iType == openborconstant("TYPE_ENEMY")){
        float Tx = getentityproperty(vEntity, "x");
   float Tz = getentityproperty(vEntity, "z");
        int Anti = getentityproperty(vEntity, "antigrab");
        int Edir = getentityproperty(vEntity, "direction");
   void EAnim = getentityproperty(vEntity, "animationID");

        if(EAnim == openborconstant(AniE)){
      float Disx = Tx - x;
      float Disz = Tz - z;

      if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1 )
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 0) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 0) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0)
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 1) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 1) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      }
        }
      }
    }
}

Example:

Anim IDLE
Loop 1
Offset x x
Bbox x x x x
Delay x
@cmd finisher "ani_idle" "ani_attack" -15 15 10 0 0
Frame data/chars/enemy1/xxxxxx.gif
@cmd finisher "ani_idle" "ani_follow1" -40 -20 10 0 0
Frame data/chars/enemy1/xxxxxx.gif

Although I do not know if it will help you :)
 
Yeah, in the script I made a mistake. Try this one

Code:
void finisher(void AniP, void Ani , int RxMin, int RxMax, int Rz, int Type, int Flag)
{// Checks closest enemy's animation & range
// If it's accepted, change animation
// AniP  : Enemy's animation
// Ani   : Animation to change to
// RxMin : Minimum x range
// RxMax : Maximum x range
// Rz    : z range
// Type  : 0 = non targetted , 1 = for targetting, 2 = for grabbing
// Flag  : 0 = facing direction not necessary , 1 = facing direction must be opposite

/*Originally smartbomb by
    Damon Vaughn Caskey
    07152008*/

    void self = getlocalvar("self");			//Caller.
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iType;                                         //Entity type.
    int  iMax      = openborvariant("ent_max");         //Entity count.

     //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iType   = getentityproperty(vEntity, "type"); //Get target type.

      //Enemy type?
      if (iType == openborconstant("TYPE_ENEMY")){
        float Tx = getentityproperty(vEntity, "x");
	float Tz = getentityproperty(vEntity, "z");
        int Anti = getentityproperty(vEntity, "antigrab");
        int Edir = getentityproperty(vEntity, "direction");
	void EAnim = getentityproperty(vEntity, "animationID");

        if(EAnim == openborconstant(AniP)){
      float Disx = Tx - x;
      float Disz = Tz - z;

      if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1 ) // Target within range on right facing?
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 0) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 0) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 1) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 1) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      }
        }
      }
    }
}
 
betterbold said:
I see . :)
I use random script in IDLE animation and he sometimes attack but don't get item...

Like I said before, the items are new entities so just for this bonus game, the items should use other type such as obstacle or NPC (don't use this if you have NPCs). Then the enemy must have candamage obstacle to allow him/her to get the item :)
 
Thanks, Bloodbane and MKLIUKANG. :D

I tryed new script but it's not work ... but I want to try it.
*logged error : can't compile script

Sure, I changed food's type "obstacle" and player can't get it.
Should players have "candamage obstacle" ?
 
I still not solve the problem but I make my game's video. ;)
You can see minigame at 0:45.
Enemy is right guy and "nomove"...
https://www.youtube.com/watch?v=Cs5P_o9QkfM
 
Back
Top Bottom