OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
damagecalculator.h
Go to the documentation of this file.
1#pragma once
2
3#include <zenkit/addon/daedalus.hh>
4
5#include "game/constants.h"
6
7class Npc;
8class Bullet;
9
11 public:
12 enum {
14 };
15
16 struct Val final {
17 Val()=default;
18 Val(int32_t v,bool b):value(v),hasHit(b){}
19 Val(int32_t v,bool b,bool i):value(v),hasHit(b),invincible(i){}
20
21 int32_t value = 0;
22 bool hasHit = false;
23 bool invincible = false;
24 };
25
26 struct Damage final {
27 int32_t val[zenkit::DamageType::NUM] = {};
28 int32_t& operator[](size_t i) { return val[i]; }
29 void operator *= (int32_t v) { for(auto& i:val) i*=v; }
30 void operator /= (int32_t v) { for(auto& i:val) i/=v; }
31 };
32
33 static Val damageValue(Npc& src, Npc& other, const Bullet* b, bool isSpell, const DamageCalculator::Damage& splDmg, const CollideMask bMsk);
34 static Val damageFall(Npc& src, float speed);
35 static auto rangeDamageValue(Npc& src) -> Damage;
36 static int32_t damageTypeMask(Npc& npc);
37
38 private:
39 static bool checkDamageMask(Npc& src, Npc& other, const Bullet* b);
40
41 static Val rangeDamage(Npc& src, Npc& other, const Bullet& b, const CollideMask bMsk);
42 static Val rangeDamage(Npc& src, Npc& other, Damage dmg, const CollideMask bMsk);
43 static Val swordDamage(Npc& src, Npc& other);
44 };
45
static auto rangeDamageValue(Npc &src) -> Damage
static Val damageValue(Npc &src, Npc &other, const Bullet *b, bool isSpell, const DamageCalculator::Damage &splDmg, const CollideMask bMsk)
static Val damageFall(Npc &src, float speed)
static int32_t damageTypeMask(Npc &npc)
Definition npc.h:25
CollideMask
Definition constants.h:252
int32_t val[zenkit::DamageType::NUM]
int32_t & operator[](size_t i)
Val(int32_t v, bool b, bool i)
Val(int32_t v, bool b)