-------------------------------------------------------------------------------- -- -- TUTORIAL 2 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 gNoneButton = -1 gWantedSettler = -1 gWantedBuilding = -1 gTargetBuilding = 0 Puppet_auto_controll = 1 -- used as toggle... gCarrierMorphCount = 0 gSettlerFocus = 0 gText = 0 sPrevText = "" gPrevText = 0 gWarriorCheck = 0 SoldierSymbolSelected = 0 -- Used as bool, helps to controll the Gui ... delay_count = 0 gXPos1 = 0 gYPos1 = 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 == 3 or gTutorialStep == 4 or gTutorialStep == 26 or gTutorialStep == 38 or gTutorialStep == 60) then gText = 1 end gTutorialStep = gTutorialStep + 1 gWantedButton1 = -1 gWantedButton2 = -1 end if (btn == gWantedButton2) then if (gTutorialStep == 25) then gText = 1 end gTutorialStep = gTutorialStep + 2 gWantedButton2 = -1 gWantedButton1 = -1 end if (btn == gNoneButton) then gNoneButton = -1 gPrevText = 1 end if (gTutorialStep == 40) then if (Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 75, 150) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 71, 143) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 69, 145) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 73, 150) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 71, 149) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 74, 152) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 77, 156) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 79, 136) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 80, 148) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 79, 144) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 75, 143) > 0 or Buildings.IsWorkingArea( Game.LocalPlayer(), Buildings.VINYARD, 81, 153) > 0) then Buildings.ResetWorkingArea(Game.LocalPlayer(), Buildings.VINYARD) end end if (gTutorialStep == 27 and btn == Control.BTN_WARRIOR_UP) then gWarriorCheck = gWarriorCheck +1 if (gWarriorCheck == 10) then gWarriorCheck = 0 Tutorial.SetButtonMarker(Control.BTN_WARRIOR4, 0) Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_CONTEXT_SIDEBAR, Control.BTN_WARRIOR4, Control.BTN_WARRIOR_UP ) -- print ("Disable buttons") end elseif (gTutorialStep == 29 and btn == Control.BTN_WARRIOR_UP) then gWarriorCheck = gWarriorCheck +1 if (gWarriorCheck == 5) then gWarriorCheck = 0 Tutorial.SetButtonMarker(Control.BTN_WARRIOR1, 0) Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_CONTEXT_SIDEBAR, Control.BTN_WARRIOR1, Control.BTN_WARRIOR_UP ) -- print ("Disable buttons") end elseif (gTutorialStep == 35 and btn == Control.BTN_WARRIOR_UP) then gWarriorCheck = gWarriorCheck +1 if (gWarriorCheck == 10) then gWarriorCheck = 0 Tutorial.SetButtonMarker(Control.BTN_WARRIOR2, 0) Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_CONTEXT_SIDEBAR, Control.BTN_WARRIOR2, Control.BTN_WARRIOR_UP ) -- print ("Disable buttons") end elseif (gTutorialStep == 37 and btn == Control.BTN_WARRIOR_UP) then gWarriorCheck = gWarriorCheck +1 if (gWarriorCheck == 1) then gWarriorCheck = 0 Tutorial.SetButtonMarker(Control.BTN_WARRIOR9, 0) Tutorial.SetButtonMarker(Control.BTN_CONTEXT_SIDEBAR, 0) Tutorial.DisableControls( Control.BTN_CONTEXT_SIDEBAR, Control.BTN_WARRIOR9, Control.BTN_WARRIOR_UP ) -- print ("Disable buttons") end end if (btn == Control.BTN_BUILDINFO_NO and gTutorialStep ~= 40) then gTutorialStep = gTutorialStep - 4 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) -- This one is used for Step 27 ... if gTutorialStep == 27 then if (settlertype == Settlers.BOWMAN_02) then -- print ("Settlers.BOWMAN_02") Order_Control(10) --calling Order_controll for 10 Bowmen end end ----------------------------------------------------------------------------------------------- if gTutorialStep == 29 then if (settlertype == Settlers.SWORDSMAN_02) then -- print ("Settlers.SWORDSMAN_02") Order_Control(5) end end ----------------------------------------------------------------------------------------------- if gTutorialStep == 35 then if (settlertype == Settlers.SWORDSMAN_03) then Order_Control(10) -- print ("Settlers.SWORDSMAN_03") end end ----------------------------------------------------------------------------------------------- if gTutorialStep == 37 then if (settlertype == Settlers.SQUADLEADER) then Order_Control(1) -- print ("Settlers.SQUADLEADER") 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 Tutorial.CloseSidebar() gTutorialStep = gTutorialStep + 1 gCarrierMorphCount = 0 gText = 1 end end -------------------------------------------------------------------------- -- main tutorial function, called every tick -------------------------------------------------------------------------- function tutorial_main() -------------------------------------------------------------------------- --major checks ... done every tick -------------------------------------------------------------------------- if (gTutorialStep >= 27 and gTutorialStep < 60) then iType = Settlers.GetTypeInBlockedPlace(Game.LocalPlayer(), 0, 155, 0, 1 ) if ( iType > 0) then Settlers.GoToPosition(Game.LocalPlayer(), 0, gXPos2, gYPos2) Tutorial.ShowText("TUT_BAD_STEP", 1) gNoneButton = Control.BTN_MESSAGE_BOX end end if (gPrevText > 0) then Tutorial.ShowText(sPrevText) gPrevText = 0 end gCommandOk = 1 delay_count = delay_count + 1 if (gTutorialStep == 1) then gText = 1 elseif (gTutorialStep == 2) then if (Settlers.Amount( Game.LocalPlayer(), Settlers.SWORDSMAN_01 ) <= 7 and Settlers.Amount( Game.LocalPlayer(), Settlers.BOWMAN_01 ) <= 0) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 10) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.RESIDENCEBIG, Buildings.UNDERCONSTRUCTION) > 0 or Buildings.Amount( Game.LocalPlayer(), Buildings.RESIDENCEBIG, Buildings.READY) > 0 ) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 16) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.GUARDTOWERBIG, Buildings.UNDERCONSTRUCTION) > 0 or Buildings.Amount( Game.LocalPlayer(), Buildings.GUARDTOWERBIG, Buildings.READY) > 0 ) then gText = 1 gTutorialStep = gTutorialStep + 1 end elseif (gTutorialStep == 22) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.BARRACKS, Buildings.UNDERCONSTRUCTION) > 0 or Buildings.Amount( Game.LocalPlayer(), Buildings.BARRACKS, Buildings.READY) > 0 ) then gTutorialStep = gTutorialStep + 1 gText = 1 end elseif (gTutorialStep == 23) then if (Buildings.Amount( Game.LocalPlayer(), Buildings.RESIDENCEBIG, Buildings.READY) > 0 and Buildings.Amount( Game.LocalPlayer(), Buildings.GUARDTOWERBIG, B...
zapolak_ns