Skip to content

Commit

Permalink
Show upgraded ammo if player has upgraded weapon, adjusted Bird's fir…
Browse files Browse the repository at this point in the history
…e rate, added JJ2+ ammo crates, fixed minor crash
  • Loading branch information
deathkiller committed Dec 15, 2023
1 parent ce8c73b commit 9712a77
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 12 deletions.
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoBouncer.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_bouncer.aura"
"Path": "Pickup/ammo_bouncer.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_bouncer_upgraded.aura",
"States": [ 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoElectro.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_electro.aura"
"Path": "Pickup/ammo_electro.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_electro_upgraded.aura",
"States": [ 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoFreezer.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_freezer.aura"
"Path": "Pickup/ammo_freezer.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_freezer_upgraded.aura",
"States": [ 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoPepper.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_pepper.aura"
"Path": "Pickup/ammo_pepper.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_pepper_upgraded.aura",
"States": [ 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoRF.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_rf.aura"
"Path": "Pickup/ammo_rf.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_rf_upgraded.aura",
"States": [ 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoSeeker.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_seeker.aura"
"Path": "Pickup/ammo_seeker.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_seeker_upgraded.aura",
"States": [ 1 ]
}
}
}
3 changes: 2 additions & 1 deletion Content/Metadata/Collectible/AmmoTNT.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

"Animations": {
"Ammo": {
"Path": "Object/tnt.aura"
"Path": "Object/tnt.aura",
"States": [ 0, 1 ]
}
}
}
3 changes: 2 additions & 1 deletion Content/Metadata/Collectible/AmmoThunderbolt.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_thunderbolt.aura"
"Path": "Pickup/ammo_thunderbolt.aura",
"States": [ 0, 1 ]
}
}
}
7 changes: 6 additions & 1 deletion Content/Metadata/Collectible/AmmoToaster.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

"Animations": {
"Ammo": {
"Path": "Pickup/ammo_toaster.aura"
"Path": "Pickup/ammo_toaster.aura",
"States": [ 0 ]
},
"AmmoUpgraded": {
"Path": "Pickup/ammo_toaster_upgraded.aura",
"States": [ 1 ]
}
}
}
6 changes: 5 additions & 1 deletion Sources/Jazz2/Actors/Collectibles/AmmoCollectible.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "AmmoCollectible.h"
#include "../../ILevelHandler.h"
#include "../../WeaponType.h"
#include "../Player.h"

Expand Down Expand Up @@ -45,7 +46,10 @@ namespace Jazz2::Actors::Collectibles
case WeaponType::Thunderbolt: async_await RequestMetadataAsync("Collectible/AmmoThunderbolt"_s); break;
}

SetAnimation(AnimState::Default);
// Show upgraded ammo if player has upgraded weapon
const auto& players = _levelHandler->GetPlayers();
bool upgraded = (!players.empty() && (players[0]->GetWeaponUpgrades()[(std::uint8_t)_weaponType] & 0x01) != 0);
SetAnimation((AnimState)(upgraded ? 1 : 0));

SetFacingDirection();

Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/Actors/Environment/Bird.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace Jazz2::Actors::Environment
_levelHandler->AddActor(shot2);

PlaySfx("Fire"_s, 0.5f);
_fireCooldown = 48.0f;
_fireCooldown = 32.0f;
}
SetState(ActorState::CollideWithTileset, false);
break;
Expand Down
14 changes: 13 additions & 1 deletion Sources/Jazz2/Compatibility/EventConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,19 @@ namespace Jazz2::Compatibility
Add(JJ2Event::FOOD_CHEESE, ConstantParamList(EventType::Food, { (uint8_t)FoodType::Cheese }));

Add(JJ2Event::CRATE_AMMO, GetAmmoCrateConverter(0));
Add(JJ2Event::CRATE_AMMO_BOUNCER, GetAmmoCrateConverter(1));
Add(JJ2Event::CRATE_AMMO_BOUNCER, [](JJ2Level* level, uint32_t jj2Params) -> ConversionResult {
uint8_t eventParams[16];
ConvertParamInt(jj2Params, {
{ JJ2ParamUInt, 3 } // Weapon
}, eventParams);

uint8_t type = eventParams[0] + 1;
if (type < 1 || type > 8) {
type = 1; // Fallback to Bouncer if out of range
}

return { EventType::CrateAmmo, { type } };
});
Add(JJ2Event::CRATE_AMMO_FREEZER, GetAmmoCrateConverter(2));
Add(JJ2Event::CRATE_AMMO_SEEKER, GetAmmoCrateConverter(3));
Add(JJ2Event::CRATE_AMMO_RF, GetAmmoCrateConverter(4));
Expand Down
5 changes: 5 additions & 0 deletions Sources/Jazz2/Events/EventMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ namespace Jazz2::Events
// Linked actor was deactivated, but not destroyed
// Reset its generator, so it can be respawned immediately
std::uint32_t generatorIdx = *(std::uint32_t*)_eventLayout[tx + ty * _layoutSize.X].EventParams;
if (generatorIdx >= _generators.size()) {
// Do nothing if generator if wrongly configured
return;
}

_generators[generatorIdx].TimeLeft = 0.0f;
_generators[generatorIdx].SpawnedActor = nullptr;
}
Expand Down

0 comments on commit 9712a77

Please sign in to comment.