Why Spawn01 Script never works for me?

Bruce

Active member
I am trying to use the script below, but it has never worked for me for some reasons.
My game resolution is 960 x 544.

Either this spawn0("SummonX", 200, 50, 0);
or this @cmd spawn0 "SummonX" 200 50 0
NEVER WORKED!



The only thing that has worked:
Code:
anim    freespecial9
    summonframe 1 900 0 1000 0
    custentity SummonX
    .....
    .....

Even so it still does not make sense to me as SummonX spawns
at about X: 50 Y: 10 to the left side of the player instead of
at X:900 Y:1000 to the right side of the player (if I understood it correctly).

I can't see SummonX on the screen if I use this code, WHY???:
Code:
anim    freespecial9

    summonframe 1 0 0 0 0
    custentity SummonX
    .....
    .....


My goal is to be able to use Bloodbane's script.
Can someone please please help?
Thank you so much

Script by Bloodbane
from: Spawn01 Script

Code:
void spawn0(void vName, float fX, float fY, float fZ)
{
    //Spawns entity at defined coords
    //
    //vName: Model name of entity to be spawned in.
    //fX: X coordinate
    //fY: Y height from ground
        //fZ: Z coordinate

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.

    clearspawnentry(); //Clear current spawn entry.
        setspawnentry("name", vName); //Acquire spawn entity by name.

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    return vSpawn; //Return spawn
}
 
Solution
SummonX drops down from the top of the screen down to the ground.

Well, you spawn it 700 pixels above the ground, so if it's affected by gravity it will fall.
How do I spawn SummonX relative to the screen (which is always 960 x 544 regardless at which section of the level I am at)
and have it stayed still at this this location until its lifespan runs out?

Both spawnframe and summonframe has 5th parameter which if set to 1, will spawn entity relative to screen.
For script based spawning, you should use this:
C:
void spawn06(void vName, float fX, float fY, float fZ, int Flag)
{
    //Spawns entity based on left screen edge and z axis
    //Auto adjust with camera's position
    //vName: Model name of entity to be...
So I need to load SummonX on both Model.txt and in the player header?

either in models or player header, no need for both

at about X: 50 Y: 10 to the left side of the player instead of
at X:900 Y:1000 to the right side of the player (if I understood it correctly).

check the SummonX entity's offset also as spawning in this way works via the spawning entity's offset too.
 
either in models or player header, no need for both



check the SummonX entity's offset also as spawning in this way works via the spawning entity's offset too.
I have already had SummonX loaded in the models.txt
I just checked the SummonX offset and its offet is in the center of the bottom of its actually image.
I just can't figure out why this code works as the values are out of the game resolution range. Iit just does not make any sense :-(

Code:
anim    freespecial9
    summonframe 1 900 0 1000 0
    custentity SummonX
    .....
    .....

Thank you
 
Either this spawn0("SummonX", 200, 50, 0);
or this @cmd spawn0 "SummonX" 200 50 0
NEVER WORKED!

First of all, that spawn0 function spawns entity spawns at specified coordinate NOT relative to spawning entity. Therefore if you spawn it when you are at scrollpos higher than 200, you won't see it cause it's spawned at exactly x=200 and y=50 which is to the left of screen or behind.
summonframe and spawnframe OTOH spawns relative to spawner so depending on your resolution and position, you might see the spawned entity.

So do you want to spawn summonX relative to spawner, relative to screen or at specified coords?

I just can't figure out why this code works as the values are out of the game resolution range

I have guesses on what summonX could be but can you elaborate more about it?
 
First of all, that spawn0 function spawns entity spawns at specified coordinate NOT relative to spawning entity. Therefore if you spawn it when you are at scrollpos higher than 200, you won't see it cause it's spawned at exactly x=200 and y=50 which is to the left of screen or behind.
summonframe and spawnframe OTOH spawns relative to spawner so depending on your resolution and position, you might see the spawned entity.

So do you want to spawn summonX relative to spawner, relative to screen or at specified coords?
I finally figured that out last night after trials and errors before reading this. Yes you are right that the spawn0 function only spawns SummonX at the specifc coords, but my level is 3000+ big in size. This is why I was only able to see SummonX at the beginning of the stage. I think I figured out how to spawn SummonX relative to the spawner now.

Now I am having another issue with spawning SummonX.
When I set
Code:
spawn0("SummonX", 950, 700, 600);
SummonX drops down from the top of the screen down to the ground.

How do I spawn SummonX relative to the screen (which is always 960 x 544 regardless at which section of the level I am at)
and have it stayed still at this this location until its lifespan runs out?
In another words, if I set the SummonX (which is the trap) to spawn at X: 480 Y: 272 relative to the screen,
SummonX should be spawned around the middle of the screen and stays there until lifespan runs out regardless at which section of the level I am at.
lol I am still trying to understand about the Z vallue :-(
I hope this makes sense to you.
I greatly appreciate for your help, thank you
 
SummonX drops down from the top of the screen down to the ground.

Well, you spawn it 700 pixels above the ground, so if it's affected by gravity it will fall.
How do I spawn SummonX relative to the screen (which is always 960 x 544 regardless at which section of the level I am at)
and have it stayed still at this this location until its lifespan runs out?

Both spawnframe and summonframe has 5th parameter which if set to 1, will spawn entity relative to screen.
For script based spawning, you should use this:
C:
void spawn06(void vName, float fX, float fY, float fZ, int Flag)
{
    //Spawns entity based on left screen edge and z axis
    //Auto adjust with camera's position
    //vName: Model name of entity to be spawned in.
    //fX: X distance relative to left edge
    //fY: Y height from ground
      //fZ: Z coordinate

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

   if (Direction == 0 && Flag==1){ //Is entity facing left?                  
      fX = Screen-fX; //Reverse X direction to match facing and screen length
   }

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX + XPos, fZ + YPos, fY); //Set spawn location.
    return vSpawn; //Return spawn
}
 
Solution
Well, you spawn it 700 pixels above the ground, so if it's affected by gravity it will fall.


Both spawnframe and summonframe has 5th parameter which if set to 1, will spawn entity relative to screen.
For script based spawning, you should use this:
C:
void spawn06(void vName, float fX, float fY, float fZ, int Flag)
{
    //Spawns entity based on left screen edge and z axis
    //Auto adjust with camera's position
    //vName: Model name of entity to be spawned in.
    //fX: X distance relative to left edge
    //fY: Y height from ground
      //fZ: Z coordinate

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

   if (Direction == 0 && Flag==1){ //Is entity facing left?                  
      fX = Screen-fX; //Reverse X direction to match facing and screen length
   }

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX + XPos, fZ + YPos, fY); //Set spawn location.
    return vSpawn; //Return spawn
}

This is what I wanted and it is working perfectly,
Thank you so much for your help.
God bless you!
 
Back
Top Bottom