Skip to content

Commit

Permalink
cgame: add cg_itemFx
Browse files Browse the repository at this point in the history
bitmask. 1-bob 2-rotate 4-spawn scale
  • Loading branch information
yumirak committed Mar 6, 2024
1 parent a44ff86 commit 433e81b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
27 changes: 20 additions & 7 deletions code/cgame/cg_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,24 @@ static void CG_Item( centity_t *cent ) {

// items bob up and down continuously
scale = 0.005 + cent->currentState.number * 0.00001;
cent->lerpOrigin[2] += 4 + cos( ( cg.time + 1000 ) * scale ) * 4;
if (cg_itemFx.integer & 0x1) {
cent->lerpOrigin[2] += 4 + cos( ( cg.time + 1000 ) * scale ) * 4;
}

memset (&ent, 0, sizeof(ent));

// autorotate at one of two speeds
if ( item->giType == IT_HEALTH ) {
VectorCopy( cg.autoAnglesFast, cent->lerpAngles );
AxisCopy( cg.autoAxisFast, ent.axis );
if (cg_itemFx.integer & 0x2) {
if ( item->giType == IT_HEALTH ) {
VectorCopy( cg.autoAnglesFast, cent->lerpAngles );
AxisCopy( cg.autoAxisFast, ent.axis );
} else {
VectorCopy( cg.autoAngles, cent->lerpAngles );
AxisCopy( cg.autoAxis, ent.axis );
}
} else {
VectorCopy( cg.autoAngles, cent->lerpAngles );
AxisCopy( cg.autoAxis, ent.axis );
VectorCopy(cent->currentState.apos.trBase, cent->lerpAngles);
AnglesToAxis(cent->lerpAngles, ent.axis);
}

wi = NULL;
Expand Down Expand Up @@ -317,14 +324,20 @@ static void CG_Item( centity_t *cent ) {

// if just respawned, slowly scale up
msec = cg.time - cent->miscTime;
if ( msec >= 0 && msec < ITEM_SCALEUP_TIME ) {
if (msec >= 0 && msec < ITEM_SCALEUP_TIME && cg_itemFx.integer & 0x4) {
frac = (float)msec / ITEM_SCALEUP_TIME;
frac *= cg_itemSize.value;
VectorScale( ent.axis[0], frac, ent.axis[0] );
VectorScale( ent.axis[1], frac, ent.axis[1] );
VectorScale( ent.axis[2], frac, ent.axis[2] );
ent.nonNormalizedAxes = qtrue;
} else {
frac = 1.0;
frac *= cg_itemSize.value;
VectorScale( ent.axis[0], frac, ent.axis[0] );
VectorScale( ent.axis[1], frac, ent.axis[1] );
VectorScale( ent.axis[2], frac, ent.axis[2] );
ent.nonNormalizedAxes = qtrue;
}

// items without glow textures need to keep a minimum light value
Expand Down
3 changes: 2 additions & 1 deletion code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,8 @@ extern vmCvar_t cg_damagePlum;
extern vmCvar_t cg_damagePlumStyle;
extern vmCvar_t cg_damagePlumSize;
//

extern vmCvar_t cg_itemFx;
extern vmCvar_t cg_itemSize;

//
// cg_main.c
Expand Down
7 changes: 7 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ vmCvar_t cg_damagePlum;
vmCvar_t cg_damagePlumStyle;
vmCvar_t cg_damagePlumSize;
//
vmCvar_t cg_itemFx;
vmCvar_t cg_itemSize;


typedef struct {
vmCvar_t *vmCvar;
char *cvarName;
Expand Down Expand Up @@ -416,6 +420,9 @@ static cvarTable_t cvarTable[] = {
{ &cg_damagePlum, "cg_damagePlum", "1", CVAR_USERINFO | CVAR_ARCHIVE},
{ &cg_damagePlumStyle, "cg_damagePlumColorStyle", "1", CVAR_USERINFO | CVAR_ARCHIVE},
{ &cg_damagePlumSize, "cg_damagePlumSize", "8", CVAR_USERINFO | CVAR_ARCHIVE},
//
{ &cg_itemFx, "cg_itemFx", "7", CVAR_ARCHIVE },
{ &cg_itemSize, "cg_itemSize", "1.0", CVAR_ARCHIVE },
// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }
};

Expand Down

0 comments on commit 433e81b

Please sign in to comment.