GE Lua Documentation

Press F to search!

workload

Definition


-- @/lua/ge/extensions/gameplay/statisticModules/watchJturn.lua:29

local function watchJturn( v , vid , dtSim)
  simTime = simTime + dtSim --probably broken
  if vid ~= myvid then cancel() end
  myvid = vid

  velocity:set(v:getVelocityXYZ())
  if velocity:length() < 8 then cancel(); return end
  velocity:normalize()
  -- vpos:set(v:getPositionXYZ())
  vdir:set(v:getDirectionVectorXYZ())

  if vdir:dot(velocity) < -THRESHOLD then
    triggered = true
    if simTime > lastBack+REFRESH then
      lastBack = simTime
      -- log("I","","back"..dumps(simTime))
      backingdir:set(vdir)
      frontTimer = 1
    end
  end
  if triggered then
    if vdir:dot(velocity) > THRESHOLD and backingdir:dot(velocity) < THRESHOLDUTURN then
      frontTimer = frontTimer - dtSim
      if(frontTimer<0) then
        triggered = false
        -- log("I","","JTURN")
        gameplay_statistic.metricAdd("vehicle/jturn",1)
        cancel()
      end
    end
    if (lastBack + TIMEOUT) < simTime then
      -- log("I","","FRONT 1="..dumps((lastBack + TIMEOUT) < simTime))
      cancel()
    end
  end
  -- print(simTime)
  -- if upWorldVector:dot(vup) > THRESHOLD then
  --   if triggered then
  --     if lastRoof + TIMEOUT > simTime and lastUpright + TIMEOUT*2 > simTime then
  --       log("I","","rolllllllll")
  --       gameplay_statistic.metricAdd("vehicle/rollover",1)
  --     else
  --       log("I","","rol timeout r" ..dumps(lastRoof + TIMEOUT > simTime).."\tup="..dumps(lastUpright + TIMEOUT*2 > simTime))
  --     end
  --     cancel()
  --   end
  --   if simTime > lastUpright+REFRESH then
  --     lastUpright = simTime
  --   end
  -- end
  -- if upWorldVector:dot(vup) < -THRESHOLD and abs(vdir:dot(velocity)) lastRoof+REFRESH then
  --   log("I","","roof")
  --   triggered = true
  --   lastRoof = simTime
  -- end
  -- print( dumps(upWorldVector:dot(vup)).."\t"..dumps(vdir:dot(velocity)) .."\ttr="..dumps(triggered) )
end

Callers