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