Page 1 of 1

About adding more enemies

Posted: Sat Sep 06, 2014 12:07 pm
by khairaoui
hi guys :)
in order to the boring levels in BOD ( i mean there is not such difficulty ) i was wondering :roll: how to add different enemies in the main game please help me to have more fun in it mr.MBK_MBK or mr.prospero or anyone else :D thanks

Re: About adding more enemies

Posted: Sun Sep 07, 2014 2:17 am
by prospero
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

Gladius=Bladex.CreateEntity("RagnarGladiusKOM","Gladius",0,0,0,"Weapon")
ItemTypes.ItemDefaultFuncs(Gladius)
escudo=Bladex.CreateEntity("RagnarEscudoKOM","Escudo5",0,0,0)
ItemTypes.ItemDefaultFuncs(escudo)

pers=Bladex.CreateEntity("KOMkngt","Knight_Traitor",-81406.529435, -6366.32180405, 45316.01156,"Person")
pers.Angle=5.8640284647
pers.Level=1
pers.ActionAreaMin=pow(2,4)
pers.ActionAreaMax=pow(2,5)
EnemyTypes.EnemyDefaultFuncs(pers)
pers.SetOnFloor()
#pers.Data.JoinGroup(pers.Name, "KOMEDOR")
Actions.TakeObject(pers.Name,"RagnarGladiusKOM")
Actions.TakeObject(pers.Name,"RagnarEscudoKOM")
Actions.TakeObject("KOMkngt","llave45")

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.

But....

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. :D

Re: About adding more enemies

Posted: Mon Sep 08, 2014 12:23 pm
by khairaoui
sorry i didn't get it :roll: i need a ' how to ' help in the barb level so i can do it in all maps :wink:
thanks :D
Greetings

Re: About adding more enemies

Posted: Mon Sep 08, 2014 5:00 pm
by cieply
khairaoui wrote:sorry i didn't get it...
  • run game with console ( http://www.arokhslair.net/forum/viewtop ... =12&t=2702 )
    run whatever map you want
    go where you want to put knight
    in console put: char.Position and move your character a bit
    write line by line what Prospero has told you (can copy/paste but line by line) altering coordinates with those you've got from char.Position
    voilĂ 
later, when you're happy with result you can put it in Enemies.py of the map en enjoy your work
Enemies.py and armas.py can be your source of inspiration

you can also install EBrowser preferably with patch 1.2 and use it to put objects - very useful tool

Re: About adding more enemies

Posted: Mon Sep 08, 2014 9:48 pm
by khairaoui
hi cieply thanks for your reply :)
i did what u said to me and the result was the following :

http://download1506.mediafire.com/8poiq ... /blade.png

i didn't know what to do after that :roll: 'cause that window i'm sure it's not the console u told me

Re: About adding more enemies

Posted: Tue Sep 09, 2014 12:16 pm
by prospero
Yes. Start the game - but first go to Setup and select 'window' mode. When the game is loaded you should have BOD in a little window in the corner. Drag the console to one side. R-click the top of the Blade window and click 'Size'. Use arrow keys to expand the Blade window so it's bigger, but doesn't overlap the console too much.

This function is handy for saving positions. Copy it to the end of DefFuncs.py in whatever map, but change the filepath to the name of the map folder you are working on. Barb_M1 of whatever.

Code: Select all

def GetPlayerPos():
	char=Bladex.GetEntity("Player1")
	x=int(char.Position[0])
	y=int(char.Position[1])
	z=int(char.Position[2])
	file = open("../../BODLoader/Mods/FugitiveIVpt1/pos.txt","a")
        file.write("("+str(x)+","+str(y)+","+str(z)+")"+"\n")
        file.close()
        
      
Bladex.AddInputAction("GetPlayerPos", 0)
Bladex.AddBoundFunc("GetPlayerPos", GetPlayerPos)
Bladex.AssocKey("GetPlayerPos", "Keyboard", "V", 1)
Then when playing the game just prss the V key when the Player is in the place you want to add an enemy.

Re: About adding more enemies

Posted: Tue Sep 09, 2014 4:03 pm
by khairaoui
i did your instructions but i got an error and when i hit ' v ' nothing appear :( , this is a pic :

http://www.mediafire.com/view/8ym5e92w7 ... LADE+1.png

Re: About adding more enemies

Posted: Wed Sep 10, 2014 1:11 pm
by prospero
That error is nothing to do with it. Lots of non-critical errors pop up in BOD. :roll:

When you press V there will be no indication. But there should be a pos.txt file created in the folder you pointed the filepath to.

btw. This file is created only if it doesn't exist. After that it just keeps getting added to. To save confusion it's an idea to delete it's contents once in a while or simply delete the file.