Solved SpawnMate help

Question that is answered or resolved.

Viper Snake

Member
I'm using the spawnMate script to spawn an axe the Minotaur boss can throw, so that when the Minotaur dies it instantly disappears with him. The problem is I also use another version of spawnMate (slightly modified so that it spawns from screen edge instead of the entity) to spawn the bosses custom health bar. Killing the Minotaur any time after he has thrown the axe seems to overwrite the previous spawnMate and the boss lifebar entity doesn't die with him. What do I need to do to get both of these entities to die at the same time?

Code:
void spawnMate(void vName, float fX, float fY, float fZ)
{//Spawns Mate next to caller
 //Spawned Mate & caller will know each other
 //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
   int Health = getentityproperty(self, "health");
   int Map = getentityproperty(self, "map");
   void Mate; //Spawn object.
	
   Mate = spawn01(vName, fX, fY, fZ); //Spawn Mate
   changeentityproperty(Mate, "map", Map); //Match Mate's remap with self's
   changeentityproperty(Mate, "maxhealth", Health); //Match Mate's health with self's
   changeentityproperty(Mate, "health", Health); //Match Mate's health with self's

   setentityvar(self, 0, Mate); //Store mate to self
   setentityvar(Mate, 0, self); //Store self to mate
}

takedamagescript that I combined with the blink script:
Code:
void main()
{// Equalize health with mate's health
  void self = getlocalvar("self"); //Get calling entity
  void Mate = getentityvar(self, 0); //Find Mate
  void MateX = getentityproperty(Mate, "exists");
  int Health = getentityproperty(self,"health");

  if(Mate!=NULL() && MateX){
    if(Health > 0){
      changeentityproperty(Mate, "health", Health);
	  changeentityproperty(self, "colourmap", 1);
	  changeentityproperty(self, "maptime", 30 + openborvariant("elapsed_time"));	  
    } else {
      setentityvar(self, 0, NULL());
      setentityvar(Mate, 0, NULL());
      damageentity(Mate, self, 99999, 1, openborconstant("ATK_NORMAL"));
    }
  }
}

 
spawnMate is for spawning a partner which fights together with his/her own AI. Unlike regular spawning function, that function registered each character to each other. This allows one to give order to the other including killing the other if he/she dies
For thrown projectiles including large axe, you could use other function (I have to make slight edit first)

The problem is I also use another version of spawnMate (slightly modified so that it spawns from screen edge instead of the entity) to spawn the bosses custom health bar

You don't need entity just for custom lifebar. An update script is sufficient for that
 
Bloodbane said:
spawnMate is for spawning a partner which fights together with his/her own AI. Unlike regular spawning function, that function registered each character to each other. This allows one to give order to the other including killing the other if he/she dies
For thrown projectiles including large axe, you could use other function (I have to make slight edit first)

The problem is I also use another version of spawnMate (slightly modified so that it spawns from screen edge instead of the entity) to spawn the bosses custom health bar

You don't need entity just for custom lifebar. An update script is sufficient for that

Thank you for the reply Bloodbane.
Is there an example somewhere of doing it with update script? The boss lifebar entity gets spawned in the boss spawn animation and is just a sprite going over the lifebar. The boss death animation spawns 8 separate entites to do a melting animation for it in the same place right when it disappears.


EDIT: Solved by Bloodbane thanks to these scripts:
Code:
void spawnP(void vName, float fX, float fY, float fZ, int Num)
{//Spawns projectile and store it
 //vName: Model name of entity to be spawned in.
 //fX: X location adjustment
 //fY: Y location adjustment
 //fZ: Z location adjustment

   void self = getlocalvar("self"); //Get calling entity.
   void vSpawn; //Spawn object.
	
   vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in effect
   setentityvar(self, Num, vSpawn); //Store projectile
}

void shooterP(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz, int Num)
{//Spawns special projectile next to caller then give speed and store it
 //vName: Model name of entity to be spawned in.
 //fX: X location adjustment
 //fY: Y location adjustment
 //fZ: Z location adjustment
 //Vx: X speed.
 //Vy: Dive speed.
 //Vz: Z speed.
 //Num: number of entity variable to store the 

   void self = getlocalvar("self"); //Get calling entity.
   int Direction = getentityproperty(self, "direction");
   void vSpawn; //Spawn object.
	
   vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in projectile.
   if (Direction == 0){ //Is entity facing left?                  
      Vx = -Vx; //Reverse Vx direction to match facing
   }

   changeentityproperty(vSpawn, "velocity", Vx, Vz, Vy);
   setentityvar(self, Num, vSpawn); //Store projectile
}

void killP(int Num)
{ // Kill the stored projectile
    void self = getlocalvar("self");
    void Proj = getentityvar(self, Num);

    if(Proj!=NULL()){
      killentity(Proj);
    }
}

I spawned the axe with @cmd spawnP "minotaur_axe" 64 80 0 1 and have @cmd killP 1 in the minotaur's death animation.
 
Back
Top Bottom