If Wagstaff's tools try to spawn too close (within 1 turf tile) of either the "Hubbub for Grub" or "Eggs in a Basket" Cawnival Games then it will crash the game

  • Pending

Explanation for why this occurs:

Like many things in the Moonstorm, Wagstaff's tools cannot spawn on the Grub or Memory Cawnival games. This is achieved by picking an initial location for these entities then applying an offset that is calculated using the FindWalkableOffset function, then teleporting the entities to this location. In moonstormManager.lua, the FindWalkableOffset function always takes in the customcheckfn as an input. The customcheckfn is what actually prevents the entities from spawning within 1 turf tile of these two specific Cawnival games. HOWEVER, the FindWalkableOffset function has a default return value of nil. So if that function doesn't find any offsets based on its inputs, then it will output nil. This is normally not an issue, as moonstormManager.lua usually has checks to make sure this value isn't nil before using it. However, when spawning Wagstaff's tools, this check is not performed. Below are lines 657-659 of moonstormManager.lua. These lines are from the spawnTool() function. Notice that "pos" is set to the output of the FindWalkableOffset function; however, no check is performed to make sure that "pos" does not equal nil before the game attempts to add it to "currentpos".

657        local currentpos = Vector3(self.wagstaff.Transform:GetWorldPosition())
658        local pos = FindWalkableOffset(currentpos, math.random()*2*PI, 6+ (math.random()* 4), 16nilnil, customcheckfn, nilnil)
659        local newpos = currentpos + pos

At the end of this post, I have included the error and stack traceback from the server log. The error occurs in line 10 of vector3.lua (this line is the "__add( rhs )" function). The error occurs when a vector3 instance goes to add "rhs" to itself. It tries to index "rhs", but you can't index a nil value. The traceback reveals that this function was called from line 659 of the spawnTool() function in moonstormmanager.lua. This line is shown above to be the line where the offset is added to Wagstaff's position. The rest of the traceback isn't really useful, but I included it anyways.




Here is a simple fix. Just check that "pos" isn't nil before adding it to "currentpos", then have the Transform set the position to "currentpos" (instead of "newpos"). This may not be the fix you want to implement, but I figured I throw it in here.

657        local currentpos = Vector3(self.wagstaff.Transform:GetWorldPosition())
658        local pos = FindWalkableOffset(currentpos, math.random()*2*PI, 6+ (math.random()* 4), 16nilnil, customcheckfn, nilnil)
--begin changes
659        if pos then
660                currentpos = currentpos + pos
661        end
662        tool.Transform:SetPosition(currentpos.x,0,currentpos.z)
--end changes
663        table.insert(self.wagstaff_tools,tool)





Error and Traceback:

[00:03:02]: [string "scripts/vector3.lua"]:10: attempt to index local 'rhs' (a nil value)
LUA ERROR stack traceback:
scripts/vector3.lua:10 in () ? (Lua) <9-11>
   self =
      y = 6.7687944138584e-009
      x = 406.54754638672
      z = -45.137607574463
   rhs = nil
