1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#include "magic.hh"
#include "config.hh"
#include "creature.hh"
#include "stubs.hh"
static const char SpellSyllable[51][6] = {
"",
"al",
"ad",
"ex",
"ut",
"om",
"para",
"ana",
"evo",
"ori",
"mort",
"lux",
"liber",
"vita",
"flam",
"pox",
"hur",
"moe",
"ani",
"ina",
"eta",
"amo",
"hora",
"gran",
"cogni",
"res",
"mas",
"vis",
"som",
"aqua",
"frigo",
"tera",
"ura",
"sio",
"grav",
"ito",
"pan",
"vid",
"isa",
"iva",
"con",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
};
// TImpact
// =============================================================================
void TImpact::handleField(int a, int b, int c){
// no-op
}
void TImpact::handleCreature(TCreature *Victim){
// no-op
}
bool TImpact::isAggressive(void){
return true;
}
// TDamageImpact
// =============================================================================
TDamageImpact::TDamageImpact(TCreature *Actor, int DamageType, int Power, bool AllowDefense){
if(Actor == NULL){
error("TDamageImpact::TDamageImpact: Actor ist NULL.\n");
}
this->Actor = Actor;
this->DamageType = DamageType;
this->Power = Power;
this->AllowDefense = AllowDefense;
}
void TDamageImpact::handleCreature(TCreature *Victim){
if(Victim == NULL){
error("TDamageImpact::handleCreature: Opfer existiert nicht.\n");
return;
}
TCreature *Actor = this->Actor;
if(Actor != NULL && Actor != Victim){
if(WorldType != NON_PVP || !Actor->IsPeaceful() || !Victim->IsPeaceful()){
int DamageType = this->DamageType;
int Damage = this->Power;
if(DamageType == DAMAGE_PHYSICAL && this->AllowDefense){
// TODO(fusion): Shouldn't we clamp `Damage` to zero?
Damage -= Victim->Combat.GetDefendDamage();
}
Victim->Damage(Actor, Damage, DamageType);
}
}
}
// Magic Related Functions
// =============================================================================
void CheckMana(TCreature *Creature, int ManaPoints, int SoulPoints, int Delay){
if(Creature == NULL){
error("CheckMana: Übergebene Kreatur existiert nicht.\n");
throw ERROR;
}
if(Creature->Type != PLAYER || ManaPoints < 0){
return;
}
TSkill *Mana = Creature->Skills[SKILL_MANA];
if(Mana == NULL){
error("CheckMana: Kein Skill MANA!\n");
throw ERROR;
}
TSkill *Soul = Creature->Skills[SKILL_SOUL];
if(Soul == NULL){
error("CheckMana: Kein Skill SOULPOINTS!\n");
throw ERROR;
}
if(!CheckRight(Creature->ID, UNLIMITED_MANA)){
if(Mana->Get() < ManaPoints){
throw NOTENOUGHMANA;
}
if(Soul->Get() < SoulPoints){
throw NOTENOUGHSOULPOINTS;
}
Mana->Change(-ManaPoints);
Soul->Change(-SoulPoints);
}
if(ManaPoints > 0){
Creature->Skills[SKILL_MAGIC_LEVEL]->Increase(ManaPoints);
}
// NOTE(fusion): Maintain largest exhaust?
uint32 EarliestSpellTime = ServerMilliseconds + Delay;
if(Creature->EarliestSpellTime < EarliestSpellTime){
Creature->EarliestSpellTime = EarliestSpellTime;
}
}
|