Scripts / [SOLVED] prompt on top of NPC head.

Author
Message
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Nov 2021 16:42
How can i prompt text above the head of the NPC
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

The author of this post has marked a post as an answer.

Go to answer
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Nov 2021 19:32
use decals is the easiest solution.. working out 2D placement in a 3D world is not simple without some dedicated commands...
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 10th Dec 2021 22:21
Yeah, decals best bet.
Unreal bypasses poly meshing and directly shines the scene into the "camera" or actually
I'd say onto your device screen with their Nanite technology, so they must be the divine
purveyors of 3d to 2d. They seem to have invented an artificial eye graphics engine.

In other words, a single 220 poly sword or a 22 Million poly scene both render the same.
At least it seems like they say that. https://www.youtube.com/watch?v=qC5KtatMcUw
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 05:10 Edited at: 11th Dec 2021 06:10
Yes, the only thing i want to do at this time is to have and indicator of some sort above the NPC head when they are looking at player and shooting the Player, witch i got right at this point but only with Promtplocal. So the Player will see a indicator of some sort if he is i looking in the direction of an NPC witch are shooting at that moment, because some times in my game it is not always clearly visible witch npc is shooting at the player, i want the player to have an idea witch Npc is shooting at him. So for now i am using Promptlocal and as you can se in this picture i have a white star under the NPC
https://forum.game-guru.com/attachment/29311
So it would be nice to have it above the NPC to give a better indication were he is, especially if the scene is pact full of entities or in a bush scene.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 11th Dec 2021 09:00
best bet if you want to stick with text is put it on github to ask for an x and y offset to the prompt local command
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 11:00
Hey Smallg thanks for the reminder of github
I just requested it on github // x and y offset to the prompt local command in GG Classic #1662
Lets hope this is something small that can be fixed easily
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 11:41 Edited at: 11th Dec 2021 11:49
You may find this interesting:
https://forum.game-guru.com/thread/219297#msg2595380

Edited to add: Attached decals for use with script
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 12:04 Edited at: 11th Dec 2021 12:14
Thanks AmenMoses, i was just busy testing the previous script but did not see any thing.

Ok:.. my brain just went in to a flat spin. hahaha how do i attach the decals and health bar script
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 19:09 Edited at: 11th Dec 2021 19:17
IIRC (was some time ago) just drop the decals into the level and attach the script to them.

Aha, I seem to be missing a decal and I think it need an additional line added to the characters AI script to trigger them.

I'll see if I can track down the example fpm I made.

Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 19:18 Edited at: 11th Dec 2021 19:25
Ok, i dropped the decals in and attached the health_bar script on to both of them but do not see any thing on the npc.

Quote: "I'll see if I can track down the example fpm I made."

Thanks a lot
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 19:22 Edited at: 11th Dec 2021 19:25
Right, forget that script and use the ones attached

Attach those to the appropriate decals then add the following line to your characters AI script:

AI_Attach_health_bar ( e )

Put it as the first line in the _main part
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 19:30
ok i have attach the scripts to the red and green decal but still nothing, decals still visible at start
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 19:39 Edited at: 11th Dec 2021 19:41


have put inside ai_slodier but still nothing
only green decal becomes smaller were it is placed on map.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 19:50
Ok so scrub all that, my scripts are so old they no longer work with GG so I am fixing them, stay tuned.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 19:52
ok after insert line in ai_soldier script when start red decal not visible but green is, once NPC are shot then red decal visible again at start point
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 19:55
Quote: "Ok so scrub all that, my scripts are so old they no longer work with GG so I am fixing them, stay tuned."

Thank you AmenMoses you are supper cool.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 20:24 Edited at: 11th Dec 2021 21:37


Right so that's what it looks like now.

Attach script to decals

In the AI script put the line:
AttachHealthBar( e )
in _main function

Now set the decals to be:
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 20:30 Edited at: 11th Dec 2021 20:32
And now it should work.

Oh and put down say 10 red ones and 10 green ones and they should get attached to the characters automagically as they get close enough.

If you only want them showing on the guy shooting at you then you would need to figure out that logic yourself, not sure how you actually figure out who is shooting at you though.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 20:39
Thanks a lot will test quickly.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 21:37
Thank You are the best. its working fine.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Dec 2021 21:38
Updated the script and attached the new version to the post above.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 11th Dec 2021 23:34 Edited at: 11th Dec 2021 23:47
Thank you so much AM.
I have inserted the funtion AttachHealthBar( e ) in the module_combatcore.lua script here , were i also use PromptLocal(e,"*")

So now the health bar only gets activated as soon as a Npc starts to shoot. ( nice )
I wil just have to find a way to stop showing the health bar if the Npc do not shoot.
At this point the PromptLocal(e,"*") only Prompt as long as they shoot but
once the health bar is attached it stay attached , i cant get it to stop showing as with the PromptLocal(e,"*")


Thanks again for all the hard work.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Dec 2021 11:48
That's a clever solution, later I'll show you an even cleverer one which doesn't involve editing the module_combatcore.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Dec 2021 12:03 Edited at: 12th Dec 2021 12:17
@AmenMoses, is it possible you can make the script so that after the AttachHealthBar( e ) is activated in the ai_soldier script that i can hide or un hide the decals at anytime lets say with a variable from another script.
I have tried to do that and has failed in every attempt.
I have tried to pick up a variable from in the module_combatcore.lua script ( healthbar = 1 )
It is were I PromptLocal(e,"*") . the PromptLocal for some reason works and goes on and off at the same
time the soldier fires but i can get it right with the variable


