Cant spawn same enemy from himself

dantedevil

Well-known member
I'm working in the animation of a new fatality.
In this death animation,  the enemy (BD2) is cut in 2 parts in half.
So the torso fly in one direction and the legs remain in the same place nailed to the floor.
To make this create the death animation with the legs frames in the end.
From the torso have the anim follow 40.
Then before the first frames of the legs alone, here spwan the same enemy with te animation foolow40 (torso).
Here the animation:
Code:
anim death74
#KITANA
	loop	0
   @script
   void vSelf = getlocalvar("self");                 //Caller.
   void vEntity;                                     //Target entity placeholder.    
   int  iEntity;                                     //Entity enumeration holder.    
   int  iType;                                       //Entity type.    
   int  iMax      = openborvariant("ent_max");       //Entity count.    
   if(frame==1){                                     //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 (vEntity != vSelf)                                               //Not Self? 
    
       if (iType == openborconstant("TYPE_ENEMY")){          
   void iTime = openborvariant("elapsed_time") + getentityproperty(vEntity, "freezetime");          
   changeentityproperty(vEntity, "frozen", 1);          
   changeentityproperty(vEntity, "freezetime", iTime + 5.7*200);
         }      }    }
   @end_script 
        nodieblink    3 
	delay	7
        sound   data/sounds/finhim.wav
	offset	82 165
	frame	data/chars/bd2/r03.png
	offset	82 170
	frame	data/chars/bd2/r04.png
	offset	82 177
	frame	data/chars/bd2/r05.png
	delay	50
	offset	84 175
	frame	data/chars/bd2/spain.png
	delay	1
        sound   data/sounds/cuth.wav
        @cmd    spawnAni "bloody3"  16 0 1 "ANI_FOLLOW2" 0 0 0
	frame	data/chars/bd2/f2kit01.png
	delay	10
	sound   data/sounds/m5pain2.wav
	frame	data/chars/bd2/f2kit01.png
	delay	69
	frame	data/chars/bd2/f2kit01.png
	delay	1
        sound   data/sounds/cuth.wav
        @cmd    spawnAni "bloody3"  -17 0 1 "ANI_FOLLOW2" 0 0 0
	frame	data/chars/bd2/f2kit02.png
	delay	5
	frame	data/chars/bd2/f2kit02.png
	delay	6
	frame	data/chars/bd2/f2kit03.png
	sound   data/sounds/m5pain2.wav
	frame	data/chars/bd2/f2kit02.png
	delay	70
	frame	data/chars/bd2/f2kit03.png
	delay	6
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
        sound   data/sounds/mandie1.wav
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
	frame	data/chars/bd2/f2kit02.png
	frame	data/chars/bd2/f2kit03.png
        load    bd2
	delay	1
        @cmd    spawnAni "bd2"  0 0 1 "ANI_FOLLOW40" 0 0 0
	frame	data/chars/bd2/f2kit201.png
	delay	200
	frame	data/chars/bd2/f2kit201.png
	frame	data/chars/bd2/f2kit201.png


anim follow40
	loop	0
	offset	84 175
	delay   20
	landframe  4
        @cmd    leaper -1 3 0
	sound   data/sounds/m5fall.wav
	frame	data/chars/bd2/f2kit101.png
	offset	82 177
	frame	data/chars/bd2/f2kit102.png
	delay   10
	frame	data/chars/bd2/f2kit103.png
	delay   999
	frame	data/chars/bd2/f2kit103.png
	delay   1
	sound   data/sounds/fall1.wav
	frame	data/chars/bd2/f2kit104.png
	frame	data/chars/bd2/f2kit104.png

After a few test not work.
So try to spawn another enemy from bd2 and change the bd2 to bd3 and work ok.
Seems the problem comes when try to spawn the same character from himself.
I want use this method to avoid crate a new entity for every enemy.
It's any way to do this?
And is possibble spawn with the same palette of the spawner?
 
