Jump to content
  • 0

Text above actor ?


Jaska

Question

Edit: I just go now with a copy/paste solution from Stronghold which used an exclamation mark over actors to show if they are interactable.

 

 

---------------------------------------------------------------------------------------

I found this but can't get it working:
https://zdoom.org/wiki/Hudmessageonactor

 

I have the messageOnActor.acs on /acs folder on my pk3. I compiled it to object: messageOnActor.o.. not sure if compiling is even needed. Then I have LOADACS on the root of the pk3 with messageOnActor  (or acs/messageOnActor).

 

ACS of the map:

#include "zcommon.acs"
#import "acs/messageOnActor.acs"

str laptopMSG = "Laptop";

Script 3 OPEN //Messages on actors
{

    HUDMessageOnActor(21, 1, 1920, 1080, 0, 32, 256, -1, laptopMSG, 5, CR_RED)
    //Print(s:laptopMSG);
    Delay(35);
    Restart;
}

I've also tried to

"include messageOnActor.acs"

"include messageOnActor.o"

"import messageOnActor.o"

 

HUDMessageOnActor(21, 1, 1920, 1080, 0, -32, 256, -1, laptopMSG, 5, CR_RED);

 

And different delays .. and resolution.. How to dynamically get right resolution?

---------------------------------------------------------------------------------------

 

Propably should use zscript after all?

Also found this but not need all of the functionality.. Something simple(r) would be good.
Use To Pickup:
https://forum.zdoom.org/viewtopic.php?t=61369

Edited by Jaska

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

I did a bit of playing, but couldn't get it to work (though TBH I didn't try for long). It did lead me to another variant of that function lib though:

 

https://forum.zdoom.org/viewtopic.php?p=845387

 

LATER ON...

I think the idea is to render a HUD message that tracks a thing with the givem TID - in other words, if you turn, or the thing is tracking sideways relative to you, the HUD message is positioned where that thing is. It looks like the code is supposed to work out the relative bearing of the thing compared to your current position and direction, and it's distance from you. It uses this info to print a HUD message, essentially where you can currently see the thing in current HUD view (so the end result is you see a message overlaying the sprite, which should move as - for example - the thing walks about)

 

I sort of got it working, by removing some of the conditions, and also increasing the repeat to 0.1 sec rather than 1 sec. I now see a HUD message that kind-of tracks the thing...

 

I think you probably couldn't get it working, because the script maybe doesn't work as it should? (see first comment of https://forum.zdoom.org/viewtopic.php?p=845387)


Here is the hacky script I am testing with. Note the commented out lines, to actually get something to display:

#include "zcommon.acs"
// #import "acs/messageOnActor.acs"

str laptopMSG = "Laptop";
int counter = 0;

Script 3 OPEN //Messages on actors
{
    
    log(s:"open script");
    SetFont("BIGFONT");
    HUDMessageOnActor(21, 1, 1920, 1080, 0, 32, 128, -1, laptopMSG, 50, CR_RED);
    //Print(s:laptopMSG);
    Delay(3);
    Restart;
}


//Original code by Isle
function void HudMessageOnActor(int tid, int msgID, int hudX, int hudY, int xOffset, int yOffset, int range, str sprite, str text, int holdTime, str colour)
{
    counter++;
    log(s:"calling hud msg, counter ",i:counter);
    int dist, angle, vang, pitch, x, y;
    
    if (holdTime == 0) { holdTime = 0.1; }    
    if (hudX == 0) { hudX = 640; }
    if (hudY == 0) { hudY = 480; }
    
    if(sprite != -1)
    {
        SetFont(sprite);
        text = "A";
    }
    log(s:"hud size: ",i:hudx, i:hudy);
    SetHudSize(hudX, hudY, 1);
    x = GetActorX(tid) - GetActorX(0);
    y = GetActorY(tid) - GetActorY(0);
    log(s:"thing: ",i:x,i:y);
    vang = VectorAngle(x,y);
    angle = (vang - GetActorAngle(0) + 1.0) % 1.0;
    
    if(((vang+0.125)%0.5) > 0.25) dist = FixedDiv(y, sin(vang));
    else dist = FixedDiv(x, cos(vang));
    log(s:"dist: ",i:dist);
    log(s:"angle: ",f:angle);
    
    
    //if ((angle < 0.23 || angle > 0.85) && (dist >> 16) < range)
    //{
        log(s:"in range...");
        if (GetActorPitch(0) >= -0.5 && GetActorPitch(0) <= 0.5)
        {
            log(s:"pitch range OK");
            pitch = VectorAngle(dist, GetActorZ(tid) - (GetActorZ(0) + GetActorViewHeight(0)));
            pitch += FixedMul(GetActorPitch(0), 1.2) % 1.0;
 
            //if ((hudX/2) * sin(angle) != 0 && cos(angle) != 0 && (hudX/2) * sin(pitch) != 0 && cos(pitch) != 0)
            //{
                
                x = hudX/2 - ((hudX/2) * sin(angle) / cos(angle));
                y = hudY/2 - ((HUDX/2) * sin(pitch) / cos(pitch));
                
                x+=xOffset;
                y+=yOffset;
                log(s:text);
                HudMessage(s:text; HUDMSG_PLAIN, msgID, colour, (x << 16), (y << 16), holdTime);
                
            //}
            
        }
        
    //}
}


This might give you a starting point, though I think the logic around the angle calculations might not be correct (or my interpretation of what this should be doing is not correct...)
 

Also: see this for getting HUD size at runtime:

https://zdoom.org/wiki/GetScreenWidth

 

Note I was doing this inside a WAD file.

 

For PK3, put the script in /acs/myscripts.acs and in a LOADACS lump in the root, just add myscripts. The named script lib will be laoded (you will of course need to compile with ACC)

Edited by smeghammer

Share this post


Link to post
  • 0

Thanks. Odd I missed that thread, did a bit searching. Tried your and couple variants and couldn't still get them working. I'm happy with the exclamation mark solution for now, it is kind of better as being "general/generic" instead of text. But I may come back to this if there is some other uses.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...