-------------------------------------------------------------- -- Foot Race script that -- updated mrb... 1/18/10 -------------------------------------------------------------- require('ai/ACT/L_ACT_GENERIC_ACTIVITY_MGR') ---------------------------------------------- -- sent when the object checks it's pick type ---------------------------------------------- function onGetPriorityPickListType(self, msg) local myPriority = 0.8 if ( myPriority > msg.fCurrentPickTypePriority ) then msg.fCurrentPickTypePriority = myPriority if self:GetVar('isInUse') then msg.ePickType = -1 else msg.ePickType = 14 -- Interactive pick type end end return msg end ---------------------------------------------- -- sent when the local player interacts with the -- object ---------------------------------------------- function onCheckUseRequirements(self, msg) local playerID = GAMEOBJ:GetLocalCharID() -- check to see if we are the correct player if playerID ~= msg.objIDUser:GetID() or self:GetVar('isInUse') then return end local player = GAMEOBJ:GetObjectByID(playerID) -- tell the object to do what it's supposed to, then turn off the interaction icon toggleActivatorIcon(self, true) if IsPlayerInActivity(self, player) then player:DisplayMessageBox{bShow = true, imageID = 3, callbackClient = self, text = "Do you want to stop the foot race?", identifier = "Foot_Race_Stop"} else player:DisplayMessageBox{bShow = true, imageID = 3, callbackClient = self, text = "Do you want to start the foot race?", identifier = "Foot_Race_Start"} end msg.bCanUse = false return msg end ---------------------------------------------- -- sent when the player responds to the message box ---------------------------------------------- function onMessageBoxRespond(self, msg) -- Response to Exit activity dialog and user pressed OK print(msg.identifier .. ' ' .. msg.iButton) if msg.identifier == "Foot_Race_Stop" or msg.identifier == "Foot_Race_Start" then toggleActivatorIcon(self) end end ---------------------------------------------- -- toggles the activator Icon based on bHide, -- to toggle it on you dont have to pass bHide ---------------------------------------------- function toggleActivatorIcon(self, bHide) local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID()) if not bHide then -- show the icon, cancel notification, set isInUse to false bHide = false self:SetVar('isInUse', false) else -- hide the icon, request notification, set isInUse to true self:SetVar('isInUse', true) end -- request the interaction update self:RequestPickTypeUpdate() end