Skip to content

Commit b75a8c5

Browse files
authored
2.3 (#15)
* Add files for 2.3
1 parent ce16724 commit b75a8c5

File tree

6 files changed

+181
-21
lines changed

6 files changed

+181
-21
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.3
2+
- Re-add files to make mods such as Khalmee's Speech Bubbles work
3+
- Fix error introduced by plugins v3 in Northstar
4+
15
2.2
26
- Fix Mod Settings not showing up in the in game menu
37
- Re-add slightly modified `_items.nut` from Northstar.CustomServers for some mods that use its functions (the one brought to my attention being Blue Fire)

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "VanillaPlus",
3-
"version_number": "2.2.0",
3+
"version_number": "2.3.0",
44
"website_url": "https://github.com/Zayveeo5e/NP.VanillaPlus",
55
"description": "Modified Northstar.Client to load Client-Side mods on Vanilla servers",
66
"dependencies": []

mods/NP.VanillaPlus/mod.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Name" : "VanillaPlus",
33
"Description": "A stripped down and modified Northstar.Client mod that allows for client-side mod loading on official Respawn servers\n\nMade by Nanohm, remastered by Cyn",
44
"LoadPriority": -1,
5-
"Version": "2.2",
5+
"Version": "2.3",
66

77
"Dependencies": {
88
"HAS_CLIENT": "Northstar.Client",
@@ -57,6 +57,10 @@
5757
"After": "AddNorthstarModMenu_MainMenuFooter"
5858
}
5959
},
60+
{
61+
"Path": "ns_custom_codecallbacks_client.gnut",
62+
"RunOn": "CLIENT"
63+
},
6064
{
6165
"Path": "client/ns_cl_chat.gnut",
6266
"RunOn": "CLIENT"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
untyped
2+
#if !HAS_CLIENT && !HAS_CUSTOM && !HAS_CUSTOMSERVERS
3+
4+
global function AddCallback_OnReceivedSayTextMessage
5+
6+
// this is global due to squirrel bridge v3 making native not be able to find non-global funcs properly
7+
// temp fix (surely it will get replaced), do not use this function please (although there isnt rly a downside to it?)
8+
global function CHudChat_ProcessMessageStartThread
9+
10+
global struct ClClient_MessageStruct {
11+
string message
12+
entity player
13+
string playerName
14+
bool isTeam
15+
bool isDead
16+
bool isWhisper
17+
bool shouldBlock
18+
bool noServerTag
19+
}
20+
21+
struct {
22+
array< ClClient_MessageStruct functionref( ClClient_MessageStruct ) > OnReceivedSayTextMessageCallbacks
23+
} NsCustomCallbacksClient
24+
25+
void function OnReceivedMessage(ClClient_MessageStruct localMessage) {
26+
27+
if ( IsWatchingReplay() && localMessage.player == null )
28+
return
29+
30+
if (localMessage.player != null)
31+
{
32+
foreach (callbackFunc in NsCustomCallbacksClient.OnReceivedSayTextMessageCallbacks)
33+
{
34+
ClClient_MessageStruct returnStruct = callbackFunc(localMessage)
35+
localMessage.message = returnStruct.message
36+
localMessage.playerName = returnStruct.playerName
37+
localMessage.isTeam = returnStruct.isTeam
38+
localMessage.isDead = returnStruct.isDead
39+
localMessage.isWhisper = returnStruct.isWhisper
40+
localMessage.shouldBlock = localMessage.shouldBlock || returnStruct.shouldBlock
41+
localMessage.noServerTag = returnStruct.noServerTag
42+
}
43+
}
44+
45+
if (localMessage.shouldBlock)
46+
{
47+
return
48+
}
49+
50+
NSChatWriteRaw(1, "\n")
51+
52+
if (localMessage.player == null)
53+
{
54+
if (!localMessage.noServerTag || localMessage.isWhisper)
55+
{
56+
NSChatWrite(1, "\x1b[95m")
57+
}
58+
}
59+
else
60+
{
61+
bool isFriendly = localMessage.player.GetTeam() == GetLocalClientPlayer().GetTeam()
62+
63+
if (isFriendly) NSChatWrite(1, "\x1b[111m")
64+
else NSChatWrite(1, "\x1b[112m")
65+
}
66+
67+
if (localMessage.isWhisper) NSChatWriteRaw(1, Localize("#HUD_CHAT_WHISPER_PREFIX"))
68+
if (localMessage.isDead) NSChatWriteRaw(1, Localize("#HUD_CHAT_DEAD_PREFIX"))
69+
if (localMessage.isTeam) NSChatWriteRaw(1, Localize("#HUD_CHAT_TEAM_PREFIX"))
70+
71+
if (localMessage.player == null)
72+
{
73+
if (!localMessage.noServerTag)
74+
{
75+
NSChatWriteRaw(1, Localize("#HUD_CHAT_SERVER_PREFIX") + " ")
76+
}
77+
}
78+
else
79+
{
80+
NSChatWriteRaw(1, localMessage.playerName)
81+
NSChatWriteRaw(1, ": ")
82+
}
83+
84+
if (localMessage.player != null || !localMessage.noServerTag || localMessage.isWhisper) NSChatWrite(1, "\x1b[0m")
85+
NSChatWrite(1, localMessage.message)
86+
}
87+
88+
void function CHudChat_ProcessMessageStartThread(int playerIndex, string message, bool isTeam, bool isDead, int messageType)
89+
{
90+
thread CHudChat_OnReceivedSayTextMessageCallback(playerIndex, message, isTeam, isDead, messageType)
91+
}
92+
93+
void function CHudChat_OnReceivedSayTextMessageCallback(int fromPlayerIndex, string message, bool isTeam, bool isDead, int messageType)
94+
{
95+
entity fromPlayer = null
96+
string fromPlayerName = ""
97+
98+
if (fromPlayerIndex >= 0 && fromPlayerIndex <= 128)
99+
{
100+
fromPlayer = GetEntByIndex(fromPlayerIndex + 1)
101+
if (fromPlayer == null) {
102+
print("Ignored chat message from invalid player index " + fromPlayerIndex + ": " + message)
103+
return
104+
}
105+
106+
fromPlayerName = fromPlayer.GetPlayerNameWithClanTag()
107+
}
108+
109+
// Null player + isTeam == true: Server with no tag.
110+
111+
if (messageType == 0 || messageType == 1)
112+
{
113+
ClClient_MessageStruct localMessage
114+
localMessage.message = message
115+
localMessage.player = fromPlayer
116+
localMessage.playerName = fromPlayerName
117+
localMessage.isTeam = fromPlayer != null && isTeam
118+
localMessage.isDead = isDead
119+
localMessage.isWhisper = false
120+
localMessage.shouldBlock = false
121+
localMessage.noServerTag = fromPlayer == null && isTeam
122+
OnReceivedMessage(localMessage)
123+
return
124+
}
125+
126+
if (messageType == 2)
127+
{
128+
ClClient_MessageStruct localMessage
129+
localMessage.message = message
130+
localMessage.player = fromPlayer
131+
localMessage.playerName = fromPlayerName
132+
localMessage.isTeam = fromPlayer != null && isTeam
133+
localMessage.isDead = isDead
134+
localMessage.isWhisper = true
135+
localMessage.shouldBlock = false
136+
localMessage.noServerTag = fromPlayer == null && isTeam
137+
OnReceivedMessage(localMessage)
138+
return
139+
}
140+
}
141+
142+
void function AddCallback_OnReceivedSayTextMessage( ClClient_MessageStruct functionref (ClClient_MessageStruct) callbackFunc )
143+
{
144+
NsCustomCallbacksClient.OnReceivedSayTextMessageCallbacks.append(callbackFunc)
145+
}
146+
#endif

mods/NP.VanillaPlus/mod/scripts/vscripts/presence/ns_cl_presence.nut

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ global struct GameStateStruct {
2323
float timeEnd
2424
}
2525

26-
void function NorthstarCodeCallback_GenerateGameState() {
27-
28-
GameStateStruct gs
29-
26+
GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs )
27+
{
3028
int highestScore = 0
3129
int secondHighest = 0
3230

@@ -62,7 +60,6 @@ void function NorthstarCodeCallback_GenerateGameState() {
6260
gs.timeEnd = expect float(level.nv.roundEndTime - Time())
6361
else
6462
gs.timeEnd = expect float(level.nv.gameEndTime - Time())
65-
66-
NSPushGameStateData(gs)
63+
return gs
6764
}
6865
#endif

mods/NP.VanillaPlus/mod/scripts/vscripts/presence/ns_ui_presence.nut

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@ untyped
33

44
globalize_all_functions
55

6-
// this struct is taken from cl_northstar_client_init
6+
// these structs are taken from cl_northstar_client_init
77
// otherwise, this file is directly the same as
88
// the one from Northstar.Client
99

10-
struct UIPresenceStruct {
11-
bool isLoading
12-
bool isLobby
13-
string loadingLevel
14-
string loadedLevel
10+
global struct UIPresenceStruct {
11+
int gameState
1512
}
1613

17-
void function NorthstarCodeCallback_GenerateUIPresence() {
18-
UIPresenceStruct uis
14+
global enum eDiscordGameState
15+
{
16+
LOADING = 0
17+
MAINMENU
18+
LOBBY
19+
INGAME
20+
}
21+
22+
UIPresenceStruct function DiscordRPC_GenerateUIPresence( UIPresenceStruct uis )
23+
{
24+
if ( uiGlobal.isLoading )
25+
uis.gameState = eDiscordGameState.LOADING;
26+
else if ( uiGlobal.loadedLevel == "" )
27+
uis.gameState = eDiscordGameState.MAINMENU;
28+
else if ( IsLobby() || uiGlobal.loadedLevel == "mp_lobby" )
29+
uis.gameState = eDiscordGameState.LOBBY;
30+
else
31+
uis.gameState = eDiscordGameState.INGAME;
1932

20-
uis.isLoading = uiGlobal.isLoading
21-
uis.isLobby = IsLobby()
22-
uis.loadingLevel = uiGlobal.loadingLevel
23-
uis.loadedLevel = uiGlobal.loadedLevel
24-
NSPushUIPresence(uis)
33+
return uis
2534
}
2635
#endif

0 commit comments

Comments
 (0)