Spawn text after taking an item

Chris Monvel

Active member
Hello people! I'm sorry if i'm creating a new thread but this subject seems to be no longer available in the forum.

As the title implies I want to spawn a text file containing some info like "You've got a special item" after picking it up. I got a script as a suggestion from certain user but i can't find it anymore at the forum. Also I'm terrible at trying to understand scripts so I'd appreciate some further explanation like "scripts for dummies".
 
Hello @Chris Monvel

I have some tools that may help you. The video explains how to apply the script to spawn text entities during item pickup, and you can download all files below.
I hope it can be useful :)

Spawn Text.zip

Thanks. It worked great and all but my idea was to spawn a text entity, not a real text per se. Does it work too? If so, what values should i replace? I want to emulate the files from the Resident Evil games.
 

Attachments

  • 847658-resident-evil-playstation-4-screenshot-various-memos-and-diaries.jpg
    847658-resident-evil-playstation-4-screenshot-various-memos-and-diaries.jpg
    81.4 KB · Views: 9
Last edited:
Thanks. It worked great and all but my idea was to spawn a text entity, not a real text per se. Does it work too? If so, what values should i replace? I want to emulate the files from the Resident Evil games.
@Chris Monvel

Yes, it works too. In fact, at the moment you pick up the item, an entity will be spawned and there's a "ondraw" script to write the text on the screen while this entity is alive.
But I made some changes to make it more like RE type, please let me know if it's what you need.


 
Last edited:
I've tested it and it's perfect!! Just as a last question, if i copy those scripts into the folder where i placed the original ttext scripts these won't be replaced right? These new RE type ones work on their own, right?
 
I've tested it and it's perfect!! Just as a last question, if i copy those scripts into the folder where i placed the original ttext scripts these won't be replaced right? These new RE type ones work on their own, right?
Great, I'm glad that the script worked :)

