hello!
» Siedler Map Source Forum » Siedler DEdK Script Forum » hello!
Seiten: 1
polaster64
|
#1 25.03.2016 21:00 Beiträge: 184 |
hello!
Hello! Im trying to make my own map again ;x.
I am searching a script for troops.
Explain:
There are 3 players. You, Your ally, and your enemy. 2 v 1, singleplayer map. I want to make something like on map Dartmor.
They are in war, you can help your ally to win.
I want to do something like their troops arent ending. I mean there is 10xHeavyCavalry and if it dies it respawns again and again, you know the perpetum mobile.
I have got an good idea but i need this script to immediately begin and finish.
polaster64
|
#2 25.03.2016 21:22 Beiträge: 184 |
Zitat von polaster64:
Hello! Im trying to make my own map again ;x.
I am searching a script for troops.
Explain:
There are 3 players. You, Your ally, and your enemy. 2 v 1, singleplayer map. I want to make something like on map Dartmor.
They are in war, you can help your ally to win.
I want to do something like their troops arent ending. I mean there is 10xHeavyCavalry and if it dies it respawns again and again, you know the perpetum mobile.
I have got an good idea but i need this script to immediately begin and finish.
Ok forget it, my whole script is gone, system fucked everything and its literally gone.
Noigi
|
#3 25.03.2016 23:13 Beiträge: 772 |
Hi polaster!
Good to hear you are trying to build a map! Dont let that setback demotivate you
A script example for respawning armies can be found here:
http://www.siedler-games.de/si...nce:setupaitroopspawngenerator
(descriptions are in german, but the code is pretty self-explanatory.
polaster64
|
#4 26.03.2016 19:04 Beiträge: 184 |
Well thanks, but I need another script. I mean I want something like this:
Your ally fights versus your enemy.
How can I make it that they will fight and fight, no end ;d.
Rectuiting or spawning troops. w/e.
Zedeg
|
#5 26.03.2016 20:01 Beiträge: 428 |
Er, that is exactly Noigi's link...
____________________
Journalisten erkundigen sich bei Wissenschaftlern meist nicht nach Grundlagen, sondern eher nach Ergebnissen und Folgerungen. Das erklärt womöglich auch, warum sich Forschungsberichte in den Medien so häufig als feststehende Erkenntnisse lesen, nicht aber als Ideen, Entdeckungen oder Indizien, um die es sich genau genommen in den meisten Fällen handelt. -Axel Bojowski
Noigi
|
#6 27.03.2016 22:31 Beiträge: 772 |
Zitat von polaster64:
Well thanks, but I need another script. I mean I want something like this:
Your ally fights versus your enemy.
How can I make it that they will fight and fight, no end ;d.
Rectuiting or spawning troops. w/e.
If you want two AI players to fight each other, you can simply set up an army spawn generator for both.
polaster64
|
#7 28.03.2016 20:42 Beiträge: 184 |
Zitat von Noigi:
Zitat von polaster64:
Well thanks, but I need another script. I mean I want something like this:
Your ally fights versus your enemy.
How can I make it that they will fight and fight, no end ;d.
Rectuiting or spawning troops. w/e.
If you want two AI players to fight each other, you can simply set up an army spawn generator for both.
And how do i create Ai players ?
I tried from ScriptExample but when i pasted it and tried to work nothing happened.
polaster64
|
#8 28.03.2016 22:36 Beiträge: 184 |
Zitat von polaster64:
Zitat von Noigi:
Zitat von polaster64:
Well thanks, but I need another script. I mean I want something like this:
Your ally fights versus your enemy.
How can I make it that they will fight and fight, no end ;d.
Rectuiting or spawning troops. w/e.
If you want two AI players to fight each other, you can simply set up an army spawn generator for both.
And how do i create Ai players ?
I tried from ScriptExample but when i pasted it and tried to work nothing happened.
counter = 0 var = 0 ( its under map tools ) --Tools.ExploreArea( -1, -1, 900 ) StartSimpleJob("CreateArmyFour2") function CreateArmyFour2 () if ( var < 900 ) then var = var +1 end if ( var == 20 ) then armyFour2 = {} armyFour2.player = 1 armyFour2.id = 1 armyFour2.strength = 4 armyFour2.position = GetPosition("z2") armyFour2.rodeLength = 10000 SetupArmy(armyFour2) local troopDescription1 = {} troopDescription1.maxNumberOfSoldiers = 4 troopDescription1.minNumberOfSoldiers = 0 troopDescription1.experiencePoints = VERYHIGH_EXPERIENCE troopDescription1.leaderType = Entities.PU_LeaderHeavyCavalry2 local troopDescription2 = {} troopDescription2.maxNumberOfSoldiers = 4 troopDescription2.minNumberOfSoldiers = 0 troopDescription2.experiencePoints = VERYHIGH_EXPERIENCE troopDescription2.leaderType = Entities.PU_LeaderBow2 local troopDescription3 = {} troopDescription3.maxNumberOfSoldiers = 4 troopDescription3.minNumberOfSoldiers = 0 troopDescription3.experiencePoints = VERYHIGH_EXPERIENCE troopDescription3.leaderType = Entities.CU_Barbarian_LeaderClub2 local troopDescription4 = {} troopDescription4.maxNumberOfSoldiers = 8 troopDescription4.minNumberOfSoldiers = 0 troopDescription4.experiencePoints = VERYHIGH_EXPERIENCE troopDescription4.leaderType = Entities.CU_BanditLeaderSword2 for i = 1,4,1 do EnlargeArmy(armyFour2,troopDescription1) end for i = 1,4,1 do EnlargeArmy(armyFour2,troopDescription2) end for i = 1,3,1 do EnlargeArmy(armyFour2,troopDescription3) end for i = 1,2,1 do EnlargeArmy(armyFour2,troopDescription4) end var = 0 return end end
Can u tell me where is the mistake that the troops arent spawning? Sometimes it works sometimes it doesnt. I dont really know wtf is happenin' ;ccc
Settlerman
|
#9 29.03.2016 10:28 Beiträge: 238 |
Do you have a script entity on your map with the right name?
polaster64
|
#10 29.03.2016 10:48 Beiträge: 184 |
Zitat von Settlerman:
Do you have a script entity on your map with the right name?
yes I do.
MadShadow
|
#11 29.03.2016 12:27 Beiträge: 372 |
Hi, I just tested your code and it works perfect. There is no error in the part you posted.
Sometimes it works sometimes it doesnt.
What do you mean exactly? Troop spawning?
Dieser Beitrag wurde von MadShadow am 29.03.2016 um 13:41 editiert.
polaster64
|
#12 29.03.2016 14:21 Beiträge: 184 |
Zitat von MadShadow:
Hi, I just tested your code and it works perfect. There is no error in the part you posted.
Sometimes it works sometimes it doesnt.
What do you mean exactly? Troop spawning?
Yes Its a script which allows to spawn troops even for the real player. But sometimes is works and sometimes it doesnt work and i dont know why ;x
MadShadow
|
#13 29.03.2016 15:31 Beiträge: 372 |
Your script then should look similar to the following:
-------------------------------------------------------------------------------- -- MapName: XXX -- -- Author: XXX -- -------------------------------------------------------------------------------- -- 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() end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called from main script to init all resources for player(s) function InitResources() -- set some resources AddGold (1000) AddSulfur(2000) AddIron (3000) AddWood (4000) AddStone (5000) AddClay (6000) end --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- This function is called to setup Technology states on mission start function InitTechnologies() 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() var = 0 StartSimpleJob("CreateArmyFour2") end function CreateArmyFour2 () if ( var < 900 ) then var = var +1 end if ( var == 20 ) then armyFour2 = {} armyFour2.player = 1 armyFour2.id = 1 armyFour2.strength = 4 armyFour2.position = GetPosition("z2") armyFour2.rodeLength = 10000 SetupArmy(armyFour2) local troopDescription1 = {} troopDescription1.maxNumberOfSoldiers = 4 troopDescription1.minNumberOfSoldiers = 0 troopDescription1.experiencePoints = VERYHIGH_EXPERIENCE troopDescription1.leaderType = Entities.PU_LeaderHeavyCavalry2 local troopDescription2 = {} troopDescription2.maxNumberOfSoldiers = 4 troopDescription2.minNumberOfSoldiers = 0 troopDescription2.experiencePoints = VERYHIGH_EXPERIENCE troopDescription2.leaderType = Entities.PU_LeaderBow2 local troopDescription3 = {} troopDescription3.maxNumberOfSoldiers = 4 troopDescription3.minNumberOfSoldiers = 0 troopDescription3.experiencePoints = VERYHIGH_EXPERIENCE troopDescription3.leaderType = Entities.CU_Barbarian_LeaderClub2 local troopDescription4 = {} troopDescription4.maxNumberOfSoldiers = 8 troopDescription4.minNumberOfSoldiers = 0 troopDescription4.experiencePoints = VERYHIGH_EXPERIENCE troopDescription4.leaderType = Entities.CU_BanditLeaderSword2 for i = 1,4,1 do EnlargeArmy(armyFour2,troopDescription1) end for i = 1,4,1 do EnlargeArmy(armyFour2,troopDescription2) end for i = 1,3,1 do EnlargeArmy(armyFour2,troopDescription3) end for i = 1,2,1 do EnlargeArmy(armyFour2,troopDescription4) end var = 0 return end end
If the player Id of the army (player 1 in this case) has not a single building on the map, the game crashes.
Settlerman
|
#14 30.03.2016 11:11 Beiträge: 238 |
CreateArmy1() CreateArmy2() -- both in the FMA Function CreateArmy1() Army = {} Army.player = 2 Army.id = 9 Army.strength = 4 Army.position = GetPosition("EnemySpawn1") Army.rodeLength = 1000 SetupArmy(Army) Army.spawnTypes = { {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderSword4, 8}, {Entities.PU_LeaderSword4, 8}, } Army.endless = true Army.spawnPos = GetPosition("EnemySpawn1") Army.spawnGenerator = "EnemyHQ1" Army.respawnTime = 10 Army.refresh = true Army.maxSpawnAmount = 4 Army.noEnemy = true Army.noEnemyDistance = 500 SetupAITroopSpawnGenerator("EnemyArmy1", Army) StartSimpleJob("ControlArmy1") end function ControlArmy1() Move("EnemyArmy1","P1") end Function CreateArmy2() Army = {} Army.player = 3 Army.id = 9 Army.strength = 4 Army.position = GetPosition("EnemySpawn2") Army.rodeLength = 1000 SetupArmy(Army) Army.spawnTypes = { {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderSword4, 8}, {Entities.PU_LeaderSword4, 8}, } Army.endless = true Army.spawnPos = GetPosition("EnemySpawn2") Army.spawnGenerator = "EnemyHQ2" Army.respawnTime = 10 Army.refresh = true Army.maxSpawnAmount = 4 Army.noEnemy = true Army.noEnemyDistance = 500 SetupAITroopSpawnGenerator("EnemyArmy2", Army) StartSimpleJob("ControlArmy2") end function ControlArmy2() Move("EnemyArmy2","P2") end
Try it with this.
If you've any question about this, just ask!
polaster64
|
#15 18.02.2018 14:09 Beiträge: 184 |
yeah im just back to making my own map and I wanna see if it is possible that sometimes the troops will attack me-player1 and sometimes the another ai player. You know - one troop spawn goes to real player and the other troop spawn goes to the another ai player.
Play4FuN
|
#16 18.02.2018 15:41 Beiträge: 704 |
I guess the best way to realise this would be to adjust the army positions.
Something like
ArmyNrOne.position = GetPosition("a") ArmyNrTwo.position = GetPosition("b")
while position a and b might be near the enemies to be attacked. You may than call FrontalAttack or Advance on these armys.
____________________
LG Play4FuN
Siedler DEdK Mapping + Scripting Tutorials
polaster64
|
#17 18.02.2018 19:06 Beiträge: 184 |
Zitat von Settlerman:
CreateArmy1() CreateArmy2() -- both in the FMA Function CreateArmy1() Army = {} Army.player = 2 Army.id = 9 Army.strength = 4 Army.position = GetPosition("EnemySpawn1") Army.rodeLength = 1000 SetupArmy(Army) Army.spawnTypes = { {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderSword4, 8}, {Entities.PU_LeaderSword4, 8}, } Army.endless = true Army.spawnPos = GetPosition("EnemySpawn1") Army.spawnGenerator = "EnemyHQ1" Army.respawnTime = 10 Army.refresh = true Army.maxSpawnAmount = 4 Army.noEnemy = true Army.noEnemyDistance = 500 SetupAITroopSpawnGenerator("EnemyArmy1", Army) StartSimpleJob("ControlArmy1") end function ControlArmy1() Move("EnemyArmy1","P1") end Function CreateArmy2() Army = {} Army.player = 3 Army.id = 9 Army.strength = 4 Army.position = GetPosition("EnemySpawn2") Army.rodeLength = 1000 SetupArmy(Army) Army.spawnTypes = { {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderPoleArm4, 8}, {Entities.PU_LeaderSword4, 8}, {Entities.PU_LeaderSword4, 8}, } Army.endless = true Army.spawnPos = GetPosition("EnemySpawn2") Army.spawnGenerator = "EnemyHQ2" Army.respawnTime = 10 Army.refresh = true Army.maxSpawnAmount = 4 Army.noEnemy = true Army.noEnemyDistance = 500 SetupAITroopSpawnGenerator("EnemyArmy2", Army) StartSimpleJob("ControlArmy2") end function ControlArmy2() Move("EnemyArmy2","P2") end
Try it with this.
If you've any question about this, just ask!
It says that there is some mistake, ERRSYNTAX
polaster64
|
#18 18.02.2018 19:14 Beiträge: 184 |
I-ve got a question. Is there any tutorial in english language that I can use to create my own map?
Play4FuN
|
#19 18.02.2018 20:27 Beiträge: 704 |
Syntaxerror: please write where the error occurs (which line) because it's much easier for you to finde the place of the error.
Tutorial: afaik not, but you can check the "ScriptExample" map which comes with the 1st AddOn. Maybe its script can help you.
____________________
LG Play4FuN
Siedler DEdK Mapping + Scripting Tutorials
polaster64
|
#20 18.02.2018 20:33 Beiträge: 184 |
Zitat von Play4FuN:
Syntaxerror: please write where the error occurs (which line) because it's much easier for you to finde the place of the error.
Tutorial: afaik not, but you can check the "ScriptExample" map which comes with the 1st AddOn. Maybe its script can help you.
this syntaxerror is a programme which detects errors?
function CreateArmyFour() if ( var < 900 ) then var = var +1 end if ( var == 600 ) then armyFour = {} armyFour.player = 1 armyFour.id = 1 armyFour.strength = 4 armyFour.position = GetPosition("Ziel1") armyFour.rodeLength = 10000 SetupArmy(armyFour) local troopDescription1 = {} troopDescription1.maxNumberOfSoldiers = 8 troopDescription1.minNumberOfSoldiers = 0 troopDescription1.experiencePoints = VERYHIGH_EXPERIENCE troopDescription1.leaderType = Entities.PU_LeaderBow4 for i = 1,4 do EnlargeArmy(armyFour,troopDescription1) end armyFour = {} armyFour.player = 1 armyFour.id = 1 armyFour.strength = 4 armyFour.position = GetPosition("Ziel1") armyFour.rodeLength = 10000 SetupArmy(armyFour) local troopDescription2 = {} troopDescription2.maxNumberOfSoldiers = 8 troopDescription2.minNumberOfSoldiers = 0 troopDescription2.experiencePoints = VERYHIGH_EXPERIENCE troopDescription2.leaderType = Entities.PU_LeaderSword4 for i = 1,4 do EnlargeArmy(armyFour,troopDescription2) end armyFour = {} armyFour.player = 1 armyFour.id = 1 armyFour.strength = 4 armyFour.position = GetPosition("Ziel1") armyFour.rodeLength = 10000 SetupArmy(armyFour) local troopDescription3 = {} troopDescription3.maxNumberOfSoldiers = 3 troopDescription3.minNumberOfSoldiers = 0 troopDescription3.experiencePoints = VERYHIGH_EXPERIENCE troopDescription3.leaderType = Entities.PU_LeaderHeavyCavalry2 for i = 1,2 do EnlargeArmy(armyFour,troopDescription3) end armyFour = {} armyFour.player = 1 armyFour.id = 1 armyFour.strength = 4 armyFour.position = GetPosition("Ziel1") armyFour.rodeLength = 10000 SetupArmy(armyFour) local troopDescription4 = {} troopDescription4.maxNumberOfSoldiers = 3 troopDescription4.minNumberOfSoldiers = 0 troopDescription4.experiencePoints = VERYHIGH_EXPERIENCE troopDescription4.leaderType = Entities.PU_LeaderCavalry2 for i = 1,2 do EnlargeArmy(armyFour,troopDescription4) end armyFour = {} armyFour.player = 1 armyFour.id = 1 armyFour.strength = 4 armyFour.position = GetPosition("Ziel1") armyFour.rodeLength = 10000 SetupArmy(armyFour) local troopDescription5 = {} troopDescription5.maxNumberOfSoldiers = 6 troopDescription5.minNumberOfSoldiers = 0 troopDescription5.experiencePoints = VERYHIGH_EXPERIENCE troopDescription5.leaderType = Entities.PU_LeaderPoleArm4 for i = 1,4 do EnlargeArmy(armyFour,troopDescription5) end var = 0 return end end
And I have another question. I want to spawn this army max 1 time and respawn it when the last unit dies, could you edit it for me?
mcb
|
#21 18.02.2018 21:35 Beiträge: 1472 |
@polaster: Syntax are the rules of a language. So a syntaxerror is something that does not follow these rules. (Therefore the compiler has no idea what to do with it and throws an error.)
@Play4Fun: Mir ist aufgefallen das da Function anstelle von function steht.
polaster64
|
#22 18.02.2018 22:20 Beiträge: 184 |
Zitat von mcb:
@polaster: Syntax are the rules of a language. So a syntaxerror is something that does not follow these rules. (Therefore the compiler has no idea what to do with it and throws an error.)
@Play4Fun: Mir ist aufgefallen das da Function anstelle von function steht.
How detect which line is wrong?
mcb
|
#23 18.02.2018 22:49 Beiträge: 1472 |
It's in the Error Message. Should be something like Filename:Line Errortext
Play4FuN
|
#25 19.02.2018 14:25 Beiträge: 704 |
oh, you are using the syntax check in the MapEditor ... please, for your and our advantage: use the syntax and varcheck or use the lua debugger!
____________________
LG Play4FuN
Siedler DEdK Mapping + Scripting Tutorials
Seiten: 1