aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DamageSource.h
blob: 2e1d249de84d0ac0c825acaa137fa60571a877df (plain)
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
#pragma once
using namespace std;

class Mob;
class Entity;
class Arrow;
class Fireball;
class Player;

#include "ChatPacket.h"

class DamageSource
{
public:
	static DamageSource *inFire;
	static DamageSource *onFire;
	static DamageSource *lava;
	static DamageSource *inWall;
	static DamageSource *drown;
	static DamageSource *starve;
	static DamageSource *cactus;
	static DamageSource *fall;
	static DamageSource *outOfWorld;
	static DamageSource *genericSource;
	static DamageSource *explosion;
	static DamageSource *controlledExplosion;
	static DamageSource *magic;
	static DamageSource *dragonbreath;
	static DamageSource *wither;
	static DamageSource *anvil;
	static DamageSource *fallingBlock;

	static DamageSource *mobAttack(shared_ptr<Mob> mob);
	static DamageSource *playerAttack(shared_ptr<Player> player);
	static DamageSource *arrow(shared_ptr<Arrow> arrow, shared_ptr<Entity> owner);
	static DamageSource *fireball(shared_ptr<Fireball> fireball, shared_ptr<Entity> owner);
	static DamageSource *thrown(shared_ptr<Entity> entity, shared_ptr<Entity> owner);
	static DamageSource *indirectMagic(shared_ptr<Entity> entity, shared_ptr<Entity> owner);
	static DamageSource *thorns(shared_ptr<Entity> source);

private:
	bool _bypassArmor;
	bool _bypassInvul;
	// food exhastion caused by being damaged by this source
	float exhaustion;
	bool isFireSource;
	bool _isProjectile;
	bool _scalesWithDifficulty;
	bool _isMagic;

public:
	bool isProjectile();
	DamageSource *setProjectile();

	bool isBypassArmor();
	float getFoodExhaustion();
	bool isBypassInvul();

	//wstring msgId;
	ChatPacket::EChatPacketMessage m_msgId; // 4J Made int so we can localise

protected:
	//DamageSource(const wstring &msgId);
	DamageSource(ChatPacket::EChatPacketMessage msgId);

public:
	virtual ~DamageSource() {}

	virtual shared_ptr<Entity> getDirectEntity();
	virtual shared_ptr<Entity> getEntity();

protected:
	DamageSource *bypassArmor();
	DamageSource *bypassInvul();
	DamageSource *setIsFire();
	DamageSource *setScalesWithDifficulty();

public:
	virtual bool scalesWithDifficulty();

	bool isMagic();
	DamageSource *setMagic();

	// 4J Stu - Made return a packet
	//virtual wstring getLocalizedDeathMessage(shared_ptr<Player> player);
	virtual shared_ptr<ChatPacket> getDeathMessagePacket(shared_ptr<Player> player);

	bool isFire();
	ChatPacket::EChatPacketMessage getMsgId(); // 4J Stu - Used to return String
};