project-zomboid-community-modding / pzns Goto Github PK
View Code? Open in Web Editor NEWA new framework for managing, spawning, and directing NPCs in Project Zomboid
License: MIT License
A new framework for managing, spawning, and directing NPCs in Project Zomboid
License: MIT License
Ex: I was doing this or that when this error came up.
So here's a doozy.
The following occurs when I walk out of the loaded cell with NPCs. They are patrolling the area, as well as a few stationary ones.
function: start -- file: WalkToTimedAction.lua line # 44 | Vanilla
Callframe at: StartAction
function: begin -- file: ISBaseTimedAction.lua line # 61 | Vanilla
function: addToQueue -- file: ISTimedActionQueue.lua line # 23 | Vanilla
function: add -- file: ISTimedActionQueue.lua line # 131 | Vanilla
function: PZNS_AddNPCActionToQueue -- file: PZNS_UtilsNPCs.lua line # 366 | MOD: PZNS_Framework
function: PZNS_WalkToSquareXYZ -- file: PZNS_WalkTo.lua line # 21 | MOD: PZNS_Framework
function: PZNS_JobGuard -- file: PZNS_JobGuard.lua line # 46 | MOD: PZNS_Framework
function: PZNS_UpdateNPCJobRoutine -- file: PZNS_ManageJobs.lua line # 68 | MOD: PZNS_Framework
function: PZNS_UpdateAllJobsRoutines -- file: PZNS_ManageJobs.lua line # 84 | MOD: PZNS_Framework.
[27-07-23 18:13:35.764] ERROR: General , 1690499615764> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: getX of non-table: null at KahluaThread.tableget line:1689..
[27-07-23 18:13:35.764] ERROR: General , 1690499615764> DebugLogStream.printException> Stack trace:.
[27-07-23 18:13:35.767] LOG : General , 1690499615767> -----------------------------------------
STACK TRACE
I noticed that there is no IG_UI_EN.txt file in the translate folder. If I want to add this file to translate the right-click menu, how should I proceed? What should I add between IGUI and PZNS_Orders?
For example:
IGUI_QNW_DebugMenu_ModeSwitch = "模式切换",
IGUI_QNW_DebugMenu_ModeSwitch_God = "上帝模式",
IGUI_QNW_DebugMenu_ModeSwitch_Ghost = "幽灵模式",
IGUI_QNW_DebugMenu_ModeSwitch_Clip = "穿墙模式",
Using 'QNW' for positioning between 'IGUI' and 'DebugMenu', what should I use to locate this mod?
Thank you for your activity and hard work. I have always believed that NPC mods are a great support for single-player gamers. Once again, thank you for your work!
PS:The above was translated entirely by ChatGPT. My English is very bad :(
Mods:
Mod Manager
Mod Options
PZNS_Framework (latest available on Steam Workshop)
Start a new game, no sandbox setting necessary. From inventory, attempt to drop or move items (such as clothing) to the floor or any container.
function: dropItem -- file: PZNS_NPCInventory.lua line # 265 | MOD: PZNS_Framework
function: onDropItems -- file: ISInventoryPaneContextMenu.lua line # 3192 | Vanilla
function: onMouseUp -- file: ISContextMenu.lua line # 90 | Vanilla
Hi,
i think it will be easy to add NamedOutfit for npc created.
Do you want a PR or it's already planned ?
(sorry i can't change the label :'( )
In SSC that crash happens time to time, i believe that is the same problem. If you walk away from npcs in "hard" fighting against zombies or other npc the program will stop responding (java level, i mean the java runtime will catch the exception, not the OS).
ERROR: General , 1691860982583> ExceptionLogger.logException> Exception thrown java.lang.NullPointerException: Cannot invoke "zombie.iso.IsoGridSquare.isInARoom()" because the return value of "zombie.characters.IsoGameCharacter.getCurrentSquare()" is null at BodyDamage.UpdateBoredom line:1829.
ERROR: General , 1691860982583> DebugLogStream.printException> Stack trace:
java.lang.NullPointerException: Cannot invoke "zombie.iso.IsoGridSquare.isInARoom()" because the return value of "zombie.characters.IsoGameCharacter.getCurrentSquare()" is null
at zombie.characters.BodyDamage.BodyDamage.UpdateBoredom(BodyDamage.java:1829)
at zombie.characters.BodyDamage.BodyDamage.Update(BodyDamage.java:2082)
at zombie.ai.states.AttackState.triggerPlayerReaction(AttackState.java:311)
at zombie.ai.states.AttackState.animEvent(AttackState.java:198)
at zombie.ai.StateMachine.stateAnimEvent(StateMachine.java:259)
at zombie.characters.IsoGameCharacter.OnAnimEvent(IsoGameCharacter.java:4235)
at zombie.core.skinnedmodel.advancedanimation.AdvancedAnimator.OnAnimEvent(AdvancedAnimator.java:264)
at zombie.core.skinnedmodel.advancedanimation.AnimLayer.invokeAnimEvent(AnimLayer.java:211)
at zombie.core.skinnedmodel.advancedanimation.AnimLayer.updateInternal(AnimLayer.java:419)
at zombie.GameProfiler.invokeAndMeasure(GameProfiler.java:166)
at zombie.core.skinnedmodel.advancedanimation.AnimLayer.Update(AnimLayer.java:323)
at zombie.core.skinnedmodel.advancedanimation.AdvancedAnimator.updateInternal(AdvancedAnimator.java:397)
at zombie.GameProfiler.invokeAndMeasure(GameProfiler.java:166)
at zombie.core.skinnedmodel.advancedanimation.AdvancedAnimator.update(AdvancedAnimator.java:368)
at zombie.characters.IsoGameCharacter.postUpdateInternal(IsoGameCharacter.java:12087)
at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83)
at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230)
at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26)
at zombie.util.Lambda.capture(Lambda.java:130)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81)
at zombie.characters.IsoGameCharacter.postupdate(IsoGameCharacter.java:12063)
at zombie.characters.IsoZombie.postUpdateInternal(IsoZombie.java:2112)
at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83)
at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230)
at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26)
at zombie.util.Lambda.capture(Lambda.java:130)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81)
at zombie.characters.IsoZombie.postupdate(IsoZombie.java:2104)
at zombie.MovingObjectUpdateSchedulerUpdateBucket.postupdate(MovingObjectUpdateSchedulerUpdateBucket.java:97)
at zombie.MovingObjectUpdateScheduler.postupdate(MovingObjectUpdateScheduler.java:177)
at zombie.CollisionManager.resolveContactsInternal(CollisionManager.java:411)
at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83)
at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230)
at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26)
at zombie.util.Lambda.capture(Lambda.java:130)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81)
at zombie.CollisionManager.ResolveContacts(CollisionManager.java:236)
at zombie.iso.IsoWorld.updateInternal(IsoWorld.java:3502)
at zombie.util.lambda.Invokers$Params1$CallbackStackItem.run(Invokers.java:37)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.core.profiling.AbstractPerformanceProfileProbe.lambda$invokeAndMeasure$0(AbstractPerformanceProfileProbe.java:83)
at zombie.util.lambda.Stacks$Params3$CallbackStackItem.invoke(Stacks.java:230)
at zombie.util.lambda.Stacks$GenericStack.invokeAndRelease(Stacks.java:26)
at zombie.util.Lambda.capture(Lambda.java:130)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:81)
at zombie.iso.IsoWorld.update(IsoWorld.java:3427)
at zombie.gameStates.IngameState.updateInternal(IngameState.java:1617)
at zombie.gameStates.IngameState.update(IngameState.java:1333)
at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:101)
at zombie.GameWindow.logic(GameWindow.java:298)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:765)
at zombie.GameWindow.run_ez(GameWindow.java:681)
at zombie.GameWindow.mainThread(GameWindow.java:495)
at java.base/java.lang.Thread.run(Unknown Source)
https://youtu.be/MZQ33P8e4Ac
In this video I'm working on mod that will periodically spawn hostile npcs inside the police stations. That police station is in Muldraugh, there is zombies inside where the spawn occurs, but I believe that the crash is not restricted to this particular situation.
The spawnNPCIsoPlayer is a function that control the spawning and despawning process based on PZNS_UtilsNPCs.PZNS_GetIsNPCSquareLoaded function, that check if the npc object has a loaded square.
Every one in-game minute the PZNS_WorldUtils.PZNS_SpawnNPCIfSquareIsLoaded is called and then for each active npc the spawnNPCIsoPlayer is called.
The logic seems that if the player go far enough the PZNS_WorldUtils.PZNS_SpawnNPCIfSquareIsLoaded will return false for some npc, and then the spawnNPCIsoPlayer should despawn the npc from world to prevent jobs issues.
What I see happening is, the PZNS_WorldUtils.PZNS_SpawnNPCIfSquareIsLoaded will return true even if the npc becomes off-screen (off rendered, or not visible even if you pan de camera), when the player returns the npc becomes invisible, the name of npc render fixed in one square (the last rendered square i suppose), but npc can do things like attack.
The mod i'm working will spawn hostile npcs prisoners in the Police Stations, i believe that my "solution" is particular for my goal so i will not make a pull request, instead i will share sections of the code.
First i created a custom spawnNPCIsoPlayer, i called oza_spawnNPCIsoPlayer. Then i override the PZNS_WorldUtils.PZNS_SpawnNPCIfSquareIsLoaded to call oza_spawnNPCIsoPlayer instead of spawnNPCIsoPlayer.
In oza_spawnNPCIsoPlayer i used PZNS_WorldUtils.PZNS_IsSquareInPlayerSpawnRange, IsoPlayerObject:setGhostMode and changed the conditional control structure to discriminate 3 scenarios:
The (2) the oza_spawnNPCIsoPlayer change the npcIsoPlayerObject to ghost mode to prevent zombie fight off-screen and do the same of the (3). The (3) do the same of the else in spawnNPCIsoPlayer and the (1) set the ghost mode to false.
The code is a mess because I'm still working on it XD, just find the oza_spawnNPCIsoPlayer
Concatenate more info on line 82 with the below code to get more context.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.