game: Add BoB effect for items support

Based on:
 * https://github.com/Paril/q2pro.git
This commit is contained in:
Denis Pauk 2024-11-26 23:36:57 +02:00
parent c7f74a3fa6
commit 58363c6696
8 changed files with 20 additions and 12 deletions

View file

@ -253,6 +253,8 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
or other source of `localization/loc_english.txt` like file.
Defaults to `english`.
* **g_itemsbobeffect**: Bob effect of items like in ReRelease. Defaults to `0`.
* **g_swap_speed**: Sets the speed of the "changing weapon" animation.
Default is `1`. If set to `2`, it will be double the speed, `3` is
the triple... up until the max of `8`, since there are at least 2

View file

@ -34,7 +34,7 @@ CL_AddPacketEntities(frame_t *frame)
{
entity_t ent = {0};
entity_state_t *s1;
float autorotate;
float autorotate, autobob;
int i;
int pnum;
centity_t *cent;
@ -49,6 +49,7 @@ CL_AddPacketEntities(frame_t *frame)
/* brush models can auto animate their frames */
autoanim = 2 * cl.time / 1000;
autobob = 5 * sinf(cl.time / 400.0f);
for (pnum = 0; pnum < frame->num_entities; pnum++)
{
@ -138,6 +139,11 @@ CL_AddPacketEntities(frame_t *frame)
}
}
if (effects & EF_BOB) {
ent.origin[2] += autobob;
ent.oldorigin[2] += autobob;
}
/* tweak the color of beams */
if (renderfx & RF_BEAM)
{

View file

@ -692,6 +692,7 @@ typedef struct
* it has a zero index model. */
#define EF_ROTATE 0x00000001 /* rotate (bonus items) */
#define EF_GIB 0x00000002 /* leave a trail */
#define EF_BOB 0x00000004 /* ReRelease BoB effect */
#define EF_BLASTER 0x00000008 /* redlight + trail */
#define EF_ROCKET 0x00000010 /* redlight + trail */
#define EF_GRENADE 0x00000020

View file

@ -2090,7 +2090,7 @@ droptofloor(edict_t *ent)
{
ent->solid = SOLID_BBOX;
ent->touch = NULL;
ent->s.effects &= ~EF_ROTATE;
ent->s.effects &= ~(EF_ROTATE | EF_BOB);
ent->s.renderfx &= ~RF_GLOW;
}
@ -2265,6 +2265,11 @@ SpawnItem(edict_t *ent, gitem_t *item)
return;
}
if (g_itemsbobeffect->value && (item->world_model_flags & EF_ROTATE))
{
item->world_model_flags |= EF_BOB;
}
if (!g_disruptor->value)
{
if ((!strcmp(ent->classname, "ammo_disruptor")) ||
@ -2727,7 +2732,6 @@ static const gitem_t gameitemlist[] = {
WEAP_MACHINEGUN,
NULL,
0,
"weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"
},
@ -2752,7 +2756,6 @@ static const gitem_t gameitemlist[] = {
WEAP_CHAINGUN,
NULL,
0,
"weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"
},
@ -2801,7 +2804,6 @@ static const gitem_t gameitemlist[] = {
WEAP_GRENADES,
NULL,
AMMO_GRENADES,
"weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "
},
@ -2826,7 +2828,6 @@ static const gitem_t gameitemlist[] = {
0,
NULL,
AMMO_TRAP,
"weapons/trapcock.wav weapons/traploop.wav weapons/trapsuck.wav weapons/trapdown.wav"
},
@ -2851,7 +2852,6 @@ static const gitem_t gameitemlist[] = {
WEAP_GRENADELAUNCHER,
NULL,
0,
"models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"
},
@ -2900,7 +2900,6 @@ static const gitem_t gameitemlist[] = {
WEAP_ROCKETLAUNCHER,
NULL,
0,
"models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"
},
@ -2925,7 +2924,6 @@ static const gitem_t gameitemlist[] = {
WEAP_HYPERBLASTER,
NULL,
0,
"weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"
},
@ -3047,7 +3045,6 @@ static const gitem_t gameitemlist[] = {
WEAP_BFG,
NULL,
0,
"sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"
},
@ -4212,7 +4209,6 @@ static const gitem_t gameitemlist[] = {
0,
NULL,
0,
"items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"
},

View file

@ -103,6 +103,7 @@ cvar_t *g_machinegun_norecoil;
cvar_t *g_quick_weap;
cvar_t *g_swap_speed;
cvar_t *g_language;
cvar_t *g_itemsbobeffect;
static void G_RunFrame(void);

View file

@ -686,6 +686,7 @@ extern cvar_t *g_machinegun_norecoil;
extern cvar_t *g_quick_weap;
extern cvar_t *g_swap_speed;
extern cvar_t *g_language;
extern cvar_t *g_itemsbobeffect;
/* this is for the count of monsters */
#define ENT_SLOTS_LEFT \

View file

@ -264,6 +264,7 @@ InitGame(void)
g_quick_weap = gi.cvar("g_quick_weap", "1", CVAR_ARCHIVE);
g_swap_speed = gi.cvar("g_swap_speed", "1", CVAR_ARCHIVE);
g_language = gi.cvar("g_language", "english", CVAR_ARCHIVE);
g_itemsbobeffect = gi.cvar("g_itemsbobeffect", "0", CVAR_ARCHIVE);
/* initilize localization */
LocalizationInit();

View file

@ -372,7 +372,7 @@ item_cashbaglarge|models/pu_icon/money/money_lg.md2|1.0|1.0|1.0|general|-16.0|-1
item_cashbagsmall|models/pu_icon/money/money_sm.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Cash the player can pick up.|0.3|0.3|1.0
item_cashroll|models/pu_icon/cash/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Cash the player can pick up.|0.3|0.3|1.0
item_coil|models/pu_icon/coil/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Pickup item: coil ('Coil').|0.3|0.3|1.0
item_flashlight|models/items/silencer/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Flashlight|0.3|1.0|1.0
item_flashlight|models/items/flashlight/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Flashlight|0.3|1.0|1.0
item_health_lg|models/pu_icon/health/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Health : large medicine bag.|0.3|0.3|1.0
item_health_sm|models/pu_icon/health_s/tris.md2|1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Health : small medkit.|0.3|0.3|1.0
item_jetpack||1.0|1.0|1.0|general|-16.0|-16.0|-16.0|16.0|16.0|16.0|shadow|0|0.0|0.0|0|0|0|0:0|0|0|none|Pickup item: jetpack ('Jetpack'). No model and broken code.|0.3|0.3|1.0