Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 4469517c661ce6f53db9a73377d8f141ba6da5fa (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
   base/npc.h
   This file is part of the Osirion project and is distributed under
   the terms and conditions of the GNU General Public License version 2
*/

#ifndef __INCLUDED_BASE_NPC_H__
#define __INCLUDED_BASE_NPC_H__

#include "base/ship.h"

namespace game
{

class Patrol;

class NPC : public Ship {

public:
	/**
	 * @brief Defines the general moode of the NPC
	 * Wander	Wamder around
	 * Formation	Follow the leader in formation
	 * Attack	Attack at will
	 * */
	enum Mood { MoodWander = 0, MoodFormation = 1, MoodAttack = 2};
	
	NPC(const ShipModel *shipmodel);
	virtual ~NPC();
	
	/* ---- inspectors ----------------------------------------- */

	/**
	 * @brief returns the general mood of the NPC
	 * */
	inline const Mood mood() const
	{
		return npc_mood;
	}

	/**
	 * @brief returns this NPC's leader
	 * */
	inline Ship *leader()
	{
		return npc_leader;
	}
	
	/**
	 * @brief returns this NPC's patrol
	 * */
	inline Patrol *patrol()
	{
		return npc_patrol;
	}
	
	/**
	 * @brief return this NPC;s fleet commander
	 * */
	inline core::Player *commander()
	{
		return npc_commander;
	}
	
	/* ---- mutators ------------------------------------------- */
	 
	/**
	 * @brief Set the general moode of the NPC
	 * */
	void set_mood(const Mood mood);
	
	/**
	 * @brief set the NPC's leader
	 * */
	void set_leader(Ship *leader);
	
	/**
	 * @brief set the NPC's patrol
	 * */
	void set_patrol(Patrol *patrol);
	
	/**
	 * @brief set the NPC's fleet commander
	 * */
	void set_commander(core::Player *player);
	
	/**
	 * @brief game frame
	 * */
	virtual void frame(const unsigned long elapsed);
	
	/**
	 * @brief factory function for wingman NPCs
	 * */
	static NPC *add_wingman(Ship *leader);
	
	/**
	 * @brief aim at closest enemy in range, returns target
	 * */
	Ship *target_closest_enemy();
	
	/**
	 * @brief calculate weapon range
	 * Calling calculate_weapon_range() will set npc_weapon_range.
	 * */
	void calculate_weapon_range();

private:
	Mood			npc_mood;
	
	Ship			*npc_leader;
	
	Patrol			*npc_patrol;
	
	unsigned long		npc_destroyed_timestamp;
	
	unsigned long		npc_repair_timestamp;
	
	float			npc_weapon_range;
	
	core::Player		*npc_commander;
	
}; // class NPC

} // namespace game

#endif // __INCLUDED_BASE_NPC_H__