blob: f8f0505d01e1e98f21cf98b2f30829e5280fad27 (
plain) (
blame)
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
|
#include "magic.hh"
#include "creature.hh"
// 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
// =============================================================================
void 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;
}
// 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;
}
}
|