• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

script sapwn alternative

dantedevil

Well-known member
1. Wath the difference between:
@cmd spawn01 and @cmd spawner.

2. I have some problems with the script spawn animations.
In one animation i set @cmd spawn01 to show a flash in a hit. After the hit the flash still show the last frame and dont go.
The only way to avoid this is setting a last frame with a empty gif or its another script to make it?

Thanks.
 
you can try to set a "lifespan" to the entity.

or, you can use this:

@script
void self = getlocalvar("self");

if( frame >= 7 ){
killentity(self);
}
@end_script

Set the frame for what you need.

Personally, I use the suicide script.
 
Take a look:

Code:
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.
}

Code:
void spawner(void vName, float fX, float fY, float fZ)
{	//Spawns entity next to caller and set them as child.
	//
	//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.
	
	vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in entity.

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

The difference is:
Spawn01 - spawns an entity next to the caller and changes the direction to match the caller direction
Spawner - Spawns an entity next to the caller, but do not change the direction, and set the the caller as Parent.
 
Since spawner function calls spawn01 function, spawner is extension of spawn01.
Spawner sets spawning entity as parent of spawned entity. This is useful for spawning NPC which follows a parent entity.
 
O Ilusionista said:
you can try to set a "lifespan" to the entity.

or, you can use this:

@script
void self = getlocalvar("self");

if( frame >= 7 ){
killentity(self);
}
@end_script

Set the frame for what you need.

Personally, I use the suicide script.
You can make it even shorter like this :

frame data/sprites/spark23.gif
@cmd killentity getlocalvar("self")
frame data/sprites/spark23.gif
 
Back
Top Bottom