"random" flash/sparks effect

NED

Well-known member
Is there a way to add a 2nd spark effect to be displayed on first frame of some pain anims. (the 2nd spark don't replace the normal, it is an add)

1-How to add effect to an anim?
2-How to make it random (something like 30% of the time)

Thanks
 
#1 - I think you should use diff pain anims for this and set hitflash in player's attack, also set attack #'s (instead of attack command, attack2, attack3 etc.)  So using ATTACK2 will make enemy play PAIN2 etc.

Code:
hitflash {name}

~{name} is the name of an entity declared in MODELS.txt.
~If this animation has an attack box which makes contact with a victim, this hitflash will play instead of the normal hitflash for this character.

ATTACKS - http://dcemulation.org/?title=OpenBORManual#Attack

Example in char's .txt

anim  attack2
loop 0
offset 40 40
hitflash data/chars/misc/flash2.txt
frame  /data/chars....
attack2 ....
frame  /data/chars....

Then if you still want the extra flash you can add it to spawn from the enemies PAIN2 anim in whatever frame you want.

To spawn ents from chars I use this script instead of spawn/summonframe

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.
	//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.

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

Usage -
@cmd spawn01 "Flash2" 0 0 0

Remember to load the entity you want to spawn in entities text

load Flash2

This script is in script.c from Bloodbane's crime Busters mod.

--------------------

#2 - It's probably not the best way, but I used a random enemy spawn script and changed it to spawn blood flashes instead of enemies.  Then in the main blood flash I added to call the script.

anim idle
loop 0
@cmd RspawnU 0 0 0
frame        data/.....
etc.


Code:
void RspawnU(float fX, float fY, float fZ)
{//Spawns random enemy next to caller.
// Spawned enemy has Upper ability
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%3 + 3;

	if (iR >= 0 && iR < 2){ 
        vName = "Blood2";
      } else if (iR >= 2 && iR < 4){ 
        vName = "Blood3";
      } else { 
        vName = "Blood4";
      }

	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.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = vName;
      }

	if (vAlias == "Joe"){ // If Joe is spawned, his alias will be adjusted to his remap
	  if (iMap == 0){
          vAlias = "Elang";
        } else if (iMap == 1){
          vAlias = "Condor";
        } else if (iMap == 2){
          vAlias = "Hawk";
        } else if (iMap == 3){
          vAlias = "Eagle";
        } else if (iMap == 4){
          vAlias = "Rajawali";
        } else if (iMap == 5){
          vAlias = "Raven";
        }
      } else if (vAlias == "Donna"){ // If Donna is spawned, her alias will be adjusted to her remap
        if (iMap == 1 || iMap == 5){
          vAlias = "Althea";
        } else if (iMap == 2){
          vAlias = "Maria";
        } else if (iMap == 3){
          vAlias = "Reina";
        } else if (iMap == 4){
          vAlias = "Zora";
        }
      } 

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

The original script is 'thug.c' from Bloodbane's Crime Busters mod.

Eventually I'll edit this script to suit better (if I can).

[attachment deleted by admin]
 
Wow! Thanks a lot to both.

Even if it seems a little complex! Why it is better to use it instead of simple "spawn"?

Finally, I used spawn classic method, but its buggy...
I can't understand which one is better...
Spawnframe (make the effect fall... with gravity, but I don't need gravity)
Summonframe (don't display the effect)

anim pain
subentity blu
#spawnframe {frame} {x} {z} {a} {relative}
summonframe 1 78 1 62 0


loop      0
offset 96 177#238 177
bbox 67 58 61 122
# move -2#-7#---------------------------recule
delay      4
sound data/chars/mex/mex_dam1.wav
      frame      data/chars/mex/pain1.gif
offset    95 177
      frame      data/chars/mex/pain1.gif
# move 0#---------------------------recule
offset    96 177
      frame      data/chars/mex/pain1.gif
offset    95 177
      frame      data/chars/mex/pain1.gif
offset    96 177
      frame      data/chars/mex/pain1.gif
offset    95 177
      frame      data/chars/mex/pain1.gif
offset    96 177
delay      12
      frame      data/chars/mex/pain1.gif
 
Spawnframe is the basic spawn command. Summonframe usually spawns or I should say summons helper NPC. Well, noone forbids you from summoning anything else though.

If you only want to spawn effect, just use spawnframe.
 
Just a little correction:

Code:
Example in char's .txt

anim   attack2
loop 0
offset 40 40
hitflash flash2 [color=red]#is not the path what you put here, but the name you gave to that hitflash effect[/color]
frame   /data/chars....
attack2 ....
frame   /data/chars....

remember you can also put your desired hitfx there  ;)
 
finally I cloned existing pain anims and used summonframe in some of them for extra blood effect)

My logic:
light moves
Pain1 high attack
Pain2 low attack

hard moves
Pain11 high attack (slide back)
Pain12 low attack (slide back)

Powerful moves
Pain21 high attack (slide back + Blood up)
Pain22 low attack (slide back + Blood down)

Using such numbers is a way to make editing faster even if it uses 30 pain anims max. :P
 
Back
Top Bottom