Post tutorial RSS Level Editing Scripting by Prospero. Part. 6

Enemies are created in exactly the same way as objects, but they all have the entity class "Person".

Posted by on - Basic Client Side Coding

Tut6. Enemies

Enemies are created in exactly the same way as objects, but they all have the entity class "Person". They will always stay on the ground and will always remain upright (until you kill them). They don't have an Orientation attribute, instead they have an 'Angle'. An Angle of 0
will make them face North in the map, going counter-clockwise to 6.

You should not alter their Scale. I think you can make them smaller, but you cannot make them bigger.

I usually have them in a seperate *.py file, Exec this file in as with Don't name your file '' or ''. As with 'Objects', there is a BOD source file with this name.

I like to give each enemy their own variable, usually a lowercase version of the individual name:

python code:
ork1=Bladex.CreateEntity("Ork1",Ork,x,  z, y,"Person")

When you have lots of baddies running about you will appreciate the value of this.

To enable the AI, enemies need a lot of data. Assign this with:

EnemyTypes.EnemyDefaultFuncs(ork1) # import EnemyTypes

Enemies need weapons. Apart from the ones that naturally fight with no weapons,(Golems, Demons, etc),they have no collision edges in the mesh for unarmed combat and no data to handle it anyway. If you don't arm them they will just run about in confusion. Also DO NOT try giving them Two-Handed stuff. It will crash the game when they try to move.

Create their weapons/shields in the usual manner Coords don't matter here, just use 0,0,0,. Don't forget the ItemDefaultFuncs code on shields and bows/quivers. To make nice neat code I name the weapons of an enemy the same as the enemy but with WP on the end for weapons, SH for shields.

0nce you have their kit created you need to get them to take it. There is a handy function in file that handles this:

python code:
Actions.TakeObject("Ork1","Ork1SH")   # import Actions

Now they are all set to rock'n'roll.

If you want to use Player characters as enemies you need to create a data class and combat charts for them. I won't go into that at the mo.

One complication is Dal Gurak. He has two phases. He will start in phase1 where he will teleport about and throw stuff at you. This phase needs scripting to assign him teleportation coords. The answer is to start him in his melee phase:

python code:

Same applies to the "DarkLord". He needs loads of scripting with his existing data, coords for teleporting, meteorites, etc. His whole class data needs rewriting in order to use him simply. I won't dwell a that for now.

The 'Kind' names for enemies are:

Lich # Mummy type guys
Cos # Little pink critters

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.