self.classname = "invasion_spawnpoint";
}
-float invasion_PickMonster()
+float invasion_PickMonster(float supermonster_count)
{
if(autocvar_g_invasion_zombies_only)
- return MONSTER_ZOMBIE;
+ return MON_ZOMBIE;
float i;
+ entity mon;
RandomSelection_Init();
- for(i = MONSTER_FIRST + 1; i < MONSTER_LAST; ++i)
+ for(i = MON_FIRST; i <= MON_LAST; ++i)
{
- if(i == MONSTER_STINGRAY || i == MONSTER_WYVERN)
+ mon = get_monsterinfo(i);
+ if((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM) || (mon.spawnflags & MON_FLAG_SUPERMONSTER && supermonster_count >= 1))
continue; // flying/swimming monsters not yet supported
RandomSelection_Add(world, i, "", 1, 1);
}
monster = spawnmonster("", mon, spawn_point, spawn_point, spawn_point.origin, FALSE, 2);
+
+ if(roundcnt >= maxrounds)
+ monster.spawnflags |= MONSTERFLAG_MINIBOSS;
}
-void invasion_SpawnMonsters()
+void invasion_SpawnMonsters(float supermonster_count)
{
- float chosen_monster = invasion_PickMonster();
+ float chosen_monster = invasion_PickMonster(supermonster_count);
invasion_SpawnChosenMonster(chosen_monster);
}
{
FOR_EACH_MONSTER(head)
{
- WaypointSprite_Kill(head.sprite);
if(head.weaponentity) remove(head.weaponentity);
+ if(head.iceblock) remove(head.iceblock);
remove(head);
}
+
+ if(roundcnt >= maxrounds)
+ {
+ NextLevel();
+ return 1;
+ }
Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit);
return 1;
}
-
- if((numspawned + numkilled) < maxspawned)
+
+ // boss round
+ if(roundcnt >= maxrounds)
{
- if(time >= last_check)
+ if(numspawned < 1)
{
- invasion_SpawnMonsters();
- last_check = time + 2;
+ maxspawned = 1;
+ invasion_SpawnMonsters(0);
}
+ }
+ else
+ {
+ float total_alive_monsters = 0, supermonster_count = 0;
- return 0;
+ FOR_EACH_MONSTER(head) if(head.health > 0)
+ {
+ if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+ ++supermonster_count;
+ ++total_alive_monsters;
+ }
+
+ if((total_alive_monsters + numkilled) < maxspawned && maxcurrent < 10) // 10 at a time should be plenty
+ {
+ if(time >= last_check)
+ {
+ invasion_SpawnMonsters(supermonster_count);
+ last_check = time + 2;
+ }
+
+ return 0;
+ }
}
- if(numspawned < 1 || numkilled < numspawned)
+ if(numspawned < 1 || numkilled < maxspawned)
return 0; // nothing has spawned yet, or there are still alive monsters
if(roundcnt >= maxrounds)
FOR_EACH_PLAYER(head)
{
- float cs = PlayerScore_Add(head, SP_INVASION_KILLS, 0);
+ float cs = PlayerScore_Add(head, SP_KILLS, 0);
if(cs > winning_score)
{
winning_score = cs;
float numplayers = 0;
FOR_EACH_PLAYER(e)
{
- ++numplayers;
e.player_blocked = 0;
+ ++numplayers;
}
roundcnt += 1;
+ maxcurrent = 0;
numspawned = 0;
numkilled = 0;
if(roundcnt > 1)
- maxspawned = rint(autocvar_g_invasion_monster_count * roundcnt / 0.7);
+ maxspawned = rint(autocvar_g_invasion_monster_count * (roundcnt * 0.5));
else
maxspawned = autocvar_g_invasion_monster_count;
- monster_skill += 0.01 * numplayers;
+ monster_skill += 0.1 * numplayers;
}
MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
{
- numkilled += 1;
+ if not(self.monster_respawned)
+ {
+ numkilled += 1;
+ maxcurrent -= 1;
- if(IS_PLAYER(frag_attacker))
- PlayerScore_Add(frag_attacker, SP_INVASION_KILLS, +1);
+ if(IS_PLAYER(frag_attacker))
+ PlayerScore_Add(frag_attacker, SP_KILLS, +1);
+ }
return FALSE;
}
MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
{
- if(self.realowner == world)
+ if not(self.spawnflags & MONSTERFLAG_SPAWNED)
{
- WaypointSprite_Kill(self.sprite);
if(self.weaponentity) remove(self.weaponentity);
+ if(self.iceblock) remove(self.iceblock);
remove(self);
return FALSE;
}
- numspawned += 1;
+ if(roundcnt < maxrounds && self.spawnflags & MONSTERFLAG_MINIBOSS)
+ self.spawnflags &= ~MONSTERFLAG_MINIBOSS;
+
+ if not(self.monster_respawned)
+ {
+ numspawned += 1;
+ maxcurrent += 1;
+ }
self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
MUTATOR_HOOKFUNCTION(invasion_PlayerDamage)
{
- if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
+ if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target) && frag_attacker != frag_target)
{
frag_damage = 0;
frag_force = '0 0 0';
}
- if(frag_attacker.flags & FL_MONSTER && frag_target.flags & FL_MONSTER)
- frag_damage = 0;
+ return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
+{
+ if(MUTATOR_RETURNVALUE) // command was already handled?
+ return FALSE;
+
+ if(cmd_name == "debuginvasion")
+ {
+ sprint(self, strcat("maxspawned = ", ftos(maxspawned), "\n"));
+ sprint(self, strcat("numspawned = ", ftos(numspawned), "\n"));
+ sprint(self, strcat("numkilled = ", ftos(numkilled), "\n"));
+ sprint(self, strcat("roundcnt = ", ftos(roundcnt), "\n"));
+ sprint(self, strcat("monsters_total = ", ftos(monsters_total), "\n"));
+ sprint(self, strcat("monsters_killed = ", ftos(monsters_killed), "\n"));
+ sprint(self, strcat("monster_skill = ", ftos(monster_skill), "\n"));
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(invasion_SetStartItems)
+{
+ start_health = 200;
+ start_armorvalue = 200;
return FALSE;
}
void invasion_ScoreRules()
{
- ScoreRules_basics(0, SFL_SORT_PRIO_SECONDARY, 0, FALSE);
- ScoreInfo_SetLabel_PlayerScore(SP_INVASION_KILLS, "kills", SFL_SORT_PRIO_PRIMARY);
+ ScoreRules_basics(0, 0, 0, FALSE);
+ ScoreInfo_SetLabel_PlayerScore(SP_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
ScoreRules_basics_end();
}
void invasion_Initialize()
{
+ independent_players = 1; // to disable extra useless scores
+
invasion_ScoreRules();
+
+ independent_players = 0;
round_handler_Spawn(Invasion_CheckPlayers, Invasion_CheckWinner, Invasion_RoundStart);
round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit);
allowed_to_spawn = TRUE;
- monster_skill = 0.01;
+ monster_skill = 0.5;
roundcnt = 0;
}
MUTATOR_HOOK(PlayerPreThink, invasion_PlayerThink, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerSpawn, invasion_PlayerSpawn, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerDamage_Calculate, invasion_PlayerDamage, CBC_ORDER_ANY);
+ MUTATOR_HOOK(SV_ParseClientCommand, invasion_PlayerCommand, CBC_ORDER_ANY);
+ MUTATOR_HOOK(SetStartItems, invasion_SetStartItems, CBC_ORDER_ANY);
MUTATOR_ONADD
{