1 //----------------------------------------------------------------------------
2 //  EDGE Data Definition File Code (Main)
3 //----------------------------------------------------------------------------
4 //
5 //  Copyright (c) 1999-2008  The EDGE Team.
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //----------------------------------------------------------------------------
18 
19 #ifndef __DDF_ATK_H__
20 #define __DDF_ATK_H__
21 
22 #include "epi/utility.h"
23 
24 #include "types.h"
25 
26 
27 // ------------------------------------------------------------------
28 // --------------------ATTACK TYPE STRUCTURES------------------------
29 // ------------------------------------------------------------------
30 
31 // -KM- 1998/11/25 Added BFG SPRAY attack type.
32 
33 // FIXME!!! Move enums into attackdef_t
34 typedef enum
35 {
36 	ATK_NONE = 0,
37 	ATK_PROJECTILE,
38 	ATK_SPAWNER,
39 	ATK_TRIPLESPAWNER,
40 	ATK_SPREADER,
41 	ATK_RANDOMSPREAD,
42 	ATK_SHOT,
43 	ATK_TRACKER,
44 	ATK_CLOSECOMBAT,
45 	ATK_SHOOTTOSPOT,
46 	ATK_SKULLFLY,
47 	ATK_SMARTPROJECTILE,
48 	ATK_SPRAY,
49 	NUMATKCLASS
50 }
51 attackstyle_e;
52 
53 typedef enum
54 {
55 	AF_None            = 0,
56 
57 	AF_TraceSmoke      = (1 << 0),
58 	AF_KillFailedSpawn = (1 << 1),
59 	AF_PrestepSpawn    = (1 << 2),
60 	AF_SpawnTelefrags  = (1 << 3),
61 
62 	AF_NeedSight       = (1 << 4),
63 	AF_FaceTarget      = (1 << 5),
64 	AF_Player          = (1 << 6),
65 	AF_ForceAim        = (1 << 7),
66 
67 	AF_AngledSpawn     = (1 << 8),
68 	AF_NoTriggerLines  = (1 << 9),
69 	AF_SilentToMon     = (1 << 10),
70 	AF_NoTarget        = (1 << 11),
71 	AF_Vampire         = (1 << 12),
72 }
73 attackflags_e;
74 
75 // attack definition class
76 class atkdef_c
77 {
78 public:
79 	atkdef_c();
80 	~atkdef_c();
81 
82 public:
83 	void Default();
84 	void CopyDetail(atkdef_c &src);
85 
86 	// Member vars
87 	epi::strent_c name;
88 
89 	attackstyle_e attackstyle;
90 	attackflags_e flags;
91 	struct sfx_s *initsound;
92 	struct sfx_s *sound;
93 	float accuracy_slope;
94 	angle_t accuracy_angle;
95 	float xoffset;
96 	float yoffset;
97 	angle_t angle_offset;  // -AJA- 1999/09/10.
98 	float slope_offset;    //
99 	angle_t trace_angle; // -AJA- 2005/02/08.
100 	float assault_speed;
101 	float height;
102 	float range;
103 	int count;
104 	int tooclose;
105 	float berserk_mul;  // -AJA- 2005/08/06.
106 	damage_c damage;
107 
108 	// class of the attack.
109 	bitset_t attack_class;
110 
111 	// object init state.  The integer value only becomes valid after
112 	// DDF_AttackCleanUp() has been called.
113 	int objinitstate;
114 	epi::strent_c objinitstate_ref;
115 
116 	percent_t notracechance;
117 	percent_t keepfirechance;
118 
119 	// the MOBJ that is integrated with this attack, or NULL
120 	const mobjtype_c *atk_mobj;
121 
122 	// spawned object (for spawners).  The mobjdef pointer only becomes
123 	// valid after DDF_AttackCleanUp().  Can be NULL.
124 	const mobjtype_c *spawnedobj;
125 	epi::strent_c spawnedobj_ref;
126 	int spawn_limit;
127 
128 	// puff object.  The mobjdef pointer only becomes valid after
129 	// DDF_AttackCleanUp() has been called.  Can be NULL.
130 	const mobjtype_c *puff;
131 	epi::strent_c puff_ref;
132 
133 private:
134 	// disable copy construct and assignment operator
atkdef_c(atkdef_c & rhs)135 	explicit atkdef_c(atkdef_c &rhs) { }
136 	atkdef_c& operator= (atkdef_c &rhs) { return *this; }
137 };
138 
139 
140 class atkdef_container_c : public epi::array_c
141 {
142 public:
143 	atkdef_container_c();
144 	~atkdef_container_c();
145 
146 private:
147 	void CleanupObject(void *obj);
148 
149 public:
150 	// List Management
GetSize()151 	int GetSize() {	return array_entries; }
Insert(atkdef_c * a)152 	int Insert(atkdef_c *a) { return InsertObject((void*)&a); }
153 	atkdef_c* operator[](int idx) { return *(atkdef_c**)FetchObject(idx); }
154 
155 	// Search Functions
156 	atkdef_c* Lookup(const char* refname);
157 };
158 
159 
160 // -----EXTERNALISATIONS-----
161 
162 extern atkdef_container_c atkdefs;			// -ACB- 2004/06/09 Implemented
163 
164 bool DDF_ReadAtks(void *data, int size);
165 
166 #endif // __DDF_ATK_H__
167 
168 //--- editor settings ---
169 // vi:ts=4:sw=4:noexpandtab
170