diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-05-30 20:12:36 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-05-30 20:12:36 -0300 |
| commit | 08780dad536eb5d0544eb2ea70e5443dc237976f (patch) | |
| tree | 673a57b538ca9016d5b386ff32c3bd67c2190c2f /src/magic.cc | |
| parent | dff5e62f6ebb1b06c234b9144458788893b6ca86 (diff) | |
| download | game-08780dad536eb5d0544eb2ea70e5443dc237976f.tar.gz game-08780dad536eb5d0544eb2ea70e5443dc237976f.zip | |
more work on `crcombat.cc`
Diffstat (limited to 'src/magic.cc')
| -rw-r--r-- | src/magic.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/magic.cc b/src/magic.cc new file mode 100644 index 0000000..f8f0505 --- /dev/null +++ b/src/magic.cc @@ -0,0 +1,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; + } +} |
