What I want is to create a base class for an inventory item with two properties GiveItem and GiveToken. I want to be able to specifiy these two properties in the classes that inherit from the base class. During pickup I want to check for a certain condition and give either the Item or Token speicified in the Default block.
Code: Select all
class w_Pickup : CustomInventory // This is the base class that all future items will inherit from
{
class<inventory> w_Item;
class<inventory> w_Token;
Property GiveItem: w_Item; // The custom properties, defined as the wiki states (???)
Property GiveToken: w_Token;
default
{
+COUNTITEM
+FLOATBOB
Inventory.PickupFlash "PickupFlash";
+INVENTORY.FANCYPICKUPSOUND
Inventory.PickupSound "misc/p_pkup";
}
states
{
Pickup:
TNT1 A 0
{
If(CountInv("w_SpellBook1"))
{ A_GiveInventory(GiveToken); } // I get an unknown identifier error here ...
Else
{ A_GiveInventory(GiveItem); } // ... and here - despite both being defined.
} // Maybe I'm defining them wrong, or accessing them wrong.
stop; // Either way it is not particularly clear on the wiki
}
}
class w_TestToken : w_ItemToken { }
class w_TestItem : ArtiHealth { }
class w_TestPickup : w_Pickup replaces ArtiHealth
{
default
{
Inventory.PickupMessage "$TXT_ARTIHEALTH";
w_Pickup.GiveItem("w_TestItem");
w_Pickup.GiveToken("w_TestToken");
}
states
{
Spawn:
PTN2 ABC 4;
Loop;
}
}
Maybe it's just me, but the wiki seems to be lacking in clarity when it comes to custom properties - sure it tells you how to define them, but to actually use them? no.