MZ Icon over player's head?

Hello, looking for a solution to display icon over player's head for RMMZ. I know it's part of Visustella's Event Core, but sadly it has problems working with AnimaX by @Pheonix KageDesu, so looking for alternative. I found this topic and used piece of code by @ct_bolt and it works, I mean, it shows the icon on screen, but I have no idea how to "attach" it to the player's head. I'll be honest, I tried to help myslef with chat gpt, and I've managed to move the icon depending on player coords, but the problem is the icon does not move when player reach the map edges - it stay in the middle and move only while map is scrolling.

Anyone have any solution for displaying icon over player's head?
Maybe there's a plugin I don't know for RMMZ instead of Visustella's one?
you could go an entire different way...

make that icon into an animation (right-click on an empty animation slot, select MV compatible data.
then use an image program to change the icon into the MV animation picture format and build your animation above a targets head)
after that, show animation on player with wait for completion parallel process

no plugin needed at all, you just have to make the animation at least 5 to 10 frames to reduce the lag with the wait for completion
Thanks for the answer @Andar, but I can't do that like this, I mean, I need this for "carry item" solution, like the player can carry all different things, so making an animations for every single item from database could be a pain. Also, I need this to be there on all maps when you wander around, I think the animation will dissappear when you change the map using teleport.
I think the animation will dissappear when you change the map using teleport.
depends on how you do this, done correctly it just resets on map change.
but I agree, doing this for every item would be a lot of work.

