So, this cannot be done in plain decorate, because CustomInventory items cannot have loops in use state. Its just impossible.
But, it is achievable in zscript with quite ease.
Take a look at this example. It's a healing powerup that provides regeneration while active. Uses the CustomInventory item as an 'ammo' or resource.
Code: Select all
class regenModule_Item : CustomInventory
{
int rgnModSwitch;
Default
{
//$Category "SoA/Items"
//$Color 9
//$Title "Regeneration Module"
+INVENTORY.INVBAR
+INVENTORY.ALWAYSPICKUP
-SOLID
Tag "$T_RGNMDL";
radius 8;
height 24;
scale 1;
inventory.icon "I_RGNM";
inventory.amount 100;
inventory.maxamount 200;
inventory.interhubamount 200;
inventory.PickupMessage "$F_RGNMDL";
}
States
{
Spawn:
RGNM AB 8;
Loop;
Use:
TNT1 A 0
{
if(invoker.rgnModSwitch == 0) {return ResolveState("Activate");}
if(invoker.rgnModSwitch == 1) {return ResolveState("Deactivate");}
return ResolveState(null);
}
Activate:
TNT1 A 0
{
invoker.rgnModSwitch = 1;
A_Giveinventory("RegenModuleActive", 1);
A_Giveinventory("regenModuleActiveToken", 1);
}
Stop;
Deactivate:
TNT1 A 0
{
invoker.rgnModSwitch = 0;
A_TakeInventory("PowerRegenModule");
A_TakeInventory("RegenModuleActive");
A_TakeInventory("regenModuleActiveToken");
}
Stop;
}
}
//==--------------------------------------------------------------------------==
//mechanics
//==--------------------------------------------------------------------------==
class regenModuleActiveToken : Inventory
{
Default
{
-INVENTORY.INVBAR
inventory.amount 1;
inventory.maxamount 1;
inventory.interhubamount 1;
}
}
class PowerRegenModule : PowerRegeneration
{
int regnModCount;
override void attachtoowner(actor user)
{
regnModCount = 0;
super.attachtoowner(user);
}
override void doeffect()
{
Super.doEffect();
if(owner.countinv("regenModule_Item") <= 1)
{
owner.takeinventory("RegenModuleActive", 1);
owner.takeinventory("regenModuleActiveToken", 1);
self.destroy();
return;
}
regnModCount++;
if(regnModCount == 35)
{
owner.takeinventory("regenModule_Item", 1);
regnModCount = 0;
}
}
Default
{
powerup.duration 0x7FFFFFFD;
powerup.strength 2;
inventory.icon "I_BLNK";
}
}
class RegenModuleActive : PowerupGiver
{
Default
{
+INVENTORY.AUTOACTIVATE
+INVENTORY.FANCYPICKUPSOUND
+Inventory.PickupFlash
powerup.duration 0x7FFFFFFD;
powerup.Type "PowerRegenModule";
powerup.color "A70000", 0.3;
inventory.pickupmessage "Regeneration!!";
inventory.maxamount 0;
inventory.usesound "pickups/slowmo";
}
States
{
Spawn:
RGNM AB 8;
Loop;
}
}
//==--------------------------------------------------------------------------==