# single enemie class, multiple enemies in script...

This topic is 5394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a pretty complex task ahead of me with my current project. What I want to do is create a 'task' system for the enemie class in the C++ code and the in the script, create an state mechine to handle different "onEvent" functions. The enemy class in the C++ side should be the only class needed for all "smart" objects and then this class would be basically derived in lua by basically creating a instance of the class and then simply setting it's varables different (ie. model file, size, whatever). The problem is, the levels will be defined in xml so im not sure if I should just include the same script file for every instance of the same creatures, or if the script should get loaded once and then it would be "instanced"... anyway... So question 1: if I bind the enemie class to lua should each enemie class simply be as follows: (keep in mind that there maybe 20 instances of the same script).
alien = new CEnemy()
alien->name = "E.T"
alien->filename = "alien.3ds"
whatever...

and the maybe...
scene.Insert(alien)


Question 2: about the state machine... Alien.OnSeeEnemy() { ... } g_onseeenemy = Alien.OnSeeEnemy(); Alrighty, just one last question, with the complexity of the scripting, would it be more feasible to create a list of C funtions, bind them to lua and then create the enemie class in lua... Sorry, I know these will be hard to answer. Im just really lost here. I guess basically what I want is a system simular to unreal scripting. Any comments... please! thanks a lot. ~Jason

• 18
• 29
• 11
• 21
• 16