-------------------------------------------------------------------------------- -- -- TUTORIAL 1 15.08.2009 -- Vitaly.Parovishnik@gameloft.com -- -------------------------------------------------------------------------------- gTutorialStep = 1 gActiveMenu = -1 gWantedMenu = -1 gWantedButton1 = -1 gWantedButton2 = -1 gWantedBuilding = -1 gPrevTutStep = -1 gTextStep = 1 gCommandOk = 1 gPrevZoomFactor = 0 gZoomPath = 0 gGeologistCheck = 0 gCarrierMorphCount = 0 gText = 1 gTime1 = 0 ---------------------------------------------------------------------------------- function DummyVictoryCheck() end ---------------------------------------------------------------------------------- function OnDragBuilding(type) if gWantedBuilding == -1 then return end if (gWantedBuilding == type) then gTutorialStep = gTutorialStep+1 gWantedBuilding = -1 end end ------------------------------------------------------------------------------ function check_zoom () if Tutorial.GetCurrentZoomFactor() <= 15 then unrequest_event( check_zoom, Events.TICK ) request_event( tutorial_main, Events.TICK ) gTutorialStep = gTutorialStep+1 end end function wait_for_zoom () unrequest_event( tutorial_main, Events.TICK ) request_event( check_zoom, Events.TICK ) end -------------------------------------------------------------------------------- -- IF SETTLERTYPE IN PRODUCTION, the gTutorialStep will be increased -- -- WARNING: FUNCTION IS NOT OPTIMAL FOR GENERAL PURPOSE -- -------------------------------------------------------------------------------- function OnSettlerProduction(settlertype) -- if Puppet_auto_controll == 12 then -- This one is used for Step 36 ... if gTutorialStep == 36 then if (settlertype == Settlers.GEOLOGIST) then print ("Settlers.GEOLOGIST") Order_Control(10) --calling Order_controll for 10 Geologistes end end end -- Subfunction, relative to above one ... -- CarrierMorphLimit will controll the maximum of Settlers changeing -- their job ... function Order_Control (CarrierMorphLimit) gCarrierMorphCount = gCarrierMorphCount + 1 if (gCarrierMorphCount == CarrierMorphLimit) then -- gCarrierMorphCount : Amount of Carriers that have chanhe gTutorialStep = gTutorialStep + 1 gCarrierMorphCount = 0 gText = 1 end end ------------------------------------------------------------------------------- function OnCommand(command) if (command == 0 ) then if (gCommandOk == 1) then Tutorial.ClearMarker() end end end ------------------------------------------------------------------------------- function BuildingOnRightPlaceAndDestroyCheck(buildingtype, x,y) if (Buildings.ExistsBuildingInArea(1,buildingtype,x,y,5, Buildings.UNDERCONSTRUCTION) == 0) then id = Buildings.GetFirstBuilding(1,buildingtype) Buildings.CrushBuilding(id) gPrevTutStep = 0 gText = 1 Tutorial.ShowText("TUT_BAD_PLACE", 1) gWantedButton1 = Control.BTN_MESSAGE_BOX end Tutorial.DeleteWorldCursor() end function abs(a) if (a > 0) then return a end return -a end function OnBtnClick(btn) if (btn == gWantedButton1) then if (gTutorialStep == 3 or gTutorialStep == 6 or gTutorialStep == 7 or gTutorialStep == 9 or gTutorialStep == 11 or gTutorialStep == 33 or gTutorialStep == 39) then gText = 1 end if (gTutorialStep == 45 or gTutorialStep == 50) then gTutorialStep = gTutorialStep - 4 else gTutorialStep = gTutorialStep + 1 end gWantedButton1 = -1 gWantedButton2 = -1 end if (btn == gWantedButton2) then gTutorialStep = gTutorialStep + 2 gWantedButton2 = -1 gWantedButton1 = -1 end if (gTutorialStep == 36 and btn == Control.BTN_SPECIALIST_UP) then gGeologistCheck = gGeologistCheck +1 if (gGeologistCheck == 10) then Tutorial.DisableControls( Control.BTN_SPECIALIST_UP, Control.BTN_SETTLERS, Control.BTN_SETTLERS_SPECIALISTS, Control.BTN_SPECIALIST1 ) end end if (btn == Control.BTN_BUILDINFO_NO) then if (gTutorialStep == 10) then gText = 1 end gTutorialStep = gTutorialStep - 3 gWantedButton1 = -1 gWantedButton2 = -1 end end ------------------------------------------------------------------------------- -- -- main tutorial function -- -------------------------------------------------------------------------------- function tutorial_main() -- Code which executes constantly during tutorial step and monitors for necessary changes gTime1 = gTime1 + 1 -- print ("TutorialStep = ", gTutorialStep) if (gTutorialStep == 1) then gTime2 = gTime1 elseif (gTutorialStep == 2 ) then if (gTime1 - gTime2 >= 30) then --1.5 sec gTutorialStep = gTutorialStep + 1 gTime1 = 0 gTime2 = 0 gWantedButton2 = -1 gWantedButton1 = -1 end end if (gTutorialStep == 1 ) then gTutorialStep = gTutorialStep + 1 elseif (gTutorialStep == 4 ) then if ((Map.PointIsOnScreen(156,144) == 1) or (Map.PointIsOnScreen(203,137) == 1) or (Map.PointIsOnScreen(160, 103) == 1) or (Map.PointIsOnScreen(194, 172) == 1) or (Map.PointIsOnScreen(151, 120) == 1) or (Map.PointIsOnScreen(214, 170) == 1) or (Map.PointIsOnScreen(169, 158) == 1) or (Map.PointIsOnScreen(183, 107) == 1)) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 5) then zoomFactor = Tutorial.GetCurrentZoomFactor() gZoomPath = gZoomPath + abs(zoomFactor - gPrevZoomFactor) gPrevZoomFactor = zoomFactor if (gZoomPath > 300000) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 10) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.WOODCUTTERHUT, Buildings.UNDERCONSTRUCTION) > 0) or (Buildings.Amount( Game.LocalPlayer(), Buildings.WOODCUTTERHUT, Buildings.READY) > 0) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 11) then if Buildings.Amount( Game.LocalPlayer(), Buildings.WOODCUTTERHUT, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 2 gText = 1 end elseif (gTutorialStep == 12) then if Buildings.Amount( Game.LocalPlayer(), Buildings.WOODCUTTERHUT, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 17) then if Buildings.Amount( Game.LocalPlayer(), Buildings.SAWMILL, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 22) then if Buildings.Amount( Game.LocalPlayer(), Buildings.STONECUTTERHUT, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 27) then if Buildings.Amount( Game.LocalPlayer(), Buildings.HUNTERHUT, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 32) then if Buildings.Amount( Game.LocalPlayer(), Buildings.FISHERHUT, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 37) then if Settlers.Amount( Game.LocalPlayer(), Settlers.GEOLOGIST ) >= 10 then Map.SetScreenPos(172,127) gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 38) then if (Settlers.AmountInArea( Game.LocalPlayer(), Settlers.GEOLOGIST,159,116,2) > 0) or (Settlers.AmountInArea( Game.LocalPlayer(), Settlers.GEOLOGIST,161,122,2) > 0) or (Settlers.AmountInArea( Game.LocalPlayer(), Settlers.GEOLOGIST,155,108,2) > 0) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 39) then if (Map.DecoObjectAmountInArea(Objects.SHIELD_COAL1, Objects.SHIELD_COAL3, 140, 110, 4) > 2) then gTutorialStep = gTutorialStep + 2 gText = 1 end elseif (gTutorialStep == 40) then if (Map.DecoObjectAmountInArea(Objects.SHIELD_COAL1, Objects.SHIELD_COAL3, 140, 110, 4) > 2) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 45) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.COALMINE, Buildings.UNDERCONSTRUCTION) > 0) then BuildingOnRightPlaceAndDestroyCheck(Buildings.COALMINE, 140,110) end if Buildings.Amount( Game.LocalPlayer(), Buildings.COALMINE, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 50) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.GOLDMINE, Buildings.UNDERCONSTRUCTION) > 0) then BuildingOnRightPlaceAndDestroyCheck(Buildings.GOLDMINE, 135,116) end if Buildings.Amount( Game.LocalPlayer(), Buildings.GOLDMINE, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 55) then if Goods.Amount( Game.LocalPlayer(), Goods.GOLDBAR) >= 2 then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 60) then if Buildings.Amount( Game.LocalPlayer(), Buildings.EYECATCHER03, Buildings.READY) > 0 then gTutorialStep = gTutorialStep + 1 gText = 1 end end if (gPrevTutStep == gTutorialStep) then return end -- The code below executes only once for each tutorial step ------------------------------------------------------------------------------- -- -- Introduce -- -------------------------------------------------------------------------------- if gTutorialStep == 1 then Tutorial.ShowText() elseif gTutorialStep == 2 then Tutorial.DisableControlsExcept( Control.BTN_M...
szczepuz999