scripts/components/moonstormmanager.lua:659 in (method) spawnTool (Lua) <634-673>
   self =
      tools_need = PERIODIC 100026: 10.154455
      TestMoonAltarLinkPositionValid = function - scripts/components/moonstormmanager.lua:734
      AdvanceWagstaff = function - scripts/components/moonstormmanager.lua:506
      beginWagstaffDefence = function - scripts/components/moonstormmanager.lua:562
      DoTestForSparks = function - scripts/components/moonstormmanager.lua:697
      startNeedTool = function - scripts/components/moonstormmanager.lua:541
      FindUnmetCharacter = function - scripts/components/moonstormmanager.lua:516
      foundTool = function - scripts/components/moonstormmanager.lua:548
      moonstorm_lightning_task = PERIODIC 100026: 27.420275
      StartMoonstorm = function - scripts/components/moonstormmanager.lua:302
      FailExperiment = function - scripts/components/moonstormmanager.lua:442
      CalcNewMoonstormBaseNodeIndex = function - scripts/components/moonstormmanager.lua:272
      DoTestForLightning = function - scripts/components/moonstormmanager.lua:713
      moonstorm_spark_task = PERIODIC 100026: 30.000000
      StopExperiment = function - scripts/components/moonstormmanager.lua:425
      defence_task = PERIODIC 100026: 7.000000
      AddMetplayer = function - scripts/components/moonstormmanager.lua:558
      GetNewWagstaffLocation = function - scripts/components/moonstormmanager.lua:535
      DoTestForWagstaff = function - scripts/components/moonstormmanager.lua:675
      StopExperimentTasks = function - scripts/components/moonstormmanager.lua:400
      MoonStorm_Ending = true
      wagstaff_tools_original = table: 0CCFD8D0
      spawnTool = function - scripts/components/moonstormmanager.lua:634
      inst = 100026 - world (valid:true)
      stormdays = 0
      spawnGestaltWave = function - scripts/components/moonstormmanager.lua:607
      TestAltarTriangleValid = function - scripts/components/moonstormmanager.lua:755
      OnSave = function - scripts/components/moonstormmanager.lua:797
      OnLoad = function - scripts/components/moonstormmanager.lua:810
      tools_task = PERIODIC 100026: 8.000000
      SpawnGestalt = function - scripts/components/moonstormmanager.lua:586
      wagstaff_tools = table: 0CCFDBA0
      wagstaff = 117850 - wagstaff_npc (valid:true)
      GetDebugString = function - scripts/components/moonstormmanager.lua:856
      spawn_wagstaff_test_task = PERIODIC 100026: 10.000000
      lastnodes = table: 11AF1038
      StopCurrentMoonstorm = function - scripts/components/moonstormmanager.lua:375
      metplayers = table: 0A33D2F0
      EndExperiment = function - scripts/components/moonstormmanager.lua:462
      beginWagstaffHunt = function - scripts/components/moonstormmanager.lua:490
   idx = 2
   toolname = wagstaff_tool_5
   tool = 118212 - wagstaff_tool_5 (valid:true)
   currentpos = (406.55, 0.00, -45.14)
   pos = nil
scripts/components/moonstormmanager.lua:672 in (field) fn (Lua) <672-672>
scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207>
   self =
      running = table: 0B2EC4B0
      waitingfortick = table: 0B2EC230
      tasks = table: 0B2EC410
      waking = table: 25A64C00
      attime = table: 0B2EC2F8
      hibernating = table: 0B2EC528
   tick = 3693
   k = PERIODIC 100026: 8.000000
   v = true
   already_dead = false
scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377>
   tick = 3693
scripts/update.lua:185 in () ? (Lua) <164-243>
   dt = 0.033333335071802
   tick = 3693
   i = 3693

[00:03:02]: [string "scripts/vector3.lua"]:10: attempt to index local 'rhs' (a nil value)
LUA ERROR stack traceback:
    scripts/vector3.lua:10 in () ? (Lua) <9-11>
    scripts/components/moonstormmanager.lua:659 in (method) spawnTool (Lua) <634-673>
    scripts/components/moonstormmanager.lua:672 in (field) fn (Lua) <672-672>
    scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207>
    scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377>
    scripts/update.lua:185 in () ? (Lua) <164-243>
[00:03:02]: Warning: Widget:SetFocusFromChild is happening on a widget outside of the screen/widget hierachy. This will cause focus moves to fail. Is     ScriptErrorWidget    not a screen?    
[00:03:02]: stack traceback:
    scripts/widgets/widget.lua:604 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626>
    scripts/widgets/widget.lua:648 in (method) SetFocus (Lua) <628-657>
    scripts/widgets/menu.lua:83 in (method) SetFocus (Lua) <74-85>
    scripts/widgets/scripterrorwidget.lua:109 in (method) OnUpdate (Lua) <102-119>
    scripts/update.lua:95 in () ? (Lua) <33-134>    

Steps to Reproduce

1. Start the Wagstaff minigame

2. Place the "Hubbub for Grub" or "Eggs in a Basket" Cawnival game near Wagstaff (I would recommend spamming them to increase the chance of the crash occurring, but you only need one)

3. If one of Wagstaff's tools tries to spawn too close (within 1 turf tile) to a Cawnival game, then the game will crash

User Feedback

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now