Merge pull request #20 from ScatterBox/main

This commit is contained in:
Ian 2023-01-22 21:06:17 -05:00 committed by GitHub
commit 97824fb1aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 2 deletions

View file

@ -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 ();

View file

@ -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();
}
//=============================================================================
/*
===============

View file

@ -25,4 +25,21 @@ void HUD_Draw (void);
void HUD_Init (void);
void HUD_NewMap (void);
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);

View file

@ -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

View file

@ -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
//