From: drjaska Date: Sat, 23 Oct 2021 15:01:25 +0000 (+0300) Subject: copypasted some weaponarena and score hooks X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f557c31c620922c321c2730088dbfc27c511d2a9;p=xonotic%2Fxonotic-data.pk3dir.git copypasted some weaponarena and score hooks setting up round based gameplay next --- diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 662f06ded..d571a2227 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -576,3 +576,5 @@ set g_mh 0 "Manhunt: Hunters go in search of the runners" set g_mh_not_dm_maps 0 "when this is set, DM maps will NOT be listed in MH" set g_mh_team_spawns 0 "when 1, players spawn from the team spawnpoints of the map, if any" set g_mh_point_limit -1 "MH point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)" +set g_mh_warmup 10 "time players get to run around before the round starts" +set g_mh_weaponarena "" "starting weapons - takes the same options as g_weaponarena" diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc index 2479f1c67..3086ee7bf 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc @@ -31,9 +31,9 @@ void mh_DelayedInit(entity this) int teams = BITS(bound(2, numteams, 2)); if(teams & BIT(0)) - mh_SpawnTeam("Red", NUM_TEAM_1); + mh_SpawnTeam("Red", NUM_TEAM_1); //is this the place to change the displayed team name? if(teams & BIT(1)) - mh_SpawnTeam("Blue", NUM_TEAM_2); + mh_SpawnTeam("Blue", NUM_TEAM_2); //is this the place to change the displayed team name? } } @@ -56,3 +56,106 @@ MUTATOR_HOOKFUNCTION(mh, Scores_CountFragsRemaining) // announce remaining frags return true; } + +// =================== +// weaponarena hooks +// =================== + +MUTATOR_HOOKFUNCTION(mh, SetWeaponArena) +{ + if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "") + M_ARGV(0, string) = autocvar_g_mh_weaponarena; +} + +//ammo is needed if weapons are given with above weaponarena unless players are given infinite ammo +MUTATOR_HOOKFUNCTION(mh, SetStartItems) +{ + start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS); + start_health = warmup_start_health = cvar("g_ca_start_health"); + start_armorvalue = warmup_start_armorvalue = cvar("g_ca_start_armor"); + start_ammo_shells = warmup_start_ammo_shells = cvar("g_ca_start_ammo_shells"); + start_ammo_nails = warmup_start_ammo_nails = cvar("g_ca_start_ammo_nails"); + start_ammo_rockets = warmup_start_ammo_rockets = cvar("g_ca_start_ammo_rockets"); + start_ammo_cells = warmup_start_ammo_cells = cvar("g_ca_start_ammo_cells"); + start_ammo_plasma = warmup_start_ammo_plasma = cvar("g_ca_start_ammo_plasma"); + start_ammo_fuel = warmup_start_ammo_fuel = cvar("g_ca_start_ammo_fuel"); +} + +MUTATOR_HOOKFUNCTION(mh, ForbidThrowCurrentWeapon) +{ + return true; +} + +MUTATOR_HOOKFUNCTION(mh, FilterItem) +{ + return true; +} + +// ============= +// score hooks +// ============= + +//refactor this when setting up score for tagging +MUTATOR_HOOKFUNCTION(mh, Damage_Calculate) +{ + entity frag_attacker = M_ARGV(1, entity); + entity frag_target = M_ARGV(2, entity); + float frag_deathtype = M_ARGV(3, float); + float frag_damage = M_ARGV(4, float); + float frag_mirrordamage = M_ARGV(5, float); + + if (IS_PLAYER(frag_target)) + if (!IS_DEAD(frag_target)) + if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id) + frag_damage = 0; + + frag_mirrordamage = 0; + + M_ARGV(4, float) = frag_damage; + M_ARGV(5, float) = frag_mirrordamage; +} + +//refactor this when setting up score for tagging +MUTATOR_HOOKFUNCTION(mh, PlayerDamage_SplitHealthArmor) +{ + if (time < game_starttime || (round_handler_IsActive() && !round_handler_IsRoundStarted())) + return; + + entity frag_attacker = M_ARGV(1, entity); + entity frag_target = M_ARGV(2, entity); + float frag_deathtype = M_ARGV(6, float); + float frag_damage = M_ARGV(7, float); + float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH)); + float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR)); + + float excess = max(0, frag_damage - damage_take - damage_save); + + //non-friendly fire + if (frag_target != frag_attacker && IS_PLAYER(frag_attacker) && DIFF_TEAM(frag_target, frag_attacker)) + GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * 1); + + //friendly fire + if (SAME_TEAM(frag_target, frag_attacker)) + GameRules_scoring_add_team(frag_attacker, SCORE, (-1 * (frag_damage - excess)) * 1); + + //handle (environmental hazard) suiciding, check first if player has a registered attacker who most likely pushed them there to avoid punishing pushed players as pushers are already rewarded + //deathtypes: + //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks + //camp = campcheck, lava = lava, slime = slime + //team change / rebalance suicides are currently not included + if (!IS_PLAYER(frag_attacker) && ( + frag_deathtype == DEATH_KILL.m_id || + frag_deathtype == DEATH_DROWN.m_id || + frag_deathtype == DEATH_HURTTRIGGER.m_id || + frag_deathtype == DEATH_CAMP.m_id || + frag_deathtype == DEATH_LAVA.m_id || + frag_deathtype == DEATH_SLIME.m_id || + frag_deathtype == DEATH_SWAMP.m_id)) + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * 1); +} + +MUTATOR_HOOKFUNCTION(mh, GiveFragsForKill, CBC_ORDER_FIRST) +{ + M_ARGV(2, float) = 0; // score will be given to the players differently + return true; +} diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh index 512697621..c4eb58b32 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh @@ -5,6 +5,8 @@ // TODO: change this? float autocvar_g_mh_point_limit; bool autocvar_g_mh_team_spawns; +//float autocvar_g_mh_warmup; +string autocvar_g_mh_weaponarena; void mh_Initialize(); REGISTER_MUTATOR(mh, false)