]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monsters.qh
Revert the more visible changes and tweak remaining ones a little to closer match...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monsters.qh
1 #ifndef MONSTERS_H
2 #define MONSTERS_H
3
4 // monster requests
5 const int MR_SETUP = 1; // (SERVER) setup monster data
6 const int MR_THINK = 2; // (SERVER) logic to run every frame
7 const int MR_DEATH = 3; // (SERVER) called when monster dies
8 const int MR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this monster
9
10 // functions:
11 entity get_monsterinfo(float id);
12
13 // special spawn flags
14 const int MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died
15 const int MONSTER_TYPE_FLY = 32;
16 const int MONSTER_TYPE_SWIM = 64;
17 const int MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced
18 const int MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster
19 const int MON_FLAG_RANGED = 512; // monster shoots projectiles
20 const int MON_FLAG_MELEE = 1024;
21
22 // entity properties of monsterinfo:
23 .float monsterid; // MON_...
24 .string netname; // short name
25 .string monster_name; // human readable name
26 .float(float) monster_func; // m_...
27 .string mdl; // currently a copy of the model
28 .string model; // full name of model
29 .int spawnflags;
30 .vector mins, maxs; // monster hitbox size
31
32 // other useful macros
33 #define MON_ACTION(monstertype,mrequest) (get_monsterinfo(monstertype)).monster_func(mrequest)
34 #define M_NAME(monstertype) (get_monsterinfo(monstertype)).monster_name
35
36 // =====================
37 //      Monster Registration
38 // =====================
39
40 float m_null(float dummy);
41 void register_monster(float id, float(float) func, float monsterflags, vector min_s, vector max_s, string modelname, string shortname, string mname);
42 void register_monsters_done();
43
44 const int MON_MAXCOUNT = 24;
45 const int MON_FIRST = 1;
46 int MON_COUNT;
47 int MON_LAST;
48
49 #define REGISTER_MONSTER_2(id,func,monsterflags,min_s,max_s,modelname,shortname,mname) \
50         int id; \
51         float func(float); \
52         void RegisterMonsters_##id() \
53         { \
54                 MON_LAST = (id = MON_FIRST + MON_COUNT); \
55                 ++MON_COUNT; \
56                 register_monster(id,func,monsterflags,min_s,max_s,modelname,shortname,mname); \
57         } \
58         ACCUMULATE_FUNCTION(RegisterMonsters, RegisterMonsters_##id)
59 #ifdef MENUQC
60 #define REGISTER_MONSTER(id,func,monsterflags,min_s,max_s,modelname,shortname,mname) \
61         REGISTER_MONSTER_2(MON_##id,m_null,monsterflags,min_s,max_s,modelname,shortname,mname)
62 #else
63 #define REGISTER_MONSTER(id,func,monsterflags,min_s,max_s,modelname,shortname,mname) \
64         REGISTER_MONSTER_2(MON_##id,func,monsterflags,min_s,max_s,modelname,shortname,mname)
65 #endif
66
67 #include "all.qh"
68
69 #undef REGISTER_MONSTER
70 ACCUMULATE_FUNCTION(RegisterMonsters, register_monsters_done);
71 #endif