FILES ----- default_actor_movement.config player.config universe_server.config interface\cockpit\blue.png interface\cockpit\cockpit.config monsters\ground\approachstate.lua monsters\pets\petball\petball.monstertype npcs\main.lua npcs\sitstate.lua npcs\sleepstate.lua npcs\guard\guardstate.lua npcs\guard\houndstate.lua npcs\guard\returntopoststate.lua [NEW] player\playereffects.animation projectiles\throwable\petball\petball.projectile scripts\pathing.lua tech\boat\boat.lua tech\boat\boat.tech terrain\cave\corecaves.terrain terrain\cave\normalcaves.terrain terrain\cave\surfacecaves.terrain DIFFS ----- default_actor_movement.config 20a21 > "liquidBuoyancy" : 0, player.config 562c562,563 < "teleportAnimator" : "/animations/teleport/playerteleport.animation", --- > "effectsAnimator" : "/player/playereffects.animation", > universe_server.config 8,9c8,9 < "updateMeasureWindow" : 60000, < "maxBehindUpdates" : 20, --- > "updateMeasureWindow" : 10000, > "maxBehindUpdates" : 30, 11d10 < "updateMeasureAverage" : 60, interface\cockpit\cockpit.config 265c265 < "pos" : [345, 120], --- > "pos" : [343, 120], 384c384 < "rect" : [ 374, 176, 430, 216 ], --- > "rect" : [ 370, 176, 426, 216 ], monsters\ground\approachstate.lua 35,40c35,38 < -- Commented out until pathing works - < -- TODO: Uncomment this when pathing works < -- if option.valid and checkStuck() > 4 then < -- self.state.pickState({flee=true}) < -- return true < -- end --- > if option.valid and checkStuck() > 4 then > self.state.pickState({flee=true}) > return true > end 45c43,44 < if moveTo(option.approachPoint, dt, {run = option.approachDistance >= 1.0}) then --- > if moveTo(option.approachPoint, dt, {run = option.approachDistance >= 1.0}) > or (option.approachDistance < 6 and moveTo(option.approachPoint, dt, {run = option.approachDistance >= 1.0, returnBest = true, maxDistance = 6})) then 48c47 < entity.setAnimationState("movement", "idle") --- > move(option.approachDelta, option.approachDistance >= 1.0) 55c54 < approachState.controlFace(dt, stateData, util.toDirection(self.toTarget[1])) --- > mcontroller.controlFace(util.toDirection(self.toTarget[1])) 57c56 < approachState.controlFace(dt, stateData, self.pathing.deltaX) --- > mcontroller.controlFace(self.pathing.deltaX) 63,73d61 < end < < function approachState.controlFace(dt, stateData, direction) < if direction ~= stateData.lastDirection and self.facingTimer <= 0 then < self.facingTimer = self.facingCooldown < mcontroller.controlFace(direction) < stateData.lastDirection = direction < else < --Maintain the old direction < mcontroller.controlFace(stateData.lastDirection) < end monsters\pets\petball\petball.monstertype 41c41,43 < "airForce" : 50.0 --- > "airForce" : 50.0, > "liquidBuoyancy" : 2, > "liquidFriction" : 8 npcs\main.lua 58,84c58,59 < < -- NPCs aren't always placed right on the ground. They may need to be < -- moved up or down a few blocks so their spawn position is actually on the < -- ground < local supportRegion = { < math.floor(position[1] + 0.5) - 1, math.floor(position[2] + 0.5) - 3, < math.floor(position[1] + 0.5) + 1, math.floor(position[2] + 0.5) - 2, < } < < for i = 0, 3, 1 do < if world.rectTileCollision(supportRegion, true) then < supportRegion[2] = supportRegion[2] + 1 < supportRegion[4] = supportRegion[4] + 1 < else < break < end < end < < for i = 0, 3, 1 do < supportRegion[2] = supportRegion[2] - 1 < supportRegion[4] = supportRegion[4] - 1 < if world.rectTileCollision(supportRegion, false) then < break < end < end < < storage.spawnPosition = { position[1], supportRegion[2] + 3.5 } --- > local groundPosition = findGroundPosition(position, -20, 3) > storage.spawnPosition = groundPosition or position npcs\sitstate.lua 26c26 < local targetPosition = world.entityPosition(stateData.targetId) --- > local targetPosition = findGroundPosition(world.entityPosition(stateData.targetId), 0, 4) 43a44,45 > world.debugLine(position, targetPosition, "green") > world.debugPoint(position, "green") npcs\sleepstate.lua 33a34 > bedPosition = findGroundPosition(bedPosition, -1, 3) or bedPosition npcs\guard\guardstate.lua 163a164 > --TODO: Make this find a valid position to patrol to npcs\guard\houndstate.lua 40a41 > targetPosition = findGroundPosition(targetPosition, -15, 3) or targetPosition npcs\guard\returntopoststate.lua 21c21 < moveTo(storage.spawnPosition, dt) --- > moveTo(storage.spawnPosition, dt, {returnBest = true, maxDistance = 25}) projectiles\throwable\petball\petball.projectile 5c5 < "timeToLive" : 5, --- > "timeToLive" : 3, 8d7 < "lightColor" : [105, 64, 0], scripts\pathing.lua 13a14,18 > local pathOptions = { > returnBest = options.returnBest, > maxDistance = options.maxDistance or 80, > swimCost = 40 > } 31c36 < if not findPath(targetPosition) then --- > if not findPath(targetPosition, pathOptions) then 33a39,42 > elseif self.pathing.path.currentEdge == nil then > --The found path is empty, try again later > self.pathing.path = nil > return true 37c46 < local path = updatePath() --- > local path = updatePath(pathOptions) 44a54,60 > if path.currentEdge == nil then > --Reached the end of the path on this update > --Find a new path right away > self.pathing.expirationTime = nil > return true > end > 54c70 < local delta = {nextPathPosition[1] - position[1], nextPathPosition[2] - position[2]} --- > local delta = world.distance(nextPathPosition, position) 76a93,103 > --Approach the jump position more precisely to follow the jump arc accurately > if delta[1] > 0.1 then > script.setUpdateDelta(1) > moveX(delta[1]) > return true > end > --Remove air friction while jumping > mcontroller.controlParameters({ > airFriction = 0 > }) > 90a118,124 > > --Teleport to node position for very accurate jumping > --(Not noticeable) > if not path.jumped then > mcontroller.setPosition(nextPathPosition) > end > 106a141,145 > --Remove air friction while jumping > mcontroller.controlParameters({ > airFriction = 0 > }) > 109,113c148 < -- Move a bit towards the next node in case we landed right on the corner < -- of a ledge, just short of the next node. < moveX(delta[1]) < -- If we landed too far from the node to get there then we'll shortly < -- recalculate the path again anyway. --- > self.pathing.path = nil 131a167,175 > > local boundBox = mcontroller.boundBox() > if math.abs(delta[1]) < 0.25 and (delta[2] > boundBox[4] or delta[2] < boundBox[2]) then > -- Unable to walk vertically - something went wrong following this path, > -- so generate a new one > self.pathing.path = nil > return true > end > 137c181,190 < repathDistance = 2 --- > function getExpirationTime(targetPosition) > local distance = world.magnitude(world.distance(mcontroller.position(), targetPosition)) > -- Update quickly near the target, and slowly at a long distance from the target > local expiryMultiplier = 1.0/9.0 + distance * 7.0 / 90.0 > -- At 5 tiles, expiryMultiplier = 0.5 > -- At 50 tiles, expiryMultiplier = 4.0 > return world.time() + expiryMultiplier * (1 + math.random()) > end > > repathDistance = 5 139c192 < function findPath(targetPosition) --- > function findPath(targetPosition, options) 141c194 < self.pathing.expirationTime = world.time() + 1.0 + math.random() --- > self.pathing.expirationTime = 0 158c211 < self.pathing.path = entity.findPath(targetPosition) --- > self.pathing.path = entity.findPath(targetPosition, options) 160c213 < self.pathing.expirationTime = world.time() + 1.0 + math.random() --- > self.pathing.expirationTime = getExpirationTime(targetPosition) 165c218 < function updatePath() --- > function updatePath(options) 167c220 < return findPath(self.pathing.targetPosition) --- > return findPath(self.pathing.targetPosition, options) tech\boat\boat.lua 53,54d52 < local collisionPoly = tech.parameter("collisionPoly") < local maxRiseSpeed = tech.parameter("maxRiseSpeed") 56d53 < local boatHeight = tech.parameter("boatHeight") 128,130d124 < < local velocity = mcontroller.velocity() < mcontroller.controlApproachYVelocity(maxRiseSpeed, buoyancy * (liquid[2] / boatHeight), true) 159,177c153 < local liquid = world.liquidAt(liquidPosition) < if not liquid then return false end < < for y = 1, 10 do < local liquidAbove = world.liquidAt({liquidPosition[1], liquidPosition[2] + y}) < if liquidAbove then < liquid[2] = liquid[2] + liquidAbove[2] < if liquidAbove[2] < 1 then break end < end < end < < local blockHeight = liquidPosition[2] % 1 < liquid[2] = liquid[2] - blockHeight < < if liquid[2] <= 0 then return < false < else < return liquid < end --- > return world.liquidAt(liquidPosition) tech\boat\boat.tech 22,23d21 < "buoyancy" : 400, < "boatHeight" : 3, 39a38 > "liquidBuoyancy" : 4, terrain\cave\corecaves.terrain 11c11 < "layerDensity" : 0.05, --- > "layerDensity" : 0.08, 26c26 < "bias" : -0.05 --- > "bias" : 0 107c107 < "numberOfWormsPerSectorRange" : [0.2, 0.2], --- > "numberOfWormsPerSectorRange" : [0.25, 0.3], terrain\cave\normalcaves.terrain 11c11 < "layerDensity" : 0.05, --- > "layerDensity" : 0.08, 26c26 < "bias" : -0.05 --- > "bias" : 0 107c107 < "numberOfWormsPerSectorRange" : [0.2, 0.2], --- > "numberOfWormsPerSectorRange" : [0.25, 0.3], terrain\cave\surfacecaves.terrain 11c11 < "layerDensity" : 0.05, --- > "layerDensity" : 0.08, 26c26 < "bias" : -0.1 --- > "bias" : 0 34,35c34,35 < "amplitude" : 12, < "bias" : 4 --- > "amplitude" : 16, > "bias" : 6 66c66 < "numberOfWormsPerSectorRange" : [0.2, 0.2], --- > "numberOfWormsPerSectorRange" : [0.25, 0.3],