]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster.qh
f21019db24c5b3bfdb58e8e3aa6d8ab996a6cb36
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster.qh
1 #ifndef MONSTER_H
2 #define MONSTER_H
3
4 // special spawn flags
5 const int MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died
6 const int MONSTER_TYPE_FLY = 32;
7 const int MONSTER_TYPE_SWIM = 64;
8 const int MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced
9 const int MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster
10 const int MON_FLAG_RANGED = 512; // monster shoots projectiles
11 const int MON_FLAG_MELEE = 1024;
12 const int MON_FLAG_CRUSH = 2048; // monster can be stomped in special modes
13 const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes
14
15 // entity properties of monsterinfo:
16 .bool(int) monster_attackfunc;
17
18 // animations
19 .vector anim_blockend;
20 .vector anim_blockstart;
21 .vector anim_melee1;
22 .vector anim_melee2;
23 .vector anim_melee3;
24 .vector anim_pain3;
25 .vector anim_pain4;
26 .vector anim_pain5;
27 .vector anim_walk;
28 .vector anim_spawn;
29
30 bool m_null(entity thismon, int) { return false; }
31 bool m_new(entity thismon, int);
32
33 /** If you register a new monster, make sure to add it to all.inc */
34 CLASS(Monster, Object)
35     ATTRIB(Monster, monsterid, int, 0)
36     ATTRIB(Monster, monster_func, bool(Monster, int), m_new)
37     /** attributes */
38     ATTRIB(Monster, spawnflags, int, 0)
39     /** human readable name */
40     ATTRIB(Monster, monster_name, string, "Monster")
41     /** short name */
42     ATTRIB(Monster, netname, string, "")
43     /** model */
44     ATTRIB(Monster, m_model, entity, NULL)
45     /** hitbox size */
46     ATTRIB(Monster, mins, vector, '-0 -0 -0')
47     /** hitbox size */
48     ATTRIB(Monster, maxs, vector, '0 0 0')
49 ENDCLASS(Monster)
50
51 // monster requests
52 const int MR_SETUP = 1; // (SERVER) setup monster data
53 .bool(Monster this) mr_setup;
54 const int MR_THINK = 2; // (SERVER) logic to run every frame
55 .bool(Monster this) mr_think;
56 const int MR_DEATH = 3; // (SERVER) called when monster dies
57 .bool(Monster this) mr_death;
58 const int MR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this monster
59 .bool(Monster this) mr_precache;
60 const int MR_PAIN = 5; // (SERVER) called when monster is damaged
61 .bool(Monster this) mr_pain;
62 const int MR_ANIM = 6; // (BOTH?) sets animations for monster
63 .bool(Monster this) mr_anim;
64
65 // other useful macros
66 #define MON_ACTION(mon,mrequest) mon.monster_func(mon, mrequest)
67 #define _MON_ACTION(mon,mrequest) MON_ACTION(get_monsterinfo(mon), mrequest)
68
69 bool m_new(entity this, int req) {
70     if (req == MR_SETUP) return this.mr_setup ? this.mr_setup(this) : false;
71     if (req == MR_THINK) return this.mr_think ? this.mr_think(this) : false;
72     if (req == MR_DEATH) return this.mr_death ? this.mr_death(this) : false;
73     if (req == MR_PRECACHE) return this.mr_precache ? this.mr_precache(this) : false;
74     if (req == MR_PAIN) return this.mr_pain ? this.mr_pain(this) : false;
75     if (req == MR_ANIM) return this.mr_anim ? this.mr_anim(this) : false;
76     return false;
77 }
78
79 #endif