]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monsters.qh
Fix some spawnflag conflicts
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monsters.qh
1 // monster requests
2 #define MR_SETUP          1 // (SERVER) setup monster data
3 #define MR_THINK                  2 // (SERVER) logic to run every frame
4 #define MR_DEATH          3 // (BOTH) called when monster dies
5 #define MR_INIT           4 // (BOTH) precaches models/sounds used by this monster
6 #define MR_CONFIG         5 // (ALL)
7
8 // functions:
9 entity get_monsterinfo(float id);
10
11 // special spawn flags
12 const float MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died
13 const float MONSTER_TYPE_FLY = 32;
14 const float MONSTER_TYPE_SWIM = 64;
15 const float MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced
16 const float MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster
17 const float MON_FLAG_RANGED = 512; // monster shoots projectiles
18 const float MON_FLAG_MELEE = 1024;
19
20 // entity properties of monsterinfo:
21 .float monsterid; // MON_...
22 .string netname; // short name
23 .string monster_name; // human readable name
24 .float(float) monster_func; // m_...
25 .string mdl; // currently a copy of the model
26 .string model; // full name of model
27 .float spawnflags;
28
29 // csqc linking
30 #ifndef MENUQC
31 .float anim_start_time;
32
33 float MSF_UPDATE                = 2;
34 float MSF_STATUS                = 4;
35 float MSF_SETUP                 = 8;
36 float MSF_ANG                   = 16;
37 float MSF_MOVE                  = 32;
38 float MSF_ANIM                  = 64;
39
40 float MSF_FULL_UPDATE  = 16777215;
41 #endif
42
43 // other useful macros
44 #define MON_ACTION(monstertype,mrequest) (get_monsterinfo(monstertype)).monster_func(mrequest)
45 #define M_NAME(monstertype) (get_monsterinfo(monstertype)).monster_name
46
47 // =====================
48 //  Monster Registration
49 // =====================
50
51 float m_null(float dummy);
52 void register_monster(float id, float(float) func, float monsterflags, vector min_s, vector max_s, string modelname, string shortname, string mname);
53 void register_monsters_done();
54
55 const float MON_MAXCOUNT = 24;
56 #define MON_FIRST 1
57 float MON_COUNT;
58 float MON_LAST;
59
60 #define REGISTER_MONSTER_2(id,func,monsterflags,min_s,max_s,modelname,shortname,mname) \
61         float id; \
62         float func(float); \
63         void RegisterMonsters_##id() \
64         { \
65                 MON_LAST = (id = MON_FIRST + MON_COUNT); \
66                 ++MON_COUNT; \
67                 register_monster(id,func,monsterflags,min_s,max_s,modelname,shortname,mname); \
68         } \
69         ACCUMULATE_FUNCTION(RegisterMonsters, RegisterMonsters_##id)
70 #define REGISTER_MONSTER(id,func,monsterflags,min_s,max_s,modelname,shortname,mname) \
71         REGISTER_MONSTER_2(MON_##id,func,monsterflags,min_s,max_s,modelname,shortname,mname)
72
73 #define MON_DUPECHECK(dupecheck,cvar) \
74         #ifndef dupecheck \
75                 #define dupecheck \
76                 float cvar; \
77         #else \
78                 #error DUPLICATE MONSTER CVAR: cvar \
79         #endif
80
81 #define MON_ADD_CVAR(monster,name) \
82                 MON_DUPECHECK(MON_CVAR_##monster##_##name, autocvar_g_monster_##monster##_##name)
83
84 #define MON_CVAR(monster,name) autocvar_g_monster_##monster##_##name
85
86 #include "all.qh"
87
88 #undef MON_ADD_CVAR
89 #undef REGISTER_MONSTER
90 ACCUMULATE_FUNCTION(RegisterMonsters, register_monsters_done)