3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
18 int CWeaponSkillLevelMap
[] = {
19 0, 1500, 2000, 3000, 5000, 7500, 10000, 15000,
20 20000, 30000, 50000, 75000, 100000, 150000,
21 200000, 300000, 500000, 750000, 1000000,
25 feuLong CWeaponSkillUnuseTickMap
[] = {
26 500000, 400000, 300000, 250000, 200000,
27 150000, 125000, 100000, 80000, 62500,
28 50000, 40000, 30000, 25000, 20000,
29 15000, 12500, 10000, 8000, 6250, 5000
32 int CWeaponSkillUnusePenaltyMap
[] = {
33 100, 125, 150, 200, 250, 300, 400, 500,
34 625, 800, 1000, 1250, 1500, 2000, 2500,
35 3000, 4000, 5000, 6250, 8000, 10000
38 cchar
*CWeaponSkillName
[WEAPON_SKILL_CATEGORIES
] = {
52 int SWeaponSkillLevelMap
[] = {
53 0, 500, 750, 1000, 1500, 2000, 3000, 5000,
54 7500, 10000, 15000, 20000, 30000, 50000,
55 75000, 100000, 150000, 200000, 300000,
59 feuLong SWeaponSkillUnuseTickMap
[] = {
60 250000, 200000, 150000, 125000, 100000,
61 80000, 62500, 50000, 40000, 30000,
62 25000, 20000, 15000, 12500, 10000,
63 8000, 6250, 5000, 4000, 3000, 2500
66 int SWeaponSkillUnusePenaltyMap
[] = {
67 250, 300, 400, 500, 625, 800, 1000,
68 1250, 1500, 2000, 2500, 3000, 4000,
69 5000, 6250, 8000, 10000, 12500, 15000,
74 int cweaponskill::GetLevelMap (int I
) const { return CWeaponSkillLevelMap
[I
]; }
75 feuLong
cweaponskill::GetUnuseTickMap (int I
) const { return CWeaponSkillUnuseTickMap
[I
]; }
76 int cweaponskill::GetUnusePenaltyMap (int I
) const { return CWeaponSkillUnusePenaltyMap
[I
]; }
77 cchar
*cweaponskill::GetName (int Category
) const { return CWeaponSkillName
[Category
]; }
79 sweaponskill::sweaponskill (citem
*Item
) : ID(Item
->GetID()), Weight(Item
->GetWeight()), Config(Item
->GetConfig()) {}
80 int sweaponskill::GetLevelMap (int I
) const { return SWeaponSkillLevelMap
[I
]; }
81 feuLong
sweaponskill::GetUnuseTickMap (int I
) const { return SWeaponSkillUnuseTickMap
[I
]; }
82 int sweaponskill::GetUnusePenaltyMap (int I
) const { return SWeaponSkillUnusePenaltyMap
[I
]; }
84 void weaponskill::Save (outputfile
&SaveFile
) const { SaveFile
<< (int)Level
<< (int)Hits
<< (int)HitCounter
; }
85 void weaponskill::Load (inputfile
&SaveFile
) { SaveFile
>> (int&)Level
>> (int&)Hits
>> (int&)HitCounter
; }
87 truth
weaponskill::AddHit (int AddHits
) {
88 if (!AddHits
) return false;
90 if (Hits
<= 5000000-AddHits
) Hits
+= AddHits
; else Hits
= 5000000;
92 while (Level
< 20 && Hits
>= GetLevelMap(Level
+ 1)) ++Level
;
93 return Level
!= OldLevel
;
97 truth
weaponskill::SubHit (int SubHits
) {
98 if (!SubHits
) return false;
99 if (Hits
>= SubHits
) Hits
-= SubHits
; else Hits
= 0;
100 int OldLevel
= Level
;
101 while (Level
&& Hits
< GetLevelMap(Level
)) --Level
;
102 return Level
!= OldLevel
;
106 void cweaponskill::AddLevelUpMessage (int Category
) const {
107 ADD_MESSAGE("You advance to skill level %d with %s!", Level
, CWeaponSkillName
[Category
]);
111 void cweaponskill::AddLevelDownMessage (int Category
) const {
112 ADD_MESSAGE("You have not practised enough with %s lately. Your skill level is reduced to %d!", CWeaponSkillName
[Category
], Level
);
116 void sweaponskill::AddLevelUpMessage (cchar
*WeaponName
) const {
117 ADD_MESSAGE("You advance to skill level %d with your %s!", Level
, WeaponName
);
121 void sweaponskill::AddLevelDownMessage (cchar
*WeaponName
) const {
122 ADD_MESSAGE("You have not practised enough with your %s lately. Your skill level is reduced to %d!", WeaponName
, Level
);
126 void sweaponskill::Save (outputfile
&SaveFile
) const {
127 weaponskill::Save(SaveFile
);
128 SaveFile
<< ID
<< Weight
<< (int)Config
;
132 void sweaponskill::Load (inputfile
&SaveFile
) {
133 weaponskill::Load(SaveFile
);
134 SaveFile
>> ID
>> Weight
>> (int&)Config
;
138 truth
weaponskill::Tick () {
139 if (Hits
&& HitCounter
++ >= GetUnuseTickMap(Level
)) {
140 HitCounter
-= GetUnuseTickMap(Level
);
141 if (SubHit(GetUnusePenaltyMap(Level
))) return true;
147 truth
sweaponskill::IsSkillOf (citem
*Item
) const {
148 return (ID
== Item
->GetID() && Weight
== Item
->GetWeight() && Config
== Item
->GetConfig());
152 truth
sweaponskill::IsSkillOfCloneMother (citem
*Item
, feuLong CMID
) const {
153 return (ID
== CMID
&& Weight
== Item
->GetWeight() && Config
== Item
->GetConfig());