X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_keyhunt.qc;h=86d76e4312c87aff1aa80e8b3602fe020e84b18b;hp=759831d39380548a191a01b6d560d389f1d0f6d2;hb=c039d054a46888048d214000273ccfc63e4611b6;hpb=cc5082d6abb23b219cae238ba35cef05be08848a diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 759831d39..86d76e431 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -1,60 +1,4 @@ #include "gamemode_keyhunt.qh" -#ifndef GAMEMODE_KEYHUNT_H -#define GAMEMODE_KEYHUNT_H - -#define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit") -int autocvar_g_keyhunt_point_leadlimit; -bool autocvar_g_keyhunt_team_spawns; -void kh_Initialize(); - -REGISTER_MUTATOR(kh, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - kh_Initialize(); - - ActivateTeamplay(); - SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, autocvar_timelimit_override, -1); - if (autocvar_g_keyhunt_team_spawns) - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back kh_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -#define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext ) - -// ALL OF THESE should be removed in the future, as other code should not have to care - -// used by bots: -float kh_tracking_enabled; -.entity kh_next; -float kh_Key_AllOwnedByWhichTeam(); - -USING(kh_Think_t, void()); -void kh_StartRound(); -void kh_Controller_SetThink(float t, kh_Think_t func); - -entity kh_worldkeylist; -.entity kh_worldkeynext; -#endif - -#ifdef IMPLEMENTATION float autocvar_g_balance_keyhunt_damageforcescale; float autocvar_g_balance_keyhunt_delay_collect; @@ -138,12 +82,6 @@ float kh_interferemsg_time, kh_interferemsg_team; float kh_key_dropped, kh_key_carried; const float ST_KH_CAPS = 1; -const float SP_KH_CAPS = 4; -const float SP_KH_PUSHES = 5; -const float SP_KH_DESTROYS = 6; -const float SP_KH_PICKUPS = 7; -const float SP_KH_KCKILLS = 8; -const float SP_KH_LOSSES = 9; void kh_ScoreRules(int teams) { ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); @@ -307,7 +245,7 @@ void kh_Key_Attach(entity key) // runs when a player picks up a key and several #endif key.flags = 0; key.solid = SOLID_NOT; - key.movetype = MOVETYPE_NONE; + set_movetype(key, MOVETYPE_NONE); key.team = key.owner.team; key.nextthink = time; key.damageforcescale = 0; @@ -346,7 +284,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs #endif key.flags = FL_ITEM; key.solid = SOLID_TRIGGER; - key.movetype = MOVETYPE_TOSS; + set_movetype(key, MOVETYPE_TOSS); key.pain_finished = time + autocvar_g_balance_keyhunt_delay_return; key.damageforcescale = autocvar_g_balance_keyhunt_damageforcescale; key.takedamage = DAMAGE_YES; @@ -505,7 +443,7 @@ void kh_Key_Collect(entity key, entity player) //a player picks up a dropped ke kh_Key_AssignTo(key, player); // this also updates .kh_state } -void kh_Key_Touch(entity this) // runs many, many times when a key has been dropped and can be picked up +void kh_Key_Touch(entity this, entity toucher) // runs many, many times when a key has been dropped and can be picked up { if(intermission_running) return; @@ -521,14 +459,14 @@ void kh_Key_Touch(entity this) // runs many, many times when a key has been dro // maybe start a shorter countdown? } - if (!IS_PLAYER(other)) + if (!IS_PLAYER(toucher)) return; - if(IS_DEAD(other)) + if(IS_DEAD(toucher)) return; - if(other == this.enemy) + if(toucher == this.enemy) if(time < this.kh_droptime + autocvar_g_balance_keyhunt_delay_collect) return; // you just dropped it! - kh_Key_Collect(this, other); + kh_Key_Collect(this, toucher); } void kh_Key_Remove(entity key) // runs after when all the keys have been collected or when a key has been dropped for more than X seconds @@ -558,7 +496,7 @@ void kh_Key_Remove(entity key) // runs after when all the keys have been collec } } - remove(key); + delete(key); kh_update_state(); } @@ -578,6 +516,8 @@ void kh_FinishRound() // runs when a team captures the keys kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound); } +void nades_GiveBonus(entity player, float score); + void kh_WinnerTeam(float teem) // runs when a team wins // Samual: Teem?.... TEEM?!?! what the fuck is wrong with you people { // all key carriers get some points @@ -959,9 +899,15 @@ void kh_WaitForPlayers() // delay start of the round until enough players are p } else { - float missing_teams_mask = boolean(p1) + boolean(p2) * 2; - if(kh_teams >= 3) missing_teams_mask += boolean(p3) * 4; - if(kh_teams >= 4) missing_teams_mask += boolean(p4) * 8; + int missing_teams_mask = 0; + if(kh_teams & BIT(0)) + missing_teams_mask += boolean(p1) * 1; + if(kh_teams & BIT(1)) + missing_teams_mask += boolean(p2) * 2; + if(kh_teams & BIT(2)) + missing_teams_mask += boolean(p3) * 4; + if(kh_teams & BIT(3)) + missing_teams_mask += boolean(p4) * 8; if(prev_missing_teams_mask != missing_teams_mask) { Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask); @@ -1093,7 +1039,7 @@ void kh_finalize() { // to be called before intermission kh_FinishRound(); - remove(kh_controller); + delete(kh_controller); kh_controller = NULL; } @@ -1141,7 +1087,7 @@ void havocbot_role_kh_carrier(entity this) if (!(this.kh_next)) { - LOG_TRACE("changing role to freelancer\n"); + LOG_TRACE("changing role to freelancer"); this.havocbot_role = havocbot_role_kh_freelancer; this.havocbot_role_timeout = 0; return; @@ -1168,7 +1114,7 @@ void havocbot_role_kh_defense(entity this) if (this.kh_next) { - LOG_TRACE("changing role to carrier\n"); + LOG_TRACE("changing role to carrier"); this.havocbot_role = havocbot_role_kh_carrier; this.havocbot_role_timeout = 0; return; @@ -1178,7 +1124,7 @@ void havocbot_role_kh_defense(entity this) this.havocbot_role_timeout = time + random() * 10 + 20; if (time > this.havocbot_role_timeout) { - LOG_TRACE("changing role to freelancer\n"); + LOG_TRACE("changing role to freelancer"); this.havocbot_role = havocbot_role_kh_freelancer; this.havocbot_role_timeout = 0; return; @@ -1209,7 +1155,7 @@ void havocbot_role_kh_offense(entity this) if (this.kh_next) { - LOG_TRACE("changing role to carrier\n"); + LOG_TRACE("changing role to carrier"); this.havocbot_role = havocbot_role_kh_carrier; this.havocbot_role_timeout = 0; return; @@ -1219,7 +1165,7 @@ void havocbot_role_kh_offense(entity this) this.havocbot_role_timeout = time + random() * 10 + 20; if (time > this.havocbot_role_timeout) { - LOG_TRACE("changing role to freelancer\n"); + LOG_TRACE("changing role to freelancer"); this.havocbot_role = havocbot_role_kh_freelancer; this.havocbot_role_timeout = 0; return; @@ -1251,7 +1197,7 @@ void havocbot_role_kh_freelancer(entity this) if (this.kh_next) { - LOG_TRACE("changing role to carrier\n"); + LOG_TRACE("changing role to carrier"); this.havocbot_role = havocbot_role_kh_carrier; this.havocbot_role_timeout = 0; return; @@ -1263,12 +1209,12 @@ void havocbot_role_kh_freelancer(entity this) { if (random() < 0.5) { - LOG_TRACE("changing role to offense\n"); + LOG_TRACE("changing role to offense"); this.havocbot_role = havocbot_role_kh_offense; } else { - LOG_TRACE("changing role to defense\n"); + LOG_TRACE("changing role to defense"); this.havocbot_role = havocbot_role_kh_defense; } this.havocbot_role_timeout = 0; @@ -1386,7 +1332,7 @@ MUTATOR_HOOKFUNCTION(kh, HavocBot_ChooseRole) MUTATOR_HOOKFUNCTION(kh, DropSpecialItems) { entity frag_target = M_ARGV(0, entity); - + kh_Key_DropAll(frag_target, false); } @@ -1394,5 +1340,3 @@ MUTATOR_HOOKFUNCTION(kh, reset_map_global) { kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round + (game_starttime - time), kh_StartRound); } - -#endif