]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/sv_monsters.qh
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_monsters.qh
1 #pragma once
2
3 #include "all.qh"
4
5 float autocvar_g_monsters;
6 bool autocvar_g_monsters_edit;
7 bool autocvar_g_monsters_sounds;
8 float autocvar_g_monsters_think_delay;
9 int autocvar_g_monsters_max;
10 int autocvar_g_monsters_max_perplayer;
11 float autocvar_g_monsters_damageforcescale = 0.8;
12 float autocvar_g_monsters_target_range;
13 bool autocvar_g_monsters_target_infront;
14 float autocvar_g_monsters_target_infront_range = 0.3;
15 bool autocvar_g_monsters_target_infront_2d = true;
16 float autocvar_g_monsters_attack_range;
17 int autocvar_g_monsters_score_kill;
18 int autocvar_g_monsters_score_spawned;
19 bool autocvar_g_monsters_typefrag;
20 bool autocvar_g_monsters_owners;
21 bool autocvar_g_monsters_playerclip_collisions;
22 float autocvar_g_monsters_miniboss_chance;
23 float autocvar_g_monsters_miniboss_healthboost;
24 float autocvar_g_monsters_drop_time;
25 float autocvar_g_monsters_spawnshieldtime;
26 bool autocvar_g_monsters_quake_resize = true;
27 bool autocvar_g_monsters_teams;
28 float autocvar_g_monsters_respawn_delay;
29 bool autocvar_g_monsters_respawn;
30 float autocvar_g_monsters_armor_blockpercent;
31 float autocvar_g_monsters_healthbars;
32 bool autocvar_g_monsters_lineofsight = true;
33 //bool autocvar_g_monsters_ignoretraces = true;
34
35 // stats networking
36 int monsters_total;
37 int monsters_killed;
38
39 // monster properties
40 .int monster_movestate; // move target priority
41 .entity monster_follow; // follow target
42 .float wander_delay; // logic delay between moving while idle
43 .float wander_distance; // distance to move between wander delays
44 .float monster_lifetime; // monster dies instantly after this delay, set from spawn
45 .float attack_range; // melee attack if closer, ranged attack if further away (TODO: separate ranged attack range?)
46 .float spawn_time; // delay monster thinking until spawn animation has completed
47 .bool candrop; // toggle to allow disabling monster item drops
48 .int monster_movestate; // will be phased out
49 .int monster_moveflags;
50 .string oldtarget2; // a copy of the original follow target string
51 .float last_trace; // logic delay between target tracing
52 .float last_enemycheck; // for checking enemy
53 .float anim_finished; // will be phased out when we have proper animations system
54 .vector monster_moveto; // custom destination for monster (reset to '0 0 0' when you're done!)
55 .vector monster_face; // custom looking direction for monster (reset to '0 0 0' when you're done!)
56 .float speed2; // run speed
57 .float stopspeed;
58 .int oldskin;
59 .string mdl_dead; // dead model for goombas
60
61 #define MONSTER_SKILLMOD(mon) (0.5 + mon.monster_skill * ((1.2 - 0.3) / 10))
62
63 // other properties
64 .bool monster_attack; // indicates whether an entity can be attacked by monsters
65
66 // monster state declarations
67 const int MONSTER_MOVE_FOLLOW = 1; // monster will follow if in range, or stand still
68 const int MONSTER_MOVE_WANDER = 2; // monster will ignore owner & wander around
69 const int MONSTER_MOVE_SPAWNLOC = 3; // monster will move to its spawn location when not attacking
70 const int MONSTER_MOVE_NOMOVE = 4; // monster simply stands still
71 const int MONSTER_MOVE_ENEMY = 5; // used only as a movestate
72 const int MONSTER_ATTACK_MELEE = 6;
73 const int MONSTER_ATTACK_RANGED = 7;
74
75 // skill declarations
76 const int MONSTER_SKILL_EASY = 1;
77 const int MONSTER_SKILL_MEDIUM = 3;
78 const int MONSTER_SKILL_HARD = 5;
79 const int MONSTER_SKILL_INSANE = 7;
80 const int MONSTER_SKILL_NIGHTMARE = 10;
81
82 const int MONSTERSKILL_NOTEASY = 256; // monster will not spawn on skill <= 1
83 const int MONSTERSKILL_NOTMEDIUM = 512; // monster will not spawn on skill 2
84 const int MONSTERSKILL_NOTHARD = 1024; // monster will not spawn on skill >= 3
85
86 // spawn flags
87 const int MONSTERFLAG_APPEAR = 2; // delay spawn until triggered
88 const int MONSTERFLAG_NORESPAWN = 4;
89 const int MONSTERFLAG_FLY_VERTICAL = 8; // fly/swim vertically
90 const int MONSTERFLAG_INFRONT = 32; // only check for enemies infront of us
91 const int MONSTERFLAG_MINIBOSS = 64;    // monster spawns as mini-boss (also has a chance of naturally becoming one)
92 const int MONSTERFLAG_INVINCIBLE = 128; // monster doesn't take damage (may be used for map objects & temporary monsters)
93 const int MONSTERFLAG_SPAWNED = 16384; // flag for spawned monsters
94 const int MONSTERFLAG_RESPAWNED = 32768; // flag for re-spawned monsters
95
96 // compatibility with old maps (soon to be removed)
97 .float monster_lifetime;
98 .int monster_skill;
99
100 // functions used elsewhere
101 void Monster_Remove(entity this);
102
103 void monsters_setstatus(entity this);
104
105 bool Monster_Spawn(entity this, bool check_appear, Monster mon);
106
107 void monster_setupcolors(entity this);
108
109 void Monster_Touch(entity this, entity toucher);
110
111 void Monster_Move_2D(entity this, float mspeed, float allow_jumpoff);
112
113 void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func);
114
115 float Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop);
116
117 bool Monster_Attack_Leap(entity this, vector anm, void(entity this, entity toucher) touchfunc, vector vel, float animtime);
118
119 entity Monster_FindTarget(entity this);
120
121 void monster_makevectors(entity this, entity targ);
122
123 void Monster_Sound(entity this, .string samplefield, float sound_delay, float delaytoo, float chan);
124
125 /** number of monsters spawned with mobspawn command */
126 int totalspawned;
127
128 // monster sounds
129 .float msound_delay; // temporary antilag system
130 #define ALLMONSTERSOUNDS \
131                 _MSOUND(death) \
132                 _MSOUND(sight) \
133                 _MSOUND(ranged) \
134                 _MSOUND(melee) \
135                 _MSOUND(pain) \
136                 _MSOUND(spawn) \
137                 _MSOUND(idle) \
138                 _MSOUND(attack)
139
140 #define _MSOUND(m) .string monstersound_##m;
141 ALLMONSTERSOUNDS
142 #undef _MSOUND
143
144 float GetMonsterSoundSampleField_notFound;
145
146 IntrusiveList g_monsters;
147 STATIC_INIT(g_monsters) { g_monsters = IL_NEW(); }
148
149 IntrusiveList g_monster_targets;
150 STATIC_INIT(g_monster_targets) { g_monster_targets = IL_NEW(); }