52 itemlist =
M_ARGV(1,
string);
59 e.monster_item =
true;
62 e.itemdef = loot_itemdef;
64 e.velocity =
randomvec() * 175 +
'0 0 325';
77 targ_org =
vec2(targ_org);
78 my_org =
vec2(my_org);
89 vector v = targ.origin + (targ.mins + targ.maxs) * 0.5;
117 || (targ.alpha != 0 && targ.alpha < 0.5)
123 vector targ_origin = (targ.absmin + targ.absmax) * 0.5;
130 && this.
enemy != targ
149 trange = this.target_range;
150 if (PHYS_INPUT_BUTTON_CROUCH(it))
152 vector theirmid = (it.absmin + it.absmax) * 0.5;
153 if (vdist(theirmid - this.origin, >, trange) || !Monster_ValidTarget(this, it, false))
157 vector targ_center = CENTER_OR_VIEWOFS(it);
161 vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
162 if (vlen2(my_center - targ_center) < vlen2(my_center - closest_target_center))
169 return closest_target;
215 this.
sprite.team = newteam;
216 this.
sprite.SendFlags |= 1;
227 this.monster_delayedfunc(this.
owner);
249 e.nextthink =
time + defer_amnt;
250 e.count = defer_amnt;
252 e.monster_delayedfunc = func;
253 e.cnt = repeat_count;
266 m =
"models/monsters/*_";
271 return strcat(m,
".", fil);
280 while ((s =
fgets(fh)))
294 string m = this.
monsterdef.m_model.model_str();
302 for (
int i = 0; i < n; ++i)
313#define _MSOUND(m) strfree(this.monstersound_##m);
325 return monstersound_##m;
343 while ((s =
fgets(fh)))
374 string sample = this.(samplefield);
377 float myscale = (this.
scale ? this.
scale : 1);
424 tracetoss(
this,
this);
435 setanim(
this, anm,
false,
true,
false);
457 || !this.monster_attackfunc
463 if (
vdist(targ.origin -
this.origin, <=,
this.attack_range))
467 if (attack_success == 1)
469 else if (attack_success > 0)
473 if (
vdist(targ.origin -
this.origin, >,
this.attack_range))
477 if (attack_success == 1)
479 else if (attack_success > 0)
584 setorigin(
this, this.
pos1);
745 vector dst_down = dst_ahead -
'0 0 3000';
748 traceline(dst_ahead, dst_down,
true,
NULL);
758 if (
trace_endpos.z < (
this.origin.z +
this.mins.z) - (
this.enemy ? 1024 : 100))
772 tracebox(dst_ahead, this.
mins, this.
maxs, dst_down,
true,
this);
849 runspeed = walkspeed = 0;
903 float bboxwidth =
min(this.
maxs.x -
this.mins.x,
this.maxs.y -
this.mins.y);
916 setanim(
this, (do_run ? this.anim_run : this.
anim_walk),
true,
false,
false);
924 if (e.target2 && e.target2 !=
"")
926 else if (e.target && e.target !=
"")
958 if (this.(weaponentity))
959 delete(this.(weaponentity));
1007 setorigin(
this, this.
pos1);
1088 || (deathtype == DEATH_FALL.m_id &&
this.draggedby !=
NULL))
1096 take = mon.
mr_pain(mon,
this, take, attacker, deathtype);
1114 if (deathtype != DEATH_DROWN.m_id && take)
1125 if (deathtype == DEATH_KILL.m_id)
1138 if (
GetResource(
this, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id)
1150 float true_limit = (limit !=
RES_LIMIT_NONE) ? limit : targ.max_health;
1180 bool reverse =
false;
1218 deadbits = (
random() < 0.5)
1225 int animbits = deadbits;
1256 || (
this.enemy.alpha < 0.5 &&
this.enemy.alpha != 0)
1258 ||
vdist(this.
origin - targ_origin, >, this.target_range)
1368 entity wp =
WaypointSprite_Spawn(WP_Monster, 0, 1024,
this,
'0 0 1' * (this.
maxs.z + 15),
NULL,
this.team,
this,
sprite,
true, RADARICON_DANGER);
1390 if (!mon || mon == MON_Null)
1401 if (this.
mdl && this.
mdl !=
"")
1402 precache_model(this.
mdl);
1429 if (this.
mdl && this.
mdl !=
"")
1430 _setmodel(
this, this.
mdl);
1471 this.monster_attackfunc = mon.monster_attackfunc;
1513 setorigin(
this, this.
origin +
'0 0 20');
1518 if (!nudgeoutofsolid_OrFallback(
this))
1533#undef ALLMONSTERSOUNDS
ERASEABLE float anglemods(float v)
ERASEABLE float shortangle_f(float ang1, float ang2)
void animdecide_setimplicitstate(entity e, float onground)
void animdecide_setstate(entity e, int newstate, float restart)
const int ANIMSTATE_FROZEN
const int ANIMSTATE_DEAD1
const int ANIMSTATE_DEAD2
IntrusiveList g_bot_targets
#define MUTATOR_CALLHOOK(id,...)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
string m_name
human readable name
virtual void mr_deadthink()
(SERVER) logic to run every frame after the monster has died
virtual void mr_death()
(SERVER) called when monster dies
virtual void mr_setup()
(SERVER) setup monster data
virtual void mr_anim()
(BOTH?) sets animations for monster
virtual void mr_pain()
(SERVER) called when monster is damaged
virtual void mr_think()
(SERVER) logic to run every frame
#define colormapPaletteColor(c, isPants)
#define setmodel(this, m)
#define PHYS_INPUT_BUTTON_CHAT(s)
vector healtharmor_applydamage(float a, float armorblock, int deathtype, float damage)
const float MOVE_NOMONSTERS
const float CONTENT_SOLID
const float EF_FULLBRIGHT
float DPCONTENTS_PLAYERCLIP
float checkpvs(vector viewpos, entity viewee)
float DPCONTENTS_MONSTERCLIP
float trace_dphitq3surfaceflags
const float EF_NODEPTHTEST
const float CONTENT_SLIME
#define CSQCMODEL_AUTOUPDATE(e)
#define CSQCMODEL_AUTOINIT(e)
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
IntrusiveList g_damagedbycontents
void SUB_Remove(entity this)
Remove entity.
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
void Violence_GibSplash(entity source, float type, float amount, entity attacker)
void Violence_GibSplash_At(vector org, vector dir, float type, float amount, entity gibowner, entity attacker)
void PrecacheGlobalSound(string sample)
string GlobalSound_sample(string pair, float r)
bool tracebox_hits_trigger_hurt(vector start, vector e_min, vector e_max, vector end)
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
entity Item_RandomFromList(string itemlist)
Takes a space-separated list of netnames, returns the itemdef of one of them (or NULL if none are ava...
bool Item_Initialise(entity item)
An optimised and generic way to initialise items (loot or permanent)
#define ITEM_SET_LOOT(item, loot)
Sets the item loot status.
void SUB_UseTargets(entity this, entity actor, entity trigger)
void WarpZone_TraceLine(vector org, vector end, float nomonsters, entity forent)
void WarpZone_RefSys_AddInverse(entity me, entity wz)
vector WarpZone_RefSys_TransformOrigin(entity from, entity to, vector org)
void WarpZone_RefSys_Copy(entity me, entity from)
const int MONSTER_TYPE_FLY
const int MON_FLAG_RANGED
monster shoots projectiles
const int MONSTER_RESPAWN_DEATHPOINT
re-spawn where we died
const int MONSTER_TYPE_SWIM
const int MONSTER_SIZE_QUAKE
void movelib_brake_simple(entity this, float force)
#define movelib_move_simple(e, newdir, velo, blendrate)
#define movelib_move_simple_gravity(e, newdir, velo, blendrate)
void set_movetype(entity this, int mt)
const int WATERLEVEL_WETFEET
#define UNSET_ONGROUND(s)
const int MOVETYPE_BOUNCE
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define new_pure(class)
purely logical entities (not linked to the area grid)
#define REGISTRY_GET(id, i)
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
bool campaign_bots_may_start
campaign mode: bots shall spawn but wait for the player to spawn before they do anything in other gam...
bool autocvar_g_fullbrightplayers
bool autocvar_g_nodepthtestplayers
#define ITEM_DAMAGE_NEEDKILL(dt)
float spamsound(entity e, int chan, Sound samp, float vol, float _atten)
use this one if you might be causing spam (e.g.
bool sound_allowed(int to, entity e)
bool StatusEffects_active(StatusEffect this, entity actor)
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 steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense)
void SUB_SetFade(entity ent, float vanish_time, float fading_time)
void CSQCModel_UnlinkEntity(entity e)
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
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)
bool Monster_Attack_Leap_Check(entity this, vector vel)
bool Monster_Respawn_Check(entity this)
void Monster_Sound(entity this,.string samplefield, float sound_delay, bool delaytoo, float chan)
void Monster_Sounds_Clear(entity this)
void Monster_Respawn(entity this)
void monster_dropitem(entity this, entity attacker)
void Monster_Dead_Think(entity this)
void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff)
void Monster_Use(entity this, entity actor, entity trigger)
vector Monster_Move_Target(entity this, entity targ)
bool Monster_Spawn(entity this, bool check_appear, Monster mon)
Setup the basic required properties for a monster.
void monster_changeteam(entity this, int newteam)
void Monster_Reset(entity this)
void Monster_Dead_Fade(entity this)
string get_monster_model_datafilename(string m, float sk, string fil)
void Monster_Delay_Action(entity this)
void Monster_Sound_Precache(string f)
void Monster_Sounds_Update(entity this)
void Monster_Anim(entity this)
void Monster_Touch(entity this, entity toucher)
void Monster_Miniboss_Setup(entity this)
void Monster_Sounds_Precache(entity this)
entity Monster_FindTarget(entity this)
void Monster_Dead(entity this, entity attacker, float gibbed)
bool Monster_ValidTarget(entity this, entity targ, bool skipfacing)
void monster_makevectors(entity this, entity targ)
bool Monster_Appear_Check(entity this, Monster monster_id)
bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop)
bool monster_facing(entity this, entity targ)
void Monster_UpdateModel(entity this)
int skin_for_monstersound
string Monster_Sound_SampleField(string type)
void Monster_Enemy_Check(entity this)
int Monster_CheckDanger(entity this, vector dst_ahead)
void Monster_Attack_Check(entity this, entity targ,.entity weaponentity)
bool Monster_Spawn_Setup(entity this)
void Monster_Appear(entity this, entity actor, entity trigger)
bool Monster_Attack_Leap(entity this, vector anm, void(entity this, entity toucher) touchfunc, vector vel, float animtime)
void monsters_setstatus(entity this)
vector Monster_WanderTarget(entity this, vector targetorigin)
Returns an origin that's near targetorigin and visible to this monster.
void Monster_Dead_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void Monster_Think(entity this)
bool Monster_Sounds_Load(entity this, string f, int first)
bool monster_attack
indicates whether an entity can be attacked by monsters
const int MONSTERFLAG_NORESPAWN
monster doesn't respawn (revive)
#define MONSTER_SKILLMOD(mon)
int autocvar_g_monsters_score_spawned
float autocvar_g_monsters_attack_range
bool autocvar_g_monsters_respawn
const int MONSTER_SKILL_EASY
int totalspawned
number of monsters spawned with mobspawn command
ALLMONSTERSOUNDS bool GetMonsterSoundSampleField_notFound
const int MONSTER_MOVE_FOLLOW
monster will follow if in range, or stand still
vector monster_moveto
custom destination for monster (reset to '0 0 0' when you're done!)
float anim_finished
will be phased out when we have proper animations system
const int MONSTERSKILL_NOTHARD
monster will not spawn on skill >= 3
entity monster_follow
monster follow target
bool autocvar_g_monsters_quake_resize
bool autocvar_g_monsters_playerclip_collisions
const int MONSTER_SKILL_MEDIUM
bool autocvar_g_monsters_target_infront_2d
const int MONSTER_MOVE_ENEMY
used only as a movestate, for monsters
float wander_delay
monster logic delay between moving while idle
const int MONSTERFLAG_SPAWNED
flag for spawned monsters
float wander_distance
distance to move between wander delays for monsters
bool autocvar_g_monsters_typefrag
bool autocvar_g_monsters_sounds
const int MONSTERFLAG_INFRONT
only check for enemies infront of us, for monsters
float spawn_time
delay monster thinking until spawn animation has completed
float last_trace
monster logic delay between target tracing
const int MONSTERSKILL_NOTMEDIUM
monster will not spawn on skill 2
IntrusiveList g_monster_targets
float autocvar_g_monsters_damageforcescale
const int MONSTERFLAG_APPEAR
delay monster spawn until triggered
const int MONSTER_MOVE_SPAWNLOC
monster will move to its spawn location when not attacking
const int MONSTERFLAG_MINIBOSS
monster spawns as mini-boss (also has a chance of naturally becoming one)
const int MONSTER_MOVE_WANDER
monster will ignore owner & wander around
float autocvar_g_monsters_miniboss_chance
float autocvar_g_monsters_spawnshieldtime
float autocvar_g_monsters
vector monster_face
custom looking direction for monster (reset to '0 0 0' when you're done!)
float autocvar_g_monsters_target_range
bool candrop
toggle to allow disabling monster item drops
const int MONSTER_SKILL_INSANE
float attack_range
melee attack if closer, ranged attack if further away (TODO: separate ranged attack range?...
float autocvar_g_monsters_healthbars
float autocvar_g_monsters_respawn_delay
string autocvar_g_monsters_miniboss_loot
bool autocvar_g_monsters_lineofsight
const int MONSTER_ATTACK_MELEE
bool autocvar_g_monsters_edit
float autocvar_g_monsters_drop_time
float speed2
monster run speed
const int MONSTER_SKILL_HARD
const int MONSTER_SKILL_NIGHTMARE
float autocvar_g_monsters_miniboss_healthboost
const int MONSTERFLAG_INVINCIBLE
monster doesn't take damage (may be used for map objects & temporary monsters)
int autocvar_g_monsters_score_kill
bool autocvar_g_monsters_target_infront
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
const int MONSTER_ATTACK_RANGED
int monster_movestate
monster move target priority
const int MONSTERFLAG_FLY_VERTICAL
monster can fly/swim vertically
float last_enemycheck
for checking monster enemy
bool autocvar_g_monsters_teams
const int MONSTER_MOVE_NOMOVE
monster simply stands still
float autocvar_g_monsters_target_infront_range
float msound_delay
temporary antilag system
float monster_lifetime
monster dies instantly after this delay, set from spawn
void GiveResource(entity receiver, Resource res_type, float amount)
Gives an entity some resource.
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.
#define GameRules_scoring_add(client, fld, value)
bool turret_closetotarget(entity this, vector targ, float range)
vector Team_ColorRGB(int teamid)
#define CENTER_OR_VIEWOFS(ent)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
ERASEABLE vector RoundPerfectVector(vector v)
void WaypointSprite_Kill(entity wp)
void WaypointSprite_UpdateTeamRadar(entity e, entity icon, vector col)
void WaypointSprite_UpdateMaxHealth(entity e, float f)
entity WaypointSprite_Spawn(entity spr, float _lifetime, float maxdistance, entity ref, vector ofs, entity showto, float t, entity own,.entity ownfield, float hideable, entity icon)
void WaypointSprite_UpdateHealth(entity e, float f)
const int MAX_WEAPONSLOTS
entity weaponentities[MAX_WEAPONSLOTS]
int weaponslot(.entity weaponentity)
float attack_finished_single[MAX_WEAPONSLOTS]