For now use a new entity to create this new fatality.
For this I need add to this script, the function to take the same palette from the spawner:
Code:
void spawnAni(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz, int Flag)
{
	//spawnB (Generic spawner) + Specific animation + velocities
	//Damon Vaughn Caskey + Douglas Baldan/O Ilusionista
	//07/06/2007 - 30/05/2013
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fZ: Y location adjustment.
      //fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");
        int map = getentityproperty(self,"map");

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    	performattack(vSpawn, openborconstant(Ani)); 
	changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);

	return vSpawn; //Return spawn.
}

So I try to take the function from this script:
Code:
void tossEnemy(void Name, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Damage, int Flag)
{ // Tossing fallen enemy
    void self = getlocalvar("self");
    int iDirection = getentityproperty(self, "direction");
    int map = getentityproperty(self,"map");
    void vSpawn;

    vSpawn = spawn01(Name, dx, dy, dz);

    damageentity(vSpawn, self, Damage, 1, openborconstant("ATK_NORMAL"));

    if(iDirection == 1){
      tossentity(vSpawn, Vy, Vx, Vz);
    } else {
      tossentity(vSpawn, Vy, -Vx, Vz);
    }
    if(Flag == 1){
      changeentityproperty(vSpawn, "map", map);
    }
}

Here my result but not work.
Something is wrong.
Code:
void spawnAniM(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz, int Flag)
{
	//spawnB (Generic spawner) + Specific animation + velocities
	//Damon Vaughn Caskey + Douglas Baldan/O Ilusionista
	//07/06/2007 - 30/05/2013
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fZ: Y location adjustment.
      //fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");
        int map = getentityproperty(self,"map");

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    	performattack(vSpawn, openborconstant(Ani)); 
	changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);

	return vSpawn; //Return spawn.
    }
    if(Flag == 1){
      changeentityproperty(vSpawn, "map", map);
    }
}
 
I run into the same issue other day: you cant spawn the same entity from an entity and make it change the animation. Because OpenBor doesn't knows which entity should he make to change the animation.
 
O Ilusionista said:
Because OpenBor doesn't knows which entity should he make to change the animation.

That's not possible at all. The engine uses memory pointers to identify entities, not names or numbers. Every entity is always uniquely known (otherwise nothing at all would work). There's another issue going on here.

DC
 
Yes this is a problem I encountered a long time ago to create multiple parts special effects with a single entity model. Tried lots of tricks, never figured what was the issue. I recall I even looked into the engine code to see if there was some kind of legacy check that blocked "recursive" spawning, without any luck.
 
I foun a way to spawn multiple parts of the same entity.

