.float siren_time; // time delay the siren
//.float stuff_time; // time delay to stuffcmd a cvar
-float test[17] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-//test[0] = status of dropped keys, test[1 - 16] = player #
+float kh_keystatus[17];
+//kh_keystatus[0] = status of dropped keys, kh_keystatus[1 - 16] = player #
//replace 17 with cvar("maxplayers") or similar !!!!!!!!!
//for(i = 0; i < maxplayers; ++i)
-// test[i] = "0";
+// kh_keystatus[i] = "0";
float kh_Team_ByID(float t)
{
- if(t == 0) return COLOR_TEAM1;
- if(t == 1) return COLOR_TEAM2;
- if(t == 2) return COLOR_TEAM3;
- if(t == 3) return COLOR_TEAM4;
+ if(t == 0) return FL_TEAM_1;
+ if(t == 1) return FL_TEAM_2;
+ if(t == 2) return FL_TEAM_3;
+ if(t == 3) return FL_TEAM_4;
return 0;
}
.float kh_dropperteam;
.entity kh_previous_owner;
.float kh_previous_owner_playerid;
+.float kh_cp_duration;
string kh_sound_capture = "kh/capture.wav";
string kh_sound_destroy = "kh/destroy.wav";
var kh_Think_t kh_Controller_Thinkfunc;
-void kh_Controller_SetThink(float t, string msg, kh_Think_t func) // runs occasionaly
+void kh_Controller_SetThink(float t, string msg, float centerprint_duration, kh_Think_t func) // runs occasionaly
{
kh_Controller_Thinkfunc = func;
kh_controller.cnt = ceil(t);
if(msg == "")
kh_Controller_Waitmsg = "";
else
+ {
+ kh_controller.kh_cp_duration = centerprint_duration;
kh_Controller_Waitmsg = strzone(msg);
+ }
if(t == 0)
kh_controller.nextthink = time; // force
}
+void kh_Controller_SetThink_NoMsg(float t, kh_Think_t func) // runs occasionaly
+{
+ kh_Controller_SetThink(t, "", 0, func);
+}
void kh_Controller_Think() // called a lot
{
//dprint(s, "\n");
- // TODO limit centerprint spam and set the appropriated duration for each centerprinted msg
FOR_EACH_PLAYER(e)
if(clienttype(e) == CLIENTTYPE_REAL)
- Send_CSQC_Centerprint_Generic(e, CPID_KH_MSG, s, 2, 0); // duration > 1 works with all the messages
+ Send_CSQC_Centerprint_Generic(e, CPID_KH_MSG, s, self.kh_cp_duration, 0);
}
self.cnt -= 1;
}
key.kh_next.kh_prev = key;
float i;
- i = test[key.owner.playerid];
+ i = kh_keystatus[key.owner.playerid];
if(key.netname == "^1red key")
i += 1;
if(key.netname == "^4blue key")
i += 4;
if(key.netname == "^6pink key")
i += 8;
- test[key.owner.playerid] = i;
+ kh_keystatus[key.owner.playerid] = i;
kh_Key_Attach(key);
WaypointSprite_AttachCarrier("", player, RADARICON_FLAGCARRIER, colormapPaletteColor(player.team - 1, 0));
player.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = kh_KeyCarrier_waypointsprite_visible_for_player;
WaypointSprite_UpdateRule(player.waypointsprite_attachedforcarrier, player.team, SPRITERULE_TEAMPLAY);
- if(player.team == COLOR_TEAM1)
+ if(player.team == FL_TEAM_1)
WaypointSprite_UpdateSprites(player.waypointsprite_attachedforcarrier, "keycarrier-red", "keycarrier-friend", "keycarrier-red");
- else if(player.team == COLOR_TEAM2)
+ else if(player.team == FL_TEAM_2)
WaypointSprite_UpdateSprites(player.waypointsprite_attachedforcarrier, "keycarrier-blue", "keycarrier-friend", "keycarrier-blue");
- else if(player.team == COLOR_TEAM3)
+ else if(player.team == FL_TEAM_3)
WaypointSprite_UpdateSprites(player.waypointsprite_attachedforcarrier, "keycarrier-yellow", "keycarrier-friend", "keycarrier-yellow");
- else if(player.team == COLOR_TEAM4)
+ else if(player.team == FL_TEAM_4)
WaypointSprite_UpdateSprites(player.waypointsprite_attachedforcarrier, "keycarrier-pink", "keycarrier-friend", "keycarrier-pink");
if(!kh_no_radar_circles)
WaypointSprite_Ping(player.waypointsprite_attachedforcarrier);
{
if(self.owner)
return;
+ if(ITEM_DAMAGE_NEEDKILL(deathtype))
+ {
+ // touching lava, or hurt trigger
+ // what shall we do?
+ // immediately return is bad
+ // maybe start a shorter countdown?
+ }
if(vlen(force) <= 0)
return;
if(time > self.pushltime)
void kh_Key_Collect(entity key, entity player) //a player picks up a dropped key
{
- sound(player, CHAN_AUTO, kh_sound_collect, VOL_BASE, ATTN_NORM);
+ sound(player, CH_TRIGGER, kh_sound_collect, VOL_BASE, ATTN_NORM);
if(key.kh_dropperteam != player.team)
{
if(self.owner) // already carried
return;
+
+ if(ITEM_TOUCH_NEEDKILL())
+ {
+ // touching sky, or nodrop
+ // what shall we do?
+ // immediately return is bad
+ // maybe start a shorter countdown?
+ }
+
if(other.classname != "player")
return;
if(other.deadflag != DEAD_NO)
kh_Key_Remove(key);
kh_no_radar_circles = FALSE;
- kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", kh_StartRound);
+ kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", 1, kh_StartRound);
}
void kh_WinnerTeam(float teem) // runs when a team wins
bprint(key.owner.netname);
first = FALSE;
}
- bprint("^7 captured the keys for the ", ColoredTeamName(teem), "\n");
+ bprint("^7 captured the keys for the ", Team_ColoredFullName(teem), "\n");
first = TRUE;
midpoint = '0 0 0';
+ firstorigin = '0 0 0';
+ lastorigin = '0 0 0';
FOR_EACH_KH_KEY(key)
{
vector thisorigin;
te_lightning2(world, lastorigin, firstorigin);
}
midpoint = midpoint * (1 / kh_teams);
- te_customflash(midpoint, 1000, 1, TeamColor(teem) * 0.5 + '0.5 0.5 0.5'); // make the color >=0.5 in each component
+ te_customflash(midpoint, 1000, 1, Team_ColorRGB(teem) * 0.5 + '0.5 0.5 0.5'); // make the color >=0.5 in each component
play2all(kh_sound_capture);
kh_FinishRound();
kh_Scores_Event(attacker, world, "push", autocvar_g_balance_keyhunt_score_push, 0);
PlayerScore_Add(attacker, SP_KH_PUSHES, 1);
centerprint(attacker, "Your push is the best!");
- bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, "^7 when ", attacker.netname, "^7 came\n");
+ bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "^7 when ", attacker.netname, "^7 came\n");
}
else
{
--j;
}
- bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, "\n");
+ bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "\n");
}
play2all(kh_sound_destroy);
te_tarexplosion(lostkey.origin);
{
if(self.siren_time < time)
{
- sound(self.owner, CHAN_AUTO, kh_sound_alarm, VOL_BASE, ATTN_NORM); // play a simple alarm
+ sound(self.owner, CH_TRIGGER, kh_sound_alarm, VOL_BASE, ATTN_NORM); // play a simple alarm
self.siren_time = time + 2.5; // repeat every 2.5 seconds
}
else
Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, "All keys are in your team's hands!\n\nHelp the key carriers to meet!", 0, 0);
else
- Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, strcat("All keys are in the ", ColoredTeamName(kh_interferemsg_team), "^7's hands!\n\nInterfere ^1NOW^7!"), 0, 0);
+ Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, strcat("All keys are in the ", Team_ColoredFullName(kh_interferemsg_team), "^7's hands!\n\nInterfere ^1NOW^7!"), 0, 0);
}
}
key.kh_dropperteam = 0;
key.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
setsize(key, KH_KEY_MIN, KH_KEY_MAX);
- key.colormod = TeamColor(initial_owner.team) * KH_KEY_BRIGHTNESS;
+ key.colormod = Team_ColorRGB(initial_owner.team) * KH_KEY_BRIGHTNESS;
key.reset = key_reset;
switch(initial_owner.team)
{
- case COLOR_TEAM1:
+ case FL_TEAM_1:
key.netname = "^1red key";
break;
- case COLOR_TEAM2:
+ case FL_TEAM_2:
key.netname = "^4blue key";
break;
- case COLOR_TEAM3:
+ case FL_TEAM_3:
key.netname = "^3yellow key";
break;
- case COLOR_TEAM4:
+ case FL_TEAM_4:
key.netname = "^6pink key";
break;
default:
key.pushltime = time + autocvar_g_balance_keyhunt_protecttime;
key.kh_dropperteam = key.team;
- sound(player, CHAN_AUTO, kh_sound_drop, VOL_BASE, ATTN_NORM);
+ sound(player, CH_TRIGGER, kh_sound_drop, VOL_BASE, ATTN_NORM);
}
void kh_Key_DropAll(entity player, float suicide) // runs whenever a player dies
if(suicide)
key.kh_dropperteam = player.team;
}
- sound(player, CHAN_AUTO, kh_sound_drop, VOL_BASE, ATTN_NORM);
+ sound(player, CH_TRIGGER, kh_sound_drop, VOL_BASE, ATTN_NORM);
}
}
{
if(result != "")
result = strcat(result, ", ");
- result = strcat(result, ColoredTeamName(teem));
+ result = strcat(result, Team_ColoredFullName(teem));
}
}
return result;
if(time < game_starttime)
{
- kh_Controller_SetThink(game_starttime - time + 0.1, "", kh_WaitForPlayers);
+ kh_Controller_SetThink_NoMsg(game_starttime - time + 0.1, kh_WaitForPlayers);
return;
}
teams_missing = kh_CheckEnoughPlayers();
if(teams_missing == "")
- kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", kh_StartRound);
+ kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", 1, kh_StartRound);
else
- kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), kh_WaitForPlayers);
+ kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers);
}
void kh_EnableTrackingDevice() // runs after each round
if(time < game_starttime)
{
- kh_Controller_SetThink(game_starttime - time + 0.1, "", kh_WaitForPlayers);
+ kh_Controller_SetThink_NoMsg(game_starttime - time + 0.1, kh_WaitForPlayers);
return;
}
teams_missing = kh_CheckEnoughPlayers();
if(teams_missing != "")
{
- kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), kh_WaitForPlayers);
+ kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers);
return;
}
{
teem = kh_Team_ByID(i);
players = 0;
- entity my_player;
+ entity my_player = world;
FOR_EACH_PLAYER(player)
if(player.deadflag == DEAD_NO)
if(!player.BUTTON_CHAT)
}
kh_tracking_enabled = FALSE;
- kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, "Scanning frequency range...", kh_EnableTrackingDevice);
+ kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, "Scanning frequency range...", -1, kh_EnableTrackingDevice);
}
float kh_HandleFrags(entity attacker, entity targ, float f) // adds to the player score
// make a KH entity for controlling the game
kh_controller = spawn();
kh_controller.think = kh_Controller_Think;
- kh_Controller_SetThink(0, "", kh_WaitForPlayers);
+ kh_Controller_SetThink_NoMsg(0, kh_WaitForPlayers);
setmodel(kh_controller, "models/keyhunt/key.md3");
kh_key_dropped = kh_controller.modelindex;
{
if(self == other)
kh_Key_DropAll(self, TRUE);
- else if(other.classname == "player" || other.classname == "gib")
+ else if(other.classname == "player")
kh_Key_DropAll(self, FALSE);
else
kh_Key_DropAll(self, TRUE);
{
if(time > 1) // game loads at time 1
error("This is a game type and it cannot be added at runtime.");
- g_keyhunt = 1;
kh_Initialize();
}
MUTATOR_ONREMOVE
{
- g_keyhunt = 0;
error("This is a game type and it cannot be removed at runtime.");
}