diff --git a/source/cl_parse.c b/source/cl_parse.c index 5ebe148..b697d36 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1530,6 +1530,10 @@ void CL_ParseServerMessage (void) case svc_limbupdate: CL_ParseLimbUpdate(); break; + + case svc_achievement: + HUD_Parse_Achievement (MSG_ReadByte()); + break; //case svc_bspdecal: // CL_ParseBSPDecal (); diff --git a/source/gl_hud.c b/source/gl_hud.c index 89c4bc0..5951338 100644 --- a/source/gl_hud.c +++ b/source/gl_hud.c @@ -1269,6 +1269,62 @@ void HUD_ProgressBar (void) //============================================================================= +/* +=============== +HUD_Achievement + +Achievements based on code by Arkage +=============== +*/ + + +int achievement; // the background image +int achievement_unlocked; +char achievement_text[MAX_QPATH]; +double achievement_time; +float smallsec; +int ach_pic; + +//sb FIXME! +achievement_list_t achievement_list[MAX_ACHIEVEMENTS]; +qpic_t *achievement_locked; + +void HUD_Achievement (void) +{ + + if (achievement_unlocked == 1) + { + smallsec = smallsec + 0.7; + if (smallsec >= 55) + smallsec = 55; + //Background image + //Sbar_DrawPic (176, 5, achievement); + // The achievement text + Draw_AlphaStretchPic (30, smallsec - 50, 200, 100, 0.7f, achievement_list[ach_pic].img); + } + + // Reset the achievement + if (Sys_DoubleTime() >= achievement_time) + { + achievement_unlocked = 0; + } + +} + +void HUD_Parse_Achievement (int ach) +{ + if (achievement_list[ach].unlocked) + return; + + achievement_unlocked = 1; + smallsec = 0; + achievement_time = Sys_DoubleTime() + 10; + ach_pic = ach; + achievement_list[ach].unlocked = 1; + //Save_Achivements(); +} + +//============================================================================= /* =============== diff --git a/source/gl_hud.h b/source/gl_hud.h index 307e34d..65fbfc4 100644 --- a/source/gl_hud.h +++ b/source/gl_hud.h @@ -25,4 +25,21 @@ void HUD_Draw (void); void HUD_Init (void); -void HUD_NewMap (void); \ No newline at end of file +void HUD_NewMap (void); + +//achievement stuff +#define MAX_ACHIEVEMENTS 5//23 +typedef struct achievement_list_s +{ + qpic_t *img; + int unlocked; + char name[64]; + char description[256]; + int progress; +} achievement_list_t; + +void Achievement_Init (void); +extern achievement_list_t achievement_list[MAX_ACHIEVEMENTS]; +extern qpic_t *achievement_locked; + +void HUD_Parse_Achievement (int ach); \ No newline at end of file diff --git a/source/pr_cmds.c b/source/pr_cmds.c index edd39b0..0755021 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -1236,6 +1236,37 @@ static void PF_Remove (void) ED_Free (ed); } +/* +================= +PF_achievement + +unlocks the achievement number for entity + +achievement(clientent, value) +================= +*/ +void PF_achievement (void) +{ + int ach; + client_t *client; + int entnum; + + entnum = G_EDICTNUM(OFS_PARM0); + ach = G_FLOAT(OFS_PARM1); + + if (entnum < 1 || entnum > svs.maxclients) + { + Con_DPrintf ("tried to unlock ach to a non-client\n"); + return; + } + + //Con_Printf (va("Achievement? %i\n", ach)); // JPG + client = &svs.clients[entnum-1]; + + MSG_WriteByte (&client->message,svc_achievement); + MSG_WriteByte (&client->message, ach); +} + /* ================= @@ -3272,7 +3303,7 @@ static builtin_t pr_builtin[] = PF_precache_sound, // #76 precache_sound2 is different only for qcc PF_precache_file, // #77 PF_setspawnparms, // #78 - NULL, // #79 + PF_achievement, // #79 NULL, // #80 PF_stof, // #81 NULL, // #82 diff --git a/source/protocol.h b/source/protocol.h index 4fe51ae..90a6700 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -213,6 +213,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //johnfitz #define svc_limbupdate 51 +#define svc_achievement 52 // [string] name [byte] decal_size [coords] pos #define svc_updatekills 53 // [string] to put in center of the screen //