From: Mario Date: Mon, 5 Aug 2013 08:24:37 +0000 (+1000) Subject: Fix some monster counting issues X-Git-Tag: xonotic-v0.8.0~241^2^2~173 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0e3e05fa1d4bcaec0be9cf17310680da6fc0abd5;p=xonotic%2Fxonotic-data.pk3dir.git Fix some monster counting issues --- diff --git a/qcsrc/server/mutators/gamemode_invasion.qc b/qcsrc/server/mutators/gamemode_invasion.qc index a45999cac..9665bdd80 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qc +++ b/qcsrc/server/mutators/gamemode_invasion.qc @@ -61,9 +61,9 @@ void invasion_SpawnMonsters() float Invasion_CheckWinner() { + entity head; if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0) { - entity head; FOR_EACH_MONSTER(head) { WaypointSprite_Kill(head.sprite); @@ -77,28 +77,40 @@ float Invasion_CheckWinner() return 1; } - if((numspawned - numkilled) < maxspawned) + if((numspawned + numkilled) < maxspawned) { if(time >= last_check) { invasion_SpawnMonsters(); - last_check = time + 0.5; + last_check = time + 2; } return 0; } - if(numspawned > 1) - return 0; + if(numspawned < 1 || numkilled < numspawned) + return 0; // nothing has spawned yet, or there are still alive monsters if(roundcnt >= maxrounds) { NextLevel(); return 1; } + + entity winner = world; + float winning_score = 0; + + FOR_EACH_PLAYER(head) + { + if(PlayerScore_Add(head, SP_INVASION_KILLS, 0) > winning_score) + winner = head; + } - Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER); - Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER); + if(winner != world) + { + Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_PLAYER_WIN, winner.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_PLAYER_WIN, winner.netname); + } round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit); @@ -168,6 +180,12 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerThink) return FALSE; } +MUTATOR_HOOKFUNCTION(invasion_PlayerSpawn) +{ + self.bot_attack = FALSE; + return FALSE; +} + MUTATOR_HOOKFUNCTION(invasion_PlayerDamage) { if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target)) @@ -208,6 +226,7 @@ MUTATOR_DEFINITION(gamemode_invasion) MUTATOR_HOOK(MonsterDies, invasion_MonsterDies, CBC_ORDER_ANY); MUTATOR_HOOK(MonsterSpawn, invasion_MonsterSpawn, CBC_ORDER_ANY); 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_ONADD