AI PLAYER, TROOP SPAWN SCRIPT AND MORE
» Siedler Map Source Forum » Siedler DEdK Script Forum » AI PLAYER, TROOP SPAWN SCRIPT AND MORE
polaster64
|
#126 17.03.2018 23:17 Beiträge: 184 |
Zitat von mcb:
I wanted you to post the complete script, because most likely you made an error somewhere else in the script.
CreateEntity: You forgot saving the id:
local p = GetPosition("house7") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse7")
hq1: It changes its model back, because it gets replaced by an entity of the same type but another player. Simply calling
Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle)
again after changing the player should fix this. (The scriptName gets added to the new entity automatically by ChangePlayer and ReplaceEntity)
Here you go, the whole script:
-------------------------------------------------------------------------------- -- MapName: Blank -- -- Author: polaster64 -- -------------------------------------------------------------------------------- -- Include main function Script.Load( Folders.MapTools.."Main.lua" ) IncludeGlobals("MapEditorTools") --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to initialize the diplomacy states function InitDiplomacy() SetHostile(1,4) SetHostile(8,4) SetNeutral(1,8) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to init all resources for player(s) function InitResources() -- set some resources AddGold (0) AddSulfur(0) AddIron (0) AddWood (0) AddStone (0) AddClay (0) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called to setup Technology states on mission start function InitTechnologies() ResearchTechnology(Technologies.T_ThiefSabotage,1) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game is loaded, setup your weather gfx -- sets here function InitWeatherGfxSets() SetupNormalWeatherGfxSet() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start you should setup your weather periods here function InitWeather() AddPeriodicSummer(10) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game to initialize player colors function InitPlayerColorMapping() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start after all initialization is done function FirstMapAction() GameCallback_GUI_SelectionChanged_Orig = GameCallback_GUI_SelectionChanged GameCallback_GUI_SelectionChanged = function() GameCallback_GUI_SelectionChanged_Orig() -- Get selected entity local EntityId = GUI.GetSelectedEntity() if Logic.IsLeader( EntityId ) == 1 then if Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryHeavy) == 1 or Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryLight) == 1 then XGUIEng.ShowWidget(gvGUI_WidgetID.SelectionLeader, 1) end end end Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E2")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E1")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E4")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E3")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E5")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E6")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3x")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3y")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3z")) CreateMilitaryGroup(1, Entities.PU_LeaderBow4, 8, GetPosition ("bow")) CreateMilitaryGroup(1, Entities.PU_LeaderPoleArm4, 8, GetPosition ("polearm")) CreateMilitaryGroup(1, Entities.PU_LeaderSword4, 8, GetPosition ("sword")) local p = GetPosition("house7") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse7") local p = GetPosition("house6") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse6") local p = GetPosition("house5") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse5") local p = GetPosition("house4") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse4") local p = GetPosition("house3") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse3") local p = GetPosition("house2") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse2") local p = GetPosition("house1") Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdHouse1") local p = GetPosition("kkk3") Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk3") local p = GetPosition("kkk4") Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk4") local p = GetPosition("kkk1") Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk1") local p = GetPosition("kkk2") Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk2") CreateArmyOne() local VictoryConditionType = 1 if VictoryConditionType == 1 then MapEditor_SetupResourceVictoryCondition( 2000, 7000, 5000, 6000, 4000, 3000 ) elseif VictoryConditionType == 2 then MapEditor_SetupDestroyVictoryCondition(2) end -- Level 0 is deactivated...ignore MapEditor_SetupAI(2, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(3, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(4, 1, 500, 0, "nic", 0, 0) MapEditor_SetupAI(5, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(6, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(7, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(8, 0, 4000, 0, "nic", 2, 0) -- HQ Defeat Condition MapEditor_CreateHQDefeatCondition() CreateNpcBratJan() CreateNpcBurmistrz() CreateNpcGuard() MakeInvulnerable("Guard") end function BriefingPoczatek() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Dario","Dario","This trip was really long, I think we are close to the SharpPoint", true); ASP("Erek","Erek","We are closer than you think!", true); -- just add as many pages as you need local resolve4 = AP{ tilte = "Erek", text = "Have a look. These are the men we've been searching for, let's help them!", position = GetPosition("Guard"), dialogCamera = false, explore = 1500, } ResolveBriefing(resolve4) StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcBurmistrz() local npc = { name = "Burmistrz", -- name of the npc callback = BriefingBurmistrz, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function CreateNpcBratJan() local npc = { name = "BratJan", -- name of the npc callback = BriefingBratJan, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingBratJan() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Hello, I have been expecting you, we need your help!", true); ASP("Dario","Dario","We are ready to help you, mayor sent us for more details."); ASP("BratJan","BrotherJohaness","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we could help you with??"); local resolve3 = AP{ tilte = "Brother Johaness", text = "Look Dario. That is our problem. We are cut out of resources, everything is in this valley right there. If you remove them you will get full control of the village. But be careful. They might still be there. Good luck.", position = GetPosition("Skaly"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need briefing.finished = function() StartSimpleJob("UsunSkaly1") ResolveBriefing(resolve3) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function UsunSkaly1() if IsDestroyed("Skaly") then BriefingBratJan2() ChangePlayer("b1", 1) ChangePlayer("b2", 1) ChangePlayer("b3", 1) ChangePlayer("b4", 1) ChangePlayer("b5", 1) ChangePlayer("b6", 1) ChangePlayer("b7", 1) ChangePlayer("b8", 1) ChangePlayer("b9", 1) ChangePlayer("b10", 1) ChangePlayer("b11", 1) ChangePlayer("b12", 1) ChangePlayer("b13", 1) ChangePlayer("b14", 1) ChangePlayer("b15", 1) ChangePlayer("b16", 1) ChangePlayer("b17", 1) ChangePlayer("b18", 1) ChangePlayer("b19", 1) ChangePlayer("b20", 1) ChangePlayer("b21", 1) ChangePlayer("b22", 1) ChangePlayer("b23", 1) ChangePlayer("b24", 1) ChangePlayer("b25", 1) ChangePlayer("b26", 1) ChangePlayer("b27", 1) ChangePlayer("b28", 1) ChangePlayer("b29", 1) ChangePlayer("b30", 1) ChangePlayer("b31", 1) ChangePlayer("b32", 1) ChangePlayer("b33", 1) ChangePlayer("b34", 1) ChangePlayer("b35", 1) ChangePlayer("b36", 1) ChangePlayer("b37", 1) ChangePlayer("b38", 1) ChangePlayer("b39", 1) ChangePlayer("b45", 1) ChangePlayer("b46", 1) ChangePlayer("b47", 1) ChangePlayer("b48", 1) ChangePlayer("b49", 1) ChangePlayer("b50", 1) ChangePlayer("b51", 1) ChangePlayer("b52", 1) ChangePlayer("b53", 1) ChangePlayer("b54", 1) ChangePlayer("hq1", 1) Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) ChangePlayer("createdhouse1",1) ChangePlayer("createdhouse2",1) ChangePlayer("createdhouse3",1) ChangePlayer("createdhouse4",1) ChangePlayer("createdhouse5",1) ChangePlayer("createdhouse6",1) ChangePlayer("createdhouse7",1) ChangePlayer("createdkkk1",1) ChangePlayer("createdkkk2",1) ChangePlayer("createdkkk3",1) ChangePlayer("createdkkk4",1) AddGold(500) AddClay(200) AddWood(300) AddStone(400) AddIron(100) AddSulfur(300) return true end end function BriefingBratJan2() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Very nice, as I said, the village belonds to you now.", true); -- just add as many pages as you need StartBriefing(briefing); -- starts the briefing (dont forget this) end function BriefingBurmistrz() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Burmistrz","Burmistrz","Thank you honorable man!", true); ASP("Dario","Dario","It was our duty to help you"); ASP("Burmistrz","Burmistrz","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we can help you with?"); local resolve1 = AP{ tilte = "Burmistrz", text = "Go talk to the Brother Johaness. He will give you more details what should you do now, the village is to your disposition.", position = GetPosition("BratJan"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need ResolveBriefing(resolve1) StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcGuard() local npc = { name = "Guard", -- name of the npc callback = BriefingGuard, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingGuard() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Guard","Guard","Ah,thank you! If you werent here on time they would kill me, god bless you!", true); ASP("Dario","Dario","Take a breath, tell us what happened."); ASP("Guard","Guard","Ok,im sorry but im really shocked. Lets get to the point.", true); ASP("Guard","Guard","Those barbarians attacked our village and they cut us out of any resources.", true); ASP("Dario","Dario","We will help you!"); -- just add as many pages as you need show = AP{ tilte = "Guard", text = "Please go to our Mayor, he will give you more details.", position = GetPosition("Burmistrz"), dialogCamera = false, explore = 500, exploreTime = 1*12, } resolve12 = AP{ tilte = "Guard", text = "After you cross the bridge, please destroy it. You will cut the only way to get to our village, I won't make it any further.", position = GetPosition("Most2"), dialogCamera = false, explore = 500, exploreTime = 1*12, } ASP("Zlodziej","Thief","I will blow up the bridge.", true); ASP("Dario","Dario","Allright people, lets move!", true); ResolveBriefing(resolve12) StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateArmyOne() armyOne = {} armyOne.player = 4 armyOne.id = 4 armyOne.strength = 4 armyOne.position = GetPosition("armyOne") armyOne.rodeLength = 1000 SetupArmy(armyOne) local troopDescription = {} troopDescription.maxNumberOfSoldiers = 4 troopDescription.minNumberOfSoldiers = 0 troopDescription.experiencePoints = HIGH_EXPERIENCE troopDescription.leaderType = Entities.CU_Barbarian_LeaderClub2 for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end local troopDescription = { maxNumberOfSoldiers = 4, minNumberOfSoldiers = 0, experiencePoints = HIGH_EXPERIENCE, leaderType = Entities.CU_BlackKnight_LeaderMace1 } for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end end function AddPages( _briefing ) local AP = function(_page) table.insert(_briefing, _page); return _page; end local ASP = function(_entity, _title, _text, _dialog) return AP(CreateShortPage(_entity, _title, _text, _dialog)); end return AP, ASP; end function CreateShortPage( _entity, _title, _text, _dialog) local page = { title = _title, text = _text, position = GetPosition( _entity ), dialogCamera = _dialog }; return page; end -- Quest data MapEditor_QuestTitle = "" MapEditor_QuestDescription = ""
mcb
|
#127 18.03.2018 00:31 Beiträge: 1472 |
Ok, where was your call of BriefingPoczatek() ?
I edited your script and added comments to every edit to explain it:
- autoformated it
- removed lots of blank lines
- moved the GUIhack and the Village creation into seperate functions
- fixed your village creation script names
- fixed ResolveBriefing in briefing.finished in nearly all briefings
- added the BriefingPoczatek() call
Please compare it with your script and ask me if some of the changes i made make no sense for you. (Also if you get Lua errors with it, can't test it without the map)
-------------------------------------------------------------------------------- -- MapName: Blank -- -- Author: polaster64 -- -------------------------------------------------------------------------------- -- Include main function Script.Load( Folders.MapTools.."Main.lua" ) IncludeGlobals("MapEditorTools") --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to initialize the diplomacy states function InitDiplomacy() SetHostile(1,4) SetHostile(8,4) SetNeutral(1,8) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to init all resources for player(s) function InitResources() -- set some resources AddGold (0) AddSulfur(0) AddIron (0) AddWood (0) AddStone (0) AddClay (0) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called to setup Technology states on mission start function InitTechnologies() ResearchTechnology(Technologies.T_ThiefSabotage,1) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game is loaded, setup your weather gfx -- sets here function InitWeatherGfxSets() SetupNormalWeatherGfxSet() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start you should setup your weather periods here function InitWeather() AddPeriodicSummer(10) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game to initialize player colors function InitPlayerColorMapping() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start after all initialization is done function FirstMapAction() HackLeaderCavalry() -- moved the GUI hack into an extra function Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E2")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E1")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E4")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E3")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E5")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E6")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3x")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3y")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3z")) CreateMilitaryGroup(1, Entities.PU_LeaderBow4, 8, GetPosition ("bow")) CreateMilitaryGroup(1, Entities.PU_LeaderPoleArm4, 8, GetPosition ("polearm")) CreateMilitaryGroup(1, Entities.PU_LeaderSword4, 8, GetPosition ("sword")) CreateVillage() -- moved the village creation into an extra function CreateArmyOne() local VictoryConditionType = 1 if VictoryConditionType == 1 then MapEditor_SetupResourceVictoryCondition( 2000, 7000, 5000, 6000, 4000, 3000 ) elseif VictoryConditionType == 2 then MapEditor_SetupDestroyVictoryCondition(2) end -- Level 0 is deactivated...ignore MapEditor_SetupAI(2, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(3, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(4, 1, 500, 0, "nic", 0, 0) MapEditor_SetupAI(5, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(6, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(7, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(8, 0, 4000, 0, "nic", 2, 0) -- HQ Defeat Condition MapEditor_CreateHQDefeatCondition() CreateNpcBratJan() CreateNpcBurmistrz() CreateNpcGuard() MakeInvulnerable("Guard") BriefingPoczatek() -- starting the 1. briefing here end function CreateVillage() local p = GetPosition("house7") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) -- you forgot to save the id at every Logic.CreateEntity SetEntityName(id, "createdhouse7") -- fixed the name local p = GetPosition("house6") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse6") local p = GetPosition("house5") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse5") local p = GetPosition("house4") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse4") local p = GetPosition("house3") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse3") local p = GetPosition("house2") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse2") local p = GetPosition("house1") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse1") local p = GetPosition("kkk3") local id = Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk3") local p = GetPosition("kkk4") local id = Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk4") local p = GetPosition("kkk1") local id = Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk1") local p = GetPosition("kkk2") local id = Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk2") end function BriefingPoczatek() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Dario","Dario","This trip was really long, I think we are close to the SharpPoint", true); ASP("Erek","Erek","We are closer than you think!", true); -- just add as many pages as you need local resolve4 = AP{ tilte = "Erek", text = "Have a look. These are the men we've been searching for, let's help them!", position = GetPosition("Guard"), dialogCamera = false, explore = 1500, } briefing.finished = function() ResolveBriefing(resolve4) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcBurmistrz() local npc = { name = "Burmistrz", -- name of the npc callback = BriefingBurmistrz, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function CreateNpcBratJan() local npc = { name = "BratJan", -- name of the npc callback = BriefingBratJan, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingBratJan() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Hello, I have been expecting you, we need your help!", true); ASP("Dario","Dario","We are ready to help you, mayor sent us for more details."); ASP("BratJan","BrotherJohaness","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we could help you with??"); local resolve3 = AP{ tilte = "Brother Johaness", text = "Look Dario. That is our problem. We are cut out of resources, everything is in this valley right there. If you remove them you will get full control of the village. But be careful. They might still be there. Good luck.", position = GetPosition("Skaly"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need briefing.finished = function() StartSimpleJob("UsunSkaly1") ResolveBriefing(resolve3) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function UsunSkaly1() if IsDestroyed("Skaly") then BriefingBratJan2() ChangePlayer("b1", 1) ChangePlayer("b2", 1) ChangePlayer("b3", 1) ChangePlayer("b4", 1) ChangePlayer("b5", 1) ChangePlayer("b6", 1) ChangePlayer("b7", 1) ChangePlayer("b8", 1) ChangePlayer("b9", 1) ChangePlayer("b10", 1) ChangePlayer("b11", 1) ChangePlayer("b12", 1) ChangePlayer("b13", 1) ChangePlayer("b14", 1) ChangePlayer("b15", 1) ChangePlayer("b16", 1) ChangePlayer("b17", 1) ChangePlayer("b18", 1) ChangePlayer("b19", 1) ChangePlayer("b20", 1) ChangePlayer("b21", 1) ChangePlayer("b22", 1) ChangePlayer("b23", 1) ChangePlayer("b24", 1) ChangePlayer("b25", 1) ChangePlayer("b26", 1) ChangePlayer("b27", 1) ChangePlayer("b28", 1) ChangePlayer("b29", 1) ChangePlayer("b30", 1) ChangePlayer("b31", 1) ChangePlayer("b32", 1) ChangePlayer("b33", 1) ChangePlayer("b34", 1) ChangePlayer("b35", 1) ChangePlayer("b36", 1) ChangePlayer("b37", 1) ChangePlayer("b38", 1) ChangePlayer("b39", 1) ChangePlayer("b45", 1) ChangePlayer("b46", 1) ChangePlayer("b47", 1) ChangePlayer("b48", 1) ChangePlayer("b49", 1) ChangePlayer("b50", 1) ChangePlayer("b51", 1) ChangePlayer("b52", 1) ChangePlayer("b53", 1) ChangePlayer("b54", 1) ChangePlayer("hq1", 1) Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) ChangePlayer("createdhouse1",1) ChangePlayer("createdhouse2",1) ChangePlayer("createdhouse3",1) ChangePlayer("createdhouse4",1) ChangePlayer("createdhouse5",1) ChangePlayer("createdhouse6",1) ChangePlayer("createdhouse7",1) ChangePlayer("createdkkk1",1) ChangePlayer("createdkkk2",1) ChangePlayer("createdkkk3",1) ChangePlayer("createdkkk4",1) AddGold(500) AddClay(200) AddWood(300) AddStone(400) AddIron(100) AddSulfur(300) return true end end function BriefingBratJan2() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Very nice, as I said, the village belonds to you now.", true); StartBriefing(briefing); -- starts the briefing (dont forget this) end function BriefingBurmistrz() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Burmistrz","Burmistrz","Thank you honorable man!", true); ASP("Dario","Dario","It was our duty to help you"); ASP("Burmistrz","Burmistrz","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we can help you with?"); local resolve1 = AP{ tilte = "Burmistrz", text = "Go talk to the Brother Johaness. He will give you more details what should you do now, the village is to your disposition.", position = GetPosition("BratJan"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need briefing.finished = function() -- fixed missing briefing.finished ResolveBriefing(resolve1) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcGuard() local npc = { name = "Guard", -- name of the npc callback = BriefingGuard, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingGuard() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Guard","Guard","Ah,thank you! If you werent here on time they would kill me, god bless you!", true); ASP("Dario","Dario","Take a breath, tell us what happened."); ASP("Guard","Guard","Ok,im sorry but im really shocked. Lets get to the point.", true); ASP("Guard","Guard","Those barbarians attacked our village and they cut us out of any resources.", true); ASP("Dario","Dario","We will help you!"); -- just add as many pages as you need local show = AP{ -- made variable local, as it is only needed in the finishing function, added missing ResolveBriefing tilte = "Guard", text = "Please go to our Mayor, he will give you more details.", position = GetPosition("Burmistrz"), dialogCamera = false, explore = 500, -- removed exploreTime, as it does nothing } local resolve12 = AP{ -- made variable local, as it is only needed in the finishing function tilte = "Guard", text = "After you cross the bridge, please destroy it. You will cut the only way to get to our village, I won't make it any further.", position = GetPosition("Most2"), dialogCamera = false, explore = 500, -- removed exploreTime, as it does nothing } ASP("Zlodziej","Thief","I will blow up the bridge.", true); ASP("Dario","Dario","Allright people, lets move!", true); briefing.finished = function() -- fixed missing finished function ResolveBriefing(resolve12) ResolveBriefing(show) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateArmyOne() armyOne = {} armyOne.player = 4 armyOne.id = 4 armyOne.strength = 4 armyOne.position = GetPosition("armyOne") armyOne.rodeLength = 1000 SetupArmy(armyOne) local troopDescription = {} troopDescription.maxNumberOfSoldiers = 4 troopDescription.minNumberOfSoldiers = 0 troopDescription.experiencePoints = HIGH_EXPERIENCE troopDescription.leaderType = Entities.CU_Barbarian_LeaderClub2 for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end local troopDescription = { maxNumberOfSoldiers = 4, minNumberOfSoldiers = 0, experiencePoints = HIGH_EXPERIENCE, leaderType = Entities.CU_BlackKnight_LeaderMace1 } for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end -- missing control job? end function HackLeaderCavalry() GameCallback_GUI_SelectionChanged_Orig = GameCallback_GUI_SelectionChanged GameCallback_GUI_SelectionChanged = function() GameCallback_GUI_SelectionChanged_Orig() -- Get selected entity local EntityId = GUI.GetSelectedEntity() if Logic.IsLeader( EntityId ) == 1 then if Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryHeavy) == 1 or Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryLight) == 1 then XGUIEng.ShowWidget(gvGUI_WidgetID.SelectionLeader, 1) end end end end function AddPages( _briefing ) local AP = function(_page) table.insert(_briefing, _page); return _page; end local ASP = function(_entity, _title, _text, _dialog) return AP(CreateShortPage(_entity, _title, _text, _dialog)); end return AP, ASP; end function CreateShortPage( _entity, _title, _text, _dialog) local page = { title = _title, text = _text, position = GetPosition( _entity ), dialogCamera = _dialog }; return page; end -- Quest data MapEditor_QuestTitle = "" MapEditor_QuestDescription = ""
polaster64
|
#128 18.03.2018 12:26 Beiträge: 184 |
Zitat von mcb:
Ok, where was your call of BriefingPoczatek() ?
I edited your script and added comments to every edit to explain it:
- autoformated it
- removed lots of blank lines
- moved the GUIhack and the Village creation into seperate functions
- fixed your village creation script names
- fixed ResolveBriefing in briefing.finished in nearly all briefings
- added the BriefingPoczatek() call
Please compare it with your script and ask me if some of the changes i made make no sense for you. (Also if you get Lua errors with it, can't test it without the map)
-------------------------------------------------------------------------------- -- MapName: Blank -- -- Author: polaster64 -- -------------------------------------------------------------------------------- -- Include main function Script.Load( Folders.MapTools.."Main.lua" ) IncludeGlobals("MapEditorTools") --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to initialize the diplomacy states function InitDiplomacy() SetHostile(1,4) SetHostile(8,4) SetNeutral(1,8) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to init all resources for player(s) function InitResources() -- set some resources AddGold (0) AddSulfur(0) AddIron (0) AddWood (0) AddStone (0) AddClay (0) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called to setup Technology states on mission start function InitTechnologies() ResearchTechnology(Technologies.T_ThiefSabotage,1) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game is loaded, setup your weather gfx -- sets here function InitWeatherGfxSets() SetupNormalWeatherGfxSet() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start you should setup your weather periods here function InitWeather() AddPeriodicSummer(10) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start and after save game to initialize player colors function InitPlayerColorMapping() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called on game start after all initialization is done function FirstMapAction() HackLeaderCavalry() -- moved the GUI hack into an extra function Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E2")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E1")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E4")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E3")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E5")) CreateMilitaryGroup(4, Entities.CU_Barbarian_LeaderClub1, 4, GetPosition ("E6")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3x")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3y")) CreateMilitaryGroup(8, Entities.PU_LeaderPoleArm2, 4, GetPosition ("E3z")) CreateMilitaryGroup(1, Entities.PU_LeaderBow4, 8, GetPosition ("bow")) CreateMilitaryGroup(1, Entities.PU_LeaderPoleArm4, 8, GetPosition ("polearm")) CreateMilitaryGroup(1, Entities.PU_LeaderSword4, 8, GetPosition ("sword")) CreateVillage() -- moved the village creation into an extra function CreateArmyOne() local VictoryConditionType = 1 if VictoryConditionType == 1 then MapEditor_SetupResourceVictoryCondition( 2000, 7000, 5000, 6000, 4000, 3000 ) elseif VictoryConditionType == 2 then MapEditor_SetupDestroyVictoryCondition(2) end -- Level 0 is deactivated...ignore MapEditor_SetupAI(2, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(3, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(4, 1, 500, 0, "nic", 0, 0) MapEditor_SetupAI(5, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(6, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(7, 0, 0, 0, "", 0, 0) MapEditor_SetupAI(8, 0, 4000, 0, "nic", 2, 0) -- HQ Defeat Condition MapEditor_CreateHQDefeatCondition() CreateNpcBratJan() CreateNpcBurmistrz() CreateNpcGuard() MakeInvulnerable("Guard") BriefingPoczatek() -- starting the 1. briefing here end function CreateVillage() local p = GetPosition("house7") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) -- you forgot to save the id at every Logic.CreateEntity SetEntityName(id, "createdhouse7") -- fixed the name local p = GetPosition("house6") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse6") local p = GetPosition("house5") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse5") local p = GetPosition("house4") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse4") local p = GetPosition("house3") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse3") local p = GetPosition("house2") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse2") local p = GetPosition("house1") local id = Logic.CreateEntity(Entities.PB_Residence3, p.X, p.Y, 0, 8) SetEntityName(id, "createdhouse1") local p = GetPosition("kkk3") local id = Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk3") local p = GetPosition("kkk4") local id = Logic.CreateEntity(Entities.PB_DarkTower3, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk4") local p = GetPosition("kkk1") local id = Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk1") local p = GetPosition("kkk2") local id = Logic.CreateEntity(Entities.CB_Bastille1, p.X, p.Y, 0, 8) SetEntityName(id, "createdkkk2") end function BriefingPoczatek() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Dario","Dario","This trip was really long, I think we are close to the SharpPoint", true); ASP("Erek","Erek","We are closer than you think!", true); -- just add as many pages as you need local resolve4 = AP{ tilte = "Erek", text = "Have a look. These are the men we've been searching for, let's help them!", position = GetPosition("Guard"), dialogCamera = false, explore = 1500, } briefing.finished = function() ResolveBriefing(resolve4) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcBurmistrz() local npc = { name = "Burmistrz", -- name of the npc callback = BriefingBurmistrz, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function CreateNpcBratJan() local npc = { name = "BratJan", -- name of the npc callback = BriefingBratJan, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingBratJan() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Hello, I have been expecting you, we need your help!", true); ASP("Dario","Dario","We are ready to help you, mayor sent us for more details."); ASP("BratJan","BrotherJohaness","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we could help you with??"); local resolve3 = AP{ tilte = "Brother Johaness", text = "Look Dario. That is our problem. We are cut out of resources, everything is in this valley right there. If you remove them you will get full control of the village. But be careful. They might still be there. Good luck.", position = GetPosition("Skaly"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need briefing.finished = function() StartSimpleJob("UsunSkaly1") ResolveBriefing(resolve3) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function UsunSkaly1() if IsDestroyed("Skaly") then BriefingBratJan2() ChangePlayer("b1", 1) ChangePlayer("b2", 1) ChangePlayer("b3", 1) ChangePlayer("b4", 1) ChangePlayer("b5", 1) ChangePlayer("b6", 1) ChangePlayer("b7", 1) ChangePlayer("b8", 1) ChangePlayer("b9", 1) ChangePlayer("b10", 1) ChangePlayer("b11", 1) ChangePlayer("b12", 1) ChangePlayer("b13", 1) ChangePlayer("b14", 1) ChangePlayer("b15", 1) ChangePlayer("b16", 1) ChangePlayer("b17", 1) ChangePlayer("b18", 1) ChangePlayer("b19", 1) ChangePlayer("b20", 1) ChangePlayer("b21", 1) ChangePlayer("b22", 1) ChangePlayer("b23", 1) ChangePlayer("b24", 1) ChangePlayer("b25", 1) ChangePlayer("b26", 1) ChangePlayer("b27", 1) ChangePlayer("b28", 1) ChangePlayer("b29", 1) ChangePlayer("b30", 1) ChangePlayer("b31", 1) ChangePlayer("b32", 1) ChangePlayer("b33", 1) ChangePlayer("b34", 1) ChangePlayer("b35", 1) ChangePlayer("b36", 1) ChangePlayer("b37", 1) ChangePlayer("b38", 1) ChangePlayer("b39", 1) ChangePlayer("b45", 1) ChangePlayer("b46", 1) ChangePlayer("b47", 1) ChangePlayer("b48", 1) ChangePlayer("b49", 1) ChangePlayer("b50", 1) ChangePlayer("b51", 1) ChangePlayer("b52", 1) ChangePlayer("b53", 1) ChangePlayer("b54", 1) ChangePlayer("hq1", 1) Logic.SetModelAndAnimSet(GetID("hq1"), Models.CB_DarkCastle) ChangePlayer("createdhouse1",1) ChangePlayer("createdhouse2",1) ChangePlayer("createdhouse3",1) ChangePlayer("createdhouse4",1) ChangePlayer("createdhouse5",1) ChangePlayer("createdhouse6",1) ChangePlayer("createdhouse7",1) ChangePlayer("createdkkk1",1) ChangePlayer("createdkkk2",1) ChangePlayer("createdkkk3",1) ChangePlayer("createdkkk4",1) AddGold(500) AddClay(200) AddWood(300) AddStone(400) AddIron(100) AddSulfur(300) return true end end function BriefingBratJan2() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("BratJan","BrotherJohaness","Very nice, as I said, the village belonds to you now.", true); StartBriefing(briefing); -- starts the briefing (dont forget this) end function BriefingBurmistrz() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Burmistrz","Burmistrz","Thank you honorable man!", true); ASP("Dario","Dario","It was our duty to help you"); ASP("Burmistrz","Burmistrz","Surely. But lets get to the topic. Those damn robbers kept attacking us, we would not stand a change if you did not come here today. Bless you!", true); ASP("Dario","Dario","Is there anything else we can help you with?"); local resolve1 = AP{ tilte = "Burmistrz", text = "Go talk to the Brother Johaness. He will give you more details what should you do now, the village is to your disposition.", position = GetPosition("BratJan"), dialogCamera = false, explore = 1500, } -- just add as many pages as you need briefing.finished = function() -- fixed missing briefing.finished ResolveBriefing(resolve1) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateNpcGuard() local npc = { name = "Guard", -- name of the npc callback = BriefingGuard, -- what should be called, when the npc gets spoken with } CreateNPC(npc) end function BriefingGuard() -- this contains all data for the briefing local briefing = {}; -- AddPage / AddShortPage functions, used to fill the briefing local AP, ASP = AddPages(briefing); -- ASP( _name, _title, _text, _dialog); -- _name: Script name of the target entity. camera will centered at this entity -- _title: Page title -- _text: Page text -- _dialog: set to true to move the camera closer, else just leave it out ASP("Guard","Guard","Ah,thank you! If you werent here on time they would kill me, god bless you!", true); ASP("Dario","Dario","Take a breath, tell us what happened."); ASP("Guard","Guard","Ok,im sorry but im really shocked. Lets get to the point.", true); ASP("Guard","Guard","Those barbarians attacked our village and they cut us out of any resources.", true); ASP("Dario","Dario","We will help you!"); -- just add as many pages as you need local show = AP{ -- made variable local, as it is only needed in the finishing function, added missing ResolveBriefing tilte = "Guard", text = "Please go to our Mayor, he will give you more details.", position = GetPosition("Burmistrz"), dialogCamera = false, explore = 500, -- removed exploreTime, as it does nothing } local resolve12 = AP{ -- made variable local, as it is only needed in the finishing function tilte = "Guard", text = "After you cross the bridge, please destroy it. You will cut the only way to get to our village, I won't make it any further.", position = GetPosition("Most2"), dialogCamera = false, explore = 500, -- removed exploreTime, as it does nothing } ASP("Zlodziej","Thief","I will blow up the bridge.", true); ASP("Dario","Dario","Allright people, lets move!", true); briefing.finished = function() -- fixed missing finished function ResolveBriefing(resolve12) ResolveBriefing(show) end StartBriefing(briefing); -- starts the briefing (dont forget this) end function CreateArmyOne() armyOne = {} armyOne.player = 4 armyOne.id = 4 armyOne.strength = 4 armyOne.position = GetPosition("armyOne") armyOne.rodeLength = 1000 SetupArmy(armyOne) local troopDescription = {} troopDescription.maxNumberOfSoldiers = 4 troopDescription.minNumberOfSoldiers = 0 troopDescription.experiencePoints = HIGH_EXPERIENCE troopDescription.leaderType = Entities.CU_Barbarian_LeaderClub2 for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end local troopDescription = { maxNumberOfSoldiers = 4, minNumberOfSoldiers = 0, experiencePoints = HIGH_EXPERIENCE, leaderType = Entities.CU_BlackKnight_LeaderMace1 } for i = 1,4,1 do EnlargeArmy(armyOne,troopDescription) end -- missing control job? end function HackLeaderCavalry() GameCallback_GUI_SelectionChanged_Orig = GameCallback_GUI_SelectionChanged GameCallback_GUI_SelectionChanged = function() GameCallback_GUI_SelectionChanged_Orig() -- Get selected entity local EntityId = GUI.GetSelectedEntity() if Logic.IsLeader( EntityId ) == 1 then if Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryHeavy) == 1 or Logic.IsEntityInCategory(EntityId,EntityCategories.CavalryLight) == 1 then XGUIEng.ShowWidget(gvGUI_WidgetID.SelectionLeader, 1) end end end end function AddPages( _briefing ) local AP = function(_page) table.insert(_briefing, _page); return _page; end local ASP = function(_entity, _title, _text, _dialog) return AP(CreateShortPage(_entity, _title, _text, _dialog)); end return AP, ASP; end function CreateShortPage( _entity, _title, _text, _dialog) local page = { title = _title, text = _text, position = GetPosition( _entity ), dialogCamera = _dialog }; return page; end -- Quest data MapEditor_QuestTitle = "" MapEditor_QuestDescription = ""
Well when I added the BriefingPoczatek() call, it said that code was outside of the script and I placed it in the same place. Strange..
Well all the changes you made are very clear and I understand them all. LuaDebugger did not find any bugs. Thanks very much!
Now I have another question about the script.
I wanted the Guard to die after the briefing is finished:
function FinishedGuard() if IsFinished("BriefingGuard") then SetHealth("Guard", 0) return true end end
I made that function and it does not work. (nil value)
What should it look like? And is there another way I can kill the guard after he says his last word?
Is there any way I can set the bridge name? Everytime I wanna name it, the bridge just dissapears from the editor I want to make a briefing and army spawn with that but I cant name the bridge. Is there any way?
Dieser Beitrag wurde von polaster64 am 18.03.2018 um 12:35 editiert.
mcb
|
#129 18.03.2018 15:27 Beiträge: 1472 |
Killing the Guard: Just put it in the briefing.finished function that gets automatically called after that briefing finishes. You also make the Guard invulnerable, so you have to make him vulverable (MakeVulnerable) again before you can kill him.
Bridge: Bridges can't be placed by the mapeditor if something about the blocking is wrong. (And by renaming it, the mapeditor deletes it and creates a new one.) Try renaming it before you modify the blocking. (Last time i had to name a bridge, i edited the s5x per bba-tool, so this is also a possibility if you know what you are doing)
polaster64
|
#130 18.03.2018 16:02 Beiträge: 184 |
Zitat von mcb:
Killing the Guard: Just put it in the briefing.finished function that gets automatically called after that briefing finishes. You also make the Guard invulnerable, so you have to make him vulverable (MakeVulnerable) again before you can kill him.
Bridge: Bridges can't be placed by the mapeditor if something about the blocking is wrong. (And by renaming it, the mapeditor deletes it and creates a new one.) Try renaming it before you modify the blocking. (Last time i had to name a bridge, i edited the s5x per bba-tool, so this is also a possibility if you know what you are doing)
Could you show this on the screens? Unfortunately I really dont understand what are you trying to tell me.
My Version:
https://imgur.com/a/pCD2f
mcb
|
#131 19.03.2018 11:33 Beiträge: 1472 |
0) Make a backup of your s5x.
1) Open the s5x with the bba-tool.
2) Open the unpacked folder.
3) Navigate to ./maps/externalmap/mapdata.xml and open it with a text editor like notepad++.
4) The start of the file should look similar to this:
<?xml version="1.0" encoding="utf-8" ?> <root> <MapProps classname="EGL::CMapProps" classid="0x33ca7b88"> <NumberOfPlayer>8</NumberOfPlayer> </MapProps> <Entities> <Entity classname="EGL::CGLEEntityCreator" classid="0x0753286d"> <Type>PU_Hero1c</Type> <Position> <X>3.754573e+004</X> <Y>3.995240e+004</Y> </Position> <Orientation>0.000000e+000</Orientation> <Flags>0</Flags> <PlayerID>1</PlayerID> <Health>-1</Health> <Name>dario</Name> <ScriptCommandLine></ScriptCommandLine> <AmbientSoundType></AmbientSoundType> <Scale>1.000000e+000</Scale> </Entity> <Entity classname="EGL::CGLEEntityCreator" classid="0x0753286d"> <Type>PU_Hero2</Type> <Position> <X>3.755297e+004</X> <Y>3.957632e+004</Y> </Position> <Orientation>0.000000e+000</Orientation> <Flags>0</Flags> <PlayerID>1</PlayerID> <Health>-1</Health> <Name>pilgrim</Name> <ScriptCommandLine></ScriptCommandLine> <AmbientSoundType></AmbientSoundType> <Scale>1.000000e+000</Scale> </Entity>
Here the entities of your map are saved.
5) Now search for the entitytype of your bridge. Should be something like PB_BridgeX for normal bridges, XD_NeutralBridgeX for the build places, PB_DrawBridgeClosedX for closed drawbridges and XD_DrawBridgeOpenX for open drawbridges. (X stands for 1-4, depending on size and direction of your bridge)
6) This entry should look like this:
<Entity classname="EGL::CGLEEntityCreator" classid="0x0753286d"> <Type>XD_NeutralBridge1</Type> <Position> <X>1.769180e+004</X> <Y>2.887401e+004</Y> </Position> <Orientation>0.000000e+000</Orientation> <Flags>0</Flags> <PlayerID>0</PlayerID> <Health>-1</Health> <Name></Name> <ScriptCommandLine></ScriptCommandLine> <AmbientSoundType></AmbientSoundType> <Scale>0.000000e+000</Scale> </Entity>
(Type depending on your bridge, and Position depending on where you placed it.)
7) Edit the Name entry and set your desired entityname. Should look like this:
<Entity classname="EGL::CGLEEntityCreator" classid="0x0753286d"> <Type>XD_NeutralBridge1</Type> <Position> <X>1.769180e+004</X> <Y>2.887401e+004</Y> </Position> <Orientation>0.000000e+000</Orientation> <Flags>0</Flags> <PlayerID>0</PlayerID> <Health>-1</Health> <Name>bridgeBuildPlace</Name> <ScriptCommandLine></ScriptCommandLine> <AmbientSoundType></AmbientSoundType> <Scale>0.000000e+000</Scale> </Entity>
8 ) Save & close the file.
9) Repackt the s5x with the bba-tool.
10) Open the modified s5x with the Editor and look if it worked.
If everything worked, saving the map in the editor is ok. (But don't try to edit the bridge in any way, it will most likely just get deleted.)