save and bone files now can be compressed with ZLib (wow!)
[k8-i-v-a-n.git] / src / game / wskill.h
blob4f4ed0a413729b6303fb159afb2d2cb24ace9b68
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
12 #ifndef __WSKILL_H__
13 #define __WSKILL_H__
15 #include "ivandef.h"
18 class outputfile;
19 class inputfile;
22 class weaponskill {
23 public:
24 weaponskill () : Level(0), Hits(0), HitCounter(0) {}
25 int GetLevel () const { return Level; }
26 int GetHits () const { return Hits; }
27 truth Tick ();
28 truth AddHit (int);
29 truth SubHit (int);
30 virtual ~weaponskill () {}
31 virtual void Save (outputfile &) const;
32 virtual void Load (inputfile &);
33 virtual int GetLevelMap (int) const = 0;
34 virtual feuLong GetUnuseTickMap (int) const = 0;
35 virtual int GetUnusePenaltyMap (int) const = 0;
37 protected:
38 int Level;
39 int Hits;
40 uInt HitCounter;
44 class cweaponskill : public weaponskill {
45 public:
46 virtual int GetLevelMap (int) const;
47 virtual feuLong GetUnuseTickMap (int) const;
48 virtual int GetUnusePenaltyMap (int) const;
49 cchar *GetName (int) const;
50 int GetBonus () const { return 1000+50*Level; }
51 void AddLevelUpMessage (int) const;
52 void AddLevelDownMessage (int) const;
56 inline outputfile &operator << (outputfile &SaveFile, const cweaponskill &WeaponSkill) {
57 WeaponSkill.Save(SaveFile);
58 return SaveFile;
62 inline inputfile &operator >> (inputfile &SaveFile, cweaponskill &WeaponSkill) {
63 WeaponSkill.Load(SaveFile);
64 return SaveFile;
68 class sweaponskill : public weaponskill {
69 public:
70 sweaponskill () : ID(0), Weight(0), Config(0) {}
71 sweaponskill (citem *);
72 virtual int GetLevelMap (int) const;
73 virtual feuLong GetUnuseTickMap (int) const;
74 virtual int GetUnusePenaltyMap (int) const;
75 int GetBonus () const { return Level ? 1150+25*(Level-1) : 1000; }
76 void AddLevelUpMessage (cchar *) const;
77 void AddLevelDownMessage (cchar *) const;
78 virtual void Save (outputfile &) const;
79 virtual void Load (inputfile &);
80 truth IsSkillOf (citem *) const;
81 truth IsSkillOfCloneMother (citem *, feuLong) const;
82 void SetID (feuLong What) { ID = What; }
83 feuLong GetID () const { return ID; }
84 void PreProcessForBone () { ID = -ID; }
86 private:
87 feuLong ID;
88 sLong Weight;
89 int Config;
93 inline outputfile &operator << (outputfile &SaveFile, const sweaponskill *WeaponSkill) {
94 WeaponSkill->Save(SaveFile);
95 return SaveFile;
99 inline inputfile &operator >> (inputfile &SaveFile, sweaponskill *&WeaponSkill) {
100 WeaponSkill = new sweaponskill;
101 WeaponSkill->Load(SaveFile);
102 return SaveFile;
106 #endif