Hi All,
I’m trying to get a little more clever with my non-player character (NPC) object creation. Currently I have unique code for each of my different NPC types. This works but takes up a lot of “space” and also means if I change a common system I change it in multiple locations (not the end of the world but not as slick as I think I ought to be). So I’m looking to figure out how to derive other NPC types off of a base NPC.
I have Programming in Lua (2nd Edition) and broadly follow 16.1 Classes, 16.2 Inheritance and 16.3 Multiple Inheritance. I’m just having a hard time putting it into practice. The challenge for me is that the examples from the book seem fairly different from what I’m attempting. Can anyone share any tips on how to approach making a base NPC class and then extending that into other NPC types?
Basically I have my normal critter that can spawn and move. I’d like to make a variant that’s larger, slower and more resilient and another one that is similar in size and speed but has some additional movement considerations.
My project also has weapons that the player can pick up. I currently only have one but imagine this system of class and inheritance will be very helpful when I work on more of those.
Thanks in advance for any help anyone can offer [import]uid: 105707 topic_id: 35562 reply_id: 335562[/import]