initial commit

This commit is contained in:
Lucia Ceionia 2024-10-30 21:18:01 -05:00
commit 5fbf1f2135
10 changed files with 1274 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
LucysTools/env.sh
Godot/.import
Godot/default_env.tres
Godot/export_presets.cfg
Godot/icon.png
Godot/icon.png.import
build/LucysTools.pck

View File

@ -0,0 +1,86 @@
extends Control
var MANAGER = null
func setup(manager):
MANAGER = manager
get_node("%lucy_bbcode").pressed = manager.allow_bbcode
get_node("%lucy_punchback").pressed = manager.do_punchback
get_node("%lucy_servername").text = manager.custom_server_name
get_node("%lucy_servermsg").text = manager.server_join_message
get_node("%lucy_fpackets").value = manager.frame_packets
get_node("%lucy_bpackets").value = manager.bulk_packets
get_node("%lucy_binterval").value = manager.bulk_interval
get_node("%lucy_finterval").value = manager.full_interval
func _ready():
print("[LUCY] Menu Ready")
func _input(event):
if event is InputEventKey and event.scancode == KEY_F5 && event.pressed:
visible = !visible
print("[LUCY] Menu visble: ", visible)
if event is InputEventKey and event.scancode == KEY_F6 && event.pressed:
var name = Steam.getLobbyData(Network.STEAM_LOBBY_ID, "name")
var nm = Steam.getNumLobbyMembers(Network.STEAM_LOBBY_ID)
var code = Steam.getLobbyData(Network.STEAM_LOBBY_ID, "code")
var type = Steam.getLobbyData(Network.STEAM_LOBBY_ID, "type")
var lobby_dat = {"name": name, "nm": nm, "code": code, "type": type}
print("[LUCY] LOBBY ", lobby_dat)
func _on_lucy_bbcode_toggled(button_pressed):
MANAGER.allow_bbcode = button_pressed
func _on_lucy_punchback_toggled(button_pressed):
MANAGER.do_punchback = button_pressed
func _on_lucy_servername_text_changed(new_text):
MANAGER.custom_server_name = new_text
func _on_lucy_servermsg_text_changed(new_text):
MANAGER.server_join_message = new_text
func _on_lucy_fpackets_value_changed(value):
MANAGER.frame_packets = value
func _on_lucy_bpackets_value_changed(value):
MANAGER.bulk_packets = value
func _on_lucy_binterval_value_changed(value):
MANAGER.bulk_interval = value
func _on_lucy_finterval_value_changed(value):
MANAGER.full_interval = value
func _on_lucy_raincloud_pressed():
if not MANAGER.ingame: return
print("[LUCY] Spawning raincloud")
var player = MANAGER.get_player()
var pos = Vector3(player.global_transform.origin.x, 42, player.global_transform.origin.z)
var zone = player.current_zone
Network._sync_create_actor("raincloud", pos, zone, - 1, Network.STEAM_ID)
func _on_lucy_meteor_pressed():
if not MANAGER.ingame: return
print("[LUCY] Spawning meteor")
var player_pos = MANAGER.get_player().global_transform.origin
var dist = INF
var point = null
for n in get_tree().get_nodes_in_group("fish_spawn"):
var node_dist = n.global_transform.origin.distance_to(player_pos)
if node_dist < dist:
dist = node_dist
point = n
var zone = "main_zone"
var pos = point.global_transform.origin
Network._sync_create_actor("fish_spawn_alien", pos, zone, - 1, Network.STEAM_ID)
func _on_lucy_freezerain_pressed():
if not MANAGER.ingame or not Network.GAME_MASTER: return
print("[LUCY] Freezing rain")
for cloud in get_tree().get_nodes_in_group("raincloud"):
if cloud.controlled == true:
cloud.speed = 0
cloud.decay = false
func _on_lucy_clearrain_pressed():
if not MANAGER.ingame or not Network.GAME_MASTER: return
print("[LUCY] Clearing rain")
for cloud in get_tree().get_nodes_in_group("raincloud"):
cloud._deinstantiate(true)

View File

