setlayer subject to spawn position

Gurtag

Member
hey guys is there a way to make an entity spawn or set it´s Z draw position subject to his actual position and not screen?
for example i use @cmd spawn01 "cyraxbomb2" x120 y21 z0 but want the spawned entity be drawn at z1 infront of his parent entity..
or set up the entity from header or animation to allways be drawn xnumber of pixels front or back his actual z position, tryed testing setlayer command and scripts but values seem to allways work subject to screen.
 
I added a setlayer function for you, try this

C:
void spawn00layer(void vName, float fX, float fY, float fZ, int layer)
{
    //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.
    changeentityproperty(vSpawn, "setlayer", layer); //Set layer.
    return vSpawn; //Return spawn.
}

@cmd spawn00layer "whatever" 100 100 1 900000

purple is the layer.
 
hey guys is there a way to make an entity spawn or set it´s Z draw position subject to his actual position and not screen?
for example i use @cmd spawn01 "cyraxbomb2" x120 y21 z0 but want the spawned entity be drawn at z1 infront of his parent entity..
Wait, I think there is some issue here. Unless I got it wrong, you are talking about Z position, not layer position. They looks to be the same thing, but they aren't.
If you use: @cmd spawn01 "cyraxbomb2" x120 y21 z1, it will be spawned 1 px in front of the caller. The code works based on the called position, not on screen position

If you use @danno script, they will be spawned based on screen position.
For example, a Z of -1 will spawn the entity 1 px behind the caller. But a setlayer of -1 will make it to be always behind everything, even if its on a higher Z position of everything else.

I can remember the value correctly, but a layer of -5 or -10 draws the entity behind the shadows.

You can use negative setlayer to draw entities behind everything, ignoring their z position. Its useful for background animations, for example.
 
I added a setlayer function for you, try this

C:
void spawn00layer(void vName, float fX, float fY, float fZ, int layer)
{
    //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.
    changeentityproperty(vSpawn, "setlayer", layer); //Set layer.
    return vSpawn; //Return spawn.
}

@cmd spawn00layer "whatever" 100 100 1 900000

purple is the layer.
hey dano thanks a lot for the script but doesnt work setlayer seems to allways work subject to screen and i am trying to make it subject to caller position..



Wait, I think there is some issue here. Unless I got it wrong, you are talking about Z position, not layer position. They looks to be the same thing, but they aren't.
If you use: @cmd spawn01 "cyraxbomb2" x120 y21 z1, it will be spawned 1 px in front of the caller. The code works based on the called position, not on screen position

If you use @danno script, they will be spawned based on screen position.
For example, a Z of -1 will spawn the entity 1 px behind the caller. But a setlayer of -1 will make it to be always behind everything, even if its on a higher Z position of everything else.

I can remember the value correctly, but a layer of -5 or -10 draws the entity behind the shadows.

You can use negative setlayer to draw entities behind everything, ignoring their z position. Its useful for background animations, for example.

yep, i want to spawn at Z0 but be draw/display as if it were at Z1 meaning looking infront of caller despite actually been spawned same Z or negative meaning behind.
 
Why not make it like this together or separately?

Code:
@cmd spawn01 "cyraxbomb2" 120 21 -1

Code:
@cmd spawn01 "cyraxbomb2" 120 21 1

Code:
@cmd spawn01 "cyraxbomb2" 120 21 0

Code:
anim freespecial4
delay 5
offset 66 119
@cmd spawn01 "cyraxbomb2" 120 21 -1
@cmd spawn01 "cyraxbomb2" 123 21 0
@cmd spawn01 "cyraxbomb2" 117 21 1
frame data/chars/somechar/unleash00.png

Otherwise, you do this.
Code:
anim freespecial4
delay 5
offset 66 119
@cmd spawn01 "cyraxbomb2" 117 21 1
frame data/chars/somechar/unleash00.png

setlayer seems to allways work subject to screen
Not true. setlayer is used for making the sprite cover anything or become behind while retaining its Z position. subject_to_screen is used for going near screen edges. Value 0 of it allows the entity to go offscreen while value 1 doesn't allow it.

a layer of -5 or -10 draws the entity behind the shadows.
From my testing of v3 6391, that's -5.

i am trying to make it subject to caller position..
i want to spawn at Z0 but be draw/display as if it were at Z1 meaning looking infront of caller despite actually been spawned same Z or negative meaning behind.
Are you trying to give that spawned entity the same Z position as its parent entity, but you want it to have its higher setlayer value than none or its actual value? @danno had already provided the one with the setlayer value/function. Maybe if it's not working, you could create a clone of the spawned entity which doesn't need to have setlayer value set.

