Merentha is an LP type MUD which means the language we code in is LPC. It is very simular
to both C and C++ but different in other ways as well.
Objects are inherited, which means from a base object we can copy the functions and abilities from it with a single line of code instead of copying all the code by hand.
To understand a little more, take a look at the diagram below...
LIGHT | ARMOUR | FOOD \ | / \ | / WEAPON-----OBJECT----DRINK / \ \ / \ \ TAMEABLE LIVING BOARD \ \ / \ \ \ / \ CONTAINER RIDEABLE------MONSTER USER / \ / \ STORAGE ROOM / \ / \ / \ / \ VENDOR BARKEEP PIER VAULTEvery object stems from the root file which is OBJECT. So a monster you create will inherit MONSTER which in itself inherits all the abilities of LIVING which inherits all the abilities of the core OBJECT.
Now what are these abilities you may ask. Well they are such things as the name of the object in question. All objects have names. The player Petrarch is an object which has the name "Petrarch". A snowball has the name "Snowball" and so on. This information is recorded in the OBJECT and since LIVING inherits OBJECT and MONSTER inherits LIVING and the monster you create will inherit MONSTER then the monster you create will not have to worry about the code needed to give an object a name, or to store it or anything of the sort, its already taken care of.
There are also other things which LIVING inherits besides OBJECT but they are not shown for the sake of simplicity. It also inherits BODY and COMBAT which describe how the body works, what limbs are on the body, what armour or weapons are wielded or worn as well.
It is also possible to do multiple inheritance. For eaxmple in the "bags" section for coding we do in one example where we inherit both ARMOUR and STORAGE to make a backpack that can both be worn and store things.
Inheritance is used all the time. Most of the files/objects you create will have at least one inheritance
line in them. This line will look something like:
You will also see lines like this:
Ok, so back to the ::create(); line. In the object/file you inherit there are functions which define many things. One of the functions in the inheritable object is a function called create()
Now this function is really a special function which will automaticlly get called in all objects when the object is created, but that is not too important right now. What is important is that in the example of a monster file you will set its name, race, level and so on in this function. However, this function also exists in the inheritable file and contains some important information. Now if you write your own create() function you will overwrite the inheritable function and lose any of the important information that the inheritable object did.
So what you want to do is call the inheritable's create() function then do your own. The problem is you can't just call the function as create(); because then you will get an infinate loop. You have to call the function as ::create(); which means call the inheritable create() function.
You can also write the function as monster::create(); if you wished. This is somewhat important when you inherit multiple objects and need to specify from which object you wish to call a function.