Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions config/ui/hud/gamehud.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,16 @@ radar_icon = [

// flag bases
loop i $numflags [
do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red")) 0.01 ]
do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red")) 0.01 ]
]

// players
looplist cn (listclients 1 1) [
if (&& $radarteammates [! (isspectator $cn)] [= $cteam (getclientteam $cn)] [!=s $cn (? $isspectator $getfollow $getclientnum)] [! (getclientflag $cn)]) [
if (isdead $cn) [
do [ radar_icon @(getclientpos $cn) 0 (+s "blip_" (? (= (getclientteam $cn) 1) "blue" "red") "_dead") ]
do [ radar_icon @(getclientpos $cn) 0 (+s "blip_" (? (isteamblue (getclientteam $cn)) "blue" "red") "_dead") ]
] [
do [ radar_icon @(getclientpos $cn) (- $getcamyaw (getclientyaw $cn)) (+s "blip_" (? (= (getclientteam $cn) 1) "blue" "red") "_alive") ]
do [ radar_icon @(getclientpos $cn) (- $getcamyaw (getclientyaw $cn)) (+s "blip_" (? (isteamblue (getclientteam $cn)) "blue" "red") "_alive") ]
]
]
]
Expand All @@ -633,16 +633,16 @@ radar_icon = [
loop i $numflags [
case (flagstate $i) 0 [
// flag is at base
do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
] 1 [
// a player has the flag
if (< (mod $getmillis 1000) 500) [
do [ radar_icon @(getclientpos (flagowner $i)) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
do [ radar_icon @(getclientpos (flagowner $i)) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
]
] 2 [
// flag is dropped somewhere
if (< (mod $getmillis 300) 150) [
do [ radar_icon @(flagdroploc $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
do [ radar_icon @(flagdroploc $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ]
]
] // 3 - flag fell under the map, don't show icon
]
Expand Down Expand Up @@ -754,7 +754,7 @@ MAX_WEAPONS = 9
if (getclientflag $cn) [
uioffset 0 $uiPad:USS [
if (< (mod $getmillis 1000) 500) [
uiFastImg [<fade:0.85>] "hud/" "flag_" (? (= (getclientflag $cn) 1) "blue" "red") $uiPad:DM
uiFastImg [<fade:0.85>] "hud/" "flag_" (? (isteamblue (getclientflag $cn)) "blue" "red") $uiPad:DM
]
] ; uialign- 1 1
]
Expand Down Expand Up @@ -1187,6 +1187,11 @@ newui "scoreboard" [
] $n)
] ]

// 1:TEAM
.teamcolorindex = [
result (? (= $arg1 0) 0 (? (isteamblue $arg1) 1 2))
]

// 1:TEAM
.scoreboard.header = [
local bflip
Expand All @@ -1200,13 +1205,13 @@ newui "scoreboard" [
uispace $uiPad:M $uiPad:M- [
uiFancyText "wide" @@@(
at "FFA Aesir Vanir" $arg1
) 1.4 @@@(INT:TRANS (
at [0x40D060 0x4060D0 0xD04040] $arg1
) 1.4 (INT:TRANS (
at [0x40D060 0x4060D0 0xD04040] (.teamcolorindex @@@arg1)
) % 80)
] ; uialign- @@(? $bflip 1 -1) -1
uispace $uiPad:O5 (*f $uiPad:O5 2.9) [
uiFancyText "wide" (getteamscore @@@arg1) 1 @@@(
at [0x40D060 0x4060D0 0xD04040] $arg1
uiFancyText "wide" (getteamscore @@@arg1) 1 (
at [0x40D060 0x4060D0 0xD04040] (.teamcolorindex @@@arg1)
)
] ; uialign- @@(? $bflip -1 1) -1
if (numscoreboard @@arg1) [
Expand Down Expand Up @@ -1242,7 +1247,7 @@ newui "scoreboard" [
[0x303030 0x282828] // ffa
[0x1C2E70 0x122466] // aesir
[0x701C1C 0x661212] // vanir
] @arg1 (& $n 1)))
] (.teamcolorindex @arg1) (& $n 1)))
)] [ @(intmul 0x303840) ]) "hud/" "row" "" [
uifill @@(? $arg3 $arg3 $.sb_rowwidth)
@@(? $arg2 [ uigroup [ uiclamp.e ; @@arg2 ] ])
Expand Down
13 changes: 13 additions & 0 deletions config/ui/menus/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ uiMenu "settings" [
uiHorSld fullbrightmodels 0 200 1 [] [+s $$arg1 "%"]
]
uiBar 1 0 $uiPad:6XL $uiPad:2XL
uiOptionRow 0 [ uitext "Team colors" 0.6 ] 2 [
uivlist 0 [
uiButton "hold2" [
uiRadio [= $teamcolors 0]
uitext "^fs^f1Aesir^fr / ^f3Vanir" 0.6
] $uiPad:D6XL 0 [ teamcolors 0 ] -1
uiButton "hold2" [
uiRadio [= $teamcolors 1]
uitext "^fs^f1Your team^fr / ^f3Enemy team" 0.6
] $uiPad:D6XL 0 [ teamcolors 1 ] -1
]
]
uiBar 1 0 $uiPad:6XL $uiPad:2XL
uiOptionRow 0 [ uitext "Radar" 0.6 ] 2 [
uiButton "hold2" [
uiCheckbox $showminimap
Expand Down
15 changes: 9 additions & 6 deletions source/game/ctf.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ struct ctfclientmode : clientmode
{
if(checkovertime()) return;
startintermission();
sendservmsgf("%s%s \fs\f2team reached the score limit\fr", teamtextcode[team], teamnames[team]);
loopvj(clients) if(clients[j]->state.aitype == AI_NONE)
{
sendf(clients[j]->clientnum, 1, "ris", N_SERVMSG, tempformatstring("%s%s \fs\f2team reached the score limit\fr", getTeamTextCode(clients[j], team), teamnames[team]));
}
}
}

Expand Down Expand Up @@ -428,12 +431,12 @@ struct ctfclientmode : clientmode
}
}
if(!f.owner && f.droptime && f.droploc.x < 0) continue;
const char *flagname = f.team==1 ? "item/flag/azul" : "item/flag/rojo";
const char *flagname = isTeamBlue(f.team) ? "item/flag/azul" : "item/flag/rojo";
float angle;
vec pos = interpflagpos(f, angle);
rendermodel(flagname, ANIM_MAPMODEL|ANIM_LOOP, pos, angle, 0, 0, MDL_CULL_VFC | MDL_CULL_OCCLUDED);

vec lightcolor = vec::hexcolor(teameffectcolor[f.team]);
vec lightcolor = vec::hexcolor(getTeamEffectColorRGB(f.team));
addgamelight(pos, lightcolor.mul(255.f * (0.625f - 0.375f * cos(2 * PI * lastmillis / 1000.f))), 32);
if (self && self->state != CS_EDITING)
{
Expand All @@ -449,14 +452,14 @@ struct ctfclientmode : clientmode
if(hud->holdingflag && f.team == hud->team)
{
vec base = f.spawnloc;
particle_hud_mark(base, 2, 1, PART_GAME_ICONS, 1, teamtextcolor[hud->team], 4.0f);
particle_hud_mark(base, 2, 1, PART_GAME_ICONS, 1, getTeamTextColorRGB(hud->team), 4.0f);
}
else if(f.owner)
{
if(lastmillis%1000 >= 500) continue;
}
else if(f.droptime && (f.droploc.x < 0 || lastmillis%300 >= 150)) continue;
particle_hud_mark(pos, f.team == 1 ? 1 : 0, 0, PART_GAME_ICONS, 1, 0xFFFFFF, 2.0f);
particle_hud_mark(pos, isTeamBlue(f.team) ? 1 : 0, 0, PART_GAME_ICONS, 1, 0xFFFFFF, 2.0f);
}
}

