Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_monsters.qh File Reference
#include "all.qh"
Include dependency graph for sv_monsters.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _MSOUND(m)
#define ALLMONSTERSOUNDS
#define MONSTER_SKILLMOD(mon)

Functions

bool Monster_Attack_Leap (entity this, vector anm, void(entity this, entity toucher) touchfunc, vector vel, float animtime)
float Monster_Attack_Melee (entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop)
void Monster_Delay (entity this, int repeat_count, float defer_amnt, void(entity) func)
entity Monster_FindTarget (entity this)
void monster_makevectors (entity this, entity targ)
void Monster_Move_2D (entity this, float mspeed, float allow_jumpoff)
void Monster_Remove (entity this)
void monster_setupcolors (entity this)
void Monster_Sound (entity this,.string samplefield, float sound_delay, float delaytoo, float chan)
bool Monster_Spawn (entity this, bool check_appear, Monster mon)
 Setup the basic required properties for a monster.
void Monster_Touch (entity this, entity toucher)
void monsters_setstatus (entity this)
 STATIC_INIT (g_monster_targets)
 STATIC_INIT (g_monsters)

Variables

float anim_finished
 will be phased out when we have proper animations system
float attack_range
 melee attack if closer, ranged attack if further away (TODO: separate ranged attack range?)
float autocvar_g_monsters
float autocvar_g_monsters_armor_blockpercent
float autocvar_g_monsters_attack_range
float autocvar_g_monsters_damageforcescale = 0.8
float autocvar_g_monsters_drop_time = 10
bool autocvar_g_monsters_edit
float autocvar_g_monsters_healthbars
bool autocvar_g_monsters_lineofsight = true
int autocvar_g_monsters_max
int autocvar_g_monsters_max_perplayer
float autocvar_g_monsters_miniboss_chance
float autocvar_g_monsters_miniboss_healthboost
string autocvar_g_monsters_miniboss_loot = "vortex"
bool autocvar_g_monsters_owners
bool autocvar_g_monsters_playerclip_collisions
bool autocvar_g_monsters_quake_resize = true
bool autocvar_g_monsters_respawn
float autocvar_g_monsters_respawn_delay
int autocvar_g_monsters_score_kill
int autocvar_g_monsters_score_spawned
bool autocvar_g_monsters_sounds
float autocvar_g_monsters_spawnshieldtime
bool autocvar_g_monsters_target_infront
bool autocvar_g_monsters_target_infront_2d = true
float autocvar_g_monsters_target_infront_range = 0.3
float autocvar_g_monsters_target_range
bool autocvar_g_monsters_teams
bool autocvar_g_monsters_typefrag
bool candrop
 toggle to allow disabling monster item drops
IntrusiveList g_monster_targets
IntrusiveList g_monsters
ALLMONSTERSOUNDS bool GetMonsterSoundSampleField_notFound
float last_enemycheck
 for checking monster enemy
float last_trace
 monster logic delay between target tracing
string mdl_dead
 dead model for goombas
bool monster_attack
 indicates whether an entity can be attacked by monsters
