O Ilusionista
Captain 80K
Discussion thread for custom sound tutorial.
void main(){
// Custom sounds for picking itens
// Douglas Baldan / O Ilusionista - 11/12/2016
// Thanks Damon Caskey for the support
void self = getlocalvar("self"); //get the self var
void hit = getlocalvar("damagetaker"); // get target entity
char Name = getentityproperty(self,"name"); // get target's name
void power = getentityproperty(hit,"mp"); // get target's current mp
int sample; // Sample to play.
int animation; // Animation to apply.
int SFX1 = loadsample("data/sounds/power-up.wav"); // load samples
int SFX2 = loadsample("data/sounds/life-up.wav");
int SFX3 = loadsample("data/sounds/full-power.wav");
int SFX4 = loadsample("data/sounds/full-life.wav");
int SFX5 = loadsample("data/sounds/power-life.wav");
switch(Name) { // check the item name
case "iMP" : // power up
sample = SFX1;
break;
case "iHP" : // life up
case "cola" : // life up
sample = SFX2;
animation = openborconstant("ANI_IDLE");
break;
case "iFMP" : // full power up
sample = SFX3;
animation = openborconstant("ANI_FOLLOW4");
break;
case "iFHP" : // full life up
sample = SFX4;
animation = openborconstant("ANI_FOLLOW3");
break;
case "iHPMP" : // life and power up
changeentityproperty(hit, "mp", power+30); // add 30 to entity power
sample = SFX5;
animation = openborconstant("ANI_FOLLOW2");
break;
default : // in case of none of above
break;
}
spawnAni("aitemFX",0,30,0,animation,NULL(),NULL(),NULL());
playsample(sample, 0, 120, 120, 100, 0);
}
void spawnAni(void vName, float fX, float fY, float fZ, int animation, float Vx, float Vy, float Vz)
{
//spawnB (Generic spawner) + Specific animation + velocities
//Damon Vaughn Caskey + Douglas Baldan
//07/06/2007
//
//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.
// Entity facing left?
if (iDirection == openborconstant("DIRECTION_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, animation);
changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);
return vSpawn; //Return spawn.
}