aboutsummaryrefslogtreecommitdiff
path: root/src/magic.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-05-31 02:25:31 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-05-31 02:25:31 -0300
commitd7c11b271633ee1f5b58d2b679b50cf95b2826e0 (patch)
treec08832dff011660dcc2af748b82d5ab0adf82d97 /src/magic.cc
parent08780dad536eb5d0544eb2ea70e5443dc237976f (diff)
downloadgame-d7c11b271633ee1f5b58d2b679b50cf95b2826e0.tar.gz
game-d7c11b271633ee1f5b58d2b679b50cf95b2826e0.zip
done with `crcombat.cc`
Diffstat (limited to 'src/magic.cc')
-rw-r--r--src/magic.cc88
1 files changed, 84 insertions, 4 deletions
diff --git a/src/magic.cc b/src/magic.cc
index f8f0505..5d6acad 100644
--- a/src/magic.cc
+++ b/src/magic.cc
@@ -1,6 +1,63 @@
#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){
@@ -17,7 +74,7 @@ bool TImpact::isAggressive(void){
// TDamageImpact
// =============================================================================
-void TDamageImpact::TDamageImpact(TCreature *Actor, int DamageType, int Power, bool AllowDefense){
+TDamageImpact::TDamageImpact(TCreature *Actor, int DamageType, int Power, bool AllowDefense){
if(Actor == NULL){
error("TDamageImpact::TDamageImpact: Actor ist NULL.\n");
}
@@ -28,6 +85,26 @@ void TDamageImpact::TDamageImpact(TCreature *Actor, int DamageType, int Power, b
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){
@@ -36,8 +113,9 @@ void CheckMana(TCreature *Creature, int ManaPoints, int SoulPoints, int Delay){
throw ERROR;
}
- if(Creature->Type != PLAYER || ManaPoints < 0)
+ if(Creature->Type != PLAYER || ManaPoints < 0){
return;
+ }
TSkill *Mana = Creature->Skills[SKILL_MANA];
if(Mana == NULL){
@@ -52,11 +130,13 @@ void CheckMana(TCreature *Creature, int ManaPoints, int SoulPoints, int Delay){
}
if(!CheckRight(Creature->ID, UNLIMITED_MANA)){
- if(Mana->Get() < ManaPoints)
+ if(Mana->Get() < ManaPoints){
throw NOTENOUGHMANA;
+ }
- if(Soul->Get() < SoulPoints)
+ if(Soul->Get() < SoulPoints){
throw NOTENOUGHSOULPOINTS;
+ }
Mana->Change(-ManaPoints);
Soul->Change(-SoulPoints);