I know you have already give so much, but i tried i can not get it right.
Thank you in advanced.

edited: sorry i only saw this now
Quote: "That's a clever solution, later I'll show you an even cleverer one which doesn't involve editing the module_combatcore. "


edited :.. Oh and before i forget the Prompt on the bottom of the screen that prompts 0 or 1 is the
variable healthbar = 1. On the video you can see with more than one soldier it does not prompt the variable correctly.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Dec 2021 13:08 Edited at: 12th Dec 2021 13:09
This post has been marked by the post author as the answer.
Try this one

Btw, undo all the changes you made to the combatcore module
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Dec 2021 14:16
Thanks , im testing quickly
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Dec 2021 14:19
See if you can figure out how it works.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Dec 2021 14:27
Mr AmenMoses. ..... ( Guru AmenMoses ) You are the Man. this script work brilliantly ,
It is supper cool.
It shows when they shoot. When i am out off range only the soldiers who are in range display the bar and even after i shot them it still shows the green and reed bars perfectly with four NPC.

Video will follow.
Thanks you have a big heart.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Dec 2021 14:32
Quote: "See if you can figure out how it works. "

Got some homework to do
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Dec 2021 14:44 Edited at: 12th Dec 2021 14:58
I guess the clever part of the script to interact with combatcore module might be happening here. ( i hope so ) together with the rest.


Again AmenMoses Thank you.

edited:... Here is the video.

Its so nice the health barr indicators also stop displaying when the Npc are reloading. cool.
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Dec 2021 14:55
Yep, it shows how you can override the functions in the module so you can do some extra processing without having to edit them.

The same trick can be used with the gameplayercontrol.lua btw.

For the rest I added a timer so that if an AI stops attacking for more than 0.5 seconds then the bars are removed.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 16th Dec 2021 14:50 Edited at: 16th Dec 2021 14:52
I almost broke GG with this . hahaha.


The idea was to stop the ai while he was doing a way point and to get him to stand still. haha
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2021 18:16 Edited at: 16th Dec 2021 18:16
The only way of interfering with the waypoint traversing code would be to override that part of the module.

i.e. module_combatcore.patrol

Just to be clear as to what my script is doing, the way the combatcore module has been written it uses global function definitions so they are stored in the global environment list.
So everytime Lua sees 'module_combatcore.fireweapon' in a script it will go look up in the global list to see what it is.
This means that if you overwrite the global list entry for 'module_combatcore.fireweapon' with your own function that will be executed instead.
But as we still need to call the *real* function then we make a copy of it so we can still call it ourselves.

Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2021 18:32
Btw anyone reading that should now understand how dangerous the use of globals can be!

For example let's say that you write a script with a bit of math and you want to get the sin of a value.

So you want to do something like:
sin = math.sin( ang )

But maybe due to a bit of sloppy cut and paste what you actually put in the script is:
math.sin = math.sin( ang )

Now when you test your script Lua with crash out with an error saying math.sin isn't a function (because you have just redefined it to be a number value!).
The error may be picked up by a completely different script being executed (the very next one that uses math.sin in fact) and you can waste a hell of a lot of time trying to track it down!

As you can redefine anything in the global environment, usually entirely by accident, the safest thing to do is make everything local and in fact to be super safe make local copies of globals that you want to use.

For example you will find things like:
local timeNow = g_Time

In my scripts, this makes a local copy of the global time value (the number of milliseconds since game start) which I will then use throughout the rest of the script, not only does this avoid any possibility of my script overwriting g_Time (and potentially screwing up any scripts run after it) but accessing a local copy is way faster than Lua having to keep looking up the variable in the global list!
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 16th Dec 2021 19:23
were in your script do you get the Characters entity numbers with out modifying the ai script.?

Also i have modify my script and it gives me the following error.

Here is my script
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2021 20:12
Did you miss this bit: ".. make sure the parameter lists are the same!"?

module_combatcore.patrol takes a lot of parameters!

All these in fact:
( e, AIObjNo, PlayerDist, MoveType, CanFire, detectstate, stopstate, combattype )
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2021 20:13
And to answer your other question, the callers of the function pass in the 'e' value.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 16th Dec 2021 20:38
Quote: "And to answer your other question, the callers of the function pass in the 'e' value."

i understand that the entity number is stored in the "e" values, what i meant was where in that one script are you able to get all the current active ai soldier's "e" values without having to modify the soldier script in that way so that you can get all the "e" values and use them accordingly, while the script is not put on any ai soldier.
Is their maybe in the global lua a list object that stores all the current active ai soldier "e" values, and if that is so then what is it and how can i use it?
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2021 21:35
There is only one 'e' value for each soldier!

The soldier script will call the module_combatcore function with the 'e' value for that soldier.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 16th Dec 2021 22:09
Ok Thanks
Current W.I.P
TheValley

Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Login to post a reply

Server time is: 2024-03-28 14:21:56
Your offset time is: 2024-03-28 14:21:56