help with spawn script

jonsilva

New member
hi
iam trying to modify the spawn02 script... to work with the level panel coordinates like the ( noscpos ) does.

i cant seem to get it working...
these are the scripts
-------------noscpos
// Removes scroll pos effect
void main()
{
    void self = getlocalvar("self"); //Get calling entity.
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int XPos = openborvariant("xpos");
    changeentityproperty(self, "position", x - XPos);
}

--------------spawn02
void spawn02(void vName, float fX, float fY, float fZ)
{
//Spawns entity based on left screen edge
//
//vName: Model name of entity to be spawned in.
//fX: X distance relative to left edge
//fY: Y height from ground
      //fZ: Z location adjustment

void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
        int XPos = openborvariant("xpos"); //Get screen edge's position

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

      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.

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

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

return vSpawn; //Return spawn.
}


anyone know how to set the script to spawn the entity based on the panel coordinates ???
 
the original spawn02 script was already made this way...


but ive alreadt tried to change / and add an
fx = fx + getentityproperty(self, "x");
changeentityproperty(vSpawn, "position", fX - XPos, fZ, fY);

but the game crashes...
the best i could do so far was to get the entity spawning
in 30x pixels from the panel
 
thanks
utunnels / malik4ever

ive got it working using the targetPos example instead of the noscpos
----TargetPos------
void targetPos(float Vy, int Tx, int Tz)
{// Targetting certain position before leaping there
//  Vy : Leaping speed
//  Tx : Leaping destination x coordinate
//  Tz : Leaping destination z coordinate
// Used with 'leap' or 'toss2'
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x"); // Get entity's x coordinate
    float z = getentityproperty(self, "z"); // Get entity's z coordinate

    if(Tx < x){
      changeentityproperty(self, "direction", 0); // Face left
    } else {
      changeentityproperty(self, "direction", 1); // Face right
    }
    setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
    setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable
}

spawn05
//Spawns entity based on level panel coordinate

void spawn05(void vName, int Tx, int Ty, int Tz)
{
//Spawns entity based on level panel coordinate

    void self = getlocalvar("self");
    float x = getentityproperty(self, "x"); // Get entity's x coordinate
    float z = getentityproperty(self, "z"); // Get entity's z coordinate
void vSpawn; //Spawn object.


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

        setlocalvar("x"+self, (Tx-x));
        setlocalvar("z"+self, (Tz-z));


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


changeentityproperty(vSpawn, "position", Tx, Tz, Ty); //Set spawn location.

return vSpawn; //Return spawn.
}


the fx small cap was why i was getting most crashes...
sometimes i get confused with all this stuff...



 
jonsilva said:
anyone know how to set the script to spawn the entity based on the panel coordinates ???

Are you trying to replicate spawnframe which is set to spawn relative to camera?
I use this function:

Code:
void spawn06(void vName, float fX, float fY, float fZ)
{
	//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){ //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
}

Unlike spawn02 I made before, this one takes camera position into placing formula too. Though this function reverse's x coordinate if spawner faces left
 
thanks for the script bloodbane

Are you trying to replicate spawnframe which is set to spawn relative to camera?
I use this function:

i whanted to use the level panel coordinates instead like the (noscpos) does...
the entity iam spawning is an airduck on the level wall
it has to spawn when an enemy dies 
 
Back
Top Bottom