Necromancer-AMV
Junior Member

Posts: 105
Registered: 11-11 |
Next, comes the CustomInventory item. It will serve as the "switch", so to speak.
ACTOR ShoulderLampOnOff : CustomInventory
{
-INVBAR
+INVENTORY.UNDRAPPABLE
Inventory.Amount 1
Inventory.MaxAmount 1
States
{
Use:
TNT1 A 0 A_JumpIfInventory("PlayerHasLampOn",1,"SwitchOff")
SwitchOn:
TNT1 A 0 A_GiveInventory("PlayerHasLampOn")
Fail
SwitchOff:
TNT1 A 0 A_TakeInventory("PlayerHasLampOff")
Fail
}
}
CustomInventory actors are incredibly flexible, having access to action functions that Inventory actors don't. Lets look at the actor. First we have the -INVBAR & +INVENTORY.UNDROPPABLE flags & MaxAmount property set as before, because we don't need to see the item, don't want the player dropping it, and don't want him to have more than 1.
Now, the Use state. Normally, this would be entered when you selected the item from the bar and pressed the "use inventory" key, but we're going to use the item through a KEYCONF alias. The first thing we do is heve it call A_JumpIfInventory. This will check the player's inventory for the specified amount. Here, we're checking to see if the player already has the PlayerHasLampOn item; we're checking to see if he has the lamp active. If the player has 1, it will jump to the SwitchOff state, where it will take it away. If false (the player doesn't have it), it will "fall through" to the SwitchOn state, giveing the player the item. Both the SwitchOff & SwitchOn states end with Fail instead of Stop, because we don't want this item being used in the normal way, where it would disappear from inventory. We want to keep on using it.
Continued in next post.
|