Implement WWII GI weapon display code.

Remaining issues with the weapons (both functionality and display):
- The "pistol", "shotgun", and "chaingun" fire too slowly.
- The flamethrower fires too quickly.
- The bazooka drop for reload is late.
- Upon starting a level, the "pistol" should show a reload frame, but it does not.

git-svn-id: https://svn.eduke32.com/eduke32@5453 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-11-25 12:08:34 +00:00
parent 0fdeed231b
commit 0433d97a54

View file

@ -2316,10 +2316,26 @@ void P_DisplayWeapon(void)
if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING))
o |= 512; o |= 512;
if (*kb > 0 && *kb < 8) if (*kb > 0)
{ {
G_DrawWeaponTileWithID(cw << 1, weapon_xoffset + 164, (looking_arc << 1) + 176 - gun_pos, if (*kb < 8)
RPGGUN + ((*kb) >> 1), gs, o, pal, 0); {
G_DrawWeaponTileWithID(cw << 1, weapon_xoffset + 164, (looking_arc << 1) + 176 - gun_pos,
RPGGUN + ((*kb) >> 1), gs, o, pal, 0);
}
else if (WW2GI)
{
int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
if (*kb >= totaltime)
{
int32_t const reload = PWEAPON(screenpeek, p->curr_weapon, Reload);
if (*kb < ((reload - totaltime) / 2 + totaltime))
gun_pos -= 10 * ((*kb) - totaltime); // down
else
gun_pos -= 10 * (reload - (*kb)); // up
}
}
} }
G_DrawWeaponTileWithID(cw, weapon_xoffset + 164, (looking_arc << 1) + 176 - gun_pos, RPGGUN, gs, G_DrawWeaponTileWithID(cw, weapon_xoffset + 164, (looking_arc << 1) + 176 - gun_pos, RPGGUN, gs,
@ -2332,6 +2348,42 @@ void P_DisplayWeapon(void)
weapon_xoffset -= 8; weapon_xoffset -= 8;
if (WW2GI)
{
int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
int32_t const reload = PWEAPON(screenpeek, p->curr_weapon, Reload);
if (*kb > 0)
gun_pos -= sintable[(*kb)<<7]>>12;
if (*kb > 0 && doanim)
weapon_xoffset += 1-(krand()&3);
if (*kb == 0)
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 146 - hla, looking_arc + 202 - gun_pos,
SHOTGUN, gs, o, pal, 0);
}
else if (*kb <= totaltime)
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 146 - hla, looking_arc + 202 - gun_pos,
SHOTGUN + 1, gs, o, pal, 0);
}
// else we are in 'reload time'
else
{
if (*kb < ((reload - totaltime) / 2 + totaltime))
gun_pos -= 10 * ((*kb) - totaltime); // D
else
gun_pos -= 10 * (reload - (*kb)); // U
G_DrawWeaponTileWithID(cw, weapon_xoffset + 146 - hla, looking_arc + 202 - gun_pos,
SHOTGUN, gs, o, pal, 0);
}
break;
}
switch (*kb) switch (*kb)
{ {
case 1: case 1:
@ -2411,6 +2463,83 @@ void P_DisplayWeapon(void)
weapon_xoffset += 1-(rand()&3); weapon_xoffset += 1-(rand()&3);
} }
if (WW2GI)
{
int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
int32_t const reload = PWEAPON(screenpeek, p->curr_weapon, Reload);
if (*kb == 0)
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 178 - hla,looking_arc+233-gun_pos,
CHAINGUN+1,gs,o,pal,0);
}
else if (*kb <= totaltime)
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 188 - hla,looking_arc+243-gun_pos,
CHAINGUN+2,gs,o,pal,0);
}
// else we are in 'reload time'
// divide reload time into fifths..
// 1) move weapon up/right, hand on clip (CHAINGUN - 17)
// 2) move weapon up/right, hand removing clip (CHAINGUN - 18)
// 3) hold weapon up/right, hand removed clip (CHAINGUN - 19)
// 4) hold weapon up/right, hand inserting clip (CHAINGUN - 18)
// 5) move weapon down/left, clip inserted (CHAINGUN - 17)
else
{
int iFifths = (reload - totaltime) / 5;
if (iFifths < 1)
iFifths = 1;
if (*kb < iFifths + totaltime)
{
// first segment
int32_t const offset = 80 - 10 * (totaltime + iFifths - (*kb));
gun_pos += offset;
weapon_xoffset += offset;
G_DrawWeaponTileWithID(cw, weapon_xoffset + 168 - hla,looking_arc+260-gun_pos,
CHAINGUN - 17,gs,o,pal,0);
}
else if (*kb < (iFifths * 2 + totaltime))
{
// second segment
gun_pos += 80; // D
weapon_xoffset += 80;
G_DrawWeaponTileWithID(cw, weapon_xoffset + 168 - hla,looking_arc+260-gun_pos,
CHAINGUN - 18,gs,o,pal,0);
}
else if (*kb < (iFifths * 3 + totaltime))
{
// third segment
// up
gun_pos += 80;
weapon_xoffset += 80;
G_DrawWeaponTileWithID(cw, weapon_xoffset + 168 - hla,looking_arc+260-gun_pos,
CHAINGUN - 19,gs,o,pal,0);
}
else if (*kb < (iFifths * 4 + totaltime))
{
// fourth segment
// down
gun_pos += 80; // D
weapon_xoffset += 80;
G_DrawWeaponTileWithID(cw, weapon_xoffset + 168 - hla,looking_arc+260-gun_pos,
CHAINGUN - 18,gs,o,pal,0);
}
else
{
// up and left
int32_t const offset = 10 * (reload - (*kb));
gun_pos += offset; // U
weapon_xoffset += offset;
G_DrawWeaponTileWithID(cw, weapon_xoffset + 168 - hla,looking_arc+260-gun_pos,
CHAINGUN - 17,gs,o,pal,0);
}
}
break;
}
switch (*kb) switch (*kb)
{ {
case 0: case 0:
@ -2482,12 +2611,12 @@ void P_DisplayWeapon(void)
G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+220-gun_pos, FIRSTGUN+5, gs, o, pal, 0); G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+220-gun_pos, FIRSTGUN+5, gs, o, pal, 0);
} }
else if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, Reload)-4) else if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, Reload) - (WW2GI ? 12 : 4))
{ {
G_DrawWeaponTileWithID(cw<<2, 184-(p->look_ang>>1), looking_arc+235-gun_pos, FIRSTGUN+8, gs, o, pal, 0); G_DrawWeaponTileWithID(cw<<2, 184-(p->look_ang>>1), looking_arc+235-gun_pos, FIRSTGUN+8, gs, o, pal, 0);
G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+210-gun_pos, FIRSTGUN+5, gs, o, pal, 0); G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+210-gun_pos, FIRSTGUN+5, gs, o, pal, 0);
} }
else if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, Reload)-2) else if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, Reload) - (WW2GI ? 6 : 2))
{ {
G_DrawWeaponTileWithID(cw<<2, 164-(p->look_ang>>1), looking_arc+245-gun_pos, FIRSTGUN+8, gs, o, pal, 0); G_DrawWeaponTileWithID(cw<<2, 164-(p->look_ang>>1), looking_arc+245-gun_pos, FIRSTGUN+8, gs, o, pal, 0);
G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+220-gun_pos, FIRSTGUN+5, gs, o, pal, 0); G_DrawWeaponTileWithID(cw, 224-(p->look_ang>>1), looking_arc+220-gun_pos, FIRSTGUN+5, gs, o, pal, 0);
@ -2509,12 +2638,41 @@ void P_DisplayWeapon(void)
if (*kb) if (*kb)
{ {
if ((*kb) < 7) if (WW2GI)
gun_pos -= 10 * (*kb); // D {
else if ((*kb) < 12) int32_t const firedelay = PWEAPON(screenpeek, p->curr_weapon, FireDelay);
gun_pos += 20 * ((*kb) - 10); // U int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
else if ((*kb) < 20)
gun_pos -= 9 * ((*kb) - 14); // D if (*kb <= firedelay)
{
// it holds here
gun_pos -= 5 * (*kb); // D
}
else if (*kb < ((totaltime - firedelay) / 2 + firedelay))
{
// up and left
int32_t const difference = (*kb) - firedelay;
gun_pos += 10 * difference; // U
weapon_xoffset += 80 * difference;
}
else if (*kb < totaltime)
{
// start high
gun_pos += 240;
gun_pos -= 12 * ((*kb) - firedelay); // D
// move left
weapon_xoffset += 90 - 5 * (totaltime - (*kb));
}
}
else
{
if (*kb < 7)
gun_pos -= 10 * (*kb); // D
else if (*kb < 12)
gun_pos += 20 * ((*kb) - 10); // U
else if (*kb < 20)
gun_pos -= 9 * ((*kb) - 14); // D
}
gun_pos += 10; gun_pos += 10;
} }
@ -2544,9 +2702,58 @@ void P_DisplayWeapon(void)
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
if ((*kb) < (PWEAPON(screenpeek, DEVISTATOR_WEAPON, TotalTime) + 1) && (*kb) > 0) if (WW2GI)
{ {
static uint8_t cycloidy [] ={ 0, 4, 12, 24, 12, 4, 0 }; if (*kb)
{
int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
int32_t const reload = PWEAPON(screenpeek, p->curr_weapon, Reload);
if (*kb < totaltime)
{
i = ksgn((*kb)>>2);
if (p->ammo_amount[p->curr_weapon] & 1)
{
G_DrawWeaponTileWithID(cw<<1, weapon_xoffset + 30 - hla, looking_arc + 240 - gun_pos,
DEVISTATOR, gs, o | 4, pal, 0);
G_DrawWeaponTileWithID(cw, weapon_xoffset + 268 - hla, looking_arc + 238 - gun_pos,
DEVISTATOR + i, -32, o, pal, 0);
}
else
{
G_DrawWeaponTileWithID(cw<<1, weapon_xoffset + 30 - hla, looking_arc + 240 - gun_pos,
DEVISTATOR + i, -32, o | 4, pal, 0);
G_DrawWeaponTileWithID(cw, weapon_xoffset + 268 - hla, looking_arc + 238 - gun_pos,
DEVISTATOR, gs, o, pal, 0);
}
}
// else we are in 'reload time'
else
{
if (*kb < ((reload - totaltime) / 2 + totaltime))
gun_pos -= 10 * ((*kb) - totaltime); // D
else
gun_pos -= 10 * (reload - (*kb)); // U
G_DrawWeaponTileWithID(cw, weapon_xoffset + 268 - hla, looking_arc + 238 - gun_pos,
DEVISTATOR, gs, o, pal, 0);
G_DrawWeaponTileWithID(cw<<1, weapon_xoffset + 30 - hla, looking_arc + 240 - gun_pos,
DEVISTATOR, gs, o | 4, pal, 0);
}
}
else
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 268 - hla, looking_arc + 238 - gun_pos,
DEVISTATOR, gs, o, pal, 0);
G_DrawWeaponTileWithID(cw<<1, weapon_xoffset + 30 - hla, looking_arc + 240 - gun_pos,
DEVISTATOR, gs, o | 4, pal, 0);
}
break;
}
if (*kb <= PWEAPON(screenpeek, DEVISTATOR_WEAPON, TotalTime) && *kb > 0)
{
static uint8_t const cycloidy[] = { 0, 4, 12, 24, 12, 4, 0 };
if (*kb >= ARRAY_SIZE(cycloidy)) if (*kb >= ARRAY_SIZE(cycloidy))
break; break;
@ -2614,6 +2821,66 @@ void P_DisplayWeapon(void)
weapon_xoffset += 28; weapon_xoffset += 28;
looking_arc += 18; looking_arc += 18;
if (WW2GI)
{
if (*kb == 0)
{
// the 'at rest' display
if (cw == GROW_WEAPON)
{
G_DrawWeaponTileWithID(cw, weapon_xoffset + 188 - hla, looking_arc + 240 - gun_pos,
SHRINKER - 2, gs, o, pal, 0);
break;
}
else if (p->ammo_amount[cw] > 0)
{
G_DrawWeaponTileWithID(cw << 1, weapon_xoffset + 184 - hla, looking_arc + 240 - gun_pos,
SHRINKER + 2, 16 - (sintable[p->random_club_frame & 2047] >> 10), o,
0, 1);
G_DrawWeaponTileWithID(cw, weapon_xoffset + 188 - hla, looking_arc + 240 - gun_pos,
SHRINKER, gs, o, pal, 0);
break;
}
}
else
{
// the 'active' display.
if (doanim)
{
weapon_xoffset += rand() & 3;
gun_pos += rand() & 3;
}
int32_t const totaltime = PWEAPON(screenpeek, p->curr_weapon, TotalTime);
int32_t const reload = PWEAPON(screenpeek, p->curr_weapon, Reload);
if (*kb < totaltime)
{
if (*kb >= PWEAPON(screenpeek, p->curr_weapon, FireDelay))
{
// after fire time.
// lower weapon to reload cartridge (not clip)
gun_pos -= (cw == GROW_WEAPON ? 15 : 10) * (totaltime - (*kb));
}
}
// else we are in 'reload time'
else if (*kb < ((reload - totaltime) / 2 + totaltime))
gun_pos -= (cw == GROW_WEAPON ? 5 : 10) * ((*kb) - totaltime); // D
else
gun_pos -= 10 * (reload - (*kb)); // U
}
G_DrawWeaponTileWithID(cw << 1, weapon_xoffset + 184 - hla, looking_arc + 240 - gun_pos,
SHRINKER + 3 + ((*kb) & 3), -32, o, cw == GROW_WEAPON ? 2 : 0, 1);
G_DrawWeaponTileWithID(cw, weapon_xoffset + 188 - hla, looking_arc + 240 - gun_pos,
SHRINKER + (cw == GROW_WEAPON ? -1 : 1), gs, o, pal, 0);
break;
}
if ((*kb) < PWEAPON(screenpeek, p->curr_weapon, TotalTime) && (*kb) > 0) if ((*kb) < PWEAPON(screenpeek, p->curr_weapon, TotalTime) && (*kb) > 0)
{ {
if (doanim) if (doanim)