Spawn child entity within parent entity

gzuk

New member
Hi, I'm new to OpenBOR, and I'm looking for a script example where a child entity is spawned inside the coordinate system of an existing parent entity, and both have sprites. Like, a magic orb or symbol appears over a character's head, and then it always moves together with that character. You wouldn't have to take care of that movement, because the coordinates relative to the character never change. Is there a working example for something like that?

I found a Wiki article about sub entities, but I couldn't figure out how it works or if that is even what I'm looking for: Sub Entity – OpenBOR Wiki

Thanks for any help! And generally, congrats on that great engine you made here.
 
Ah, that sounds like spawn function combined with bind function like this one:
C:
void spawnBind(void Name, float dx, float dy, float dz, int Dir, int Flag)
{ // Spawn entity and bind it
   void self = getlocalvar("self");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, dz);
   bindentity(Spawn, self, dx, dz, dy, Dir, Flag);
}

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

spawnBind function calls spawn01 so I included it.

There are plenty modules who have used this function. Do you need specific example?
 
Yes, thanks a lot, that looks like it's what I'm looking for. Now that you mentioned it by name, I also found a page about bind:

Bind – OpenBOR Wiki

But where does the spawn01 come from, that you included here? Is it a standard function, and there's an API reference where I can look it up? Or is it a module or snippet that someone wrote, and you always have to copy the code?
 
It's custom script, and as quoted I got it from Damon Caskey and made simpler version for my use.
It's not standard function.

is it a module or snippet that someone wrote, and you always have to copy the code?

Yeah, sort of. I always copy my library of scripts to my new project.
 
I have a problem with using spawnbind on the effect everytime I make a character do jumpframe or something moveable. It doesn't end itself after he goes back to idle or stops doing it. I'm trying to stop it from running after he's done with his special move.

Code:
anim freespecial2 #BURNING KNUCKLE

    offset 140 188
    delay 25
    load burnknuc
    #loop 1 2 4
    #jumpframe 1 1 5 0 # 3 0.5 1.2 0
    landframe 4 #5
    #frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/163_0.png
    #delay 16
    #frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/163_1.png
    #delay 5
    sound data/sounds/heroes/terry/06_terry_00011.wav
    bbox 118 108 51 79
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/162_3.png
    bbox 122 103 44 64
    @cmd spawnBind "burnknuc" 0 0 0 1 1 #spawnBind Name dx dy dz Dir Flag
    attack 161 104 51 31 11 1 0 0 0 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/162_4.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/162_6.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/162_5.png
    attack 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/162_6.png

burnknuc.txt:
Code:
name burnknuc #Burning Knuckle
type none

anim idle
    delay 3
    offset 140 188
    loop 1
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_0.png
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_1.png
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_2.png
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_3.png
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_4.png
    frame data/chars/heroes/kof_2k3_terry_sprite.7z/effects/915_5.png

I want the effect to stick to him until he stops doing it by idling or anything.
 
Back
Top Bottom