bool cpicon_send(entity this, entity to, int sf)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_CONTROLPOINT_ICON);
+ if(sf & CPSF_SETUP)
+ sf &= ~CPSF_STATUS;
WriteByte(MSG_ENTITY, sf);
if(sf & CPSF_SETUP)
{
this.lasthealth = this.max_health = this.health = autocvar_g_onslaught_gen_health;
this.takedamage = DAMAGE_AIM;
this.bot_attack = true;
- IL_PUSH(g_bot_targets, this);
+ if(!IL_CONTAINS(g_bot_targets, this))
+ IL_PUSH(g_bot_targets, this);
this.iscaptured = true;
this.islinked = true;
this.isshielded = true;
return prev ? prev : MAPINFO_TYPE_DEATHMATCH;
}
-float _MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
+float _MapInfo_CheckMap(string s, bool gametype_only) // returns 0 if the map can't be played with the current settings, 1 otherwise
{
if(!MapInfo_Get_ByName(s, 1, NULL))
return 0;
if((MapInfo_Map_supportedGametypes & MapInfo_CurrentGametype().m_flags) == 0)
return 0;
+ if (gametype_only)
+ return 1;
if((MapInfo_Map_supportedFeatures & MapInfo_CurrentFeatures()) != MapInfo_CurrentFeatures())
return 0;
return 1;
float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
{
float r;
- r = _MapInfo_CheckMap(s);
+ r = _MapInfo_CheckMap(s, false);
MapInfo_ClearTemps();
return r;
}
Gametype t = MapInfo_CurrentGametype();
MapInfo_LoadMapSettings_SaveGameType(t);
- if(!_MapInfo_CheckMap(s)) // with underscore, it keeps temps
+ if(!_MapInfo_CheckMap(s, true)) // with underscore, it keeps temps
{
if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
{
LOG_WARNF("can't play the selected map in the given game mode (%s). Falling back to a supported mode (%s).", t_prev.mdl, t.mdl);
MapInfo_LoadMapSettings_SaveGameType(t);
}
+ if(!_MapInfo_CheckMap(s, false)) { // with underscore, it keeps temps
+ LOG_WARNF("the selected map lacks features required by current settings; playing anyway.");
+ }
MapInfo_Get_ByName(s, 1, t);
}
#pragma once
// special spawn flags
-const int MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died
-const int MONSTER_TYPE_FLY = 32;
-const int MONSTER_TYPE_SWIM = 64;
-const int MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced
-const int MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster
-const int MON_FLAG_RANGED = 512; // monster shoots projectiles
-const int MON_FLAG_MELEE = 1024;
-const int MON_FLAG_CRUSH = 2048; // monster can be stomped in special modes
-const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes
-const int MONSTER_SIZE_QUAKE = 8192;
+const int MONSTER_RESPAWN_DEATHPOINT = BIT(4); // re-spawn where we died
+const int MONSTER_TYPE_FLY = BIT(5);
+const int MONSTER_TYPE_SWIM = BIT(6);
+const int MONSTER_SIZE_BROKEN = BIT(7); // TODO: remove when bad models are replaced
+const int MON_FLAG_SUPERMONSTER = BIT(8); // incredibly powerful monster
+const int MON_FLAG_RANGED = BIT(9); // monster shoots projectiles
+const int MON_FLAG_MELEE = BIT(10);
+const int MON_FLAG_CRUSH = BIT(11); // monster can be stomped in special modes
+const int MON_FLAG_RIDE = BIT(12); // monster can be ridden in special modes
+const int MONSTER_SIZE_QUAKE = BIT(13);
+const int MONSTER_TYPE_PASSIVE = BIT(14); // doesn't target or chase enemies
// entity properties of monsterinfo:
.bool(int, entity actor, entity targ) monster_attackfunc;
return false;
}
-spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); }
+spawnfunc(monster_mage) { Monster_Spawn(this, true, MON_MAGE.monsterid); }
#endif // SVQC
return false;
}
-spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); }
+spawnfunc(monster_shambler) { Monster_Spawn(this, true, MON_SHAMBLER.monsterid); }
#endif // SVQC
#ifdef SVQC
return false;
}
-spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); }
+spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER.monsterid); }
#endif // SVQC
#ifdef SVQC
return false;
}
-spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); }
+spawnfunc(monster_wyvern) { Monster_Spawn(this, true, MON_WYVERN.monsterid); }
#endif // SVQC
#ifdef SVQC
return false;
}
-spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); }
+spawnfunc(monster_zombie) { Monster_Spawn(this, true, MON_ZOMBIE.monsterid); }
#endif // SVQC
#ifdef SVQC
if(actor.spawnflags & MONSTERFLAG_NORESPAWN)
actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
+ actor.spawnflags &= ~MONSTERFLAG_APPEAR; // once it's appeared, it will respawn quickly, we don't want it to appear
+
actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
actor.monster_loot = spawnfunc_item_health_medium;
return true;
}
-void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); }
+void Monster_Respawn(entity this) { Monster_Spawn(this, true, this.monsterid); }
.vector pos1, pos2;
void Monster_Appear(entity this, entity actor, entity trigger)
{
this.enemy = actor;
- this.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop
- Monster_Spawn(this, this.monsterid);
+ Monster_Spawn(this, false, this.monsterid);
}
bool Monster_Appear_Check(entity this, int monster_id)
return;
}
- float reverse = false;
- vector a, b;
-
makevectors(this.angles);
- a = this.origin + '0 0 16';
- b = this.origin + '0 0 16' + v_forward * 32;
+ vector a = CENTER_OR_VIEWOFS(this);
+ vector b = CENTER_OR_VIEWOFS(this) + v_forward * 32;
traceline(a, b, MOVE_NORMAL, this);
+ bool reverse = false;
if(trace_fraction != 1.0)
- {
reverse = true;
-
- if(trace_ent)
- if(IS_PLAYER(trace_ent) && !(trace_ent.items & IT_STRENGTH))
- reverse = false;
- }
+ if(trace_ent && IS_PLAYER(trace_ent) && !(trace_ent.items & ITEM_Strength.m_itemid))
+ reverse = false;
+ if(trace_ent && IS_MONSTER(trace_ent))
+ reverse = true;
// TODO: fix this... tracing is broken if the floor is thin
/*
return true;
}
-bool Monster_Spawn(entity this, int mon_id)
+bool Monster_Spawn(entity this, bool check_appear, int mon_id)
{
// setup the basic required properties for a monster
entity mon = Monsters_from(mon_id);
if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
IL_PUSH(g_monsters, this);
- if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed
+ if(check_appear && Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed
if(!this.monster_skill)
this.monster_skill = cvar("g_monsters_skill");
this.flags = FL_MONSTER;
this.classname = "monster";
this.takedamage = DAMAGE_AIM;
+ if(!this.bot_attack)
+ IL_PUSH(g_bot_targets, this);
this.bot_attack = true;
- IL_PUSH(g_bot_targets, this);
this.iscreature = true;
this.teleportable = true;
this.damagedbycontents = true;
this.oldtarget2 = this.target2;
this.pass_distance = 0;
this.deadflag = DEAD_NO;
- this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM));
this.spawn_time = time;
this.gravity = 1;
this.monster_moveto = '0 0 0';
this.monster_face = '0 0 0';
this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
+ if(!this.noalign) { this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); }
if(!this.scale) { this.scale = 1; }
if(autocvar_g_monsters_edit) { this.grab = 1; }
if(autocvar_g_fullbrightplayers) { this.effects |= EF_FULLBRIGHT; }
void monsters_setstatus(entity this);
-bool Monster_Spawn(entity this, int mon_id);
+bool Monster_Spawn(entity this, bool check_appear, int mon_id);
void monster_setupcolors(entity this);
#include <server/autocvars.qh>
#include <server/defs.qh>
#endif
-entity spawnmonster (string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag)
+entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag)
{
- entity e = spawn();
-
e.spawnflags = MONSTERFLAG_SPAWNED;
if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; }
if(monster == "random")
{
RandomSelection_Init();
- FOREACH(Monsters, it != MON_Null,
+ FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MONSTER_TYPE_PASSIVE),
{
RandomSelection_AddEnt(it, 1, 1);
});
}
// Monster_Spawn checks if monster is valid
- Monster_Spawn(e, monster_id);
+ Monster_Spawn(e, false, monster_id);
return e;
}
#pragma once
-entity spawnmonster (string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag);
+entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag);
void nade_monster_boom(entity this)
{
- entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
+ entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
if(autocvar_g_nades_pokenade_monster_lifetime > 0)
e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
void tuba_instrument_send(entity this, int instr)
{
msg_entity = this;
+ if (!IS_REAL_CLIENT(this))
+ return;
int chan = MSG_ONE;
WriteHeader(chan, tuba_instrument);
WriteByte(chan, instr);
totalspawned += 1;
WarpZone_TraceBox(CENTER_OR_VIEWOFS(caller), caller.mins, caller.maxs, CENTER_OR_VIEWOFS(caller) + v_forward * 150, true, caller);
- mon = spawnmonster(arg_lower, 0, caller, caller, trace_endpos, false, false, moveflag);
+ mon = spawnmonster(spawn(), arg_lower, 0, caller, caller, trace_endpos, false, false, moveflag);
print_to(caller, strcat("Spawned ", mon.monster_name));
return;
}
}
}
-int invasion_PickMonster(int supermonster_count)
+Monster invasion_PickMonster(int supermonster_count)
{
if(autocvar_g_invasion_zombies_only)
- return MON_ZOMBIE.monsterid;
+ return MON_ZOMBIE;
RandomSelection_Init();
FOREACH(Monsters, it != MON_Null,
{
- if((it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM) || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
+ if((it.spawnflags & MONSTER_TYPE_PASSIVE) || (it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM) || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
continue;
- RandomSelection_AddFloat(it.monsterid, 1, 1);
+ RandomSelection_AddEnt(it, 1, 1);
});
- return RandomSelection_chosen_float;
+ return RandomSelection_chosen_ent;
}
entity invasion_PickSpawn()
return RandomSelection_chosen_ent;
}
-void invasion_SpawnChosenMonster(int mon)
+void invasion_SpawnChosenMonster(Monster mon)
{
entity spawn_point, monster;
{
LOG_TRACE("Warning: couldn't find any invasion_spawnpoint spawnpoints, attempting to spawn monsters in random locations");
entity e = spawn();
- setsize(e, (get_monsterinfo(mon)).mins, (get_monsterinfo(mon)).maxs);
+ setsize(e, mon.mins, mon.maxs);
if(MoveToRandomMapLocation(e, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
- monster = spawnmonster("", mon, NULL, NULL, e.origin, false, false, 2);
+ monster = spawnmonster(spawn(), "", mon.m_id, NULL, NULL, e.origin, false, false, 2);
else return;
setthink(e, SUB_Remove);
e.nextthink = time + 0.1;
}
else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
- monster = spawnmonster(spawn_point.spawnmob, mon, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
+ monster = spawnmonster(spawn(), spawn_point.spawnmob, mon.m_id, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
if(spawn_point) monster.target2 = spawn_point.target2;
monster.spawnshieldtime = time;
void invasion_SpawnMonsters(int supermonster_count)
{
- int chosen_monster = invasion_PickMonster(supermonster_count);
+ Monster chosen_monster = invasion_PickMonster(supermonster_count);
invasion_SpawnChosenMonster(chosen_monster);
}