first commit
This commit is contained in:
commit
c160183700
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Crab Champions Utilities Mod
|
||||
|
||||
This uses [UE4SS 2.5.2](https://github.com/UE4SS-RE/RE-UE4SS)
|
||||
|
||||
335
Scripts/main.lua
Normal file
335
Scripts/main.lua
Normal file
@ -0,0 +1,335 @@
|
||||
print("[BenUtils] Loaded and waiting!")
|
||||
|
||||
--- Swapping to use register/unregister
|
||||
-- Disable looplicator by default
|
||||
-- LOOPLICATOR_ENABLED = false
|
||||
--
|
||||
|
||||
|
||||
-- Globals
|
||||
LOOPLICATOR_PRE_ID = 0
|
||||
LOOPLICATOR_POST_ID = 0
|
||||
LOOPLICATOR_MULITPLIER = 2
|
||||
LOOPLICATOR_ROUNDS = 10
|
||||
LOOPLICATOR_XL_COST = 1
|
||||
|
||||
COMMANDS_REGISTERED = {}
|
||||
-- End Globals
|
||||
|
||||
---@param command string
|
||||
---@param callback function
|
||||
function RegisterCommand(command, callback)
|
||||
COMMANDS_REGISTERED[command] = callback
|
||||
print(string.format("[BenUtils] Registered command %s", command))
|
||||
end
|
||||
|
||||
function FindKeyTodem()
|
||||
print("test")
|
||||
---@type table<ACrabTotem>
|
||||
local todems = FindAllOf("CrabTotem")
|
||||
print("Found " .. #todems .. " todems")
|
||||
for i, item in ipairs(todems) do
|
||||
if item.TotemType == 3 then
|
||||
return item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param PlayerName string
|
||||
function GetPlayerStateByName(PlayerName)
|
||||
local crabs = FindAllOf("CrabPS")
|
||||
for _, v in ipairs(crabs) do
|
||||
-- local crab = v:get()
|
||||
if v.PlayerNamePrivate:ToString() == PlayerName then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function LookupCCWeaponByName(itemname)
|
||||
|
||||
end
|
||||
|
||||
function LookupCCPerkByName(itemname)
|
||||
---@type table<UCrabPerkDA>
|
||||
local perks = FindAllOf("CrabPerkDA")
|
||||
print("Found " .. #perks .. " perks")
|
||||
for i, item in ipairs(perks) do
|
||||
if item.Name:ToString() == itemname then
|
||||
return item
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function LookupCCAbilityByName(itemname)
|
||||
|
||||
end
|
||||
|
||||
function LookupCCMeleeByName(itemname)
|
||||
|
||||
end
|
||||
|
||||
function LookupCCArtifactByName(itemname)
|
||||
|
||||
end
|
||||
|
||||
-- Force UI Refresh? ACrabPC:ClientRefreshPSUI
|
||||
|
||||
---@param CRAB ACrabInteractPickup
|
||||
---@param nim any
|
||||
function CheckReturnedSelf(CRAB, nim)
|
||||
-- print(string.format("You have: %d crystals\n", CRAB.Keys))
|
||||
print(nim.PickupInfo.PickupDA.Name:ToString())
|
||||
end
|
||||
|
||||
function SetScaleMultiplier()
|
||||
---@param crab ACrabPS
|
||||
local crab = FindFirstOf("CrabPS")
|
||||
print(type(crab))
|
||||
if crab then
|
||||
print(string.format("[BenUtils] The current ScaleMultiplier is: %.3f", crab.ScaleMultiplier))
|
||||
end
|
||||
end
|
||||
|
||||
function GiveInitialStreamerLoot()
|
||||
-- Get a copy of the game state and a list of players and the StreamerLoot item
|
||||
local streamerloot = LookupCCPerkByName("Streamer Loot")
|
||||
local gamestate = FindFirstOf("CrabGS")
|
||||
local crabs = FindAllOf("CrabPS")
|
||||
local crabss = FindAllOf("CrabPC")
|
||||
local key_totem = FindKeyTodem()
|
||||
crabs[1].Crystals = 10000000000
|
||||
crabss[1]:ClientRefreshPSUI()
|
||||
---@param v ACrabPS
|
||||
-- for i, v in ipairs(crabs) do
|
||||
-- v.ServerSpawnKeyTotemPickup(key_totem,)
|
||||
|
||||
-- print(string.format("%d", x.TotemType))
|
||||
-- end
|
||||
end
|
||||
|
||||
---@param PlayerName string
|
||||
function GiveCrystalsToPlayer(PlayerName, ...)
|
||||
local args = table.pack(...)
|
||||
---@type ACrabPS
|
||||
local player = GetPlayerStateByName(PlayerName)
|
||||
if player and #args == 1 then
|
||||
player.Crystals = tonumber(args[1]) or player.Crystals
|
||||
end
|
||||
end
|
||||
|
||||
function GibCrystals()
|
||||
local crabs = FindAllOf("CrabPS")
|
||||
|
||||
if crabs then
|
||||
---@param v ACrabPS
|
||||
for i, v in ipairs(crabs) do
|
||||
v.Crystals = 10000000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SetAllPerks100()
|
||||
local crabs = FindAllOf("CrabPS")
|
||||
|
||||
if crabs then
|
||||
---@param v ACrabPS
|
||||
for i, v in ipairs(crabs) do
|
||||
print(string.format("Crab with ID: %s", v.PlayerNamePrivate:ToString()))
|
||||
if v.PlayerNamePrivate:ToString() == "Aztec" then
|
||||
---@param wmod FCrabWeaponMod
|
||||
v.WeaponMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabWeaponMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level <= 100 then
|
||||
mod.InventoryInfo.Level = 100
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabAbilityMod
|
||||
v.AbilityMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabAbilityMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level <= 100 then
|
||||
mod.InventoryInfo.Level = 100
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabMeleeMod
|
||||
v.MeleeMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabMeleeMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level <= 100 then
|
||||
mod.InventoryInfo.Level = 100
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabPerk
|
||||
v.Perks:ForEach(function(index, wmod)
|
||||
---@class mod FCrabPerk
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level <= 100 then
|
||||
mod.InventoryInfo.Level = 100
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function looplicator()
|
||||
local gamestate = FindFirstOf("CrabGS")
|
||||
|
||||
local island_num = gamestate.CurrentIsland
|
||||
if island_num % (LOOPLICATOR_ROUNDS) == 0.00 then
|
||||
gamestate.XLLevel = 1
|
||||
end
|
||||
-- This checks to see if the last round was divisble by 10
|
||||
if island_num ~= 1 and (island_num - 1) % LOOPLICATOR_ROUNDS == 0.00 then
|
||||
print("[BenUtils] Triggered Looplicator, doubling levels of all perks")
|
||||
local crabs = FindAllOf("CrabPS")
|
||||
|
||||
if crabs then
|
||||
---@param v ACrabPS
|
||||
for i, v in ipairs(crabs) do
|
||||
---@param wmod FCrabWeaponMod
|
||||
v.WeaponMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabWeaponMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level ~= 255 then
|
||||
if mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER < 255 then
|
||||
mod.InventoryInfo.Level = mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER
|
||||
else
|
||||
mod.InventoryInfo.Level = 255
|
||||
end
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabAbilityMod
|
||||
v.AbilityMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabAbilityMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level ~= 255 then
|
||||
if mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER < 255 then
|
||||
mod.InventoryInfo.Level = mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER
|
||||
else
|
||||
mod.InventoryInfo.Level = 255
|
||||
end
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabMeleeMod
|
||||
v.MeleeMods:ForEach(function(index, wmod)
|
||||
---@class mod FCrabMeleeMod
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level ~= 255 then
|
||||
if mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER < 255 then
|
||||
mod.InventoryInfo.Level = mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER
|
||||
else
|
||||
mod.InventoryInfo.Level = 255
|
||||
end
|
||||
end
|
||||
end)
|
||||
---@param wmod FCrabPerk
|
||||
v.Perks:ForEach(function(index, wmod)
|
||||
---@class mod FCrabPerk
|
||||
local mod = wmod:get()
|
||||
if mod.InventoryInfo.Level ~= 255 then
|
||||
if mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER < 255 then
|
||||
mod.InventoryInfo.Level = mod.InventoryInfo.Level * LOOPLICATOR_MULITPLIER
|
||||
else
|
||||
mod.InventoryInfo.Level = 255
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function enable_looplicator()
|
||||
if LOOPLICATOR_POST_ID == 0 and LOOPLICATOR_POST_ID == 0 then
|
||||
LOOPLICATOR_PRE_ID, LOOPLICATOR_POST_ID = RegisterHook("/Script/CrabChampions.CrabPC:ClientOnEnteredPortal",
|
||||
looplicator)
|
||||
else
|
||||
UnregisterHook("/Script/CrabChampions.CrabPC:ClientOnEnteredPortal", LOOPLICATOR_PRE_ID, LOOPLICATOR_POST_ID)
|
||||
LOOPLICATOR_PRE_ID = 0
|
||||
LOOPLICATOR_POST_ID = 0
|
||||
end
|
||||
end
|
||||
|
||||
---@param PlayerName string
|
||||
function RollTheDice(PlayerName, ...)
|
||||
print("[BenUtil] Got chat command rtd from " .. PlayerName)
|
||||
local args = table.pack(...)
|
||||
for k, v in ipairs(args) do
|
||||
print(string.format("[BenUtil] Arg: %s", v))
|
||||
end
|
||||
-- print(string.format("[BenUtil] %d arguments sent", args.n))
|
||||
end
|
||||
|
||||
---@param PlayerName FString
|
||||
---@param ChatMessage FString
|
||||
function ParseChatCommand(self, PlayerName, ChatMessage)
|
||||
local playername = PlayerName:get()
|
||||
local chatmessage = ChatMessage:get()
|
||||
local firstchar = string.sub(chatmessage:ToString(), 1, 1)
|
||||
---@type table
|
||||
local command = {}
|
||||
if firstchar == "/" then
|
||||
for i in string.gmatch(chatmessage:ToString(), "%S+") do
|
||||
table.insert(command, i)
|
||||
end
|
||||
local cmd = string.sub(command[1], 2, #command[1])
|
||||
-- local args = table.remove(command, 1)
|
||||
if COMMANDS_REGISTERED[cmd] then
|
||||
COMMANDS_REGISTERED[cmd](playername:ToString(), table.unpack(command, 2, #command))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param KeyTotem ACrabTotem
|
||||
function TestThing(self, KeyTotem)
|
||||
local test = KeyTotem:get()
|
||||
print(string.format("%d", test.NumBuffs))
|
||||
print(string.format("%d", test.NumDeBuffs))
|
||||
print(string.format("%d", test.Cost))
|
||||
end
|
||||
|
||||
---@param NextIslandInfo FCrabNextIslandInfo
|
||||
function TestThing2(self, NextIslandInfo)
|
||||
local test = NextIslandInfo:get()
|
||||
print(string.format("%d", test.CurrentIsland))
|
||||
-- print(string.format("%d", test.NumDeBuffs))
|
||||
-- print(string.format("%d", test.Cost))
|
||||
end
|
||||
|
||||
-- RegisterKeyBind(Key.F1, function()
|
||||
-- print("[BenUtils] Set Perks to 100\n")
|
||||
-- ExecuteInGameThread(function()
|
||||
-- SetAllPerks100()
|
||||
-- end)
|
||||
-- end)
|
||||
|
||||
-- RegisterKeyBind(Key.F2, function()
|
||||
-- print("[BenUtils] Money Money Money\n")
|
||||
-- ExecuteInGameThread(function()
|
||||
-- GibCrystals()
|
||||
-- end)
|
||||
-- end)
|
||||
|
||||
RegisterKeyBind(Key.F3, function()
|
||||
print("[BenUtils] Enabled Looplicator\n")
|
||||
ExecuteInGameThread(function()
|
||||
enable_looplicator()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- RegisterHook("/Script/CrabChampions.CrabPC:ClientOnInteractedWithKeyTotem", TestThing)
|
||||
-- RegisterHook("/Script/CrabChampions.CrabPC:ClientOnEnteredPortal", TestThing2)
|
||||
RegisterHook("/Script/CrabChampions.CrabPC:ClientOnReceivedChatMessage", ParseChatCommand)
|
||||
RegisterCommand("rtd", RollTheDice)
|
||||
RegisterCommand("dosh", GiveCrystalsToPlayer)
|
||||
-- RegisterHook("/Script/CrabChampions.CrabPC:ClientOnInteractedWithKeyTotem", TestThing);
|
||||
-- NotifyOnNewObject("/Script/Engine.Actor", function(ConstructedObject)
|
||||
-- print(string.format("Constructed: %s\n", ConstructedObject:GetFullName()))
|
||||
-- end)
|
||||
|
||||
--- CrabInteractPickup /Game/Island/Persistent.Persistent:PersistentLevel.CrabInteractPickup_2147481644
|
||||
Loading…
x
Reference in New Issue
Block a user