Skip to content

Merge fork#23

Open
Justin7654 wants to merge 32 commits into
Toast732:majour-updatesfrom
Justin7654:majour-updates
Open

Merge fork#23
Justin7654 wants to merge 32 commits into
Toast732:majour-updatesfrom
Justin7654:majour-updates

Conversation

@Justin7654
Copy link
Copy Markdown
Contributor

  • Adds a new tag that vehicle packs can use called sink_depth which overrides the depth that the vehicle explodes at
  • Fixes vehicles getting stuck in a infinite loop when trying to enter the resupply squad
  • Fixes vehicles not correctly refilling ammo after resupplying, causing them to immediately re-enter resupply squad next time its loaded or if its already at a base getting in another infinite loop.
  • Fixes "(Cargo.getTank) Error getting tank data" debug spam when a cargo vehicle is loaded
  • Cargo vehicle tanks now get filled correctly
  • Resupplying will now also refill reserve ammo containers, which was causing issues with some land vehicles like the Humvee
  • Improves tickVision performance by spreading out what squads are checked in "analyse player vehicles" over 20 ticks instead of every tick. Squads that are currently targeting a player vehicle will bypass this and still update every tick. I don't know how I feel about this change, the issue is still there, just less severe.

I noticed that in the base ICM, the release file had "_ENV = setupTraceback(table.copy.deep(_ENV))" commented out but in debugging.lua, it wasn't commented which resulted in it being uncommented in this fork. It might be related to a issue I have with the fork where using "?icm info" causes the game to freeze and then do a bunch of errors related to tracebacks.

Made it so that instead of looping through EVERY player sub body, then inside that loop it also loops through every single AI vehicle sub body, and then compares some stuff, it now spreads it out alittle by only doing each player sub body every 10 ticks. Idk if the last position thing is what the keypads use which would cause some issues so 10 ticks for now until a proper fix is done.
The one mine added was every 10 ticks, and the other (originally there) was every 240 ticks. Made it seperate instead of elseif so they dont conflict and the 240 tick one doesnt get skipped
This reverts commit 46e0bfd.

Revert "Seperated the 2 if statements so they dont conflict with eachother"

This reverts commit 76176c0.

Revert "Made the tickVision issue less severe."

This reverts commit a87c22c.
Fixed infinite resupply loop and updated map debug to show "needs resupply" correctly
The reloading ammo is fixed, now just need to make it reload reserve ammo and it reset vehicle state correctly.
Also tried to get resetVehicleState to work correctly, discovered it needed to be called when the vehicle is loaded, but it came with lots of other issues i dont know how to fix so im just going to leave a comment and leave that alone.
Spreads out each squad analyzing player sub bodys for every 20 ticks. If a squad is targetting the player vehicle, it can bypass this and run every frame so its keypads get updated
…k index: 1 spam when cargo vehicle is loaded

Cause of issue was using a group id instead of vehicle id
All the tanks on the cargo vehicles were 0 when you go to them. Swapped it out to the correct vehicle_id and now it works
@Justin7654
Copy link
Copy Markdown
Contributor Author

Opps, accidentally posted early.
I also discovered that in the corvette, both the front machine gun and the front turret use "ammo 1" which causes reloading to fail and makes it enter another infinite loop of trying to resupply. This didn't get fixed in the fork.

Justin7654 and others added 15 commits December 2, 2025 23:17
… now

Took so long to debug. Previously once the scout vehicles do 1 loop around the target island, they would have no more points so they would get put into holding state. Then they would be forever stuck in the holding state even after finishing the scouting and the code in the "vehicle_object.role == "scout"" branch never gets used.

