VirtusVerbis
Member
What I'm trying to do:
When a player or enemy animation plays, it will cause an item to drop (ex: player dies and drops money).
The following code works fine at the Entity Event level (ie: when I stick it into the <char>.txt file):
Conversely, if I try to simply use the spawn.h file (taken from Street Fighter 86) and apply the following:
spawn.h (which contains, among other functions):
I create a spawn.c (which contains):
I then add the following to my <char>.txt file header:
and I make the call under one of my animations:
But it doesn't work - as in the "Money" item does not appear. Whereas if I imbed the code into the char.txt, it works fine.
Can someone enlighten me please?
Thank you
When a player or enemy animation plays, it will cause an item to drop (ex: player dies and drops money).
The following code works fine at the Entity Event level (ie: when I stick it into the <char>.txt file):
Code credit goes to:
//spawn01 (Generic spawner)
//Damon Vaughn Caskey
@script
if(frame == 1){
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int iDirection = getentityproperty(self, "direction");
int fX = 0;
int fY = 0;
int fZ = 0;
clearspawnentry(); //Clear current spawn entry.
setspawnentry("name", "Money"); //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.
//return vSpawn; //only works if I comment this out, I assume this isn't a function so there is nothing to return.
}
@end_script
Conversely, if I try to simply use the spawn.h file (taken from Street Fighter 86) and apply the following:
spawn.h (which contains, among other functions):
void spawn01(void vName, float fX, float fY, float fZ)
{
//spawn01 (Generic spawner)
//Damon Vaughn Caskey
//07/06/2007
//
//Spawns entity next to caller.
//
//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.
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.
return vSpawn; //Return spawn.
}
I create a spawn.c (which contains):
#import "data/scripts/library/spawn.h"
I then add the following to my <char>.txt file header:
animationscript data/scripts/spawn.c
and I make the call under one of my animations:
anim freespecial2
...
@cmd spawn01 "Money" 0 0 0
...
But it doesn't work - as in the "Money" item does not appear. Whereas if I imbed the code into the char.txt, it works fine.
Can someone enlighten me please?
Thank you