Expand Down Expand Up @@ -552,7 +555,7 @@ struct ctfclientmode : clientmode

void flagexplosion(int i, int team, const vec &loc)
{
int fcolor = teameffectcolor[team];
int fcolor = getTeamEffectColorRGB(team);
particle_fireball(loc, 30, PART_EXPLOSION1, -1, fcolor, 4.8f);
particle_splash(PART_SPARK, 150, 300, loc, fcolor, 0.24f);
vec lightcolor = vec::hexcolor(fcolor);
Expand Down
14 changes: 10 additions & 4 deletions source/game/elimination.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ struct eliminationclientmode : clientmode
{
if(checkovertime()) return;
startintermission();
defformatstring(win, "%s%s \fs\f2team reached the score limit\fr", teamtextcode[winner], teamnames[winner]);
sendf(-1, 1, "ri2s", N_NOTICE, S_INVALID, win);
loopvj(clients) if(clients[j]->state.aitype == AI_NONE)
{
defformatstring(win, "%s%s \fs\f2team reached the score limit\fr", getTeamTextCode(clients[j], winner), teamnames[winner]);
sendf(clients[j]->clientnum, 1, "ri2s", N_NOTICE, S_INVALID, win);
}
}
else
{
defformatstring(win, "%s%s \f2team won the round", teamtextcode[winner], teamnames[winner]);
sendf(-1, 1, "ri2s", N_NOTICE, S_ROUND, win);
loopvj(clients) if(clients[j]->state.aitype == AI_NONE)
{
defformatstring(win, "%s%s \f2team won the round", getTeamTextCode(clients[j], winner), teamnames[winner]);
sendf(clients[j]->clientnum, 1, "ri2s", N_NOTICE, S_ROUND, win);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,13 +1424,13 @@ namespace game
const char *teamcolorname(gameent *d, const char *alt)
{
const int team = teamcolortext && m_teammode && validteam(d->team) ? d->team : 0;
return colorname(d, NULL, alt, teamtextcode[team]);
return colorname(d, NULL, alt, getTeamTextCode(team));
}

const char *teamcolor(const char *prefix, const char *suffix, int team, const char *alt)
{
if(!teamcolortext || !m_teammode || !validteam(team)) return alt;
return tempformatstring("\fs%s%s%s%s\fr", teamtextcode[team], prefix, teamnames[team], suffix);
return tempformatstring("\fs%s%s%s%s\fr", getTeamTextCode(team), prefix, teamnames[team], suffix);
}

void hurt(gameent* d)
Expand Down
27 changes: 19 additions & 8 deletions source/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ enum
N_PAUSEGAME, N_GAMESPEED,
N_ADDBOT, N_DELBOT, N_INITAI, N_FROMAI, N_BOTLIMIT, N_BOTBALANCE,
N_MAPCRC, N_CHECKMAPS,
N_SWITCHNAME, N_SWITCHMODEL, N_SWITCHCOLOR, N_SWITCHTEAM,
N_SWITCHNAME, N_SWITCHMODEL, N_SWITCHCOLOR, N_SWITCHTEAM, N_SWITCHTEAMCOLORS,
N_SERVCMD,
N_DEMOPACKET,
N_COUNTRY,
Expand Down Expand Up @@ -181,7 +181,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f
N_PAUSEGAME, 0, N_GAMESPEED, 0,
N_ADDBOT, 2, N_DELBOT, 1, N_INITAI, 0, N_FROMAI, 2, N_BOTLIMIT, 2, N_BOTBALANCE, 2,
N_MAPCRC, 0, N_CHECKMAPS, 1,
N_SWITCHNAME, 0, N_SWITCHMODEL, 2, N_SWITCHCOLOR, 2, N_SWITCHTEAM, 2,
N_SWITCHNAME, 0, N_SWITCHMODEL, 2, N_SWITCHCOLOR, 2, N_SWITCHTEAM, 2, N_SWITCHTEAMCOLORS, 2,
N_SERVCMD, 0,
N_DEMOPACKET, 0,
N_COUNTRY, 0,
Expand All @@ -191,7 +191,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f
#define VALHALLA_SERVER_PORT 21217
#define VALHALLA_LANINFO_PORT 21216
#define VALHALLA_MASTER_PORT 21215
#define PROTOCOL_VERSION 3 // bump when protocol changes
#define PROTOCOL_VERSION 4 // bump when protocol changes
#define DEMO_VERSION 1 // bump when demo format changes
#define DEMO_MAGIC "VALHALLA_DEMO\0\0"

Expand Down Expand Up @@ -550,13 +550,8 @@ const int MAXCOUNTRYCODELEN = 8;
const int MAXTEAMS = 2;
inline bool validteam(int team) { return team >= 1 && team <= MAXTEAMS; }
static const char * const teamnames[1+MAXTEAMS] = { "", "Aesir", "Vanir" };
static const char * const teamtextcode[1+MAXTEAMS] = { "\ff", "\f1", "\f3" };
static const char * const teamblipcolor[1+MAXTEAMS] = { "_neutral", "_blue", "_red" };
inline const char *teamname(int team) { return teamnames[validteam(team) ? team : 0]; }
static inline int teamnumber(const char *name) { loopi(MAXTEAMS) if(!strcmp(teamnames[1+i], name)) return 1+i; return 0; }
static const int teamtextcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x6496FF, 0xFF4B19 };
static const int teamscoreboardcolor[1+MAXTEAMS] = { 0, 0x3030C0, 0xC03030 };
static const int teameffectcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x2020FF, 0xFF2020 };

const int TAUNT_DELAY = 1000;
const int VOICECOM_DELAY = 2800;
Expand All @@ -583,6 +578,12 @@ enum Interaction
Count
};

