I had different thought about the rage function.
The simple idea we have at the moment is to achieve "Rage" by increasing the damage value of the weapon. That is fine for now, but I was thinking "Rage" is not really a function of the weapon, it is more an increase in the frequencies and number of strikes with the weapon. That fits into the fight sequence thing I mentioned earlier. As I said it is a more complicated thing - "A whole new kettle of krawldads" :)
I didn't think I could call a derived function into the base. |
The Rage function would exist in the CEnemy base class & be inherited by any new Enemy. The Rage function can be called by any function that exists in any of the Enemy classes. If the Rage function is called by another function in the class, then there is no need for it to be public. The idea is to have few public things as possible, and no public variables at all, because these can be altered by any object at any time.
Would I need a setter function to change the health for each enemy? A troll will have more health than say a goblin. |
No - setting the health initially is done by a constructor in each class that needs it. Changing the health to reflect damage done is done by the RecvAttack function, and the Weapon.Use() function to retrieve the damage. This function is virtual, so we can redefine it, if we want, to reflect different behaviour. The RecvAttack function is really a 'getter' in disguise, but we can get away with it because it takes an object (or pointer to obj, or reference to obj) as a parameter, and it is virtual, declared in the base class - so these thing make it an interface. interface is a Java keyword and it means to have a virtual or pure virtual functions in the base class, and these describe the way that other objects interact with the object.
I should mention that we are only going to create objects from some of the classes. We do not want to make objects from CActor, CWeapon, CCutting, because these are too general & / or it doesn't make sense to make an object out of them. If we just have 1 player (the hero) then we can make the Hero object from the CPlayer class. However if we had several different sorts of player's on our side like Heroine, Magician, Military, General, Soldier, - then we would derive these from CPlayer. We would make it impossible to create objects from CPlayer and CMililtary. We can do this by making all their constructors protected, and making sure there is a virtual function ( we already have some in CActor). Vlad & Doug4 explained this to me in another thread.
The Flee function could be called from the RecvAttack function.
The RecvAttack function is what controls what happens when something is attacked. Shall I Flee? If I fight, and my health is low, then Rage.
With Qt, did I mention to get Qt Creator? There are several different packages for Qt. The Qt SDK is mainly for phones, I think.
I am going to have a go with the info that has come up from the other threads - and get my version of the code posted.