Fix multi ammo pickup, add lives pickup text #739

This commit is contained in:
Cong
2022-05-17 22:02:55 +10:00
parent 3bbf1134d2
commit b8df2c5313
4 changed files with 25 additions and 3 deletions

View File

@@ -389,6 +389,14 @@
"GravityFactor": 0,
"DrawAbove": true
},
{
"Name": "lives_text",
"Type": "Text",
"TextMask": "00ffff",
"Range": 120,
"GravityFactor": 0,
"DrawAbove": true
},
{
"Name": "trail",
"Pic": {

View File

@@ -45,7 +45,7 @@
},
"Effects": [{
"Type": "Health",
"Health": 100
"Health": 200
}, {
"Type": "Ammo",
"Ammo": "Ammo",

View File

@@ -363,6 +363,20 @@ static void HandleGameEvent(
case GAME_EVENT_PLAYER_ADD_LIVES: {
PlayerData *p = PlayerDataGetByUID(e.u.PlayerAddLives.UID);
p->Lives += e.u.PlayerAddLives.Lives;
const TActor *a = ActorGetByUID(p->ActorUID);
if (a && a->isInUse && !a->dead)
{
GameEvent s = GameEventNew(GAME_EVENT_ADD_PARTICLE);
s.u.AddParticle.Class =
StrParticleClass(&gParticleClasses, "lives_text");
s.u.AddParticle.Pos = a->Pos;
s.u.AddParticle.Z = BULLET_Z * Z_FACTOR;
s.u.AddParticle.DZ = 4;
sprintf(
s.u.AddParticle.Text, "+%d %s", (int)e.u.PlayerAddLives.Lives,
e.u.PlayerAddLives.Lives > 1 ? "Lives" : "Life");
GameEventsEnqueue(&gGameEvents, s);
}
}
break;
case GAME_EVENT_ACTOR_MELEE:

View File

@@ -193,11 +193,11 @@ void PickupPickup(TActor *a, Pickup *p, const bool pickupAll)
case PICKUP_GUN:
if (TreatAsGunPickup(pe, a))
{
canPickup = canPickup || TryPickupGun(a, pe, pickupAll, &sound);
canPickup = TryPickupGun(a, pe, pickupAll, &sound) || canPickup;
}
else
{
canPickup = canPickup || TryPickupAmmo(a, p, pe);
canPickup = TryPickupAmmo(a, p, pe) || canPickup;
}
break;