First you have to decide how customizable you want your weapons to be. In many games the weapons could just be one class defined by different values ex:
BulletType
FireAngleVariance
FireVelocity
ClipSize
ReloadTime
FireRate
All being variables. Of course this falls apart if you want your weapons to be VERY different. In that case things become a bit more complicated. You probably want a base class.
ex.
Code:
//I know you said you didn't need code samples, but they make things easier to
//explain sometimes.
class Weapon
{
public:
virtual void Equip()=0;
virtual void Unequip()=0;
virtual void TriggerDown()=0;
virtual void TriggerReleased()=0;
virtual void Reload()=0;
};
Of course now there is going to be potentially a lot of code duplication. You could have a happy median between the these two designs by making a class with some variables and some callback functions.
Code:
class DefaultWeapon : public Weapon
{
int mFireRate;
//... more variables
private:
virtual void OnEquip(){}
virtual void OnUnequip(){}
virtual void OnFire(){}
virtual void OnReload(){}
public:
//I wish C++ had a way to guarantee no further overriding of these functions.
virtual void Equip()
{
DisplayModel();
//...
OnEquip();
//...
}
virtual void Unequip()
{
DisplayModel();
//...
OnEquip();
//...
}
virtual void TriggerDown()
{
if(mFireRate < gCurTime - mLastFireTime)
{
mLastFireTime = gCurTime;
//maybe actually fire a bullet, or leave that to OnFire()
OnFire();
}
}
virtual void TriggerReleased(){}
virtual void Reload()
{
//maybe actually do reload timing, or if that needs to be customized
//OnReload could do it.
OnReload();
}
};
That's how I would do it. You can see that DefaultWeapon inherited from Weapon. This way people can inherit from DefaultWeapon if they want to make a simple weapon quickly, and Weapon if they need a very customizable one. I have 2 layers of complexity here, but more may be useful. I would definitely have one layer with no callback functions so generic weapons can tested quickly. Depending on what your needs are you'll have to decide how many layers you need and how customizable they should be.
I don't have too much experience with this because I've never made a game that required more variation than I could get with the first method (no virtual functions, just variables). So be wary that you may need to change my design a bit. I imagine it should work though, it's based off of a pattern I use often.
edit:
I assumed you were using C++. If you are using C then you would use function pointers for the callbacks instead of virtual functions.