const int MONSTER_ATTACK_MELEE = 6
const int MONSTER_ATTACK_RANGED = 7
vector monster_face
 custom looking direction for monster (reset to '0 0 0' when you're done!)
entity monster_follow
 monster follow target
bool monster_item
 identifier for dropped monster loot TODO: generic identifiers? ok_item exists too!
float monster_lifetime
 monster dies instantly after this delay, set from spawn
const int MONSTER_MOVE_ENEMY = 5
 used only as a movestate, for monsters
const int MONSTER_MOVE_FOLLOW = 1
 monster will follow if in range, or stand still
const int MONSTER_MOVE_NOMOVE = 4
 monster simply stands still
const int MONSTER_MOVE_SPAWNLOC = 3
 monster will move to its spawn location when not attacking
const int MONSTER_MOVE_WANDER = 2
 monster will ignore owner & wander around
int monster_moveflags
int monster_movestate
 monster move target priority
vector monster_moveto
 custom destination for monster (reset to '0 0 0' when you're done!)
int monster_skill
const int MONSTER_SKILL_EASY = 1
const int MONSTER_SKILL_HARD = 5
const int MONSTER_SKILL_INSANE = 7
const int MONSTER_SKILL_MEDIUM = 3
const int MONSTER_SKILL_NIGHTMARE = 10
const int MONSTERFLAG_APPEAR = BIT(1)
 delay monster spawn until triggered
const int MONSTERFLAG_FLY_VERTICAL = BIT(3)
 monster can fly/swim vertically
const int MONSTERFLAG_INFRONT = BIT(5)
 only check for enemies infront of us, for monsters
const int MONSTERFLAG_INVINCIBLE = BIT(7)
 monster doesn't take damage (may be used for map objects & temporary monsters)
const int MONSTERFLAG_MINIBOSS = BIT(6)
 monster spawns as mini-boss (also has a chance of naturally becoming one)
const int MONSTERFLAG_NORESPAWN = BIT(2)
 monster doesn't respawn (revive)
const int MONSTERFLAG_RESPAWNED = BIT(15)
 flag for respawned monsters
const int MONSTERFLAG_SPAWNED = BIT(14)
 flag for spawned monsters
int monsters_killed
int monsters_total
const int MONSTERSKILL_NOTEASY = BIT(8)
 monster will not spawn on skill <= 1
const int MONSTERSKILL_NOTHARD = BIT(10)
 monster will not spawn on skill >= 3
const int MONSTERSKILL_NOTMEDIUM = BIT(9)
 monster will not spawn on skill 2
float msound_delay
 temporary antilag system
int oldskin
string oldtarget2
 a copy of the original follow target string for monsters
float spawn_time
 delay monster thinking until spawn animation has completed
float speed
 monster walk speed
float speed2
 monster run speed
float stopspeed
int totalspawned
 number of monsters spawned with mobspawn command
float wander_delay
 monster logic delay between moving while idle
float wander_distance
 distance to move between wander delays for monsters

Macro Definition Documentation

◆ _MSOUND

#define _MSOUND ( m)
Value:
.string monstersound_##m;

Definition at line 138 of file sv_monsters.qh.

◆ ALLMONSTERSOUNDS

#define ALLMONSTERSOUNDS
Value:
_MSOUND(death) \
_MSOUND(sight) \
_MSOUND(ranged) \
_MSOUND(melee) \
_MSOUND(pain) \
_MSOUND(spawn) \
_MSOUND(idle) \
_MSOUND(attack)
#define spawn
#define _MSOUND(m)

Definition at line 128 of file sv_monsters.qh.

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)

Referenced by Monster_Sound_SampleField(), and Monster_Sounds_Clear().

◆ MONSTER_SKILLMOD

#define MONSTER_SKILLMOD ( mon)
Value:
(0.5 + mon.monster_skill * ((1.2 - 0.3) / 10))

Definition at line 63 of file sv_monsters.qh.

Referenced by M_Golem_Attack_Smash(), M_Wyvern_Attack_Fireball_Explode(), M_Zombie_Attack_Leap_Touch(), Monster_Attack_Melee(), Monster_Move(), and Monster_Spawn_Setup().

Function Documentation

◆ Monster_Attack_Leap()

bool Monster_Attack_Leap ( entity this,
vector anm,
void(entity this, entity toucher) touchfunc,
vector vel,
float animtime )

Definition at line 430 of file sv_monsters.qc.

431{
432 if (!Monster_Attack_Leap_Check(this, vel))
433 return false;
434
435 setanim(this, anm, false, true, false);
436
437 if (this.animstate_endtime > time && IS_MONSTER(this))
439 else
440 this.attack_finished_single[0] = this.anim_finished = time + animtime;
441
442 if (IS_MONSTER(this))
444 settouch(this, touchfunc);
445 ++this.origin_z;
446 this.velocity = vel;
447 UNSET_ONGROUND(this);
448
449 return true;
450}
float animstate_endtime
Definition anim.qh:38
#define setanim(...)
Definition anim.qh:45
vector velocity
float time
int state
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
#define settouch(e, f)
Definition self.qh:73
bool Monster_Attack_Leap_Check(entity this, vector vel)
float anim_finished
will be phased out when we have proper animations system
const int MONSTER_ATTACK_RANGED
#define IS_MONSTER(v)
Definition utils.qh:23
float attack_finished_single[MAX_WEAPONSLOTS]

References anim_finished, animstate_endtime, attack_finished_single, entity(), IS_MONSTER, Monster_Attack_Leap_Check(), MONSTER_ATTACK_RANGED, setanim, settouch, state, time, toucher, UNSET_ONGROUND, vector, and velocity.

Referenced by M_Zombie_Attack().

◆ Monster_Attack_Melee()

float Monster_Attack_Melee ( entity this,
entity targ,
float damg,
vector anim,
float er,
float animtime,
int deathtype,
float dostop )

References anim, entity(), toucher, and vector.

◆ Monster_Delay()

void Monster_Delay ( entity this,
int repeat_count,
float defer_amnt,
void(entity) func )

Definition at line 243 of file sv_monsters.qc.

244{
245 // deferred attacking, checks if monster is still alive and target is still valid before attacking
247
249 e.nextthink = time + defer_amnt;
250 e.count = defer_amnt;
251 e.owner = this;
252 e.monster_delayedfunc = func;
253 e.cnt = repeat_count;
254}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
#define setthink(e, f)
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
void Monster_Delay_Action(entity this)

References entity(), Monster_Delay(), Monster_Delay_Action(), new_pure, setthink, and time.

Referenced by M_Golem_Attack(), M_Wyvern_Attack(), M_Zombie_Defend_Block(), and Monster_Delay().

◆ Monster_FindTarget()

entity Monster_FindTarget ( entity this)

Definition at line 137 of file sv_monsters.qc.

138{
139 if (MUTATOR_CALLHOOK(MonsterFindTarget))
140 return this.enemy; // Handled by a mutator
141
142 entity closest_target = NULL;
143 vector my_center = CENTER_OR_VIEWOFS(this);
144
145 float trange;
146 // find the closest acceptable target to pass to
147 IL_EACH(g_monster_targets, it.monster_attack,
148 {
149 trange = this.target_range;
150 if (PHYS_INPUT_BUTTON_CROUCH(it))
151 trange *= 0.75; // TODO cvar this
152 vector theirmid = (it.absmin + it.absmax) * 0.5;
153 if (vdist(theirmid - this.origin, >, trange) || !Monster_ValidTarget(this, it, false))
154 continue;
155
156 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
157 vector targ_center = CENTER_OR_VIEWOFS(it);
158
159 if (closest_target)
160 {
161 vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
162 if (vlen2(my_center - targ_center) < vlen2(my_center - closest_target_center))
163 closest_target = it;
164 }
165 else
166 closest_target = it;
167 });
168
169 return closest_target;
170}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
#define IL_EACH(this, cond, body)
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
entity enemy
Definition sv_ctf.qh:153
IntrusiveList g_monster_targets
#define CENTER_OR_VIEWOFS(ent)
Definition utils.qh:31

References CENTER_OR_VIEWOFS, enemy, entity(), g_monster_targets, IL_EACH, MUTATOR_CALLHOOK, NULL, and vector.

Referenced by Monster_Enemy_Check().

◆ monster_makevectors()

void monster_makevectors ( entity this,
entity targ )

Definition at line 85 of file sv_monsters.qc.

86{
87 if (IS_MONSTER(this))
88 {
89 vector v = targ.origin + (targ.mins + targ.maxs) * 0.5;
90 this.v_angle = vectoangles(v - (this.origin + this.view_ofs));
91 this.v_angle.x = -this.v_angle.x;
92 }
93
94 makevectors(this.v_angle);
95}
vector v_angle
Definition player.qh:236
vector origin
vector vectoangles(vector v)
#define makevectors
Definition post.qh:21
vector view_ofs
Definition progsdefs.qc:151

References entity(), IS_MONSTER, makevectors, origin, v_angle, vectoangles(), vector, and view_ofs.

Referenced by M_Golem_Attack_Lightning(), Monster_Attack_Check(), and Monster_Delay_Action().

◆ Monster_Move_2D()

void Monster_Move_2D ( entity this,
float mspeed,
float allow_jumpoff )

References entity().

◆ Monster_Remove()

void Monster_Remove ( entity this)

Definition at line 947 of file sv_monsters.qc.

948{
949 if (!this || IS_CLIENT(this))
950 return; // don't remove it?
951
952 if (!MUTATOR_CALLHOOK(MonsterRemove, this))
953 Send_Effect(EFFECT_ITEM_PICKUP, this.origin, '0 0 0', 1);
954
955 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
956 {
957 .entity weaponentity = weaponentities[slot];
958 if (this.(weaponentity))
959 delete(this.(weaponentity));
960 }
962 delete(this);
963}
#define IS_CLIENT(s)
Definition player.qh:241
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
entity sprite
Definition sv_assault.qc:11
void WaypointSprite_Kill(entity wp)
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

References entity(), IS_CLIENT, MAX_WEAPONSLOTS, MUTATOR_CALLHOOK, origin, Send_Effect(), sprite, WaypointSprite_Kill(), and weaponentities.

Referenced by CommonCommand_editmob(), Invasion_CheckWinner(), Monster_Reset(), and Monster_Spawn().

◆ monster_setupcolors()

void monster_setupcolors ( entity this)

Definition at line 172 of file sv_monsters.qc.

173{
174 if (teamplay && this.team)
175 this.colormap = 1024 + (this.team - 1) * 17;
176 else if (IS_PLAYER(this.realowner))
177 this.colormap = this.realowner.colormap;
178 else
179 {
181 this.colormap = 1126;
182 else if (this.monster_skill <= MONSTER_SKILL_MEDIUM)
183 this.colormap = 1075;
184 else if (this.monster_skill <= MONSTER_SKILL_HARD)
185 this.colormap = 1228;
186 else if (this.monster_skill <= MONSTER_SKILL_INSANE)
187 this.colormap = 1092;
188 else if (this.monster_skill <= MONSTER_SKILL_NIGHTMARE)
189 this.colormap = 1160;
190 else
191 this.colormap = 1024;
192 }
193
194 if (this.colormap > 0)
195 this.glowmod = colormapPaletteColor(this.colormap & 0x0F, false);
196 else
197 this.glowmod = '1 1 1';
198}
int team
Definition main.qh:188
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
#define IS_PLAYER(s)
Definition player.qh:242
float colormap
vector glowmod
const int MONSTER_SKILL_EASY
const int MONSTER_SKILL_MEDIUM
int monster_skill
const int MONSTER_SKILL_INSANE
const int MONSTER_SKILL_HARD
const int MONSTER_SKILL_NIGHTMARE
bool teamplay
Definition teams.qh:59
entity realowner

References colormap, colormapPaletteColor, entity(), glowmod, IS_PLAYER, monster_skill, MONSTER_SKILL_EASY, MONSTER_SKILL_HARD, MONSTER_SKILL_INSANE, MONSTER_SKILL_MEDIUM, MONSTER_SKILL_NIGHTMARE, realowner, team, and teamplay.

Referenced by monster_changeteam(), and Monster_Spawn().

◆ Monster_Sound()

void Monster_Sound ( entity this,
.string samplefield,
float sound_delay,
float delaytoo,
float chan )

References entity().

◆ Monster_Spawn()

bool Monster_Spawn ( entity this,
bool check_appear,
Monster mon )

Setup the basic required properties for a monster.

Definition at line 1388 of file sv_monsters.qc.

1389{
1390 if (!mon || mon == MON_Null) // invalid monster
1391 return false;
1393 {
1394 Monster_Remove(this);
1395 return false;
1396 }
1397
1398 if (!(this.spawnflags & MONSTERFLAG_RESPAWNED) && !(this.flags & FL_MONSTER))
1399 {
1400 IL_PUSH(g_monsters, this);
1401 if (this.mdl && this.mdl != "")
1402 precache_model(this.mdl);
1403 if (this.mdl_dead && this.mdl_dead != "")
1404 precache_model(this.mdl_dead);
1405 }
1406
1407 if (check_appear && Monster_Appear_Check(this, mon))
1408 return true; // return true so the monster isn't removed
1409
1410 if (!this.monster_skill)
1411 this.monster_skill = cvar("g_monsters_skill");
1412
1413 // support for quake style removing monsters based on skill
1417 {
1418 Monster_Remove(this);
1419 return false;
1420 }
1421
1422 if (this.team && !teamplay)
1423 this.team = 0;
1424
1425 if (!(this.spawnflags & MONSTERFLAG_SPAWNED) // naturally spawned monster
1426 && !(this.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either
1428
1429 if (this.mdl && this.mdl != "")
1430 _setmodel(this, this.mdl);
1431 else
1432 setmodel(this, mon.m_model);
1433
1434 if (!this.m_name || this.m_name == "")
1435 this.m_name = mon.m_name;
1436
1437 if (this.statuseffects && this.statuseffects.owner == this)
1438 {
1441 }
1442 else
1443 this.statuseffects = NULL;
1444
1445 this.flags = FL_MONSTER;
1446 this.classname = "monster";
1447 this.takedamage = DAMAGE_AIM;
1448 if (!this.bot_attack)
1449 IL_PUSH(g_bot_targets, this);
1450 this.bot_attack = true;
1451 this.iscreature = true;
1452 this.teleportable = true;
1453 if (!this.damagedbycontents)
1455 this.damagedbycontents = true;
1456 this.monsterdef = mon;
1457 this.event_damage = Monster_Damage;
1458 this.event_heal = Monster_Heal;
1459 settouch(this, Monster_Touch);
1460 this.use = Monster_Use;
1461 this.solid = SOLID_BBOX;
1463 StatusEffects_apply(STATUSEFFECT_SpawnShield, this, time + autocvar_g_monsters_spawnshieldtime, 0);
1464 this.enemy = NULL;
1465 this.velocity = '0 0 0';
1466 this.moveto = this.origin;
1467 this.pos1 = this.origin;
1468 this.pos2 = this.angles;
1469 this.reset = Monster_Reset;
1470 this.netname = mon.netname;
1471 this.monster_attackfunc = mon.monster_attackfunc;
1472 this.candrop = true;
1473 this.oldtarget2 = this.target2;
1474 this.deadflag = DEAD_NO;
1475 this.spawn_time = time;
1476 this.gravity = 1;
1477 this.monster_moveto = '0 0 0';
1478 this.monster_face = '0 0 0';
1480
1481 if (!this.noalign) this.noalign = (mon.spawnflags & (MONSTER_TYPE_FLY | MONSTER_TYPE_SWIM));
1482 if (!this.scale) this.scale = 1;
1483 if (autocvar_g_monsters_edit) this.grab = 1;
1486 if (mon.spawnflags & MONSTER_TYPE_SWIM) this.flags |= FL_SWIM;
1487
1490
1491 if (mon.spawnflags & MONSTER_TYPE_FLY)
1492 {
1493 this.flags |= FL_FLY;
1495 }
1496
1498 this.scale *= 1.3;
1499
1500 setsize(this, RoundPerfectVector(mon.m_mins * this.scale), RoundPerfectVector(mon.m_maxs * this.scale));
1501 this.view_ofs = '0 0 0.35' * this.maxs.z;
1502
1503 Monster_UpdateModel(this);
1504
1505 if (!Monster_Spawn_Setup(this))
1506 {
1507 Monster_Remove(this);
1508 return false;
1509 }
1510
1511 if (!this.noalign)
1512 {
1513 setorigin(this, this.origin + '0 0 20');
1514 tracebox(this.origin + '0 0 64', this.mins, this.maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this);
1515 setorigin(this, trace_endpos);
1516 }
1517
1518 if (!nudgeoutofsolid_OrFallback(this))
1519 {
1520 // Stuck and not fixable
1521 Monster_Remove(this);
1522 return false;
1523 }
1524
1525 if (!(this.spawnflags & MONSTERFLAG_RESPAWNED))
1526 monster_setupcolors(this);
1527
1528 CSQCMODEL_AUTOINIT(this);
1529
1530 return true;
1531}
float bot_attack
Definition api.qh:38
IntrusiveList g_bot_targets
Definition api.qh:149
string mdl_dead
Definition breakable.qc:27
int grab
Definition cheats.qh:26
string netname
short name
Definition monster.qh:44
string m_name
human readable name
Definition monster.qh:42
vector m_mins
hitbox size
Definition monster.qh:53
int spawnflags
attributes
Definition monster.qh:39
vector m_maxs
hitbox size
Definition monster.qh:55
string netname
Definition powerups.qc:20
float gravity
Definition items.qh:17
int spawnflags
Definition ammo.qh:15
string mdl
Definition item.qh:89
#define setmodel(this, m)
Definition model.qh:26
string m_name
Definition scores.qh:142
const int FL_SWIM
Definition constants.qh:71
const int FL_MONSTER
Definition constants.qh:74
const int FL_FLY
Definition constants.qh:70
string classname
float flags
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
vector mins
float DPCONTENTS_BODY
const float SOLID_BBOX
const float EF_FULLBRIGHT
float effects
float DPCONTENTS_PLAYERCLIP
vector trace_endpos
vector maxs
float DPCONTENTS_MONSTERCLIP
float MOVE_WORLDONLY
const float EF_NODEPTHTEST
float dphitcontentsmask
#define use
#define CSQCMODEL_AUTOINIT(e)
float damagedbycontents
Definition damage.qh:45
IntrusiveList g_damagedbycontents
Definition damage.qh:143
ent angles
Definition ent_cs.qc:121
solid
Definition ent_cs.qc:165
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float cvar(string name)
entity monsterdef
Definition monster.qh:21
const int MONSTER_TYPE_FLY
Definition monster.qh:6
const int MONSTER_TYPE_SWIM
Definition monster.qh:7
const int MONSTER_SIZE_QUAKE
Definition monster.qh:14
vector moveto
Definition movelib.qc:4
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_WALK
Definition movetypes.qh:132
const int MOVETYPE_FLY
Definition movetypes.qh:134
float DEAD_NO
Definition progsdefs.qc:274
float deadflag
Definition progsdefs.qc:149
float scale
Definition projectile.qc:14
bool autocvar_g_fullbrightplayers
Definition client.qh:17
bool autocvar_g_nodepthtestplayers
Definition client.qh:34
bool noalign
Definition items.qh:37
bool iscreature
Definition main.qh:46
void StatusEffects_apply(StatusEffect this, entity actor, float eff_time, int eff_flags)
StatusEffect statuseffects
Entity statuseffects.
void StatusEffects_update(entity e)
void StatusEffects_clearall(entity store)
vector pos2
Definition subs.qh:50
vector pos1
Definition subs.qh:50
const int DAMAGE_AIM
Definition subs.qh:81
float takedamage
Definition subs.qh:78
void Monster_Remove(entity this)
void Monster_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
bool Monster_Heal(entity targ, entity inflictor, float amount, float limit)
void monster_setupcolors(entity this)
void Monster_Use(entity this, entity actor, entity trigger)
void Monster_Reset(entity this)
void Monster_Touch(entity this, entity toucher)
bool Monster_Appear_Check(entity this, Monster monster_id)
void Monster_UpdateModel(entity this)
bool Monster_Spawn_Setup(entity this)
vector monster_moveto
custom destination for monster (reset to '0 0 0' when you're done!)
const int MONSTERSKILL_NOTHARD
monster will not spawn on skill >= 3
bool autocvar_g_monsters_quake_resize
bool autocvar_g_monsters_playerclip_collisions
const int MONSTERFLAG_SPAWNED
flag for spawned monsters
float spawn_time
delay monster thinking until spawn animation has completed
const int MONSTERSKILL_NOTMEDIUM
monster will not spawn on skill 2
int monsters_total
float autocvar_g_monsters_spawnshieldtime
float autocvar_g_monsters
Definition sv_monsters.qh:5
vector monster_face
custom looking direction for monster (reset to '0 0 0' when you're done!)
bool candrop
toggle to allow disabling monster item drops
bool autocvar_g_monsters_edit
Definition sv_monsters.qh:6
const int MONSTERFLAG_RESPAWNED
flag for respawned monsters
string oldtarget2
a copy of the original follow target string for monsters
const int MONSTERSKILL_NOTEASY
monster will not spawn on skill <= 1
IntrusiveList g_monsters
string target2
float teleportable
ERASEABLE vector RoundPerfectVector(vector v)
Definition vector.qh:209

References angles, autocvar_g_fullbrightplayers, autocvar_g_monsters, autocvar_g_monsters_edit, autocvar_g_monsters_playerclip_collisions, autocvar_g_monsters_quake_resize, autocvar_g_monsters_spawnshieldtime, autocvar_g_nodepthtestplayers, bot_attack, candrop, classname, CSQCMODEL_AUTOINIT, cvar(), DAMAGE_AIM, damagedbycontents, DEAD_NO, deadflag, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_MONSTERCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, dphitcontentsmask, EF_FULLBRIGHT, EF_NODEPTHTEST, effects, enemy, entity(), FL_FLY, FL_MONSTER, FL_SWIM, flags, g_bot_targets, g_damagedbycontents, g_monsters, grab, gravity, IL_PUSH(), iscreature, Monster::m_maxs, Monster::m_mins, m_name, Monster::m_name, maxs, mdl, mdl_dead, mins, Monster_Appear_Check(), Monster_Damage(), monster_face, Monster_Heal(), monster_moveto, Monster_Remove(), Monster_Reset(), monster_setupcolors(), MONSTER_SIZE_QUAKE, monster_skill, MONSTER_SKILL_EASY, MONSTER_SKILL_HARD, MONSTER_SKILL_MEDIUM, Monster_Spawn_Setup(), Monster_Touch(), MONSTER_TYPE_FLY, MONSTER_TYPE_SWIM, Monster_UpdateModel(), Monster_Use(), monsterdef, MONSTERFLAG_RESPAWNED, MONSTERFLAG_SPAWNED, monsters_total, MONSTERSKILL_NOTEASY, MONSTERSKILL_NOTHARD, MONSTERSKILL_NOTMEDIUM, MOVE_WORLDONLY, moveto, MOVETYPE_FLY, MOVETYPE_WALK, Monster::netname, netname, noalign, NULL, oldtarget2, origin, pos1, pos2, RoundPerfectVector(), scale, set_movetype(), setmodel, settouch, solid, SOLID_BBOX, spawn_time, Monster::spawnflags, spawnflags, statuseffects, StatusEffects_apply(), StatusEffects_clearall(), StatusEffects_update(), takedamage, target2, team, teamplay, teleportable, time, trace_endpos, use, velocity, and view_ofs.

Referenced by Monster_Appear(), Monster_Respawn(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), and spawnmonster().

◆ Monster_Touch()

void Monster_Touch ( entity this,
entity toucher )

Definition at line 510 of file sv_monsters.qc.

511{
512 if (!toucher)
513 return;
514
515 if (toucher.monster_attack && this.enemy != toucher && !IS_MONSTER(toucher)
516 && time >= this.spawn_time
517 && Monster_ValidTarget(this, toucher, true))
518 this.enemy = toucher;
519}
entity entity toucher
Definition self.qh:72
bool Monster_ValidTarget(entity this, entity targ, bool skipfacing)

References enemy, entity(), IS_MONSTER, Monster_ValidTarget(), spawn_time, time, and toucher.

Referenced by M_Zombie_Attack_Leap_Touch(), Monster_Dead(), Monster_Move(), and Monster_Spawn().

◆ monsters_setstatus()

void monsters_setstatus ( entity this)

Definition at line 34 of file sv_monsters.qc.

35{
36 STAT(MONSTERS_TOTAL, this) = monsters_total;
37 STAT(MONSTERS_KILLED, this) = monsters_killed;
38}
#define STAT(...)
Definition stats.qh:82
int monsters_killed

References entity(), monsters_killed, monsters_total, and STAT.

Referenced by PlayerThink().

◆ STATIC_INIT() [1/2]

STATIC_INIT ( g_monster_targets )

Definition at line 151 of file sv_monsters.qh.

152{
154}
#define IL_NEW()

References g_monster_targets, and IL_NEW.

◆ STATIC_INIT() [2/2]

STATIC_INIT ( g_monsters )

Definition at line 145 of file sv_monsters.qh.

146{
147 g_monsters = IL_NEW();
148}

References g_monsters, and IL_NEW.

Variable Documentation

◆ anim_finished

float anim_finished

will be phased out when we have proper animations system

Definition at line 53 of file sv_monsters.qh.

Referenced by M_Mage_Attack_Push(), M_Mage_Defend_Heal(), M_Mage_Defend_Shield(), M_Zombie_Defend_Block(), Monster_Attack_Leap(), Monster_Attack_Melee(), and Monster_Move().

◆ attack_range

float attack_range

melee attack if closer, ranged attack if further away (TODO: separate ranged attack range?)

Definition at line 45 of file sv_monsters.qh.

Referenced by M_Golem_Attack_Swing(), and Monster_Spawn_Setup().

◆ autocvar_g_monsters

◆ autocvar_g_monsters_armor_blockpercent

float autocvar_g_monsters_armor_blockpercent

Definition at line 30 of file sv_monsters.qh.

Referenced by M_Zombie_Defend_Block_End().

◆ autocvar_g_monsters_attack_range

float autocvar_g_monsters_attack_range

Definition at line 15 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup().

◆ autocvar_g_monsters_damageforcescale

float autocvar_g_monsters_damageforcescale = 0.8

Definition at line 10 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup().

◆ autocvar_g_monsters_drop_time

float autocvar_g_monsters_drop_time = 10

Definition at line 24 of file sv_monsters.qh.

Referenced by monster_dropitem().

◆ autocvar_g_monsters_edit

bool autocvar_g_monsters_edit

Definition at line 6 of file sv_monsters.qh.

Referenced by CommonCommand_editmob(), and Monster_Spawn().

◆ autocvar_g_monsters_healthbars

float autocvar_g_monsters_healthbars

Definition at line 31 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup().

◆ autocvar_g_monsters_lineofsight

bool autocvar_g_monsters_lineofsight = true

Definition at line 32 of file sv_monsters.qh.

Referenced by Monster_ValidTarget().

◆ autocvar_g_monsters_max

int autocvar_g_monsters_max

Definition at line 8 of file sv_monsters.qh.

Referenced by CommonCommand_editmob().

◆ autocvar_g_monsters_max_perplayer

int autocvar_g_monsters_max_perplayer

Definition at line 9 of file sv_monsters.qh.

Referenced by CommonCommand_editmob().

◆ autocvar_g_monsters_miniboss_chance

float autocvar_g_monsters_miniboss_chance

Definition at line 21 of file sv_monsters.qh.

Referenced by Monster_Miniboss_Setup().

◆ autocvar_g_monsters_miniboss_healthboost

float autocvar_g_monsters_miniboss_healthboost

Definition at line 22 of file sv_monsters.qh.

Referenced by Monster_Miniboss_Setup().

◆ autocvar_g_monsters_miniboss_loot

string autocvar_g_monsters_miniboss_loot = "vortex"

Definition at line 23 of file sv_monsters.qh.

Referenced by monster_dropitem().

◆ autocvar_g_monsters_owners

bool autocvar_g_monsters_owners

Definition at line 19 of file sv_monsters.qh.

Referenced by spawnmonster().

◆ autocvar_g_monsters_playerclip_collisions

bool autocvar_g_monsters_playerclip_collisions

Definition at line 20 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ autocvar_g_monsters_quake_resize

bool autocvar_g_monsters_quake_resize = true

Definition at line 26 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ autocvar_g_monsters_respawn

bool autocvar_g_monsters_respawn

Definition at line 29 of file sv_monsters.qh.

Referenced by Monster_Respawn_Check().

◆ autocvar_g_monsters_respawn_delay

float autocvar_g_monsters_respawn_delay

Definition at line 28 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup().

◆ autocvar_g_monsters_score_kill

int autocvar_g_monsters_score_kill

Definition at line 16 of file sv_monsters.qh.

Referenced by Monster_Dead().

◆ autocvar_g_monsters_score_spawned

int autocvar_g_monsters_score_spawned

Definition at line 17 of file sv_monsters.qh.

Referenced by Monster_Dead().

◆ autocvar_g_monsters_sounds

bool autocvar_g_monsters_sounds

Definition at line 7 of file sv_monsters.qh.

Referenced by Monster_Sound().

◆ autocvar_g_monsters_spawnshieldtime

float autocvar_g_monsters_spawnshieldtime

Definition at line 25 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ autocvar_g_monsters_target_infront

bool autocvar_g_monsters_target_infront

Definition at line 12 of file sv_monsters.qh.

Referenced by Monster_Attack_Check(), and Monster_ValidTarget().

◆ autocvar_g_monsters_target_infront_2d

bool autocvar_g_monsters_target_infront_2d = true

Definition at line 14 of file sv_monsters.qh.

Referenced by monster_facing().

◆ autocvar_g_monsters_target_infront_range

float autocvar_g_monsters_target_infront_range = 0.3

Definition at line 13 of file sv_monsters.qh.

Referenced by monster_facing().

◆ autocvar_g_monsters_target_range

float autocvar_g_monsters_target_range

Definition at line 11 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup(), and SOUND().

◆ autocvar_g_monsters_teams

bool autocvar_g_monsters_teams

Definition at line 27 of file sv_monsters.qh.

Referenced by Monster_Move(), and spawnmonster().

◆ autocvar_g_monsters_typefrag

bool autocvar_g_monsters_typefrag

Definition at line 18 of file sv_monsters.qh.

Referenced by Monster_ValidTarget().

◆ candrop

bool candrop

toggle to allow disabling monster item drops

Definition at line 47 of file sv_monsters.qh.

Referenced by Monster_Damage(), monster_dropitem(), and Monster_Spawn().

◆ g_monster_targets

◆ g_monsters

◆ GetMonsterSoundSampleField_notFound

ALLMONSTERSOUNDS bool GetMonsterSoundSampleField_notFound

Definition at line 142 of file sv_monsters.qh.

Referenced by Monster_Sound_SampleField(), and Monster_Sounds_Load().

◆ last_enemycheck

float last_enemycheck

for checking monster enemy

Definition at line 52 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup(), and Monster_Think().

◆ last_trace

float last_trace

monster logic delay between target tracing

Definition at line 51 of file sv_monsters.qh.

Referenced by Monster_Move(), and Monster_Move_Target().

◆ mdl_dead

string mdl_dead

dead model for goombas

Definition at line 60 of file sv_monsters.qh.

◆ monster_attack

bool monster_attack

indicates whether an entity can be attacked by monsters

Definition at line 66 of file sv_monsters.qh.

Referenced by func_breakable_setup(), monster_changeteam(), Monster_Spawn_Setup(), PutObserverInServer(), PutPlayerInServer(), and SV_OnEntityPreSpawnFunction().

◆ MONSTER_ATTACK_MELEE

◆ MONSTER_ATTACK_RANGED

◆ monster_face

vector monster_face

custom looking direction for monster (reset to '0 0 0' when you're done!)

Definition at line 55 of file sv_monsters.qh.

Referenced by Monster_Enemy_Check(), Monster_Move(), and Monster_Spawn().

◆ monster_follow

entity monster_follow

monster follow target

Definition at line 41 of file sv_monsters.qh.

Referenced by M_Mage_Defend_Heal_Check(), Monster_Move(), Monster_Move_Target(), and Monster_ValidTarget().

◆ monster_item

bool monster_item

identifier for dropped monster loot TODO: generic identifiers? ok_item exists too!

Definition at line 61 of file sv_monsters.qh.

◆ monster_lifetime

float monster_lifetime

monster dies instantly after this delay, set from spawn

Definition at line 44 of file sv_monsters.qh.

Referenced by Monster_Dead(), Monster_Dead_Fade(), Monster_Dead_Think(), and Monster_Think().

◆ MONSTER_MOVE_ENEMY

const int MONSTER_MOVE_ENEMY = 5

used only as a movestate, for monsters

Definition at line 73 of file sv_monsters.qh.

Referenced by Monster_Move_Target().

◆ MONSTER_MOVE_FOLLOW

const int MONSTER_MOVE_FOLLOW = 1

monster will follow if in range, or stand still

Definition at line 69 of file sv_monsters.qh.

Referenced by Monster_Move_Target().

◆ MONSTER_MOVE_NOMOVE

const int MONSTER_MOVE_NOMOVE = 4

monster simply stands still

Definition at line 72 of file sv_monsters.qh.

Referenced by Monster_Move_Target().

◆ MONSTER_MOVE_SPAWNLOC

const int MONSTER_MOVE_SPAWNLOC = 3

monster will move to its spawn location when not attacking

Definition at line 71 of file sv_monsters.qh.

Referenced by Monster_Move_Target().

◆ MONSTER_MOVE_WANDER

const int MONSTER_MOVE_WANDER = 2

monster will ignore owner & wander around

Definition at line 70 of file sv_monsters.qh.

Referenced by Monster_Move_Target(), and Monster_Spawn_Setup().

◆ monster_moveflags

int monster_moveflags

Definition at line 49 of file sv_monsters.qh.

Referenced by Monster_Move_Target(), Monster_Spawn_Setup(), and spawner_use().

◆ monster_movestate

int monster_movestate

monster move target priority

will be phased out

Definition at line 40 of file sv_monsters.qh.

Referenced by Monster_Move_Target().

◆ monster_moveto

vector monster_moveto

custom destination for monster (reset to '0 0 0' when you're done!)

Definition at line 54 of file sv_monsters.qh.

Referenced by Monster_Enemy_Check(), Monster_Move(), Monster_Move_Target(), and Monster_Spawn().

◆ monster_skill

int monster_skill

Definition at line 100 of file sv_monsters.qh.

Referenced by monster_setupcolors(), Monster_Spawn(), and spawner_use().

◆ MONSTER_SKILL_EASY

const int MONSTER_SKILL_EASY = 1

Definition at line 78 of file sv_monsters.qh.

Referenced by monster_setupcolors(), and Monster_Spawn().

◆ MONSTER_SKILL_HARD

const int MONSTER_SKILL_HARD = 5

Definition at line 80 of file sv_monsters.qh.

Referenced by monster_setupcolors(), and Monster_Spawn().

◆ MONSTER_SKILL_INSANE

const int MONSTER_SKILL_INSANE = 7

Definition at line 81 of file sv_monsters.qh.

Referenced by monster_setupcolors(), and nade_monster_boom().

◆ MONSTER_SKILL_MEDIUM

const int MONSTER_SKILL_MEDIUM = 3

Definition at line 79 of file sv_monsters.qh.

Referenced by monster_setupcolors(), and Monster_Spawn().

◆ MONSTER_SKILL_NIGHTMARE

const int MONSTER_SKILL_NIGHTMARE = 10

Definition at line 82 of file sv_monsters.qh.

Referenced by monster_setupcolors().

◆ MONSTERFLAG_APPEAR

const int MONSTERFLAG_APPEAR = BIT(1)

delay monster spawn until triggered

Definition at line 89 of file sv_monsters.qh.

Referenced by Monster_Appear_Check().

◆ MONSTERFLAG_FLY_VERTICAL

const int MONSTERFLAG_FLY_VERTICAL = BIT(3)

monster can fly/swim vertically

Definition at line 91 of file sv_monsters.qh.

Referenced by Monster_Move(), and Monster_WanderTarget().

◆ MONSTERFLAG_INFRONT

const int MONSTERFLAG_INFRONT = BIT(5)

only check for enemies infront of us, for monsters

Definition at line 92 of file sv_monsters.qh.

Referenced by Monster_Attack_Check(), and Monster_ValidTarget().

◆ MONSTERFLAG_INVINCIBLE

const int MONSTERFLAG_INVINCIBLE = BIT(7)

monster doesn't take damage (may be used for map objects & temporary monsters)

Definition at line 94 of file sv_monsters.qh.

Referenced by M_Mage_Defend_Heal(), Monster_Damage(), and Monster_Spawn_Setup().

◆ MONSTERFLAG_MINIBOSS

const int MONSTERFLAG_MINIBOSS = BIT(6)

monster spawns as mini-boss (also has a chance of naturally becoming one)

Definition at line 93 of file sv_monsters.qh.

Referenced by invasion_SpawnChosenMonster(), monster_dropitem(), and Monster_Miniboss_Setup().

◆ MONSTERFLAG_NORESPAWN

const int MONSTERFLAG_NORESPAWN = BIT(2)

monster doesn't respawn (revive)

Definition at line 90 of file sv_monsters.qh.

Referenced by Monster_Respawn_Check(), and spawnmonster().

◆ MONSTERFLAG_RESPAWNED

const int MONSTERFLAG_RESPAWNED = BIT(15)

◆ MONSTERFLAG_SPAWNED

const int MONSTERFLAG_SPAWNED = BIT(14)

flag for spawned monsters

Definition at line 95 of file sv_monsters.qh.

Referenced by Monster_Dead(), Monster_Reset(), Monster_Spawn(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and spawnmonster().

◆ monsters_killed

int monsters_killed

◆ monsters_total

int monsters_total

◆ MONSTERSKILL_NOTEASY

const int MONSTERSKILL_NOTEASY = BIT(8)

monster will not spawn on skill <= 1

Definition at line 84 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ MONSTERSKILL_NOTHARD

const int MONSTERSKILL_NOTHARD = BIT(10)

monster will not spawn on skill >= 3

Definition at line 86 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ MONSTERSKILL_NOTMEDIUM

const int MONSTERSKILL_NOTMEDIUM = BIT(9)

monster will not spawn on skill 2

Definition at line 85 of file sv_monsters.qh.

Referenced by Monster_Spawn().

◆ msound_delay

float msound_delay

temporary antilag system

Definition at line 127 of file sv_monsters.qh.

Referenced by Monster_Sound().

◆ oldskin

int oldskin

Definition at line 59 of file sv_monsters.qh.

Referenced by FixPlayermodel().

◆ oldtarget2

string oldtarget2

a copy of the original follow target string for monsters

Definition at line 50 of file sv_monsters.qh.

Referenced by Monster_Damage(), and Monster_Spawn().

◆ spawn_time

float spawn_time

delay monster thinking until spawn animation has completed

Definition at line 46 of file sv_monsters.qh.

Referenced by Monster_Move(), Monster_Move_2D(), Monster_Spawn(), Monster_Spawn_Setup(), Monster_Touch(), and PutPlayerInServer().

◆ speed

float speed

monster walk speed

Definition at line 56 of file sv_monsters.qh.

◆ speed2

float speed2

monster run speed

Definition at line 57 of file sv_monsters.qh.

Referenced by Monster_Think(), and tubasound().

◆ stopspeed

float stopspeed

Definition at line 58 of file sv_monsters.qh.

Referenced by Monster_Think().

◆ totalspawned

int totalspawned

number of monsters spawned with mobspawn command

Definition at line 124 of file sv_monsters.qh.

Referenced by CommonCommand_editmob(), Monster_Dead(), Monster_Dead_Damage(), and Monster_Dead_Fade().

◆ wander_delay

float wander_delay

monster logic delay between moving while idle

Definition at line 42 of file sv_monsters.qh.

Referenced by Monster_Move_Target(), and Monster_Spawn_Setup().

◆ wander_distance

float wander_distance

distance to move between wander delays for monsters

Definition at line 43 of file sv_monsters.qh.

Referenced by Monster_Spawn_Setup(), and Monster_WanderTarget().