One of the things I have changed is that it is possible to carry more than one scanner in the inventory. So, a player might be able to pick up a few and use the scanner several times during a long map. That's all fine.
I was also pleased to find that if the scanner is already active, you can't activate a second one from your inventory until the first one has run out (so you don't waste one by accident if you hit the inventory activation key by mistake while the scanner is active). So, that's good too. I was going to try to figure out how to do that, but there's no need; it already works like that.
However, it would be nice if I could add a message and sound to the item so that if the player does try to use a second scanner while one is already active, they get told something like "You already have an active scanner" and a little "beep" plays. At the moment, it just does nothing - which is fine, but it could be better.
The problem is, I can't figure out where or how to add it. Any ZScript gurus out there able to help?
My code for reference:
Code: Select all
class NJScanner : PowerupGiver
{
Default
{
+INVENTORY.FANCYPICKUPSOUND
Inventory.MaxAmount 25;
Powerup.Duration -90;
Scale 0.5;
Tag "Portacomp Scanner\n90 seconds of enhanced map";
Inventory.Icon "I_PMSC";
Powerup.Type "PowerScanner";
Inventory.PickupSound "misc/allmap";
Inventory.UseSound "misc/allmap";
Inventory.PickupMessage "Picked up a map scanner.";
}
States
{
Spawn:
PMSC ABCD 6;
Loop;
}
override bool Use (bool pickup)
{
if (!level.AllMap)
{
if (Owner.CheckLocalView())
{
Console.MidPrint(null, "\cEThis only works\n\cEif you have a computer map active.");
Owner.A_StartSound ("*puzzfail", CHAN_ITEM, CHANF_DEFAULT, 1.0, ATTN_NORM, 0, 0);
}
return false;
}
return Super.Use (pickup);
}
}