void CG_LimboPanel_ClassBar_Draw(panel_button_t *button) { const char *text = NULL; char buffer[64]; float w; if (CG_LimboPanel_GetTeam() == TEAM_SPECTATOR) { text = "JOIN A TEAM"; } else if (BG_CursorInRect(&classButton0.rect)) { text = BG_ClassnameForNumber(0); } else if (BG_CursorInRect(&classButton1.rect)) { text = BG_ClassnameForNumber(1); } else if (BG_CursorInRect(&classButton2.rect)) { text = BG_ClassnameForNumber(2); } else if (BG_CursorInRect(&classButton3.rect)) { text = BG_ClassnameForNumber(3); } else if (BG_CursorInRect(&classButton4.rect)) { text = BG_ClassnameForNumber(4); } if (!text) { text = BG_ClassnameForNumber(CG_LimboPanel_GetClass()); } Q_strncpyz(buffer, text, sizeof (buffer)); Q_strupr(buffer); w = CG_Text_Width_Ext(buffer, button->font->scalex, 0, button->font->font); CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex, button->font->scaley, button->font->colour, buffer, 0, 0, button->font->style, button->font->font); }
/* ======================= G_RegisterPlayerClasses ======================= */ void G_RegisterPlayerClasses(void) { bg_playerclass_t *classInfo; bg_character_t *character; int team, cls; for (team = TEAM_AXIS; team <= TEAM_ALLIES; team++) { for (cls = PC_SOLDIER; cls < NUM_PLAYER_CLASSES; cls++) { classInfo = BG_GetPlayerClassInfo(team, cls); character = BG_GetCharacter(team, cls); Q_strncpyz(character->characterFile, classInfo->characterFile, sizeof(character->characterFile)); if (!G_RegisterCharacter(character->characterFile, character)) { G_Error("ERROR: G_RegisterPlayerClasses: failed to load character file '%s' for the %s %s\n", character->characterFile, (team == TEAM_AXIS ? "Axis" : "Allied"), BG_ClassnameForNumber(classInfo->classNum)); } } } }
/** * @brief Sends an class setup message. Enables etpro like classscripts */ void CG_Class_f(void) { char cls[64]; const char *classtype, *teamstring; int weapon1, weapon2, playerclass; bg_playerclass_t *classinfo; team_t team; if (cg.demoPlayback) { return; } team = cgs.clientinfo[cg.clientNum].team; if (team == TEAM_SPECTATOR) { return; } if (trap_Argc() < 2) { CG_Printf("Invalid command format.\n"); return; } switch (team) { case TEAM_AXIS: classtype = "r"; teamstring = CG_TranslateString("Axis"); break; case TEAM_ALLIES: classtype = "b"; teamstring = CG_TranslateString("Allies"); break; default: CG_Printf("Invalid team.\n"); return; } trap_Argv(1, cls, 64); if (!Q_stricmp(cls, "s") || !Q_stricmp(cls, "0")) { playerclass = PC_SOLDIER; } else if (!Q_stricmp(cls, "m") || !Q_stricmp(cls, "1")) { playerclass = PC_MEDIC; } else if (!Q_stricmp(cls, "e") || !Q_stricmp(cls, "2")) { playerclass = PC_ENGINEER; } else if (!Q_stricmp(cls, "f") || !Q_stricmp(cls, "3")) { playerclass = PC_FIELDOPS; } else if (!Q_stricmp(cls, "c") || !Q_stricmp(cls, "4")) { playerclass = PC_COVERTOPS; } else { CG_Printf("Invalid class format.\n"); return; } classinfo = BG_GetPlayerClassInfo(team, playerclass); if (trap_Argc() > 2) { trap_Argv(2, cls, 64); weapon1 = atoi(cls); if (weapon1 <= 0 || weapon1 > MAX_WEAPS_PER_CLASS) { weapon1 = classinfo->classWeapons[0]; } else if (!classinfo->classWeapons[weapon1 - 1]) { CG_Printf("Invalid command format for weapon.\n"); return; } else { weapon1 = classinfo->classWeapons[weapon1 - 1]; } } else { weapon1 = classinfo->classWeapons[0]; } if (trap_Argc() > 3) { trap_Argv(3, cls, 64); weapon2 = atoi(cls); weapon2 = CG_GetSecondaryWeapon(weapon2, team, playerclass); } else { weapon2 = CG_GetSecondaryWeapon(-1, team, playerclass); } // Print out the selected class and weapon info if (cgs.clientinfo[cg.clientNum].skill[SK_HEAVY_WEAPONS] >= 4 && playerclass == PC_SOLDIER && !Q_stricmp(weaponTable[weapon1].desc, weaponTable[weapon2].desc)) { CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc), 400, cg_fontScaleCP.value, -1); } else { switch (weapon2) { case WP_AKIMBO_COLT: case WP_AKIMBO_LUGER: case WP_AKIMBO_SILENCEDCOLT: case WP_AKIMBO_SILENCEDLUGER: CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s and %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc, weaponTable[weapon2].desc), 400, cg_fontScaleCP.value, -1); break; default: CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s and a %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc, weaponTable[weapon2].desc), 400, cg_fontScaleCP.value, -1); break; } } // Send the switch command to the server trap_SendClientCommand(va("team %s %i %i %i\n", classtype, playerclass, weapon1, weapon2)); }
void CG_LimboPanel_SendSetupMsg(qboolean forceteam) { weapon_t weap1, weap2; const char *str; team_t team; weaponType_t *wt; if (forceteam) { team = CG_LimboPanel_GetTeam(); } else { team = cgs.clientinfo[cg.clientNum].team; } if (team == TEAM_SPECTATOR) { if (forceteam) { if (cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR) { trap_SendClientCommand("team s 0 0 0\n"); } CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return; } weap1 = CG_LimboPanel_GetSelectedWeaponForSlot(1); weap2 = CG_LimboPanel_GetSelectedWeaponForSlot(0); switch (team) { case TEAM_AXIS: str = "r"; break; case TEAM_ALLIES: str = "b"; break; default: str = NULL; // rain - don't go spec break; } // rain - if this happens, we're dazed and confused, abort if (!str) { return; } trap_SendClientCommand(va("team %s %i %i %i\n", str, CG_LimboPanel_GetClass(), weap1, weap2)); if (forceteam) { CG_EventHandling(CGAME_EVENT_NONE, qfalse); } // print center message switch (CG_LimboPanel_GetTeam()) { case TEAM_AXIS: str = "Axis"; break; case TEAM_ALLIES: str = "Allied"; break; default: // rain - added default str = "unknown"; break; } wt = WM_FindWeaponTypeForWeapon(weap1); CG_PriorityCenterPrint(va("You will spawn as an %s %s with a %s.", str, BG_ClassnameForNumber(CG_LimboPanel_GetClass()), wt ? wt->desc : "^1UNKNOWN WEAPON"), SCREEN_HEIGHT - 88, SMALLCHAR_WIDTH, -1); cgs.limboLoadoutSelected = qtrue; cgs.limboLoadoutModified = qtrue; }
/** * @brief Sends an class setup message. Enables etpro like classscripts */ void CG_Class_f(void) { char cls[64]; const char *classtype, *teamstring; int weapon1, weapon2, playerclass; bg_playerclass_t *classinfo; team_t team; weaponType_t *wt; if (cg.demoPlayback) { return; } team = cgs.clientinfo[cg.clientNum].team; if (team == TEAM_SPECTATOR) { return; } if (trap_Argc() < 2) { CG_Printf("Invalid command format.\n"); return; } switch (team) { case TEAM_AXIS: classtype = "r"; teamstring = "Axis"; break; case TEAM_ALLIES: classtype = "b"; teamstring = "Allies"; break; default: CG_Printf("Invalid team.\n"); return; } trap_Argv(1, cls, 64); if (!Q_stricmp(cls, "s")) { playerclass = PC_SOLDIER; } else if (!Q_stricmp(cls, "m")) { playerclass = PC_MEDIC; } else if (!Q_stricmp(cls, "e")) { playerclass = PC_ENGINEER; } else if (!Q_stricmp(cls, "f")) { playerclass = PC_FIELDOPS; } else if (!Q_stricmp(cls, "c")) { playerclass = PC_COVERTOPS; } else { CG_Printf("Invalid class format.\n"); return; } classinfo = BG_GetPlayerClassInfo(team, playerclass); if (trap_Argc() > 2) { trap_Argv(2, cls, 64); weapon1 = atoi(cls); if (!classinfo->classWeapons[weapon1 - 1]) { CG_Printf("Invalid command format for weapon.\n"); return; } } else { weapon1 = 1; } if (cgs.clientinfo[cg.clientNum].skill[SK_HEAVY_WEAPONS] >= 4 && playerclass == PC_SOLDIER) { weapon2 = (team == TEAM_AXIS) ? WP_MP40 : WP_THOMPSON; } else if (cgs.clientinfo[cg.clientNum].skill[SK_LIGHT_WEAPONS] >= 4) { if (playerclass == PC_COVERTOPS) { weapon2 = (team == TEAM_AXIS) ? WP_AKIMBO_SILENCEDLUGER : WP_AKIMBO_SILENCEDCOLT; } else { weapon2 = (team == TEAM_AXIS) ? WP_AKIMBO_LUGER : WP_AKIMBO_COLT; } } else { if (playerclass == PC_COVERTOPS) { weapon2 = (team == TEAM_AXIS) ? WP_SILENCER : WP_SILENCED_COLT; } else { weapon2 = (team == TEAM_AXIS) ? WP_LUGER : WP_COLT; } } // Print out the selected class and weapon info wt = WM_FindWeaponTypeForWeapon(classinfo->classWeapons[weapon1 - 1]); CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as a %s %s with a %s."), teamstring, BG_ClassnameForNumber(playerclass), wt ? wt->desc : "^1UNKNOWN WEAPON"), SCREEN_HEIGHT - 88, SMALLCHAR_WIDTH, -1); // Send the switch command to the server trap_SendClientCommand(va("team %s %i %i %i\n", classtype, playerclass, classinfo->classWeapons[weapon1 - 1], weapon2)); }