P.S.: Hmmm... I think I'm beginning to get what you're trying to say. What you want is that spawned entity to be summoned at the same position as its parent entity. But you want to summon it to be more frontal than normally summoning it with spawn01 on the Z value. This got me thinking about your idea. Are you planning to make it into a 2D level for this?

C:
void spawn00layer(void vName, float fX, float fY, int layer)
{
    //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, 0+layer, fY); //Set spawn location but with a layer value based on Z.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    changeentityproperty(vSpawn, "setlayer", layer); //Set layer.
    return vSpawn; //Return spawn.
}

Anyway. I just changed the Z position value to 0 while allowing the layer value (in case the level would be 3D) because you said you want it to be at the same position as its parent entity.
 
Why not make it like this together or separately?

Code:
@cmd spawn01 "cyraxbomb2" 120 21 -1

Code:
@cmd spawn01 "cyraxbomb2" 120 21 1

Code:
@cmd spawn01 "cyraxbomb2" 120 21 0

Code:
anim freespecial4
delay 5
offset 66 119
@cmd spawn01 "cyraxbomb2" 120 21 -1
@cmd spawn01 "cyraxbomb2" 123 21 0
@cmd spawn01 "cyraxbomb2" 117 21 1
frame data/chars/somechar/unleash00.png

Otherwise, you do this.
Code:
anim freespecial4
delay 5
offset 66 119
@cmd spawn01 "cyraxbomb2" 117 21 1
frame data/chars/somechar/unleash00.png


Not true. setlayer is used for making the sprite cover anything or become behind while retaining its Z position. subject_to_screen is used for going near screen edges. Value 0 of it allows the entity to go offscreen while value 1 doesn't allow it.


From my testing of v3 6391, that's -5.



Are you trying to give that spawned entity the same Z position as its parent entity, but you want it to have its higher setlayer value than none or its actual value? @danno had already provided the one with the setlayer value/function. Maybe if it's not working, you could create a clone of the spawned entity which doesn't need to have setlayer value set.

P.S.: Hmmm... I think I'm beginning to get what you're trying to say. What you want is that spawned entity to be summoned at the same position as its parent entity. But you want to summon it to be more frontal than normally summoning it with spawn01 on the Z value. This got me thinking about your idea. Are you planning to make it into a 2D level for this?

C:
void spawn00layer(void vName, float fX, float fY, int layer)
{
    //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, 0+layer, fY); //Set spawn location but with a layer value based on Z.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    changeentityproperty(vSpawn, "setlayer", layer); //Set layer.
    return vSpawn; //Return spawn.
}

Anyway. I just changed the Z position value to 0 while allowing the layer value (in case the level would be 3D) because you said you want it to be at the same position as its parent entity.


sorry i am awkward explaining myself. yes it is on a 2d level, i want the spawned grenade to display infront everything wile spawning at same Z that its parent entity, if i give just a value of 1 pixel in z spawn i get the grenades to fall like this video. but if i spawn them at Z0 most of the time they display behind most things and i want to prevent that.

 
What is your level's Z limit value of numbers in levels.txt?

Is it like this?
Code:
z 200 200
file data/level/level3.txt

Or this?
Code:
z 200 201
file data/level/level3.txt

What's the depth value of the platform that Cyrax is standing on? Is it 1 or larger?

Code:
name    Ice_Floor
type    none
shadow    0
facing    1
antigravity 100
setlayer 1
offscreenkill    10500
subject_to_platform 0


anim    idle
    loop    1
    delay    3
    offset    0 15
    platform    0 15 0 0 360 360 360 15
    frame    data/chars/platforms/ice/icefloor.png
     
#|edited by openBor Stats v 0.64
 
it doesnt really matter.. could be 3d level the thing is that setlayer would allways work subject to screen and not the actual entity position wich is intended functionality i know, i was tossing the question in case there was another way.. thanks a lot for all the help guys..
 
I forgot to ask you this question. Is that thrown bomb set to subject_to_platform?

I mean this one on the platform entity.
Code:
subject_to_platform 1
 
I forgot to ask you this question. Is that thrown bomb set to subject_to_platform?

I mean this one on the platform entity.
Code:
subject_to_platform 1
yes of course, it works fine if i spawn it at Z0, it just display behind cyrax, it is not big deal, i asked in case there was an abailable functionality like the one i tryed to descrive ..
 
Back
Top Bottom