@ -0,0 +1,239 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://mods/Lucy.LucysTools/lucys_menu.gd" type="Script" id=1]
[node name="lucys_menu" type="Control"]
margin_right = 800.0
margin_bottom = 329.0
script = ExtResource( 1 )
[node name="PanelContainer" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
margin_left = 7.0
margin_top = 7.0
margin_right = 793.0
margin_bottom = 322.0
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"]
margin_right = 786.0
margin_bottom = 14.0
text = "Lucy's Options - F5 to Toggle Menu"
[node name="HSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 786.0
margin_bottom = 22.0
[node name="HFlowContainer" type="HFlowContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 26.0
margin_right = 786.0
margin_bottom = 66.0
rect_pivot_offset = Vector2( -141, -49 )
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer"]
margin_top = 13.0
margin_right = 286.0
margin_bottom = 27.0
text = "Allow BBCode in Chat (start message with %)"
[node name="lucy_bbcode" type="CheckButton" parent="PanelContainer/VBoxContainer/HFlowContainer"]
unique_name_in_owner = true
margin_left = 290.0
margin_right = 366.0
margin_bottom = 40.0
[node name="Label2" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer"]
margin_left = 370.0
margin_top = 13.0
margin_right = 505.0
margin_bottom = 27.0
text = "Punch back on Punch"
[node name="lucy_punchback" type="CheckButton" parent="PanelContainer/VBoxContainer/HFlowContainer"]
unique_name_in_owner = true
margin_left = 509.0
margin_right = 585.0
margin_bottom = 40.0
[node name="HFlowContainer4" type="HFlowContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 70.0
margin_right = 786.0
margin_bottom = 94.0
rect_pivot_offset = Vector2( -141, -49 )
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer4"]
margin_top = 5.0
margin_right = 135.0
margin_bottom = 19.0
text = "Custom Server Name"
[node name="lucy_servername" type="LineEdit" parent="PanelContainer/VBoxContainer/HFlowContainer4"]
unique_name_in_owner = true
margin_left = 139.0
margin_right = 197.0
margin_bottom = 24.0
expand_to_text_length = true
placeholder_text = "Name"
[node name="HFlowContainer5" type="HFlowContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 98.0
margin_right = 786.0
margin_bottom = 122.0
rect_pivot_offset = Vector2( -141, -49 )
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer5"]
margin_top = 5.0
margin_right = 127.0
margin_bottom = 19.0
text = "Server Join Message"
[node name="lucy_servermsg" type="LineEdit" parent="PanelContainer/VBoxContainer/HFlowContainer5"]
unique_name_in_owner = true
margin_left = 131.0
margin_right = 189.0
margin_bottom = 24.0
expand_to_text_length = true
placeholder_text = "Message"
[node name="HFlowContainer2" type="HFlowContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 126.0
margin_right = 786.0
margin_bottom = 146.0
[node name="lucy_raincloud" type="Button" parent="PanelContainer/VBoxContainer/HFlowContainer2"]
margin_right = 118.0
margin_bottom = 20.0
text = "Spawn Raincloud"
[node name="lucy_meteor" type="Button" parent="PanelContainer/VBoxContainer/HFlowContainer2"]
margin_left = 122.0
margin_right = 224.0
margin_bottom = 20.0
text = "Spawn Meteor"
[node name="lucy_freezerain" type="Button" parent="PanelContainer/VBoxContainer/HFlowContainer2"]
margin_left = 228.0
margin_right = 314.0
margin_bottom = 20.0
text = "Freeze Rain"
[node name="lucy_clearrain" type="Button" parent="PanelContainer/VBoxContainer/HFlowContainer2"]
margin_left = 318.0
margin_right = 393.0
margin_bottom = 20.0
text = "Clear Rain"
[node name="HSeparator2" type="HSeparator" parent="PanelContainer/VBoxContainer"]
margin_top = 150.0
margin_right = 786.0
margin_bottom = 154.0
[node name="HSplitContainer" type="HSplitContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 158.0
margin_right = 786.0
margin_bottom = 182.0
split_offset = 100
[node name="HFlowContainer3" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer"]
margin_right = 218.0
margin_bottom = 24.0
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer3"]
margin_top = 5.0
margin_right = 118.0
margin_bottom = 19.0
text = "Per Frame Packets"
[node name="lucy_fpackets" type="SpinBox" parent="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer3"]
unique_name_in_owner = true
margin_left = 122.0
margin_right = 196.0
margin_bottom = 24.0
max_value = 256.0
value = 32.0
rounded = true
allow_greater = true
[node name="HFlowContainer" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer"]
margin_left = 230.0
margin_right = 786.0
margin_bottom = 24.0
[node name="Label2" type="Label" parent="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer"]
margin_top = 5.0
margin_right = 116.0
margin_bottom = 19.0
text = "Bulk Read Packets"
[node name="lucy_bpackets" type="SpinBox" parent="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer"]
unique_name_in_owner = true
margin_left = 120.0
margin_right = 194.0
margin_bottom = 24.0
max_value = 4096.0
value = 128.0
rounded = true
allow_greater = true
[node name="HSplitContainer2" type="HSplitContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 186.0
margin_right = 786.0
margin_bottom = 210.0
split_offset = 100
[node name="HFlowContainer3" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer2"]
margin_right = 216.0
margin_bottom = 24.0
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer3"]
margin_top = 5.0
margin_right = 116.0
margin_bottom = 19.0
text = "Bulk Read Interval"
[node name="lucy_binterval" type="SpinBox" parent="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer3"]
unique_name_in_owner = true
margin_left = 120.0
margin_right = 194.0
margin_bottom = 24.0
max_value = 120.0
step = 0.05
value = 0.8
allow_greater = true
[node name="HFlowContainer" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer2"]
margin_left = 228.0
margin_right = 786.0
margin_bottom = 24.0
[node name="Label2" type="Label" parent="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer"]
margin_top = 5.0
margin_right = 111.0
margin_bottom = 19.0
text = "Full Read Interval"
[node name="lucy_finterval" type="SpinBox" parent="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer"]
unique_name_in_owner = true
margin_left = 115.0
margin_right = 189.0
margin_bottom = 24.0
max_value = 120.0
step = 0.05
value = 6.4
allow_greater = true
[connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer/lucy_bbcode" to="." method="_on_lucy_bbcode_toggled"]
[connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer/lucy_punchback" to="." method="_on_lucy_punchback_toggled"]
[connection signal="text_changed" from="PanelContainer/VBoxContainer/HFlowContainer4/lucy_servername" to="." method="_on_lucy_servername_text_changed"]
[connection signal="text_changed" from="PanelContainer/VBoxContainer/HFlowContainer5/lucy_servermsg" to="." method="_on_lucy_servermsg_text_changed"]
[connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_raincloud" to="." method="_on_lucy_raincloud_pressed"]
[connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_meteor" to="." method="_on_lucy_meteor_pressed"]
[connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_freezerain" to="." method="_on_lucy_freezerain_pressed"]
[connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_clearrain" to="." method="_on_lucy_clearrain_pressed"]
[connection signal="value_changed" from="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer3/lucy_fpackets" to="." method="_on_lucy_fpackets_value_changed"]
[connection signal="value_changed" from="PanelContainer/VBoxContainer/HSplitContainer/HFlowContainer/lucy_bpackets" to="." method="_on_lucy_bpackets_value_changed"]
[connection signal="value_changed" from="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer3/lucy_binterval" to="." method="_on_lucy_binterval_value_changed"]
[connection signal="value_changed" from="PanelContainer/VBoxContainer/HSplitContainer2/HFlowContainer/lucy_finterval" to="." method="_on_lucy_finterval_value_changed"]

View File

@ -0,0 +1,135 @@
extends Node
const LUCYS_MENU_SCENE = preload("res://mods/Lucy.LucysTools/lucys_menu.tscn")
var lucys_menu = null
onready var root = get_tree().root
var do_punchback = false setget set_punchback
var allow_bbcode = false setget set_bbcode
var custom_server_name = "" setget set_server_name
var server_join_message = "[color=#5BCEFA]TRAN[/color][color=#F5A9B8]S RIG[/color][color=#ffffff]HTS![/color]" setget set_join_message
var frame_packets = 50 setget set_frame_packets
var bulk_packets = 200 setget set_bulk_packets
var bulk_interval = 1 setget set_bulk_interval
var full_interval = 5 setget set_full_interval
# Patched Network vars
# var LUCY_PACKETS_READ = 0
# var LUCY_BULK_FULL_TIMER = 0
# var LUCY_FRAME_PACKETS = 32
# var LUCY_BULK_PACKETS = 128
# var LUCY_BULK_INTERVAL = 0.8
# var LUCY_BULK_FULL_INTERVAL = 6.4
# var LUCY_CHAT_BBCODE
# var LUCY_SRV_NAME
# var LUCY_PUNCHED_ME
var ingame = false
func set_punchback(punchback):
do_punchback = punchback
func set_bbcode(bbcode):
allow_bbcode = bbcode
Network.LUCY_CHAT_BBCODE = bbcode
func set_server_name(name):
custom_server_name = name
Network.LUCY_SRV_NAME = name
func set_join_message(msg):
server_join_message = msg
func set_frame_packets(val):
frame_packets = val
Network.LUCY_FRAME_PACKETS = val
func set_bulk_packets(val):
bulk_packets = val
Network.LUCY_BULK_PACKETS = val
func set_bulk_interval(val):
bulk_interval = val
Network.LUCY_BULK_INTERVAL = val
Network.BULK_PACKET_READ_TIMER = 0
func set_full_interval(val):
full_interval = val
Network.LUCY_BULK_FULL_INTERVAL = val
Network.LUCY_BULK_FULL_TIMER = 0
func _ready():
print("[LUCY] Loaded LucysTools")
load_settings()
root.connect("child_entered_tree", self, "_on_enter")
Network.connect("_new_player_join", self, "new_player")
PlayerData.connect("_punched", self, "punched")
func get_player() -> Actor:
for p in get_tree().get_nodes_in_group("player"):
if p.controlled and p.owner_id == Network.STEAM_ID:
return p
return null
func punched(from, type):
print("[LUCY] punched!")
if not do_punchback: return
if Network.LUCY_PUNCHED_ME == 0 or Network.LUCY_PUNCHED_ME == Network.STEAM_ID: return
var punched_me = null
for p in get_tree().get_nodes_in_group("player"):
if p.owner_id == Network.LUCY_PUNCHED_ME: punched_me = p
if punched_me == null: return
if punched_me.controlled: return
print("[LUCY] punching back...")
Network.LUCY_PUNCHED_ME = 0
Network._send_P2P_Packet({"type": "player_punch", "from": get_player().global_transform.origin, "player": Network.STEAM_ID, "punch_type": type, "nya": "nya"}, str(punched_me.owner_id), 2)
func new_player(id):
print("[LUCY] new player!")
if server_join_message.empty() or not Network.GAME_MASTER: return
print("[LUCY] sending join message")
Network._send_message(server_join_message)
func _on_enter(node: Node):
if node.name == "main_menu":
lucys_menu = LUCYS_MENU_SCENE.instance()
node.add_child(lucys_menu)
ingame = false
lucys_menu.setup(self)
if node.name == "playerhud":
lucys_menu = LUCYS_MENU_SCENE.instance()
node.add_child(lucys_menu)
ingame = true
lucys_menu.setup(self)
func load_settings():
print("[LUCY] Loading settings")
var file = File.new()
if file.open(OS.get_executable_path().get_base_dir().plus_file("GDWeave/configs/LucysTools.json"),File.READ) == OK:
var parse = JSON.parse(file.get_as_text())
file.close()
var result = parse.result
# trigger setters
self.do_punchback = result.do_punchback
self.allow_bbcode = result.allow_bbcode
self.custom_server_name = result.custom_server_name
self.server_join_message = result.server_join_message
self.frame_packets = result.frame_packets
self.bulk_packets = result.bulk_packets
self.bulk_interval = result.bulk_interval
self.full_interval = result.full_interval
func save_settings():
print("[LUCY] Saving settings")
var settings = {
"do_punchback": do_punchback,
"allow_bbcode": allow_bbcode,
"custom_server_name": custom_server_name,
"server_join_message": server_join_message,
"frame_packets": frame_packets,
"bulk_packets": bulk_packets,
"bulk_interval": bulk_interval,
"full_interval": full_interval
}
var file = File.new()
if file.open(OS.get_executable_path().get_base_dir().plus_file("GDWeave/configs/LucysTools.json"),File.WRITE) == OK:
file.store_string(JSON.print(settings))
file.close()
func _exit_tree():
save_settings()

26
Godot/project.godot Normal file
View File

@ -0,0 +1,26 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
[application]
config/name="Godot"
config/icon="res://icon.png"
[gui]
common/drop_mouse_on_gui_input_disabled=true
[physics]
common/enable_pause_aware_picking=true
[rendering]
environment/default_environment="res://default_env.tres"

7
LucysTools/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.idea/
.vs/
*.user
/local
bin/
obj/

7
LucysTools/Config.cs Normal file
View File

@ -0,0 +1,7 @@
using System.Text.Json.Serialization;
namespace LucysTools;
public class Config {
[JsonInclude] public bool SomeSetting = true;
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblySearchPaths>$(AssemblySearchPaths);$(GDWeavePath)/core</AssemblySearchPaths>
</PropertyGroup>
<ItemGroup>
<Reference Include="GDWeave" Private="false"/>
<Reference Include="Serilog" Private="false"/>
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(GDWeavePath)' != ''">
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))'">true</IsWindows>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">true</IsLinux>
</PropertyGroup>
<Exec
Command="xcopy /Y /I &quot;$(TargetDir)&quot; &quot;$(GDWeavePath)/mods/$(AssemblyName)&quot;"
Condition="'$(IsWindows)' == 'true'"
/>
<Exec
Command="cp -r $(TargetDir) '$(GDWeavePath)/mods/$(AssemblyName)/'"
Condition="'$(IsLinux)' == 'true'"
/>
</Target>
</Project>

728
LucysTools/Mod.cs Normal file
View File

@ -0,0 +1,728 @@
using GDWeave;
using GDWeave.Godot;
using GDWeave.Godot.Variants;
using GDWeave.Modding;
namespace LucysTools;
public class Mod : IMod {
public static IModInterface ModInterface;
public Config Config;
public Mod(IModInterface modInterface) {
modInterface.Logger.Information("Lucy was here :3");
ModInterface = modInterface;
modInterface.RegisterScriptMod(new LucysNetFixes());
modInterface.RegisterScriptMod(new LucysChatChanges());
}
public void Dispose() {
// Cleanup anything you do here
}
}
public class LucysChatChanges : IScriptMod
{
bool IScriptMod.ShouldRun(string path) => path == "res://Scenes/HUD/playerhud.gdc";
Func<Token,bool>[] start_sendmsg = {
t => t.Type == TokenType.PrFunction,
t => t is IdentifierToken {Name: "_send_message"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] sendmsg_openbracket = {
t => t is IdentifierToken {Name: "color"},
t => t.Type == TokenType.Period,
t => t is IdentifierToken {Name: "to_html"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] sendmsg_closebracket = {
t => t is IdentifierToken {Name: "text"},
t => t.Type == TokenType.OpAssign,
t => t is IdentifierToken {Name: "text"},
t => t.Type == TokenType.Period,
t => t is IdentifierToken {Name: "replace"},
t => t.Type == TokenType.ParenthesisOpen,
t => t is ConstantToken {Value:StringVariant{Value: "["}},
t => t.Type == TokenType.Comma,
t => t.Type == TokenType.Constant,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] sendmsg_breakdownbracket = {
t => t.Type == TokenType.CfElif,
t => t is IdentifierToken {Name: "line"},
t => t.Type == TokenType.Period,
t => t is IdentifierToken {Name: "begins_with"},
t => t.Type == TokenType.ParenthesisOpen,
t => t is ConstantToken {Value:StringVariant{Value: "["}},
t => t.Type == TokenType.ParenthesisClose,
};
IEnumerable<Token> IScriptMod.Modify(string path, IEnumerable<Token> tokens)
{
var start_sendmsg_waiter = new MultiTokenWaiter(start_sendmsg);
var sendmsg_openbracket_waiter = new MultiTokenWaiter(sendmsg_openbracket);
var sendmsg_closebracket_waiter = new MultiTokenWaiter(sendmsg_closebracket);
var sendmsg_breakdownbracket_waiter = new MultiTokenWaiter(sendmsg_breakdownbracket);
foreach (var token in tokens) {
if (start_sendmsg_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Chat mod 0...");
yield return token;
// if text.beings_with('%'):
// text = text.trim_prefix('%')
// Network._send_message(text,chat_local)
// return
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("text");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("begins_with");
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("%"));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.OpAnd);
yield return new IdentifierToken("Network");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("LUCY_CHAT_BBCODE");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline,2);
yield return new IdentifierToken("text");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("text");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("trim_prefix");
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("%"));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline,2);
yield return new IdentifierToken("Network");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("_send_message");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("text");
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("chat_local");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline,2);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline,1);
} else if (sendmsg_openbracket_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Chat mod 1...");
yield return token;
yield return new Token(TokenType.CfIf);
yield return new Token(TokenType.OpNot);
yield return new IdentifierToken("Network");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("LUCY_CHAT_BBCODE");
yield return new Token(TokenType.Colon);
} else if (sendmsg_closebracket_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Chat mod 2...");
yield return token;
yield return new Token(TokenType.CfIf);
yield return new Token(TokenType.OpNot);
yield return new IdentifierToken("Network");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("LUCY_CHAT_BBCODE");
yield return new Token(TokenType.Colon);
} else if (sendmsg_breakdownbracket_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Chat mod 3...");
yield return token;
yield return new Token(TokenType.OpAnd);
yield return new ConstantToken(new BoolVariant(false));
} else {
yield return token;
}
}
}
}
public class LucysNetFixes : IScriptMod {
bool IScriptMod.ShouldRun(string path) => path == "res://Scenes/Singletons/SteamNetwork.gdc";
Func<Token,bool>[] original_kick = {
//t => t.Type == TokenType.Constant && t.AssociatedData == 158, // kick
t => t is ConstantToken {Value:StringVariant{Value: "kick"}},
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline
};
Func<Token,bool>[] original_ban = {
//t => t.Type == TokenType.Constant && t.AssociatedData == 160, // ban
t => t is ConstantToken {Value:StringVariant{Value: "ban"}},
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline
};
Func<Token,bool>[] original_punch = {
t => t is ConstantToken {Value:StringVariant{Value: "player_punch"}},
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline
};
Func<Token,bool>[] original_msg = {
//t => t.Type == TokenType.Constant && t.AssociatedData == 139, // message
t => t is ConstantToken {Value:StringVariant{Value: "message"}},
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline
};
Func<Token,bool>[] original_read_all = {
t => t.Type == TokenType.PrFunction,
//t => t.Type == TokenType.Identifier && t.AssociatedData == 69, // _read_all_P2P_packets
t => t is IdentifierToken {Name: "_read_all_P2P_packets"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.OpAssign,
t => t.Type == TokenType.Constant,
};
Func<Token,bool>[] original_process = {
t => t.Type == TokenType.PrFunction,
//t => t.Type == TokenType.Identifier && t.AssociatedData == 63, // _process
t => t is IdentifierToken {Name: "_process"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.CfIf,
t => t.Type == TokenType.OpNot,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.CfReturn,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.Period,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.CfIf,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.OpGreater,
t => t.Type == TokenType.Constant,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] original_physics_process = {
t => t.Type == TokenType.PrFunction,
//t => t.Type == TokenType.Identifier && t.AssociatedData == 68, // _physics_process
t => t is IdentifierToken {Name: "_physics_process"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.CfIf,
t => t.Type == TokenType.OpNot,
t => t.Type == TokenType.Identifier,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.CfReturn,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] original_globals = {
t => t.Type == TokenType.PrVar,
//t => t.Type == TokenType.Identifier && t.AssociatedData == 31, // REPLICATIONS_RECIEVED
t => t is IdentifierToken {Name: "REPLICATIONS_RECIEVED"},
t => t.Type == TokenType.OpAssign,
t => t.Type == TokenType.BracketOpen,
t => t.Type == TokenType.BracketClose,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] original_p2p_test = {
//t => t.Type == TokenType.Identifier && t.AssociatedData == 71, // PACKET
t => t is IdentifierToken {Name: "PACKET"},
t => t.Type == TokenType.Period,
//t => t.Type == TokenType.Identifier && t.AssociatedData == 241, // empty
t => t is IdentifierToken {Name: "empty"},
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Colon,
t => t.Type == TokenType.Newline,
t => t.Type == TokenType.BuiltInFunc,
t => t.Type == TokenType.ParenthesisOpen,
t => t.Type == TokenType.Constant,
t => t.Type == TokenType.ParenthesisClose,
t => t.Type == TokenType.Newline,
};
Func<Token,bool>[] original_setlobbyname = {
t => t is IdentifierToken {Name: "setLobbyData"},
t => t.Type == TokenType.ParenthesisOpen,
t => t is IdentifierToken {Name: "lobby_id"},
t => t.Type == TokenType.Comma,
t => t.Type == TokenType.Constant,
t => t.Type == TokenType.Comma,
t => t.Type == TokenType.BuiltInFunc,
t => t.Type == TokenType.ParenthesisOpen,
t => t is IdentifierToken {Name: "STEAM_USERNAME"},
t => t.Type == TokenType.ParenthesisClose,
};
IEnumerable<Token> IScriptMod.Modify(string path, IEnumerable<Token> tokens) {
var kick_waiter = new MultiTokenWaiter(original_kick);
var ban_waiter = new MultiTokenWaiter(original_ban);
var msg_waiter = new MultiTokenWaiter(original_msg);
var read_all_waiter = new MultiTokenWaiter(original_read_all);
var process_waiter = new MultiTokenWaiter(original_process);
var physics_process_waiter = new MultiTokenWaiter(original_physics_process);
var globals_waiter = new MultiTokenWaiter(original_globals);
var p2p_test_waiter = new MultiTokenWaiter(original_p2p_test);
var setlobbyname_waiter = new MultiTokenWaiter(original_setlobbyname);
var punch_waiter = new MultiTokenWaiter(original_punch);
foreach (var token in tokens) {
if (globals_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network globals...");
yield return token;
// var LUCY_PACKETS_READ = 0
// var LUCY_BULK_FULL_TIMER = 0
// var LUCY_FRAME_PACKETS = 32
// var LUCY_BULK_PACKETS = 128
// var LUCY_BULK_INTERVAL = 0.8
// var LUCY_BULK_FULL_INTERVAL = 6.4
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_PACKETS_READ");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_BULK_FULL_TIMER");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_FRAME_PACKETS");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(32));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_BULK_PACKETS");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(128));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_BULK_INTERVAL");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new RealVariant(0.8));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_BULK_FULL_INTERVAL");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new RealVariant(6.4));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_CHAT_BBCODE");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(false));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_SRV_NAME");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new StringVariant(""));
yield return new Token(TokenType.Newline, 0);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("LUCY_PUNCHED_ME");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Newline, 0);
} else if (p2p_test_waiter.Check(token)) {
yield return token;
// check if packet had sender?
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("packet_sender");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("PACKET");
yield return new Token(TokenType.BracketOpen);
yield return new ConstantToken(new StringVariant("steam_id_remote"));
yield return new Token(TokenType.BracketClose);
yield return new Token(TokenType.Newline, 2);
} else if (kick_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network kick fixes...");
yield return token;
// print("[KICK]")
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("[KICK]"));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 4);
// if GAME_MASTER: return
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("GAME_MASTER");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 4);
// if packet_sender != KNOWN_GAME_MASTER: return
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("packet_sender");
yield return new Token(TokenType.OpNotEqual);
yield return new IdentifierToken("KNOWN_GAME_MASTER");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 4);
} else if (ban_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network ban fixes...");
yield return token;
// print("[BAN]")
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("[BAN]"));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 4);
// if GAME_MASTER: return
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("GAME_MASTER");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 4);
// if packet_sender != KNOWN_GAME_MASTER: return
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("packet_sender");
yield return new Token(TokenType.OpNotEqual);
yield return new IdentifierToken("KNOWN_GAME_MASTER");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 4);
} else if (msg_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network msg fixes...");
yield return token;
// print("[msg ", _get_username_from_id(packet_sender), "] ", DATA.message)
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("[msg "));
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("_get_username_from_id");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("packet_sender");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Comma);
yield return new ConstantToken(new StringVariant("] "));
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("DATA");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("message");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 4);
} else if (read_all_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network _read_all_P2P_packets fixes...");
// func _read_all_P2P_packets(channel = 0
yield return token;
// Our new function
//
// func _read_all_P2P_packets(channel = 0, limit = 64):
// var read_count = 0
// while Steam.getAvailableP2PPacketSize(channel) > 0 and read_count < limit:
// _read_P2P_Packet(channel)
// read_count += 1
// LUCY_PACKETS_READ += read_count
// return
// ...old code
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("limit");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(64));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("read_count");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfWhile);
yield return new IdentifierToken("Steam");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("getAvailableP2PPacketSize");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("channel");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.OpGreater);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.OpAnd);
yield return new IdentifierToken("read_count");
yield return new Token(TokenType.OpLess);
yield return new IdentifierToken("limit");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("_read_P2P_Packet");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("channel");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("read_count");
yield return new Token(TokenType.OpAssignAdd);
yield return new ConstantToken(new IntVariant(1));
yield return new Token(TokenType.Newline, 1);
yield return new IdentifierToken("LUCY_PACKETS_READ");
yield return new Token(TokenType.OpAssignAdd);
yield return new IdentifierToken("read_count");
yield return new Token(TokenType.Newline, 0);
// Give old function new signature, it'll come after in token stream
yield return new Token(TokenType.PrFunction);
yield return new IdentifierToken("_old_read_all_P2P_packets");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("channel");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
} else if (process_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network _process fixes...");
// func _process(delta):
// if not STEAM_ENABLED: return
// Steam.run_callbacks()
// if STEAM_LOBBY_ID > 0:
//
yield return token;
// better code
// if STEAM_LOBBY_ID > 0:
// for i in 3: _read_all_P2P_packets(i,LUCY_FRAME_PACKETS)
// return
// if false:
yield return new Token(TokenType.CfFor);
yield return new IdentifierToken("i");
yield return new Token(TokenType.OpIn);
yield return new ConstantToken(new IntVariant(3));
yield return new Token(TokenType.Colon);
yield return new IdentifierToken("_read_all_P2P_packets");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("i");
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("LUCY_FRAME_PACKETS");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfIf);
yield return new ConstantToken(new BoolVariant(false));
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
} else if (physics_process_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network _physics_process fixes...");
// func _physics_process(delta):
// if not STEAM_ENABLED: return
//
yield return token;
// better code
// var do_print = false
// BULK_PACKET_READ_TIMER -= delta
// if BULK_PACKET_READ_TIMER <= 0:
// print("Bulk Reading Packets.")
// for i in 3: _read_all_P2P_packets(i,LUCY_BULK_PACKETS)
// BULK_PACKET_READ_TIMER = LUCY_BULK_INTERVAL
// do_print = true
// LUCY_BULK_FULL_TIMER -= delta
// if LUCY_BULK_FULL_TIMER <= 0:
// print("Reading all packets.")
// for i in 3: _read_all_P2P_packets(i,1000000)
// LUCY_BULK_FULL_TIMER = LUCY_BULK_FULL_INTERVAL
// do_print = true
// if do_print:
// print("PACKETS ", LUCY_PACKETS_READ)
// LUCY_PACKETS_READ = 0
// return
// var do_print = false
// BULK_PACKET_READ_TIMER -= delta
// if BULK_PACKET_READ_TIMER <= 0:
// print("Bulk Reading Packets.")
// for i in 3: _read_all_P2P_packets(i,LUCY_BULK_PACKETS)
// BULK_PACKET_READ_TIMER = LUCY_BULK_INTERVAL
// do_print = true
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("do_print");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(false));
yield return new Token(TokenType.Newline, 1);
yield return new IdentifierToken("BULK_PACKET_READ_TIMER");
yield return new Token(TokenType.OpAssignSub);
yield return new IdentifierToken("delta");
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("BULK_PACKET_READ_TIMER");
yield return new Token(TokenType.OpLessEqual);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("Bulk Reading Packets."));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.CfFor);
yield return new IdentifierToken("i");
yield return new Token(TokenType.OpIn);
yield return new ConstantToken(new IntVariant(3));
yield return new Token(TokenType.Colon);
yield return new IdentifierToken("_read_all_P2P_packets");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("i");
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("LUCY_BULK_PACKETS");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("BULK_PACKET_READ_TIMER");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("LUCY_BULK_INTERVAL");
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("do_print");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(true));
yield return new Token(TokenType.Newline, 1);
// LUCY_BULK_FULL_TIMER -= delta
// if LUCY_BULK_FULL_TIMER <= 0:
// print("Reading all packets.")
// for i in 3: _read_all_P2P_packets(i,1000000)
// LUCY_BULK_FULL_TIMER = LUCY_BULK_FULL_INTERVAL
// do_print = true
yield return new IdentifierToken("LUCY_BULK_FULL_TIMER");
yield return new Token(TokenType.OpAssignSub);
yield return new IdentifierToken("delta");
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("LUCY_BULK_FULL_TIMER");
yield return new Token(TokenType.OpLessEqual);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("Reading all packets."));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.CfFor);
yield return new IdentifierToken("i");
yield return new Token(TokenType.OpIn);
yield return new ConstantToken(new IntVariant(3));
yield return new Token(TokenType.Colon);
yield return new IdentifierToken("_read_all_P2P_packets");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("i");
yield return new Token(TokenType.Comma);
yield return new ConstantToken(new IntVariant(1000000));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("LUCY_BULK_FULL_TIMER");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("LUCY_BULK_FULL_INTERVAL");
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("do_print");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(true));
yield return new Token(TokenType.Newline, 1);
// if do_print:
// print("PACKETS ", LUCY_PACKETS_READ)
// LUCY_PACKETS_READ = 0
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("do_print");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.BuiltInFunc, (uint)BuiltinFunction.TextPrint);
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("PACKETS "));
yield return new Token(TokenType.Comma);
yield return new IdentifierToken("LUCY_PACKETS_READ");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("LUCY_PACKETS_READ");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new IntVariant(0));
yield return new Token(TokenType.Newline, 1);
// return
yield return new Token(TokenType.CfReturn);
yield return new Token(TokenType.Newline, 1);
} else if (punch_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network punch mod...");
yield return token;
yield return new Token(TokenType.CfIf);
yield return new Token(TokenType.OpNot);
yield return new IdentifierToken("DATA");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("has");
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("nya"));
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Colon);
yield return new IdentifierToken("LUCY_PUNCHED_ME");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("packet_sender");
yield return new Token(TokenType.Newline,4);
} else if (setlobbyname_waiter.Check(token)) {
Mod.ModInterface.Logger.Information("Adding Lucy Network lobby name mod...");
// Steam.setLobbyData(lobby_id, "name", str(STEAM_USERNAME)
yield return token;
// Steam.setLobbyData(lobby_id, "name", str(STEAM_USERNAME) if LUCY_SRV_NAME == "" else LUCY_SRV_NAME
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("LUCY_SRV_NAME");
yield return new Token(TokenType.OpEqual);
yield return new ConstantToken(new StringVariant(""));
yield return new Token(TokenType.CfElse);
yield return new IdentifierToken("LUCY_SRV_NAME");
} else {
yield return token;
}
}
}
}

5
LucysTools/manifest.json Normal file
View File

@ -0,0 +1,5 @@
{
"Id": "Lucy.LucysTools",
"AssemblyPath": "LucysTools.dll",
"PackPath": "LucysTools.pck"
}