From: Lyberta Date: Mon, 28 Aug 2017 11:05:18 +0000 (+0300) Subject: Survival: New waypoint sprites. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b1f89f4cfd36b03768e7851256429a4049fa7d1c;p=xonotic%2Fxonotic-data.pk3dir.git Survival: New waypoint sprites. --- diff --git a/qcsrc/common/mutators/mutator/waypoints/all.inc b/qcsrc/common/mutators/mutator/waypoints/all.inc index 73f22b836c..46ac1c3384 100644 --- a/qcsrc/common/mutators/mutator/waypoints/all.inc +++ b/qcsrc/common/mutators/mutator/waypoints/all.inc @@ -54,6 +54,9 @@ REGISTER_WAYPOINT(OnsCPAttack, _("Control point"), '1 0.5 0', 2); REGISTER_WAYPOINT(OnsGen, _("Generator"), '1 0.5 0', 1); REGISTER_WAYPOINT(OnsGenShielded, _("Generator"), '1 0.5 0', 1); +REGISTER_WAYPOINT(SurvivalKill, _("Kill"), '0.8 0.8 0', 1); +REGISTER_WAYPOINT(SurvivalDefend, _("Defend"), '0 1 0', 1); + REGISTER_WAYPOINT(Weapon, _("Weapon"), '0 0 0', 1); REGISTER_WAYPOINT(Monster, _("Monster"), '1 0 0', 1); diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qc b/qcsrc/server/mutators/mutator/gamemode_survival.qc index 34ba7cdba1..10a0f431a8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qc +++ b/qcsrc/server/mutators/mutator/gamemode_survival.qc @@ -131,6 +131,7 @@ int autocvar_g_surv_defender_cannon_fodder_frag_fuel; .string surv_playermodel; ///< Player model forced by the game. .entity surv_attack_sprite; ///< Holds the sprite telling attackers to attack. +.entity surv_defend_sprite; ///< Holds the sprite telling defenders to defend. int surv_type; ///< Holds the type of survival. See SURVIVAL_TYPE constants. bool surv_warmup; ///< Holds whether warmup is active. @@ -195,6 +196,11 @@ void Surv_UpdateAliveStats(); /// \return No return. void Surv_UpdateDefenderHealthStat(); +/// \brief Updates the health of defender sprite. +/// \param[in,out] player Player that has the sprite. +/// \return No return. +void Surv_UpdateWaypointSpriteHealth(entity player); + //========================= Free functions ==================================== void Surv_Initialize() @@ -853,6 +859,10 @@ void Surv_RemovePlayerFromAliveList(entity player, int teamnum) { WaypointSprite_Kill(player.surv_attack_sprite); } + if (player.surv_defend_sprite) + { + WaypointSprite_Kill(player.surv_defend_sprite); + } switch (teamnum) { case surv_attackerteam: @@ -1096,6 +1106,10 @@ void Surv_RoundCleanup() { WaypointSprite_Kill(it.surv_attack_sprite); } + if (it.surv_defend_sprite) + { + WaypointSprite_Kill(it.surv_defend_sprite); + } if (it.surv_savedplayerstate) { delete(it.surv_savedplayerstate); @@ -1257,22 +1271,47 @@ void Surv_DeterminePlayerModel(entity player) /// \return No return. void Surv_SetupWaypointSprite(entity player) { - WaypointSprite_Spawn(WP_AssaultDestroy, 0, 0, player, '0 0 64', NULL, + WaypointSprite_Spawn(WP_SurvivalKill, 0, 0, player, '0 0 64', NULL, surv_attackerteam, player, surv_attack_sprite, false, RADARICON_OBJECTIVE); + WaypointSprite_Spawn(WP_SurvivalDefend, 0, 0, player, '0 0 64', NULL, + surv_defenderteam, player, surv_defend_sprite, false, + RADARICON_OBJECTIVE); + //player.surv_attack_sprite.colormod = colormapPaletteColor(player.team - 1, + // false); + //player.surv_defend_sprite.colormod = colormapPaletteColor(player.team - 1, + // false); + float max_hp; if (autocvar_g_instagib == 1) { - WaypointSprite_UpdateMaxHealth(player.surv_attack_sprite, - PlayerTemplate_GetFloatValue("surv_defender", "start_armor") + 1); - WaypointSprite_UpdateHealth(player.surv_attack_sprite, - player.armorvalue + 1); + max_hp = PlayerTemplate_GetFloatValue(Surv_GetPlayerTemplate(player), + "start_armor") + 1; + WaypointSprite_UpdateMaxHealth(player.surv_attack_sprite, max_hp); + WaypointSprite_UpdateMaxHealth(player.surv_defend_sprite, max_hp); + Surv_UpdateWaypointSpriteHealth(player); return; } - WaypointSprite_UpdateMaxHealth(player.surv_attack_sprite, - PlayerTemplate_GetFloatValue("surv_defender", "start_health") + - PlayerTemplate_GetFloatValue("surv_defender", "start_armor")); - WaypointSprite_UpdateHealth(player.surv_attack_sprite, player.health + - player.armorvalue); + max_hp = PlayerTemplate_GetFloatValue(Surv_GetPlayerTemplate(player), + "start_health") + PlayerTemplate_GetFloatValue(Surv_GetPlayerTemplate( + player), "start_armor"); + WaypointSprite_UpdateMaxHealth(player.surv_attack_sprite, max_hp); + WaypointSprite_UpdateMaxHealth(player.surv_defend_sprite, max_hp); + Surv_UpdateWaypointSpriteHealth(player); +} + +void Surv_UpdateWaypointSpriteHealth(entity player) +{ + float hp; + if (autocvar_g_instagib == 1) + { + hp = player.armorvalue + 1; + } + else + { + hp = player.health + player.armorvalue; + } + WaypointSprite_UpdateHealth(player.surv_attack_sprite, hp); + WaypointSprite_UpdateHealth(player.surv_defend_sprite, hp); } //=============================== Callbacks =================================== @@ -2029,19 +2068,11 @@ MUTATOR_HOOKFUNCTION(surv, PlayerDamaged) if (target.health < 1) { WaypointSprite_Kill(target.surv_attack_sprite); + WaypointSprite_Kill(target.surv_defend_sprite); } else { - if (autocvar_g_instagib == 1) - { - WaypointSprite_UpdateHealth(target.surv_attack_sprite, - target.armorvalue + 1); - } - else - { - WaypointSprite_UpdateHealth(target.surv_attack_sprite, - target.health + target.armorvalue); - } + Surv_UpdateWaypointSpriteHealth(target); } }