Here an example:
Code:
anim death24
#KITANA
	loop	0
   @script
   void vSelf = getlocalvar("self");                 //Caller.
   void vEntity;                                     //Target entity placeholder.    
   int  iEntity;                                     //Entity enumeration holder.    
   int  iType;                                       //Entity type.    
   int  iMax      = openborvariant("ent_max");       //Entity count.    
   if(frame==1){                                     //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 (vEntity != vSelf)                                               //Not Self? 
    
       if (iType == openborconstant("TYPE_ENEMY")){          
   void iTime = openborvariant("elapsed_time") + getentityproperty(vEntity, "freezetime");          
   changeentityproperty(vEntity, "frozen", 1);          
   changeentityproperty(vEntity, "freezetime", iTime + 5.7*200);
         }      }    }
   @end_script 
        nodieblink    3 
	delay	7
        sound   data/sounds/finhim.wav
	offset	82 165
	frame	data/chars/bd2/r03.png
	offset	82 170
	frame	data/chars/bd2/r04.png
	offset	82 177
	frame	data/chars/bd2/r05.png
	delay	60
	offset	84 175
	frame	data/chars/bd2/spain.png
	frame	data/chars/bd2/spain.png
	frame	data/chars/bd2/spain.png
	frame	data/chars/bd2/spain.png
	delay	81
	frame	data/chars/bd2/spain.png
	delay	4
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/pain.png
        sound   data/sounds/mandie1.wav
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/pain.png
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/pain.png
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/pain.png
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/spain3.png
	frame	data/chars/bd2/spain2.png
	delay	12
	frame	data/chars/bd2/spain2.png
	frame	data/chars/bd2/spain3.png
        sound  data/sounds/rip.wav
	@cmd	spawn01 "bloody3" 0 20 1
	@cmd	spawn01 "bloody3" 0 60 1
	@cmd	spawn01 "bloody3" 0 100 1
	delay	1
        @cmd    spawn01 "bloodfl" 0 0 -1
	@script
		if(frame == 22){
			void ent = spawn01("bones", 0, 90, 1);
			performattack(ent, openborconstant("ANI_freespecial1"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 0, 60, 1);
			performattack(ent, openborconstant("ANI_freespecial2"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 0, 20, 1);
			performattack(ent, openborconstant("ANI_freespecial3"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 30, 1);
			performattack(ent, openborconstant("ANI_freespecial4"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -10, 30, 1);
			performattack(ent, openborconstant("ANI_freespecial5"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 20, 1);
			performattack(ent, openborconstant("ANI_freespecial6"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -10, 20, 1);
			performattack(ent, openborconstant("ANI_freespecial7"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 10, 1);
			performattack(ent, openborconstant("ANI_freespecial8"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 35, 1);
			performattack(ent, openborconstant("ANI_freespecial8"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -10, 10, 1);
			performattack(ent, openborconstant("ANI_freespecial8"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -10, 55, 1);
			performattack(ent, openborconstant("ANI_freespecial8"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -10, 70, 1);
			performattack(ent, openborconstant("ANI_freespecial13"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 55, 1);
			performattack(ent, openborconstant("ANI_freespecial14"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 10, 70, 1);
			performattack(ent, openborconstant("ANI_freespecial15"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", -15, 80, 1);
			performattack(ent, openborconstant("ANI_freespecial16"), 1);
    }
		if(frame == 22){
			void ent = spawn01("bones", 15, 80, 1);
			performattack(ent, openborconstant("ANI_freespecial17"), 1);
		}
	@end_script
	@cmd	spawn01 "bloodexp" 0 30 -1
	frame	data/chars/bd2/empty.png
	delay	160
	frame	data/chars/bd2/empty.png
	delay	2
        subentity fat
        spawnframe 24 264 210 0 1
	frame	data/chars/bd2/empty.png
	frame	data/chars/bd2/empty.png
	frame	data/chars/bd2/empty.png
        @cmd    killentity getlocalvar("self")
	frame	data/chars/bd2/empty.png
 
I tried by it doesn't works for me:

@script
if(frame == 0){
void ent = spawn01("riot", 0, 0, 1);
performattack(ent, openborconstant("ANI_FOLLOW11"), 1);
}
if(frame == 1){
void ent = spawn01("riot", 0, 0, 20);
performattack(ent, openborconstant("ANI_FOLLOW11"), 1);
}
if(frame == 2){
void ent = spawn01("riot", 0, 0, 40);
performattack(ent, openborconstant("ANI_FOLLOW11"), 1);
}
if(frame == 3){
void ent = spawn01("riot", 0, 0, 60);
performattack(ent, openborconstant("ANI_FOLLOW11"), 1);
}
@end_script

I am using this code on an entity called "riot" and I want it to spawn clones of him. but the spawn doesn't happen.
 
No log, the engine really starts to get crazy - wrong spawns, wrong positions, wrong everything...

But I think I know why this happens: I was using a spawnscript to force the enemy to spawn into a custom animation.
I will make some tests later, thanks.
 
Thats very rare my friend.

Other solution is use this scripts yours.
Works ok for me too.
Code:
void spawnAni(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz)
{
	//spawnB (Generic spawner) + Specific animation + velocities
	//Damon Vaughn Caskey + Douglas Baldan/O Ilusionista
	//07/06/2007 - 30/05/2013
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fZ: Y location adjustment.
      //fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    	performattack(vSpawn, openborconstant(Ani)); 
	changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);

	return vSpawn; //Return spawn.
}
 
Back
Top Bottom