In the history and when the scout code was originally written, the if statement was originally #vehicle_object.path > 1 but it later got changed to >0 and then doing nextPath and another check for >0. Its always greater than 0 before nextPath since it would error so the fix was to remove that first if statement and move everything down after nextPath gets used so it properly runs if its reached the last point in the path and its a scout vehicle.
Script:
- Fixed abunch of warnings in VsCode due to incorrect typing and function use
- Made NSO graph_node debug points for boats stand out more, before the shade of blues were almost identical. Non-NSO ones are still alittle hard to see
- Fixed mass always being nil in vehicle_players due to it using getVehicleData instead of getVehicleComponents
- Fixed the script checking the tag "spawning_distance" instead of "spawning_radius" which is used on all the AI vehicles
- Some debug statements added, alittle spammy so might remove later once done
Playlist:
- Removed abunch of NSO graph nodes where they are outdated and no roads exist on that tile anymore. Mainly focused on the area where land AI keeps getting trapped on NSO nodes
- Fixed North Harbor boat pathfinding being entirely separated from the world in non-NSO mode due to ICM having graph_nodes tagged as being NSO only on the corner of the tiles around north harbor, which got merged with the default AI paths addon's corner nodes
- Partial NSO support at fishing village. Not complete
- Fixed boats bypassing the custom NSO pathfinding in the sawyer river where those little islands are
- Commands system now uses the OOP command system used in IMAI
- Flags.lua updated to IMAI
- matrix.lua, a few lines of addonCommuncation.lua, and math.lua updated to IMAI (Added functionality only)
- unitConversions.lua, vector2.lua, vector3.lua and speedTracker.lua added because im planning to port the improved land driving AI over and thats whats started this whole thing
- Fixed some warnings
Code:
- Added types
- Fixed warnings throughout the addon
- Improved documentation in a bunch of places with more detailed descriptions and parameter/return types
- Deleted commands_OLD.txt from the last commit
- Squad.lua now has use other than containing the code for making squads. It now houses lookups, management functions, and other code related to squads. No more directly accessing the squad table and repeating the same code repeatedly or calling obscure undocumented functions at the bottom of main.lua
- Fixed land squads joining squads they cant get to
- Fixed squads getting set to defend/patrol islands they cant drive to
- Other minor things that i dont have time to write because im really in a rush to push this
Playlist:
- Completed NSO update at fishing village
- Renamed land-access tags to land_access
- Fixed boats at the arid power plant base being stuck in it and not being able to pathfind anywhere else due to no graph nodes nearby (Maybe fixed? Untested if it actually worked)