I don't know what plugins exist for MZ, but you might look for a "visual equipment" type of plugin. Those usually overlay an armor picture based on equipment slots, but they might be adapted to show an item beased on a fictive "carry slot". It would at least be a start for something
Thanks. Yeah thats what AnimaX do (the plugin that I'm suing), but I still hit the wall because I would need to create ~100 items to "wear" to represend carried items. Thats why I want to made it by icons and use iconsheet for this.
I'll be honest, I tried to help myslef with chat gpt
As a general statement, that's not useful. The percentage of AI-generated code we've seen around here that functions at all is very low - it's like asking a middle schooler to help with your calculus homework. They might write some of the right numbers by accident.

the icon does not move when player reach the map edges - it stay in the middle and move only while map is scrolling.
That's the intention of the plugin you linked to - it draws the icon to the screen. It's like using Show Picture.

You could certainly submit it to VS as a feature request - events and the character come from the same data type, so it should be easy for them to add player as an option for the plugin command to attach the icon.

But here you go.

Code:
function PlayerIcon(iconId)
{
    let playerSprite, sprites = SceneManager._scene._spriteset._characterSprites;

    for (let i = 0; i < sprites.length; i++)
    {
        if (sprites[i]._character == $gamePlayer)
        {
            playerSprite = sprites[i];
            break;
        }
    }
    playerSprite.headIcon = new Sprite();
    playerSprite.headIcon.bitmap = ImageManager.loadSystem('IconSet');
    let pw = ImageManager.iconWidth;
    let ph = ImageManager.iconHeight;
    let sx = iconId % 16 * pw;
    let sy = Math.floor(iconId / 16) * ph;
    playerSprite.headIcon.setFrame(sx, sy, pw, ph);
    playerSprite.headIcon.anchor.x = 0.5;
    playerSprite.headIcon.anchor.y = 2.5;
    playerSprite.addChild(playerSprite.headIcon);
};

So you can do a Script command PlayerIcon(3):
1729261195210.png
have you tried Picture Sequences by Pheonix KageDesu?
as it might be compitable with AnimaX
have you tried Picture Sequences by Pheonix KageDesu?
as it might be compitable with AnimaX
Didn't know about this, but this would still force me to have all item icons to be images - I would like to avoid this as much as possible and use Iconset. But anyway, thank you so much!

As a general statement, that's not useful. The percentage of AI-generated code we've seen around here that functions at all is very low - it's like asking a middle schooler to help with your calculus homework. They might write some of the right numbers by accident.


That's the intention of the plugin you linked to - it draws the icon to the screen. It's like using Show Picture.

You could certainly submit it to VS as a feature request - events and the character come from the same data type, so it should be easy for them to add player as an option for the plugin command to attach the icon.

But here you go.

Code:
function PlayerIcon(iconId)
{
    let playerSprite, sprites = SceneManager._scene._spriteset._characterSprites;

    for (let i = 0; i < sprites.length; i++)
    {
        if (sprites[i]._character == $gamePlayer)
        {
            playerSprite = sprites[i];
            break;
        }
    }
    playerSprite.headIcon = new Sprite();
    playerSprite.headIcon.bitmap = ImageManager.loadSystem('IconSet');
    let pw = ImageManager.iconWidth;
    let ph = ImageManager.iconHeight;
    let sx = iconId % 16 * pw;
    let sy = Math.floor(iconId / 16) * ph;
    playerSprite.headIcon.setFrame(sx, sy, pw, ph);
    playerSprite.headIcon.anchor.x = 0.5;
    playerSprite.headIcon.anchor.y = 2.5;
    playerSprite.addChild(playerSprite.headIcon);
};

So you can do a Script command PlayerIcon(3):
Thank you so much @ATT_Turan, this is super helpful for me, also for learning purposes. I agree that code made by chat gpt can be...let'c call it tricky, that's why I'm even more glad that I have your help here. It works fantastic! The only problem I still have is that I would like to be able to provide a variable X as an argument, so that instead of PlayerIcon(number), I could just call PlayerIcon() and the function would always take the icon number from the variable. Can you help me do this? I'm trying to figure it out myself, but I'm not very talented when it comes to programming/coding (as you can probably tell xD)...

Regardless, thank you both of you very much again!
The only problem I still have is that I would like to be able to provide a variable X as an argument, so that instead of PlayerIcon(number), I could just call PlayerIcon() and the function would always take the icon number from the variable.
I don't see what the problem is, just supply the variable as the argument.
Code:
PlayerIcon($gameVariables.value(45))

And if it's always the same, then you can copy that line someplace and paste it in whenever you need it. Or put the script call in a common event and never worry about it again, just call the common event.
I don't see what the problem is, just supply the variable as the argument.
Code:
PlayerIcon($gameVariables.value(45))

And if it's always the same, then you can copy that line someplace and paste it in whenever you need it. Or put the script call in a common event and never worry about it again, just call the common event.
I really tried that, only now I realized that I typed "gameVariable" instead of "gameVariables"... Again, thank you so much for the help!

@ATT_Turan, I don't want to be greedy, but is there a solution to clear the icon? I tried tochange it to 0, but looks like it's stacking the icons, not deleting/overwriting them.
You only asked for a solution to display an icon over the player's head, you never said you wanted it to go away 😛

This version should remove it if you pass 0 for the argument.

Code:
function PlayerIcon(iconId)
{
    let playerSprite, sprites = SceneManager._scene._spriteset._characterSprites;

    for (let i = 0; i < sprites.length; i++)
    {
        if (sprites[i]._character == $gamePlayer)
        {
            playerSprite = sprites[i];
            break;
        }
    }
    if (iconId == 0)
    {
        if (playerSprite.headIcon)
        {
            let icon = playerSprite.headIcon;
            playerSprite.removeChild(icon);
            icon.destroy();
        }
        return;
    }

    playerSprite.headIcon = new Sprite();
    playerSprite.headIcon.bitmap = ImageManager.loadSystem('IconSet');
    let pw = ImageManager.iconWidth;
    let ph = ImageManager.iconHeight;
    let sx = iconId % 16 * pw;
    let sy = Math.floor(iconId / 16) * ph;
    playerSprite.headIcon.setFrame(sx, sy, pw, ph);
    playerSprite.headIcon.anchor.x = 0.5;
    playerSprite.headIcon.anchor.y = 2.5;
    playerSprite.addChild(playerSprite.headIcon);
};
You only asked for a solution to display an icon over the player's head, you never said you wanted it to go away 😛
You're right 😅 Works like a charm, thank you!
As a general statement, that's not useful. The percentage of AI-generated code we've seen around here that functions at all is very low - it's like asking a middle schooler to help with your calculus homework. They might write some of the right numbers by accident.


That's the intention of the plugin you linked to - it draws the icon to the screen. It's like using Show Picture.

You could certainly submit it to VS as a feature request - events and the character come from the same data type, so it should be easy for them to add player as an option for the plugin command to attach the icon.

But here you go.

Code:
function PlayerIcon(iconId)
{
    let playerSprite, sprites = SceneManager._scene._spriteset._characterSprites;

    for (let i = 0; i < sprites.length; i++)
    {
        if (sprites[i]._character == $gamePlayer)
        {
            playerSprite = sprites[i];
            break;
        }
    }
    playerSprite.headIcon = new Sprite();
    playerSprite.headIcon.bitmap = ImageManager.loadSystem('IconSet');
    let pw = ImageManager.iconWidth;
    let ph = ImageManager.iconHeight;
    let sx = iconId % 16 * pw;
    let sy = Math.floor(iconId / 16) * ph;
    playerSprite.headIcon.setFrame(sx, sy, pw, ph);
    playerSprite.headIcon.anchor.x = 0.5;
    playerSprite.headIcon.anchor.y = 2.5;
    playerSprite.addChild(playerSprite.headIcon);
};

So you can do a Script command PlayerIcon(3):
View attachment 320774
if you could do this available for events too.. it would be awesome!

@TheRamenGirl, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/icon-over-players-head.172673/