But now why I am stuck. I implemented a system where a callback function would be called when a flying object hit something. Normally, I just stop the item and do nothing, but for weapons I need to apply damage. I looked at how the original attack function was coded, and found that monsters and players have a reference to a "body" object that handles combat and other type-specific functionality. Body has a function "Attack", that attacks a other body object. This means that I can override it in subclasses for more advanced attacks. For my projectile impact function, I wanted to do something similar to the basic attack function, (Not necessarily the attack function of the thrower) except modify some stats based on size. I tried just calling the method as a static method and passing a dummy object as self, but apparently self has to actually be a instance of the class. I came up with 3 ways to solve this:
A) Make body subclass a dummy class, except the dummy class has a fully functional attack method that I can use when I don't want to create a full instance of the body class
B) Just use a instance of body with a dummy reference to a monster object, so I can feed it it's own values
C) Make the dummy class inherit from monster body, and override getstat() so I can custom morph the accuracy stat
D) Make all attacks static functions in the main class, and have subclasses only specify which ones they know how to do. This way, I have removed almost all code from the monster classes and it solves a side problem because I can now define then in a CSV, XML or JSON file. However, I feel all those static methods will be extremely ugly.
E) Same as D, but define loose functions instead of static methods
F) Anybody have any more ideas?
(Oops, 5 options)
If anybody can give my any advice how to do this, it would be greatly appreciated!
(Ps. I uploaded it to github, and I will post a code guide when I have solved this issue)