1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
global function ClDroppedWeaponFlyout_Init
global function ClientCodeCallback_BodyGroupChanged
global function ClientCodeCallback_UseEntGainedFocus
global function ClientCodeCallback_UseEntLostFocus
global function AddCallback_OnPetTitanChanged
global function ClientCodeCallback_OnPetTitanModeChanged
global function AddCallback_OnPetTitanModeChanged
global function ClientCodeCallback_OnPetTitanChanged
global function DestroyPickupFlyout
global function HidePickupFlyout
global function ShowPickupFlyout
global function IsCurrentlyFocusedWeapon
global function IsPickupFlyoutValid
#if HAS_WEAPON_PICKUP_HIGHLIGHT
global function ServerCallback_RefreshWeaponHighlights
#endif
enum eFlyoutType
{
STANDARD_WEAPON
BT_LOADOUT_PICKUP
}
struct
{
var flyoutRUI
var lastWeaponRuiSet
int flyoutType
entity focusedEnt
table<string, asset> modImages
} file
void function ClDroppedWeaponFlyout_Init()
{
RegisterSignal( "PetTitanChanged" )
RegisterSignal( "PetTitanModeChanged" )
var dataTable = GetDataTable( $"datatable/pilot_weapon_mods_common.rpak" )
int numRows = GetDatatableRowCount( dataTable )
for ( int i = 0; i < numRows; i++ )
{
string modRef = GetDataTableString( dataTable, i, PILOT_WEAPON_MOD_COMMON_COLUMN )
asset modImage = GetDataTableAsset( dataTable, i, PILOT_WEAPON_MOD_COMMON_IMAGE_COLUMN )
file.modImages[ modRef ] <- modImage
}
AddCinematicEventFlagChangedCallback( CE_FLAG_HIDE_MAIN_HUD, WeaponPickupFlyout_UpdateVisibility )
#if HAS_WEAPON_PICKUP_HIGHLIGHT
AddCreateCallback( "weaponx", ClWeaponCreationCallback )
#endif
}
void function ClientCodeCallback_BodyGroupChanged( entity ent, int bodyGroupIndex, int oldState, int newState )
{
// PrintFunc( "entity " + ent + " index " + bodyGroupIndex + "newstate " + newState )
if ( IsSpectre( ent ) || IsStalker( ent ) )
{
if ( bodyGroupIndex == ent.FindBodyGroup( "removableHead" ) )
{
ModelFX_DisableGroup( ent, "foe_lights" )
ModelFX_DisableGroup( ent, "friend_lights" )
}
}
}
void function ClientCodeCallback_UseEntGainedFocus( entity ent )
{
foreach ( callbackFunc in clGlobal.onUseEntGainFocusCallbacks )
{
callbackFunc( ent )
}
DestroyPickupFlyout()
int neededType = eFlyoutType.STANDARD_WEAPON
if ( ent.GetClassName() == "weaponx" )
{
#if SP
int loadoutIndex = GetSPTitanLoadoutIndexForWeapon( ent.GetWeaponClassName() )
neededType = (loadoutIndex >= 0) ? eFlyoutType.BT_LOADOUT_PICKUP : eFlyoutType.STANDARD_WEAPON
#endif
if ( neededType == eFlyoutType.STANDARD_WEAPON )
{
if ( (file.flyoutRUI == null) || file.flyoutType != neededType )
{
DestroyPickupFlyout()
file.flyoutRUI = RuiCreate( $"ui/dropped_weapon_flyout.rpak", clGlobal.topoFullScreen, RUI_DRAW_HUD, 0 )
file.flyoutType = neededType
}
int modNum = 1
array<string> weaponMods = ent.GetMods()
foreach ( mod in weaponMods )
{
if ( modNum >= 5 ) // setting mod5 in the rui crashes client
break
if ( mod in file.modImages )
RuiSetImage( file.flyoutRUI, "mod" + modNum++, file.modImages[ mod ] )
}
RuiSetGameTime( file.flyoutRUI, "startTime", Time() )
RuiTrackFloat3( file.flyoutRUI, "pos", ent, RUI_TRACK_ABSORIGIN_FOLLOW )
RuiSetString( file.flyoutRUI, "titleText", expect string( ent.GetWeaponInfoFileKeyField( "shortprintname" ) ) )
RuiSetString( file.flyoutRUI, "descriptionText", expect string( ent.GetWeaponInfoFileKeyField( "description" ) ) )
RuiSetBool( file.flyoutRUI, "isOffhandWeapon", ent.IsWeaponOffhand() )
RuiSetImage( file.flyoutRUI, "icon", ent.GetWeaponInfoFileKeyFieldAsset( "hud_icon" ) )
RuiSetFloat( file.flyoutRUI, "worldOffsetY", GetLocalViewPlayer().IsTitan() ? 98.0 : 32.0 )
RuiSetResolutionToScreenSize( file.flyoutRUI )
if ( ent.GetWeaponSettingBool( eWeaponVar.is_burn_mod ) )
RuiSetFloat3( file.flyoutRUI, "color", BURN_CARD_WEAPON_HUD_COLOR_VECTOR )
var rui = ClWeaponStatus_GetWeaponHudRui( GetLocalViewPlayer(), ent )
if ( rui != null )
{
RuiSetBool( rui, "isHighlighted", true )
file.lastWeaponRuiSet = rui
}
}
// #if SP
// else if ( neededType == eFlyoutType.BT_LOADOUT_PICKUP )
// {
// // The first one is picked up automatically an dhandled by a different custom system.
// if ( ent.GetWeaponClassName() == SP_FIRST_TITAN_LOADOUT_KIT )
// return
// if ( (file.flyoutRUI == null) || file.flyoutType != neededType )
// {
// DestroyPickupFlyout()
// file.flyoutRUI = CreateCockpitRui( $"ui/dropped_weapon_bt_loadout_flyout.rpak", 0 )
// file.flyoutType = neededType
// }
// RuiSetGameTime( file.flyoutRUI, "startTime", Time() )
// RuiSetString( file.flyoutRUI, "titleText", GetSPTitanLoadoutForIndex_MenuItem( loadoutIndex ) )
// RuiSetImage( file.flyoutRUI, "icon", ent.GetWeaponInfoFileKeyFieldAsset( "hud_icon" ) )
// }
// #endif
}
file.focusedEnt = ent
if ( GetWeaponFlyoutAliveTime() < 0.5 && IsWeaponFlyoutVisible() )
{
HidePickupFlyout( 2.0 )
SetWeaponFlyoutRemainingTime( 2.0 )
}
else
{
DestroyWeaponFlyout()
}
#if HAS_AMMO_FULL_FLYOUT
if ( IsAmmoFullWeapon( ent ) )
HideAmmoFullFlyout()
#endif
#if HAS_WEAPON_PICKUP_HIGHLIGHT
ManageHighlightEntity( ent )
#endif
#if SP
ScriptCallback_UpdateOnscreenHint()
#endif
}
void function ClientCodeCallback_UseEntLostFocus( entity ent )
{
foreach ( callbackFunc in clGlobal.onUseEntLoseFocusCallbacks )
{
callbackFunc( ent )
}
DestroyPickupFlyout()
if ( file.lastWeaponRuiSet != null )
{
RuiSetBool( file.lastWeaponRuiSet, "isHighlighted", false )
file.lastWeaponRuiSet = null
}
if ( file.focusedEnt == ent )
{
file.focusedEnt = null
}
#if HAS_WEAPON_PICKUP_HIGHLIGHT
if ( IsValid( ent ) )
ManageHighlightEntity( ent )
#endif
}
bool function IsPickupFlyoutValid()
{
return ( file.flyoutRUI != null )
}
bool function IsCurrentlyFocusedWeapon( entity ent )
{
return file.focusedEnt == ent
}
void function DestroyPickupFlyout()
{
if ( file.flyoutRUI == null )
return
RuiDestroy( file.flyoutRUI )
file.flyoutRUI = null
#if SP
ScriptCallback_UpdateOnscreenHint()
#endif
}
void function HidePickupFlyout( float hideDuration )
{
if ( file.flyoutRUI == null )
return
RuiSetFloat( file.flyoutRUI, "hideDuration", hideDuration )
RuiSetGameTime( file.flyoutRUI, "hideStartTime", Time() )
}
void function ShowPickupFlyout()
{
if ( file.flyoutRUI == null )
return
RuiSetFloat( file.flyoutRUI, "hideDuration", 0.0 )
#if SP
ScriptCallback_UpdateOnscreenHint()
#endif
}
void function WeaponPickupFlyout_UpdateVisibility( entity player )
{
if ( file.flyoutRUI == null )
return
int ceFlags = player.GetCinematicEventFlags()
bool hideHud = ( ceFlags & CE_FLAG_HIDE_MAIN_HUD ) > 0
RuiSetBool( file.flyoutRUI, "inCinematic", hideHud )
}
#if HAS_WEAPON_PICKUP_HIGHLIGHT
void function ServerCallback_RefreshWeaponHighlights( int eHandle )
{
entity weapon = GetEntityFromEncodedEHandle( eHandle )
if ( weapon != null )
ManageHighlightEntity( weapon )
}
void function ClWeaponCreationCallback( entity weapon )
{
}
#endif
void function AddCallback_OnPetTitanChanged( void functionref( entity ) callbackFunc )
{
clGlobal.onPetTitanChangedCallbacks.append( callbackFunc )
}
void function ClientCodeCallback_OnPetTitanChanged( entity player )
{
if ( !IsValid( player ) || player != GetLocalViewPlayer() )
return
if ( !IsMenuLevel() )
thread PetTitanChanged( player )
player.Signal( "PetTitanChanged" )
// Added via AddCallback_OnPetTitanModeChanged
foreach ( callbackFunc in clGlobal.onPetTitanChangedCallbacks )
{
callbackFunc( player )
}
}
void function ClientCodeCallback_OnPetTitanModeChanged( entity player )
{
if ( !IsValid( player ) || player != GetLocalViewPlayer() )
return
if ( !IsValid( player.GetPetTitan() ) ) // should be an assert...
return
player.Signal( "PetTitanModeChanged" )
// Added via AddCallback_OnPetTitanModeChanged
foreach ( callbackFunc in clGlobal.onPetTitanModeChangedCallbacks )
{
callbackFunc( player )
}
}
void function AddCallback_OnPetTitanModeChanged( void functionref( entity ) callbackFunc )
{
clGlobal.onPetTitanModeChangedCallbacks.append( callbackFunc )
}
|