Skip to content

Commit

Permalink
allow disabling ammo cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
stohrendorf committed Feb 20, 2021
1 parent 6ccbb39 commit df3c4f7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

cheats = {
"godMode": True,
"allAmmoCheat": True,
"inventory": {
TR1ItemId.Key1: 10,
TR1ItemId.Key2: 10,
Expand Down
8 changes: 8 additions & 0 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ std::pair<RunResult, std::optional<size_t>> Engine::run(World& world, bool isCut
= core::get<bool>(core::get<pybind11::dict>(pybind11::globals(), "cheats").value_or(pybind11::dict{}), "godMode")
.value_or(false);

const bool allAmmoCheat
= core::get<bool>(core::get<pybind11::dict>(pybind11::globals(), "cheats").value_or(pybind11::dict{}),
"allAmmoCheat")
.value_or(false);

std::shared_ptr<menu::MenuDisplay> menu;
Throttler throttler;
while(true)
Expand Down Expand Up @@ -191,6 +196,9 @@ std::pair<RunResult, std::optional<size_t>> Engine::run(World& world, bool isCut
return {RunResult::RequestLoad, std::nullopt};
}

if(allAmmoCheat)
m_inventory.fillAllAmmo();

world.gameLoop(world.getTitle(), godMode);
}
else
Expand Down
8 changes: 8 additions & 0 deletions src/engine/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,13 @@ class Inventory
default: BOOST_THROW_EXCEPTION(std::domain_error("weaponId"));
}
}

void fillAllAmmo()
{
m_pistolsAmmo.ammo = 1000;
m_magnumsAmmo.ammo = 1000;
m_uzisAmmo.ammo = 1000;
m_shotgunAmmo.ammo = 1000;
}
};
} // namespace engine
3 changes: 1 addition & 2 deletions src/engine/lara/abstractstatehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool AbstractStateHandler::tryReach(CollisionInfo& collisionInfo)

if(collisionInfo.front.ceilingSpace.y > 0_len || collisionInfo.mid.ceilingSpace.y > -core::ClimbLimit2ClickMin
|| collisionInfo.mid.floorSpace.y < 200_len)
{ //! @todo Magick 200
{
return false;
}

Expand Down Expand Up @@ -348,7 +348,6 @@ bool AbstractStateHandler::tryClimb(const CollisionInfo& collisionInfo)
return false;
}

//! @todo MAGICK +/- 30 degrees
auto alignedRotation = alignRotation(m_lara.m_state.rotation.Y, 30_deg);
if(!alignedRotation)
{
Expand Down
5 changes: 0 additions & 5 deletions src/engine/objects/laraobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,11 +1632,6 @@ bool LaraObject::fireWeapon(const WeaponId weaponId,

const auto ammoPtr = getWorld().getEngine().getInventory().getAmmo(weaponId);

if(true /* FIXME engine::allAmmoCheat */)
{
ammoPtr->ammo = 1000;
}

if(ammoPtr->ammo == 0)
{
playSoundEffect(TR1SoundEffect::EmptyAmmo);
Expand Down

0 comments on commit df3c4f7

Please sign in to comment.