Spawn Event based on Player HP script help

Aerisetta

Active member
Hello

I made a script but it does not trigger what I want.

This is an enemy attack
If the enemy successfully attacks the player and enters grab (follow 1), I want it to spawn06 this event IF the player has 90HP

Right now, nothing happens, no crash or errors though

Code:
anim    follow1
@script
  if(frame==1){
    void self = getlocalvar("self");
    void target = getentityproperty(self,"opponent");
    int THP = getentityproperty(target,"health");

    if(THP == 90){
      spawn06("LoseAerisettaL1", 800, 0, 800);
    }
  }
@end_script
    quakeframe    4 5 1
    jumpframe    0 0 0
    @cmd    slamstart2
    @cmd    position 1 65 -20 0 0
    delay    20
    offset    800 620
    sound    data/sounds/punch_.wav
    frame    data/chars/badgirl/grab02.png
    @cmd    position 2 0 0 0 0
    frame    data/chars/badgirl/grab03.png
    delay    10
    frame    data/chars/badgirl/grab03.png
    #@cmd    position 2 110 0 0 0
    @cmd    setglobalvar "zoomentity" NULL()
    @cmd    hurt 5
    frame    data/chars/badgirl/grab03.png
    @cmd    finish 2 2 -5 5 0 0
    @cmd    depost 0
    @cmd    clearGrab
    delay    10
    frame    data/chars/badgirl/grab03.png
 
Hello @Aerisetta


HMM. I have seen that you have if(frame == 1) is executed on the second frame.

it means that a damage will be executed when having more than the specific life. and otherwise create the entity on the screen. But if it is an entity that shows an animation on the full screen, it needs a couple of adjustments.

This is the script you use, right?
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
}

Well the script has the ability to create an entity at the position of the screen, but it also has a flip function depending on where the entity calling the script is looking at.

To solve this you must the image must have the offset in the exact middle of the image, both in x and y. and it will work for sure

but the image will flip if the entity looks the other way
 
Here is a version without reversing the images, in flag you must put 0

void sreenspawn(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
//flag: 1 for reverse, 0 spawn the entity with no reverse funcion
//Make by Blade Master :D

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 (flag == 1 && 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
}
 
I want it to spawn06 this event IF the player has 90HP

This requirement is very strict. If player has slightly different health, the spawn06 script won't be run.
Maybe you need to give health range check instead such as:
C:
   if(THP >= 81 && THP < 95){
      spawn06("LoseAerisettaL1", 800, 0, 800);
    }
 
Back
Top Bottom