- DAXON'S PAGE
- PERSO'S PAGE
- SGI'S PAGE
- SLADER'S PAGE
- VASJA'S PAGE
- TPTPT'S PAGE
- 01 - Get the good size
- 02 - Prepare the structure
- 03 - Textures
- 04 - Build the Skeleton
- 05 - Create new members
- 06 - Used Chiliskiner for rebuild skeleton
- 07 - Link skeleton
- 08 - Orientation of menbers
- 09 - Create Anchor
- 10 - Orientation of Anchor
- 11 - Link Anchor
- 12 - Finalise the character
- 13 - Add Edge for natural weapon
- PROSPERO'S PAGE
- 01 - Starting
- 02 - Stopping 'Ice Skating'
- 03 - A bit of boring theory
- 04 - Adding objects
- 05 - Weapons
- 06 - Enemies
- 07 - Controling enemies
- 08 - Trigger Sectors
- 09 - Cutscenes and camera stuff
- 10 - Sounds
- 11 - Doors
- 12 - De-bugging
- 13 - Sun, Water, Footsteps
- 14 - Gates
- 15 - Death of Enemies
- 16 - Classes
- 17 - Traps
- 18 - Torches
- 19 - New Races
- 20 - A Painless Way to Install New Objects
- 01 - BOD and 3DSMAX 2.5
- 02 - BOD and 3DSMAX 2.5
-
NEW CHARACTER TUTORIAL
-
BOD PYTHON SCRIPTING
BOD Python Scripting
16 - Classes
Heavy stuff here. Classes are basically databases. When the data contained within a class is assigned to something the something is controlled by the class. Any number of things can be controlled individually by the same class. Whats more you can create sub-classes that add extra features to the parent class. All the Characters in the game derive their data from the class 'PlayerPerson' in Basic_Funcs.py. This initializes all the core functions and variables.
Player chars use their data directly from this class.
A sub-class. NPCPerson in Enm_Def.py derives (or 'inherits') from this class and adds other data as well as all the AI features for enemies.
Each enemy race then has it's own sub-class of NPCPerson in the file EnemyTypes.py.
Now comes the interesting bit. You can make your own classes to alter enemy behaviour (within certain limits). In the last tut I demo'ed how to get a function called from enemy death. Perfectly sound method, but say you had 100 orks in your map and you wanted that code on each one. You would have a lot of repetitive code to write. Better if you use a subclass with that feature built in:
Make a new file. MyMapTypes.py
import Bladex import EnemyTypes import Enm_Def import GameStateAux class MyMapOrk(EnemyTypes.Ork): DeathFunc=None Deathargs=() def __init__(self,me): EnemyTypes.Ork.__init__(self, me)# initialize parent class me.ImDeadFunc=self.NewImDeadFunc def NewImDeadFunc(self, EntityName): # define new ImDeadFunc Enm_Def.NPCPerson.StdImDead(self,EntityName) if self.Deathfunc: apply(self.Deathfunc,self.Deathargs) # Saving and Loading code def __getstate__(self): NPCPerson_state= EnemyTypes.Ork.__getstate__(self) if (NPCPerson_state[0]!=1): return NPCPerson_state NPCPerson_state[1]["MyMapOrk"]=(GameStateAux.SaveFunctionAux(self,Deathfunc),self.Deathargs) return NPCPerson_state def __setstate__(self,parm): EnemyTypes.Ork.__setstate__(self,parm) version=parm[0] if version==1: parms=parm[1]["MyMapOrk"] GameStateAux.LoadFunctionAux(parms[0],self,"Deathfunc") self.Deathargs=parms[1]Now you must import MyMapTypes to your enemy.py file. Instead of the
EnemyTypes.EnemyDefaultFuncs code you must point the enemy to your new class:
ork1.Data=MyMapTypes.MyMapOrk(ork1) #and assign them the function to be called on death ork1.Data.Deathfunc=Ork1DED # you can pass arguments with this ork1.Data.Deathargs=(ork1.Name,)The class will remember all the Deathfuncs/args for all members of the class. (1000's of them if you want)
This is just a quick (but useful) example. Use the same principle to add/modify any aspect of the class. It is complicated stuff, but study some of the classes in the files to get an idea of how it all works.