enum TeamColors
{
Default = 0,
EnemyRed
};

namespace physics
{
struct SlideInfo
Expand Down Expand Up @@ -1310,6 +1311,16 @@ namespace game

extern const playermodelinfo &getplayermodelinfo(gameent *d);

#ifndef STANDALONE
extern int teamcolors;
extern bool isTeamBlue(int team);
extern const char *getTeamTextCode(int team);
extern const char *getTeamBlipColor(int team);
extern int getTeamTextColorRGB(int team);
extern int getTeamScoreboardColorRGB(int team);
extern int getTeamEffectColorRGB(int team);
#endif

// hud.cpp
extern void drawradar(const float x, const float y, const float s);
extern void setbliptex(const int team, const char* type = "");
Expand Down
15 changes: 8 additions & 7 deletions source/game/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ namespace game
void printteam()
{
if((self->clientnum >= 0 && !m_teammode) || !validteam(self->team)) conoutf(CON_ECHO, "\fs\f1You are not in a team\fr");
else conoutf("\fs\f1Your team is:\fr \fs%s%s\fr", teamtextcode[self->team], teamnames[self->team]);
else conoutf("\fs\f1Your team is:\fr \fs%s%s\fr", getTeamTextCode(self->team), teamnames[self->team]);
}
ICOMMAND(team, "sN", (char *s, int *numargs),
{
if(*numargs > 0) switchteam(s);
else if(!*numargs) printteam();
else if((self->clientnum < 0 || m_teammode) && validteam(self->team)) result(tempformatstring("\fs%s%s\fr", teamtextcode[self->team], teamnames[self->team]));
else if((self->clientnum < 0 || m_teammode) && validteam(self->team)) result(tempformatstring("\fs%s%s\fr", getTeamTextCode(self->team), teamnames[self->team]));
});
ICOMMAND(getteam, "", (), intret((self->clientnum < 0 || m_teammode) && validteam(self->team) ? self->team : 0));
ICOMMAND(getteamname, "i", (int *num), result(teamname(*num)));
ICOMMAND(getteamcolor, "", (), intret(teamtextcolor[m_teammode ? self->team : 0]));
ICOMMAND(getteamtextcode, "", (), result(teamtextcode[m_teammode ? self->team : 0]));
ICOMMAND(getteamcolor, "", (), intret(getTeamTextColorRGB(m_teammode ? self->team : 0)));
ICOMMAND(getteamtextcode, "", (), result(getTeamTextCode(m_teammode ? self->team : 0)));

struct authkey
{
Expand Down Expand Up @@ -1176,9 +1176,9 @@ namespace game
}
else
{
textColor = teamtextcode[team];
textColor = getTeamTextCode(team);
}
conoutf(CON_CHAT, "%s \fs%s(team)\fr: \fs%s%s\fr", d->name, teamtextcode[team], textColor, text);
conoutf(CON_CHAT, "%s \fs%s(team)\fr: \fs%s%s\fr", d->name, getTeamTextCode(team), textColor, text);
playchatsound(d, isMention);
}

Expand Down Expand Up @@ -1427,6 +1427,7 @@ namespace game
sendstring(self->name, p);
putint(p, self->playermodel);
putint(p, self->playercolor);
putint(p, teamcolors);
sendstring(self->preferred_flag, p);
string hash = "";
if(connectpass[0])
Expand Down Expand Up @@ -2459,7 +2460,7 @@ namespace game
w->team = validteam(team) ? team : 0;
static const char * const fmt[2] = { "%s \fs\f0switched to team\fr %s%s", "%s \fs\f0forced to team\fr %s%s"};
if(reason >= 0 && size_t(reason) < sizeof(fmt)/sizeof(fmt[0]))
conoutf(fmt[reason], colorname(w), teamtextcode[w->team], teamnames[w->team]);
conoutf(fmt[reason], colorname(w), getTeamTextCode(w->team), teamnames[w->team]);
break;
}

Expand Down
Loading