To join all scripts in the same folder, you will need to carefully mix the animation.c file because in the RE version I moved the spawnScreen, spawnText and spawn01 scripts to the same file. Or you can simply rename each script file (don't forget to change the text entity header too) and maintain both working.

In addition, the "text" entity has some differences, I suggest rename both and in order to create two versions (something like text1 and text2).
 
Great, I'm glad that the script worked :)

To join all scripts in the same folder, you will need to carefully mix the animation.c file because in the RE version I moved the spawnScreen, spawnText and spawn01 scripts to the same file. Or you can simply rename each script file (don't forget to change the text entity header too) and maintain both working.

In addition, the "text" entity has some differences, I suggest rename both and in order to create two versions (something like text1 and text2).
Alright! Amazing contribution. Thank you so much for your time and patience! 😁
 
Hi @Kratus I know it's annoying reviving old posts with newer information but i just noticed something unusual. I created a special item which, when picked up, serves a 1up item and spawning a text image. This is a modified version of your RE files you created for me some time ago. I noticed at first it worked perfectly, but then while playing other levels and picking the item up, the text spawned on different placements. I thought the text entity was supposed to be binded to the screen no matter the item was placed.

 
Hi @Kratus I know it's annoying reviving old posts with newer information but i just noticed something unusual. I created a special item which, when picked up, serves a 1up item and spawning a text image. This is a modified version of your RE files you created for me some time ago. I noticed at first it worked perfectly, but then while playing other levels and picking the item up, the text spawned on different placements. I thought the text entity was supposed to be binded to the screen no matter the item was placed.

Hi @Chris Monvel , yes I remember the text spawn script. Please, can you post both the current code and entity you are using? It seems that the X position is fine, buth the Y is wrong, right?

I updated the spawnscreen inside the animation.c, please try replacing with this new one.

C:
void spawnScreen(void name, float fX, float fY, float fZ, int dir, void ani)
{//Spawn entity at specific location relative to xPos and yPos
    void self    = getlocalvar("self");
    void vSpawn    = spawn01(name, 0, 0, 0, 0, dir, NULL(), NULL(), ani);
    float xPos    = openborvariant("xpos");
    float yPos    = openborvariant("ypos");

    fX = xPos+fX;
    fY = yPos+fY;
    fZ = yPos+fZ;
    changeentityproperty(vSpawn, "position", fX, fZ, fY);
}
 
Last edited:
Hi @Chris Monvel , yes I remember the text spawn script. Please, can you post both the current code and entity you are using? It seems that the X position is fine, buth the Y is wrong, right?

I updated the spawnscreen inside the animation.c, please try replacing with this new one.

C:
void spawnScreen(void name, float fX, float fY, float fZ, int dir, void ani)
{//Spawn entity at specific location relative to xPos and yPos
    void self    = getlocalvar("self");
    void vSpawn    = spawn01(name, 0, 0, 0, 0, dir, NULL(), NULL(), ani);
    float xPos    = openborvariant("xpos");
    float yPos    = openborvariant("ypos");

    fX = xPos+fX;
    fY = yPos+fY;
    fZ = yPos+fZ;
    changeentityproperty(vSpawn, "position", fX, fZ, fY);
}
Yeah! Its named "Sandwich" and contains this:

-------------------------------------------------------------------------------------
#import "data/scripts/animation.c"

void main()
{
spawnScreen("sandwich_image", 0, 0, 0, 1, "ANI_FOLLOW1");
}
--------------------------------------------------------------------------------------


The image contains this:

--------------------------------------------------------------------------------------
name sandwich_image
type text
shadow 0
setlayer 1000000001
palette data/chars/files/sandwich_image.gif

anim idle
loop 0
delay -1000
offset 0 0
frame data/chars/files/empty.png

anim follow1
loop 0
delay -1000
offset 0 -5
frame data/chars/files/sandwich_image.gif

anim follow2
loop 0
delay -1000
offset 0 0
frame data/chars/files/empty.png
-----------------------------------------------------------------------------------------
 

Attachments

  • sandwich_image.gif
    sandwich_image.gif
    9.6 KB · Views: 1
Last edited:
Yeah! Its named "Sandwich" and contains this:

-------------------------------------------------------------------------------------
#import "data/scripts/animation.c"

void main()
{
spawnScreen("sandwich_image", 0, 0, 0, 1, "ANI_FOLLOW1");
}
--------------------------------------------------------------------------------------


The image contains this:

--------------------------------------------------------------------------------------
name sandwich_image
type text
shadow 0
setlayer 1000000001
palette data/chars/files/sandwich_image.gif

anim idle
loop 0
delay -1000
offset 0 0
frame data/chars/files/empty.png

anim follow1
loop 0
delay -1000
offset 0 -5
frame data/chars/files/sandwich_image.gif

anim follow2
loop 0
delay -1000
offset 0 0
frame data/chars/files/empty.png
-----------------------------------------------------------------------------------------
@Chris Monvel Please, try replacing the spawnScreen script with the new one I posted and let me know if it solves the issue.
If I'm not wrong it's in the path "data/scripts/animation.c".
 
Oh I'm so sorry! :( I terribly suck at scripts

Well I tried and still the same
Maybe there's something in your game that is interfering in the script, I tested in a basic BOR mod and works fine.
The script will get the exact screen coordinates but maybe the position is changed by another script or native function. I can take a look at your game files if you want, I'm curious to discover what's happening.
 
Maybe there's something in your game that is interfering in the script, I tested in a basic BOR mod and works fine.
The script will get the exact screen coordinates but maybe the position is changed by another script or native function. I can take a look at your game files if you want, I'm curious to discover what's happening.
Yeah no problem! I'll send you a PM
 
Yeah no problem! I'll send you a PM
@Chris Monvel I discovered where the issue is, you have a big variety of Z range values, so I adapted the script for this kind of situation.
Please, replace the spawnScreen code with this new one, I tested and it fixed with the Jill's Sandwich.

C:
void spawnScreen(void name, float fX, float fY, float fZ, int dir, void ani)
{//Spawn entity at specific location relative to xPos and yPos
    void self    = getlocalvar("self");
    void vSpawn    = spawn01(name, 0, 0, 0, 0, dir, NULL(), NULL(), ani);
    float xPos    = openborvariant("xpos");
    float yPos    = openborvariant("ypos");
    float z       = getentityproperty(self, "z");

    fX = xPos+fX;
    fY = z-yPos+fY;
    fZ = z+fZ;
    changeentityproperty(vSpawn, "position", fX, fZ, fY);
}

1687936328867.png
 
Guys, I've checked spawnScreen script and there's simpler solution, which is this:
C:
void spawnScreen(void name, float fX, float fY, float fZ, int dir, void ani)
{//Spawn entity at specific location relative to xPos and yPos
  void vSpawn    = spawn01(name, 0, 0, 0, 0, dir, NULL(), NULL(), ani);
  float xPos    = openborvariant("xpos");
  float yPos    = openborvariant("ypos");

  fX = xPos+fX;
  fZ = yPos+fZ;
  changeentityproperty(vSpawn, "position", fX, fZ, fY);
}

Yes, I only omitted fY adjustment line to solve it (aside of omitting self).
 
Back
Top Bottom