Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Improve weapon flags patching from TFE to TSE.
Browse files Browse the repository at this point in the history
- Remove Napalm and Sniper Bullets from ammo packs for TFE levels.
- Add ammo multiplication for ammo packs.
  • Loading branch information
DreamyCecil committed Dec 13, 2020
1 parent 3c242c4 commit 205e709
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
9 changes: 7 additions & 2 deletions Sources/EntitiesMP/AmmoPack.es
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ functions:
if( m_iSniperBullets != 0) {m_strDescription.PrintF("%s: Sniper bullets (%d)", m_strDescription, m_iSniperBullets);}
}

void AdjustDifficulty(void)
{
void AdjustDifficulty(void) {
//m_fValue = ceil(m_fValue*GetSP()->sp_fAmmoQuantity);

// [Cecil] Remove Napalm and Sniper Bullets in TFE
if (GetSP()->sp_iAMPOptions & AMP_CONVERSION) {
m_iNapalm = 0;
m_iSniperBullets = 0;
}

if (GetSP()->sp_bInfiniteAmmo && m_penTarget==NULL) {
Destroy();
}
Expand Down
24 changes: 12 additions & 12 deletions Sources/EntitiesMP/Common/ExtraFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ void ConvertWeapon(INDEX &iFlags, const INDEX &iWeapon) {
// Laser
case 14:
iFlags |= WeaponFlag(WEAPON_LASER);
iFlags &= ~WeaponFlag(14);
//iFlags &= ~WeaponFlag(14);
break;

// Cannon
case 16:
iFlags |= WeaponFlag(WEAPON_IRONCANNON);
iFlags &= ~WeaponFlag(16);
//iFlags &= ~WeaponFlag(16);
break;

// non-existent weapons
case 10: case 12: case 15: case 17:
case WEAPON_FLAMER: case WEAPON_SNIPER:
iFlags &= ~WeaponFlag(iWeapon);
//iFlags &= ~WeaponFlag(iWeapon);
break;

default: iFlags |= WeaponFlag(iWeapon);
Expand Down Expand Up @@ -90,9 +90,9 @@ extern void ConvertWorld(CEntity *penWorld) {
INDEX iWeapons = *piWeapons & ~GetSP()->sp_iWeaponGiver;
INDEX iNewWeapons = 0x03;

for (INDEX iGetWeapon = WEAPON_KNIFE; iGetWeapon < WEAPON_LAST; iGetWeapon++) {
for (INDEX iGetWeapon = 1; iGetWeapon < 18; iGetWeapon++) {
// replace the weapon if we have it
if (iWeapons & WeaponFlag(iGetWeapon)) {
if (WeaponExists(iWeapons, iGetWeapon)) {
ConvertWeapon(iNewWeapons, iGetWeapon);
}
}
Expand All @@ -101,23 +101,23 @@ extern void ConvertWorld(CEntity *penWorld) {

} else if (IsOfClass(pen, "Player Marker")) {
CPlayerMarker *penWeapons = (CPlayerMarker *)pen;
INDEX *iWeapons = &penWeapons->m_iGiveWeapons;
INDEX *iTakeWeapons = &penWeapons->m_iTakeWeapons;
INDEX *piWeapons = &penWeapons->m_iGiveWeapons;
INDEX *piTakeWeapons = &penWeapons->m_iTakeWeapons;
INDEX iNewWeapons = 0x03;
INDEX iNewTakeWeapons = 0;

for (INDEX iGetWeapon = WEAPON_KNIFE; iGetWeapon < WEAPON_LAST; iGetWeapon++) {
for (INDEX iGetWeapon = 1; iGetWeapon < 18; iGetWeapon++) {
// replace the weapon if we have it
if (*iWeapons & WeaponFlag(iGetWeapon)) {
if (WeaponExists(*piWeapons, iGetWeapon)) {
ConvertWeapon(iNewWeapons, iGetWeapon);
}

if (*iTakeWeapons & WeaponFlag(iGetWeapon)) {
if (WeaponExists(*piTakeWeapons, iGetWeapon)) {
ConvertWeapon(iNewTakeWeapons, iGetWeapon);
}
}
*iWeapons = iNewWeapons;
*iTakeWeapons = iNewTakeWeapons;
*piWeapons = iNewWeapons;
*piTakeWeapons = iNewTakeWeapons;
CPrintF(" - Converted PlayerMarker\n");

} else if (IsOfClass(pen, "KeyItem")) {
Expand Down
23 changes: 14 additions & 9 deletions Sources/EntitiesMP/PlayerWeapons.es
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ functions:
rmMain.rm_ulFlags |= RMF_WEAPON; // TEMP: for Truform
if (tmInvisibility>tmNow) {
rmMain.rm_colBlend = (rmMain.rm_colBlend&0xffffff00)|ubBlend;
}
}

m_moWeaponSecond.SetupModelRendering(rmMain);
m_moWeaponSecond.RenderModel(rmMain);
Expand Down Expand Up @@ -2760,6 +2760,7 @@ functions:
void AddDefaultAmmoForWeapon(INDEX iWeapon, FLOAT fMaxAmmoRatio) {
// [Cecil] Multiply ammo
FLOAT fMul = AmmoMul();

// [Cecil] Define ammo amounts here
FLOAT iShotgun = Max((FLOAT)ceil( 10.0f * fMul), m_iMaxShells * fMaxAmmoRatio);
FLOAT iDShotgun = Max((FLOAT)ceil( 20.0f * fMul), m_iMaxShells * fMaxAmmoRatio);
Expand Down Expand Up @@ -3199,15 +3200,19 @@ functions:
(eapi.iIronBalls>0 && m_iIronBalls<m_iMaxIronBalls) ||
(eapi.iSniperBullets>0 && m_iSniperBullets<m_iMaxSniperBullets))
{
// [Cecil] Multiply given ammo
FLOAT fAmmoMul = AmmoMul();

// add ammo from back pack
m_iShells+=eapi.iShells;
m_iBullets+=eapi.iBullets;
m_iRockets+=eapi.iRockets;
m_iGrenades+=eapi.iGrenades;
m_iNapalm+=eapi.iNapalm;
m_iElectricity+=eapi.iElectricity;
m_iIronBalls+=eapi.iIronBalls;
m_iSniperBullets+=eapi.iSniperBullets;
m_iShells += ceil(fAmmoMul * FLOAT(eapi.iShells));
m_iBullets += ceil(fAmmoMul * FLOAT(eapi.iBullets));
m_iRockets += ceil(fAmmoMul * FLOAT(eapi.iRockets));
m_iGrenades += ceil(fAmmoMul * FLOAT(eapi.iGrenades));
m_iNapalm += ceil(fAmmoMul * FLOAT(eapi.iNapalm));
m_iElectricity += ceil(fAmmoMul * FLOAT(eapi.iElectricity));
m_iIronBalls += ceil(fAmmoMul * FLOAT(eapi.iIronBalls));
m_iSniperBullets += ceil(fAmmoMul * FLOAT(eapi.iSniperBullets));

// make sure we don't have more ammo than maximum
ClampAllAmmo();

Expand Down

0 comments on commit 205e709

Please sign in to comment.