---- Moves the bus door while players are close to it. ---- Updated: 7/01/09 jnf... local ProxRadius = 75 local soundName = '{9a24f1fa-3177-4745-a2df-fbd996d6e1e3}' function onStartup(self) self:SetVar("counter", 0) self:SetProximityRadius{radius = ProxRadius, name = "busDoor"} self:StopPathing() end function moveDoor(self, bOpen) --print('move door **************') if bOpen then --print('open door **************') self:GoToWaypoint{iPathIndex = 0} else --print('close door **************') self:GoToWaypoint{iPathIndex = 1} end self:PlayNDAudioEmitter{m_NDAudioEventGUID = soundName} end function onProximityUpdate(self, msg) -- If this isn't the proximity radius for the bus door behavior, then we're done here if (msg.name ~= "busDoor") then return end local faction = msg.objId:GetFaction() -- Make sure only humans are taken into account if faction.faction ~= 1 then return end --print('proximity update **************') local counter = self:GetVar("counter") --print(counter) if (msg.status == "ENTER") then if counter == 0 then moveDoor(self, true) end counter = counter + 1 elseif (msg.status == "LEAVE") then if counter > 0 then counter = counter - 1 if counter == 0 then moveDoor(self, false) end end end self:SetVar("counter", counter) end function onArrivedAtDesiredWaypoint(self, msg) if msg.iPathIndex == 1 then self:PlayFXEffect{ name = "busDust", effectType = "create"} -- effectID = 642, --print('play effect busDust') end end