-------------------------------------------------------------- -- Script on the Parrots Crash in Gnarled Forest -- keeps the player from getting to the treasure -- -- stolen from the spider cave entrance script in AG -- updated Brandi... 1/28/10 -------------------------------------------------------------- require('o_mis') local textVar = "You must wear a ninja cowl to get past the parrots." -- default values for mBox local mBox = {boxTarget = nil, isDisp = false, isTouch = false, isFirst = true, boxSelf = nil, boxText = '', boxTime = 1 } function onStartup(self,msg) self:SetVar("playerIn",false) end function MakeBox() -- check to make sure we have a target if mBox.boxTarget == nil or mBox.isDisp then return end mBox.isDisp = true -- --print('Creating Box') newTime = mBox.boxTime GAMEOBJ:GetTimer():AddTimerWithCancel( newTime, "BoxTimer", mBox.boxSelf ) mBox.boxTarget:DisplayTooltip { bShow = true, strText = mBox.boxText, iTime = mBox.boxTime*1000 } end function onCollisionPhantom(self,msg) local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID()) if (player:GetID() ~= msg.objectID:GetID()) then return end if (self:GetVar("playerIn") == false) then GAMEOBJ:GetTimer():AddTimerWithCancel( 0.6, "playerEntered",self ) self:SetVar("player", msg.objectID) local AnimObj = self:GetObjectsInGroup{ group = 'ParrotCrash', ignoreSpawners = true }.objects[1] AnimObj:StopFXEffect{name = "parrotwall"} AnimObj:PlayFXEffect{name = "parrotwall", effectID = 967, effectType = "pushy"} AnimObj:PlayAnimation{ animationID = 'parrot', bPlayImmediate = true } local anim_time = AnimObj:GetAnimationTime{ animationID = "parrot" }.time self:SetVar("playerIn",true) end end function onTimerDone(self,msg) local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID()) if (msg.name == "playerEntered") then if player then local dir = self:GetObjectDirectionVectors().forward dir.y = 20 dir.x = 5--dir.x * 50 dir.z = -30--dir.z * 50 mBox.boxTarget = player player:PlayFXEffect{name = "birdcavepushback", effectID = 1537, effectType = "create"}--effectID = 1378, effectType = "push-back"} player:PlayAnimation{ animationID = "knockback-recovery" } player:Knockback { vector = dir } self:SetVar("playerIn",false) end if not player then return end --or mBox.isTouch or mBox.isDisp mBox.boxSelf = self mBox.isTouch = true mBox.boxText = textVar GAMEOBJ:GetTimer():AddTimerWithCancel( 0.1, "EventTimer", self ) end if msg.name == "BoxTimer" then mBox.isDisp = false resetBox() end -- checks to see if EventTimer has been called and if we are ready to do MakeBox(), need a valid mBox.boxTarget if msg.name == "EventTimer" then if not mBox.boxTarget then GAMEOBJ:GetTimer():AddTimerWithCancel( 0.1, "EventTimer", mBox.boxSelf ) return end MakeBox() end end function resetBox() -- checks to see if we are ready to reset mBox if mBox.isDisp or mBox.isTouch then return end -- default values mBox = {boxTarget = nil, isDisp = false, isTouch = false, isFirst = true, boxSelf = nil, boxText = '', boxTime = 1 } end