Simple enough on first principles. All you need is a set of map coordinates.
This is a block of code from the Tabriz map that creates a Traitor Knight:
Code: Select all
pers=Bladex.CreateEntity("KOMkngt","Knight_Traitor",-81406.529435, -6366.32180405, 45316.01156,"Person")
The coords are the three values separated by commas after "Knight_Traitor"
The first one is the X axis on the map. Negative values East of the origin. Positive West.
Second is the hight - Negative Up. This isn't the hight from the ground. The ground can be anywhere.
Third is Y axis. Negative North, Positive South.
The code creates the model, adds all the code to make him work and creates his weapons and 'gives' them to him. The centre of the model is the reference point as far as positioning goes.
Of course when you are in the map you have no idea which direction is where and where you are in terms of coordinates.
There is an onscreen readout that is enabled by enabling Debug mode in Reference.py. Readouts are cycled with the T key and one gives current Player position and angle. There is also a neat piece of code which you can add to allow the recording of Player positions to a .txt file.
The first parameter in the code .....CreateEntity("Name",...... Is the individual name of the enemy. Has to be unique in the map.
So, in theory if you simply copy/paste that block of code in the same file, change name - "KOMkngt" to "KOMkngt2" or whatever. Alter the x and y coords (think of them as millimeters) so that they aren't too close. Then you should have an extra Knight near "KOMkngt". Also their weapons need individual names.
Lots of complications. If you don't place them carefully they can end up in a solid part of the map.
Notice the Action Areas in the code. This is a clever part to control and limit their movement. There is a primary and secondary area. You no doubt have noticed how this works in the game. The area numbers are hard-coded into the sectors of the maps. Enemies must always start in their primary areas. They can go into secondary area to fight, but if the Player is out of both areas they will retreat to primary. There can be any number of areas and any shape. And to further complicate things a sector with number 1 will translate as 0 in scripts. Python counts from 0. Omitting this code altogether is OK, but it means enemies can go anywhere. They often get lost and go into strange modes which consume CPU power.
Most enemies are 'hidden' until needed. Note lots of HideBadGuy() lines. This means invisible and totally non-responsive. A certain event during the game will activate them. This ensures they are in the right place when needed and don't consume resources.
So you see there is a bit more to it than might appear. Like cutscenes. You don't want any live enemies near during a cutscene while you are defenceless. Some events are triggered by the death of an enemy - or group of enemies. Add an extra one and you mess that up.
Not trying to put you off, just pointing out a few things.