//Script for Cobra Statue

#include "data/scripts/library/2Dspawn.h"
#include "data/scripts/library/target.h"

void spawnSlave(void vName, int Num, float fX, float fY, float fZ)
{	//Spawns slave next to caller and set them as child.
	//
	//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 entity.

        setentityvar(self, Num, vSpawn);
	changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
    
	return vSpawn; //Return spawn.
}

void Sltarget(int Num, float Vx, float Vy, float dx, float dy)
{// Targetting slave before shooting
// Num = Slave number
// Vx = x velocity
// Vy = y velocity
// dx = x added distance
// dy = y added distance

    void self = getlocalvar("self");
    void Slave = getentityvar(self, Num);

    setlocalvar("x"+self, target1(Slave, Vx, Vy, dx, dy, 0, "x", 0) );
    setlocalvar("y"+self, target1(Slave, Vx, Vy, dx, dy, 0, "y", 0) );
}

void SltargetT(int Num, float Time, float dx, float dy)
{// Targetting slave before shooting
// Num = Slave number
// Time = specified time
// dx = x added distance
// dy = y added distance

    void self = getlocalvar("self");
    void Slave = getentityvar(self, Num);

    setlocalvar("x"+self, target1T(Slave, Time, dx, dy, "x", 0) );
    setlocalvar("y"+self, target1T(Slave, Time, dx, dy, "y", 0) );
}

void anichangeSl(int Num, void Ani)
{// Change Slave's animation
// Num = Slave number
// Ani = Desired animation
    void self = getlocalvar("self");
    void Slave = getentityvar(self, Num);

    changeentityproperty(Slave, "animation", openborconstant(Ani));
}