Known Issues:
- Dont know if this is related to my changes, might not be since i saw this error awhile ago, but the first convoy that spawned was spamming that it couldn't get its squad. That band-aid fix i made fixed it kind of.
Code:
- Version incremented to 0.4.0.27
- Fixed regression from previous commit which caused getSquadFromGroup to fail after a vehicle used transferToSquad (removeVehicle blindly set its squad_vehicles to nil, and since transferring added and then removed, the squad_vehicles entry pointing to the new squad would get erased)
- Added warnings when setting up the world if theres a base which can spawn land vehicles but doesn't have a land_access
- Simplified some squad management in tickAI for attacking islands, replacing checks for if a boat can access a island to instead use Squad.canAccessIsland so it also can support land vehicle checks
- Added test_path command, which shows you the pathfinding from your location to the given coordinates. Use it to confirm if pathfinding can cross something or if something is reachable or to find suspicious paths to narrow down on broken areas
- Added show_dead_ends, which performs pathfinding on every graph node to map out connections. By default it places markers on graph nodes which only have 1 connection (So if theres 2 "dead ends" in the middle of a road, then theres something broken with the pathfinding there). If given "true" as its second argument, it will also draw lines to visualize all the pathfinding connections (Like Roblox's Navigation Mesh debug mode). That mode is really laggy but can show additional problems and also is just a cool visualization

Playlist:
- Fixed the following islands not having a land_access tag resulting in broken land AI behaviour:
    - Olsen Bay
    - Toastery Village
    - Fort Lewin
    - Kelp Mesa
- The following islands no longer have boat access:
    - Benzin Plateau
    - Station Enzo
    - Dean Hall
- Renamed ARID_ISLAND_8_10 to BENZIN PLATEAU
- Fixed none of the graph nodes having connections on arid_island_3_9 and 1 other tile
- Fixed a ton of broken connections. This includes single disconnected graph_nodes, and graph_nodes not getting merged on tile borders. Arid pathfinding is much much better and more reliable now.
- Fixed a facility not having any pathfinding on mega_island_10_7

Known regressions from base ICM:
- None

Known issues that have not been fixed:
- A roads pathfinding on mega_island_10_7 is completely broken in multiple places due to the nodes getting merged with NSO nodes
- Kobold Iron Quarry at arid_island_17_14 has lots of connection issues which cause lots of lines to get drawn (???) randomly around some of its nodes.
- Some slight traceback spam when AI gets loaded/unloaded due to invalid groups being given to getSquadFromGroup
Adds a GitHub Action which automatically creates a release which users can unzip and put into their stormworks missions folder without any changes. The releases will also be more stable since some of my commits have bugs and are generally unstable.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Justin7654 <95324492+Justin7654@users.noreply.github.com>
…spam

- Fixed matrix is nil error in matrix.distance/tickVehicles. Root cause isn't fixed but now it will just print a warning in chat instead of a error
- Commented out some prints in Squad.lua due to annoying traceback spam. I'll uncomment and find the actual issue later on
- Simplified a graph node connection
Refactored math.euclideanDistance and math.angleToFace to use explicit arguments to improve documentation and typing warnings
Renamed remaining use of AnyIsland to ANY_ISLAND
Squad.canJoinSquad no longer requires a squad leader for checks which dont need a squad leader
Replaced a math.min(math.max)) with math.clamp()
Other small improvements for readability
- Replaced addToSquadron with Squad.getBestSquadForVehicle and replaced the only code which used addToSquadron with a version which used Squad.getBestSquadForVehicle (addToSquadron is now deprecated)
- Renamed Vehicle.getSpeed to Vehicle.getTargetSpeed
- Deleted squad recovery code as the root bug was fixed
- Migrated some more code from setSquadCommand to Squad.setCommand
- Removed unnecessary tonumber call when getting sink_depth tag
- Added ICMRouteSegment class so that Cargo.getBestRoute's return has autocomplete and diagnostics
- Fixed issue with Cargo.bestBestRoute where it would break when its trying to resupply from a island which cant spawn any vehicles (Checkpoint Tom, prob because there's another flag on the same tile) resulting in it returning a route where island_index is nil resulting in warnings and it never sending it. It now instead properly outputs that there's no best route
- Adds convoy cooldown command
- Tags.getValue now uses function overloading so its return value will be a string when as_string is true and number any other time. (Improves diagnostic warnings and typing for some classes)
- Fixed ?vreset constantly saying that the argument must be a number even when it is
- Fixed vehicle teleport call when vehicles are loaded too close giving vehicle_object instead of a group ID

Playlist:
- Allowed Checkpoint Tom to spawn land vehicles (even if they spawn at the other flag) to resolve it being unable to send cargo
- Moved some graph nodes around at Uran Wind Power Plant to hopefully fix some boats getting stuck and not being able to pathfind anywhere
main.lua:
- Added type annotations to player_vehicles and cargo_vehicles in g_savedata for autocomplete
- Increased convoy base_wait_time from 45 seconds to 2 minutes to hopefully reduce the issues of the convoy vehicle leaving without any escorts while the escorts are still enroute
- Added profiling to setupMain to help optimize the setup time
- Removed land_access tag check in setupMain
- Implemented spatial hashing optimization in onVehicleDamaged where it checks what AI vehicles did the damage. Also found & noted a issue i found with the current logic
- Check table length of valid_ai_vehicles (which loops over the list) once and then reference that instead of checking the length for every item in valid_ai_vehicles
- Added type annotations for PLAYER_VEHICLE
- Added parameter type annotations for cleanVehicle()
- Replaced repeated code in cleanVehicle with a signle Squad.removeVehicle call after confirming it didn't do anything
- player_vehicle voxel data now gets populated in onVehicleLoad
- The distance check that AI vehicles do in onVehicleLoad now uses spatial hashing to only check vehicles within 200m instead of every AI vehicle. The check may false negative if both vehicles spawning_distance adds up to a number above 200, but that's why the number is so big.
- "analyse player vehicles" in tickVision now uses spatial hashing, which very significantly reduced the performance impact. When combined with the checks being spread out, makes the impact basically 0. Still keeping the check spreading because this doesn't need to be updated every single tick anyways.
- "analyse player vehicles" is now spread out by 10 ticks instead of 20 ticks
- "analyse players" in tickVision is now spread out by 10 ticks. Does not yet use spatial hashing due to complications in how it currently works. Will be rewritten later on
- Removed pathing debug messages i previously added
- Added debug text to map debug when a AI vehicle is killed and its current death timer
- Turned off tickVehicleCleaner profiler as it is always 0ms
- Turned on tickModifiers profiler as a replacement
- Removed "temporary backwards compatibility for testing version" code in tickCargoVehicles
- Added debug prints throughout tickCargoVehicles about the convoy state
- Fixed cargo vehicles not getting killed and instead joining the normal AI squads when its finished with the cargo. (Now force kills)
- Fixed "check to see if we have a valid convoy" safety check in tickSquadrons never working because convoy is initialized as {} instead of nil
- Added safeguard for when a cargo vehicle is waiting to have cargo transferred to it from another cargo vehicle but there is no other cargo vehicle. Don't know the root cause yet.
- Added tickSpatialGrid() for updating spatial hashing positions for AI vehicles and player vehicles
- Added code to maintain the ai vehicles spatial grid (like removing from the grid in cleanVehicle)

icmCommands.lua:
- Moved capturepoint command to island.lua
- Added getgroupid command so i can see what AI vehicle chat debug is talking about

cache.lua:
- Removed debug prints since it would get spammed a ton during cargo calculations and it also made it slower

pathfinding.lua:
- Fixed duplicate lines in map debug. Before, there was a line from the start position to end position and a second line from the AI's position to the end position. Could maybe fix the random lines being left behind on the map too.

spatialGrid.lua:
- Added

spatialGridDefinitions.lua:
- Added

characters.lua:
- Added some debug to troubleshoot a bug that sometimes happens

cargo.lua:
- Replaced a direct command set to instead use Squad.setCommand
- Fixed some type annotations
- Fixed some false diagnostic warnings

squad.lua:
- getLeader no longer automatically disbands the squad if its empty as it caused issues
- Squad.disband now also resets the assigned_squad_index of any islands referencing the squad being disbanded

vehicle.lua:
- Added killvehicle command

playlist.xml:
- Updated the Checkpoint ChickenSaur - Checkpoint Tom conflict by adding individual spawn zones using owner=
main.lua changes:
- setupMain
   - Fixed Tags.has call giving the island variable instead of island.tags
   - Replaced the repeated giant island tables for the player base, ai base, and neutral bases with a Island.createIslandData() call so its easier to make changes and see what the island data includes
   - Optimized neutral island creation by adding a spawned_neutral_islands variable that counts up instead of repeatedly using table.length to loop over it every iteration
   - Optimized spawn zone linking by adding all_islands and islands_by_name tables so it doesn't need to loop over every island everytime it finds a spawn zone with a owners= tag. When it does need to loop over all the islands, it can do it with a single loop instead of duplicating the code for the AI base, player base, and neutral bases.
- Moved some of the capturing logic code in tickGamemode to captureSystem.lua to make it way easier to read instead of a massive thing of if statements together with all the other if statements

island.lua changes:
- Moved into islands folder
- Added Island.createIslandData function
- Renamed Island.canSpawn to Island.canSpawnPrefab
- All of the GetDataFrom(x) functions now use the IslandRegistry system

islandRegistry.lua added:
- System which loops over every island in g_savedata on world load and indexes them into tables so you can look them up without looping over every island. Also handles setting up the island_grid spatial hashing. Currently has: by_index, by_group_id, by_name, by_faction, by_land_access

captureSystem.lua added:
- A direct port of some of the code that used to be in tickGamemode to now be separated into functions and be overall easier to read
- One of the only changes that affect people using the addon: Capturing now speeds up as more people capture (up to 4 max) instead of it going down. 100% -> 135% -> 170% -> 200%

capturePointPayments.lua changes:
- Moved into islands folder

spatialGrid.lua changes:
- Added optional OOP, you can now do stuff like player_vehicles_grid:add() instead of SpatialGrid.add(player_vehicles_grid). That is also now the recommended way of doing it
- Added freezing. You can call freeze() on a spatial grid and it will return a FrozenSpatialGrid class, which has all of its methods except :query() removed and its data is different. object_keys is completely gone and its only needed for updating the grid, and cells is replaced with a row structure which is better for querying. It also converts the cell contents from a dictionary/table to a list which maybe uses less memory and is also faster to loop through when querying. Don't have a big enough static grid though to test how big of a impact the changes make.

spatialGridDefinitions.lua changes:
- Added island_grid for querying nearby capture points. The object ID's are the islands index.

other changes:
- Removed differences between ISLAND, AI_ISLAND, and PLAYER_ISLAND in function arguments since they are all almost the same thing except AI_ISLAND is the AI base island and PLAYER_ISLAND is the players base island.
- Replaced all instances of is.canSpawn with Island.canSpawnPrefab
- Ported binder.lua from IMAI
- Made IslandRegistry use the binder to setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants