Getting a locked-on entity through Lua

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
mrcluster
Private First Class
Posts: 80
Joined: Thu Sep 01, 2016 3:41 pm
Projects :: Tatooine - Jundland Wastes
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Getting a locked-on entity through Lua

Post by mrcluster »

Figured I'd ask if there's a way to do this. I'm looking to access a unit's current lock-on target, and I don't know of any way. Does on exist, and if so what must be done?

Hmm, I found some interesting parts of the 1playerhud.hud file:
Hidden/Spoiler:
[code] PropagateAlpha(1)
Position(0.787504, 0.828324, 0.000000, "Viewport")
Alpha(0.500000)
FadeOutTime(1.000000)
EventEnable("player1.lockOnClassName")
EventDisable("player1.lockOnDisable")
Text("player1lockon.className")
{
TextBreak("Word")
TextAlignment("Center", "Top")
TextFont("gamefont_tiny")
TextStyle("Shadow")
EventText("player1.lockOnClassName")
Position(0.006355, 0.015880, 0.000000, "Viewport")
ZOrder(127)
EventEnable("initialize")
}

Text("player1lockon.name")
{
TextBreak("Word")
TextAlignment("Center", "Top")
TextFont("gamefont_tiny")
TextStyle("Shadow")
EventText("player1.lockOnName")
Position(0.007546, 0.057666, 0.000000, "Viewport")
ZOrder(127)
EventEnable("player1.lockOnName")
EventDisable("player1.lockOnDisable")
}

Text("player1lockon.distance")
{
TextBox(0.136719, 0.000000)
TextBreak("Word")
TextFont("gamefont_small")
TextStyle("Shadow")
TextAlignment("Center", "Top")
EventNumber("player1.lockOnDistance")
FloatFormat("%.0f")
Position(-0.059591, 0.082852, 0.000000, "Viewport")
ZOrder(127)
EventEnable("initialize")
}[/code]
What are these "events"? How can I access them? These could be very useful for potentially retrieving the entity through Lua.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Getting a locked-on entity through Lua

Post by Marth8880 »

Pretty sure you can't.

HUD events are just callbacks sent by C++ to the game's HUD manager to tell it when to do certain things, such as when to bring up the minimap display.
mrcluster
Private First Class
Posts: 80
Joined: Thu Sep 01, 2016 3:41 pm
Projects :: Tatooine - Jundland Wastes
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Re: Getting a locked-on entity through Lua

Post by mrcluster »

Marth8880 wrote:Pretty sure you can't.

HUD events are just callbacks sent by C++ to the game's HUD manager to tell it when to do certain things, such as when to bring up the minimap display.
Ah, a shame. My best idea would be a brute-force approach of hooking into the lock-on key through ScriptCB_SetFunctionIdForButtonId (if the function works how I think it does), then looping through a list of entity IDs and checking if the entity meets requirements that'd make it "locked-on", though that's extremely hacky.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Getting a locked-on entity through Lua

Post by Marth8880 »

ScriptCB_SetFunctionIdForButtonId? Where have you seen that? :o
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Getting a locked-on entity through Lua

Post by Teancum »

Marth8880 wrote:ScriptCB_SetFunctionIdForButtonId? Where have you seen that? :o
viewtopic.php?p=219713#p219713
Post Reply