-------------------------------------------------------------------------------- -- -- TUTORIAL 3 26.08.2009 -- Vitaly.Parovishnik@gameloft.com -- -------------------------------------------------------------------------------- gActiveMenu = -1 gWantedMenu = -1 gTutorialStep = 1 gTemp = 0 -- multiuse variable gPrevTutStep = -1 gCommandOk = 1 gWantedButton1 = -1 gWantedButton2 = -1 gWantedSettler = 0 gWantedBuilding = -1 gTargetBuilding = 0 idMarketplace = -1 iType = 0 gCarrierMorphCount = 0 gSettlerFocus = 0 gText = 0 gSettlerCheck = 0 gToolCheck = 0 SoldierSymbolSelected = 0 -- Used as bool, helps to controll the Gui ... delay_count = 0 gXPos = 0 gYPos = 0 gXPos2 = 0 gYPos2 = 0 ------------------------------------------------------------------------------- -- Kill a building if missplaced -- ------------------------------------------------------------------------------- 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 ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- functions ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- function OnCommand(command) if (command == 0) and (gCommandOk == 1) then Tutorial.ClearMarker() end end function OnBtnClick(btn) if (btn == gWantedButton1) then if (gTutorialStep == 2 or gTutorialStep == 3 or gTutorialStep == 25 or gTutorialStep == 37 or gTutorialStep == 38 or gTutorialStep == 55 or gTutorialStep == 79 or gTutorialStep == 80 or gTutorialStep == 101 or gTutorialStep == 106) then gText = 1 end gTutorialStep = gTutorialStep + 1 gWantedButton1 = -1 gWantedButton2 = -1 end if (btn == gWantedButton2) then gTutorialStep = gTutorialStep + 2 gWantedButton2 = -1 gWantedButton1 = -1 end if (gTutorialStep == 57 and btn == Control.BTN_TOLLS_UP) then gToolCheck = gToolCheck +1 if (gToolCheck == 5) then gToolCheck = 0 gTemp = 1 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.SetButtonMarker(Control.BTN_TOLLS_GOODS6, 0) Tutorial.DisableControls( Control.BTN_TOLLS_GOODS6, Control.BTN_TOLLS_UP ) end elseif (gTutorialStep == 72 and btn == Control.BTN_VEHICLE_UP) then gToolCheck = gToolCheck +1 if (gToolCheck == 1) then gToolCheck = 0 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.SetButtonMarker(Control.BTN_VEHICLE1, 0) Tutorial.DisableControls( Control.BTN_VEHICLE1, Control.BTN_VEHICLE_UP ) gTemp = 2 end elseif (gTutorialStep == 76 and btn == Control.BTN_SPECIALIST_UP) then gSettlerCheck = gSettlerCheck +1 if (gSettlerCheck == 8) then gSettlerCheck = 0 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_SETTLERS, Control.BTN_SETTLERS_SPECIALISTS, Control.BTN_SPECIALIST3, Control.BTN_SPECIALIST_UP ) end elseif (gTutorialStep == 89 and btn == Control.BTN_SETTLER_UP) then gSettlerCheck = gSettlerCheck +1 if (gSettlerCheck == 2) then gSettlerCheck = 0 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_SETTLER_DIGGER, Control.BTN_SETTLER_UP ) end elseif (gTutorialStep == 92 and btn == Control.BTN_SETTLER_UP) then gSettlerCheck = gSettlerCheck +1 if (gSettlerCheck == 2) then gSettlerCheck = 0 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_SETTLERS, Control.BTN_SETTLERS_BASIC_OCCUPATIONS, Control.BTN_SETTLER_BUILDER, Control.BTN_SETTLER_UP ) end elseif (gTutorialStep == 110 and btn == Control.BTN_SPECIALIST_UP) then gSettlerCheck = gSettlerCheck +1 Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) if (gSettlerCheck == 1) then gSettlerCheck = 0 Tutorial.DisableControls( Control.BTN_SPECIALIST2, Control.BTN_SPECIALIST_UP ) end end if (btn == Control.BTN_BUILDINFO_NO) then gTutorialStep = gTutorialStep - 3 gWantedButton1 = -1 gWantedButton2 = -1 end end -------------------------------------------------------------------------------- -- IF SETTLERTYPE IN PRODUCTION, the gTutorialStep will be increased -- -- WARNING: FUNCTION IS NOT OPTIMAL FOR GENERAL PURPOSE -- -------------------------------------------------------------------------------- function OnSettlerProduction(settlertype) if gTutorialStep == 76 then if (settlertype == Settlers.PIONEER) then -- print ("Settlers.PIONEER") Order_Control(8) --calling Order_controll for 8 Pioneer end end -------------------------------------------------------------------------------- if gTutorialStep == 89 then if (settlertype == Settlers.DIGGER) then -- print ("Settlers.DIGGER") Order_Control(2) end end -------------------------------------------------------------------------------- if gTutorialStep == 92 then if (settlertype == Settlers.BUILDER) then -- print ("Settlers.BUILDER") Order_Control(2) end end -------------------------------------------------------------------------------- if gTutorialStep == 110 then if (settlertype == Settlers.THIEF) then -- print ("Settlers.THIEF") Order_Control(1) 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 Tutorial.CloseSidebar() end end -------------------------------------------------------------------------- -- goods request -------------------------------------------------------------------------- function OnStorageAreaGetGood(buildingtype, goodtype, amount) if ( goodtype == Goods.STONE) and (buildingtype == Buildings.MARKETPLACE) then unrequest_event( OnStorageAreaGetGood, Events.GOODARRIVE) gTutorialStep = gTutorialStep + 1 gText = 1 end end -------------------------------------------------------------------------- -- main tutorial function, called every tick -------------------------------------------------------------------------- function tutorial_main() -------------------------------------------------------------------------- --major checks ... done every tick -------------------------------------------------------------------------- gCommandOk = 1 delay_count = delay_count + 1 -- print ("TutorialStep = ", gTutorialStep) if (gTutorialStep >= 75 and gTutorialStep <= 81) then iType = Settlers.GetTypeInBlockedPlace(Game.LocalPlayer(), Settlers.PIONEER, 0, 120, 4 ) if ( iType == Settlers.PIONEER) then Settlers.GoToPosition(Game.LocalPlayer(), Settlers.PIONEER, gXPos2, gYPos2) iType = 0 end end if (gTutorialStep >= 82 and gTutorialStep <= 86) then iType = Settlers.GetTypeInBlockedPlace(Game.LocalPlayer(), Settlers.PIONEER, 0, 68, 2 ) if ( iType == Settlers.PIONEER) then Settlers.GoToPosition(Game.LocalPlayer(), Settlers.PIONEER, 179, 45) iType = 0 end end if (gTutorialStep >= 86 and gTutorialStep <= 97) then Map.LockScreenPos(179, 45) end ------------------------------------------------------------------------------- -- -- Introduce -- -------------------------------------------------------------------------------- if (gTutorialStep == 1) then --steps Tutorial.DisableControlsExcept( Control.BTN_MESSAGES, Control.BTN_MESSAGE_BOX, Control.BTN_RESOURCE_BAR, Control.BTN_MINIMAP, Control.BTN_ZOOM, Control.BTN_COMPRESS_TIME, Control.BTN_BUILDINFO_BUILD, Control.BTN_BUILDINFO_YES, Control.BTN_BUILDINFO_NO ) Map.SetScreenPos(151,142) gTutorialStep = gTutorialStep + 1 gText = 1 elseif (gTutorialStep == 2) then if (gText == 1) then Tutorial.ShowText("TUT_03_001", 1) gText = 0 end gWantedButton1 = Control.BTN_MESSAGE_BOX elseif (gTutorialStep == 3) then if (gText == 1) then Tutorial.ShowText("TUT_03_002", 1) gText = 0 end gWantedButton1 = Control.BTN_MESSAGE_BOX ------------------------------------------------------------------------------- -- -- Start Building Waterworker's Hut (WATERWORKHUT) -- ------------------------------------------------------------------------------- elseif (gTutorialStep == 4) then if (gText == 1) then Map.SetScreenPos(149,182) Tutorial.ShowText("TUT_03_003") gText = 0 end Tutorial.EnableControls( Control.BTN_BUILDINGS, Control.BTN_BUILD_FOOD, Control.BTN_BUILDING4 ) Tutorial.SetButtonMarker(Control.BTN_BUILDINGS, 1) ...
zapolak_ns