CrosshairEntityCallback

版本 v2.0.0·更新於 2024-06-30

Modding resource. Provide some useful callbacks on crosshair.

模組介紹 作者原文

Deprecated. Use ClPlayerCallback instead.

This mod provides some useful functions in client.

You should not install this until you are told.

Functions

cl_player.gnut

// This allows you to get the entity your crosshair look at.

void function AddCallback_CrosshairCurrentTargetChanged( void functionref( entity player, entity newTarget ) callbackFunc )

Examples

This is a helper to print entity info you look at.

untyped

global function MyHelperInit

struct {

entity currentCrosshairEntity

var rui

vector position = Vector(0.51, 0.52, 0.0) //x axis: 0.0 is max left, 1.0 is max right; y axis: 0.0 is max top, 1.0 is max down; z doesn't do anything

vector colour = Vector(1, 1, 1) // rgb, range: 0 - 0.0 to 255 - 1.0

float alpha = 0.6 //maxiumum alpha of the text, range: 0.0 to 1.0

float size = 28 //size of the text

} file

void function MyHelperInit(){

thread Monitor()

}

void function Monitor(){

WaitFrame()

AddCallback_CrosshairCurrentTargetChanged(GetCrosshairEntity)

RegisterButtonPressedCallback(KEY_O, PrintEnt)

AddOnDeathCallback( "player", OnPlayerDeath_StopRui )

// RUI

file.rui = RuiCreate( $"ui/cockpit_console_text_top_left.rpak", clGlobal.topoCockpitHudPermanent, RUI_DRAW_COCKPIT, -1 )

RuiSetInt(file.rui, "maxLines", 1)

RuiSetInt(file.rui, "lineNum", 1)

RuiSetFloat2(file.rui, "msgPos", file.position)

RuiSetFloat3(file.rui, "msgColor", file.colour)

RuiSetFloat(file.rui, "msgFontSize", file.size)

RuiSetString(file.rui, "msgText", "")

RuiSetFloat(file.rui, "msgAlpha", 0.0)

RuiSetFloat(file.rui, "thicken", 0.0)

thread DisplayRUI()

}

// You need to check the target manually. It refers to LocalClientPlayer(you) in default if there is nothing in your crosshair.

void function GetCrosshairEntity( entity player, entity target) {

if (target!= file.currentCrosshairEntity) {

file.currentCrosshairEntity = target

}

}

void function DisplayRUI() {

while (true) {

WaitFrame()

if(IsLobby() || IsMenuLevel() || IsWatchingReplay())

{

RuiSetFloat(file.rui, "msgAlpha", 0.0)

continue

}

entity player = GetLocalClientPlayer()

if(player == null || IsSpectre(player))

{

RuiSetFloat(file.rui, "msgAlpha", 0.0)

continue

}

string s = ""

// Caution.

if (file.currentCrosshairEntity!= player) {

if (!IsValid(file.currentCrosshairEntity)) {

continue

}

s += file.currentCrosshairEntity + "\n"

{

try {

s += file.currentCrosshairEntity.GetSignifierName()+ "\n"

} catch (exception){

print(exception)

}

}

{

try {

s += file.currentCrosshairEntity.GetClassName()+ "\n"

} catch (exception){

print(exception)

}

}

}

RuiSetString(file.rui, "msgText", s)

RuiSetFloat(file.rui, "msgAlpha", 1.0)

}

}

void function OnPlayerDeath_StopRui( entity player )

{

if ( player!= GetLocalViewPlayer() )

return

RuiSetFloat(file.rui, "msgAlpha", 0.0)

}

安裝與使用 安裝:Northstar 用戶端模組

  1. 先安裝 Northstar 用戶端(Titanfall 2 的開源社群用戶端,官方發布頁提供安裝器),模組由它載入。
  2. 把本站下載的壓縮包解壓,內容放入 Titanfall2 目錄下的 Northstar/mods/ 資料夾。
  3. 透過 NorthstarLauncher.exe 啟動遊戲,控制台會列出已載入的模組。

Northstar 用於私人伺服器與自訂內容,請勿用它連線官方伺服器。

檔案與校驗

檔案名稱
CrosshairEntityCallback-2.0.0.zip
檔案大小
28.5 KiB