]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/all.qh
570254e9242e3e43c597efa2fc7ab07773d8585c
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / all.qh
1 #ifndef MONSTERS_ALL_H
2 #define MONSTERS_ALL_H
3
4 #include "../util.qh"
5
6 // monster requests
7 const int MR_SETUP = 1; // (SERVER) setup monster data
8 const int MR_THINK = 2; // (SERVER) logic to run every frame
9 const int MR_DEATH = 3; // (SERVER) called when monster dies
10 const int MR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this monster
11 const int MR_PAIN = 5; // (SERVER) called when monster is damaged
12 const int MR_ANIM = 6; // (BOTH?) sets animations for monster
13
14 // functions
15 entity get_monsterinfo(float id);
16
17 // special spawn flags
18 const int MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died
19 const int MONSTER_TYPE_FLY = 32;
20 const int MONSTER_TYPE_SWIM = 64;
21 const int MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced
22 const int MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster
23 const int MON_FLAG_RANGED = 512; // monster shoots projectiles
24 const int MON_FLAG_MELEE = 1024;
25
26 // entity properties of monsterinfo
27 .float monsterid; // MON_...
28 .string netname; // short name
29 .string monster_name; // human readable name
30 .float(float) monster_func; // M_...
31 .float(float attack_type) monster_attackfunc; // attack function
32 .string mdl; // currently a copy of the model
33 .string model; // full name of model
34 .int spawnflags;
35 .vector mins, maxs; // monster hitbox size
36
37 // animations
38 .vector anim_blockend;
39 .vector anim_blockstart;
40 .vector anim_melee1;
41 .vector anim_melee2;
42 .vector anim_melee3;
43 .vector anim_pain3;
44 .vector anim_pain4;
45 .vector anim_pain5;
46 .vector anim_walk;
47 .vector anim_spawn;
48
49 // other useful macros
50 #define MON_ACTION(monstertype,mrequest) (get_monsterinfo(monstertype)).monster_func(mrequest)
51
52 // =====================
53 //      Monster Registration
54 // =====================
55
56 float m_null(float dummy);
57 void register_monster(float id, float(float) func, float(float) attackfunc, float monsterflags, vector min_s, vector max_s, string modelname, string shortname, string mname);
58 void register_monsters_done();
59
60 const int MON_MAXCOUNT = 24; // increase as necessary, limit is infinite, but keep loops small!
61 const int MON_FIRST = 1;
62 int MON_COUNT;
63 int MON_LAST;
64
65 #define REGISTER_MONSTER_2(id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname) \
66         int id; \
67         float func(float); \
68         float attackfunc(float); \
69         void RegisterMonsters_##id() \
70         { \
71                 MON_LAST = (id = MON_FIRST + MON_COUNT); \
72                 ++MON_COUNT; \
73                 register_monster(id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname); \
74         } \
75         ACCUMULATE_FUNCTION(RegisterMonsters, RegisterMonsters_##id)
76 #ifdef SVQC
77 #define REGISTER_MONSTER(id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname) \
78         REGISTER_MONSTER_2(MON_##id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname)
79 #elif defined(CSQC)
80 #define REGISTER_MONSTER(id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname) \
81         REGISTER_MONSTER_2(MON_##id,func,m_null,monsterflags,min_s,max_s,modelname,shortname,mname)
82 #else
83 #define REGISTER_MONSTER(id,func,attackfunc,monsterflags,min_s,max_s,modelname,shortname,mname) \
84         REGISTER_MONSTER_2(MON_##id,m_null,m_null,monsterflags,min_s,max_s,modelname,shortname,mname)
85 #endif
86
87 #include "all.inc"
88
89 #undef REGISTER_MONSTER
90 ACCUMULATE_FUNCTION(RegisterMonsters, register_monsters_done);
91 #endif