/*
	PostNuke Wasteland PAWN Scriptextensions
	Author: NeoPhoenix
	Date: 02.08.2013
*/

//Items
enum
{
	ITEM_ACTION_SLOT,
	WEAPON_SLOT_1,
	WEAPON_SLOT_2,
	BACKPACK_SLOT,
	BLEEDING_SLOT,
	EQUIPMENT_SLOT,
	COSMETIC_HAT,
	COSMETIC_MASK,
	COSMETIC_GLASSES,
	COSMETIC_BODY,
}

enum (+=1)
{
	None = 0,
	Spine,
	Head,
	LeftUpperArm,
	RightUpperArm,
	LeftHand,
	RightHand,
	LeftThigh,
	RightThigh,
	LeftFoot,
	RightFoot,
	RightCalf,
	LeftCalf,
	LeftForearm,
	RightForearm,
	LeftClavicle,
	RightClavicle,
	Neck,
	Jaw
}

enum (<<=1)
{
	canUse = 1,
	canTrade,
	canThrowAway,
	canDestroy,
	canWear,
	canInteract,
	canEverything = (canUse|canTrade|canThrowAway|canDestroy|canWear|canInteract),
	CAN_DEFAULT = canTrade|canThrowAway|canDestroy,
}

enum (<<=1)
{
	iBurns = 1,
	iEquip,
}

enum (+=1)
{
	iSize_small,
	iSize_normal,
	iSize_carry,
}

#define DEFAULT_STACKSIZE	(512)
#define DEFAULT_OBJ_ID		(1239)
#define item:: item_
#define item_Use:%1(%2)\
			forward item_Use_%1(%2);\
			public item_Use_%1(%2)
#define item_Interact:%1(%2)\
			forward item_Interact_%1(%2);\
			public item_Interact_%1(%2)

stock item::GivePlayerItem(playerid,itemid,anzahl,bool:display=true)
{
	if(itemid <= 0 || anzahl <= 0) return 0;
	return CallRemoteFunction("item__GivePlayerItem","dddd",playerid,itemid,anzahl,_:display);
}

stock item::_RemovePlayerItem(playerid,itemid,anzahl)
{
	if(itemid <= 0 || anzahl <= 0) return 0;
	return CallRemoteFunction("item__RemovePlayerItem","ddd",playerid,itemid,anzahl);
}

stock item::CreateItemFS(name[],
					stacksize=DEFAULT_STACKSIZE,
					value=0,
					Float:weight=0.0,
					actions=CAN_DEFAULT,
					Float:effects[5]={0.0,...},
					properties=0,
					objectid=DEFAULT_OBJ_ID,
					size=iSize_small,
					holdbone=RightHand,
					Float:holdinfo[9]={0.0,...},
					wearinfo[2]={0,0},
					Float:wearattach[9]={0.0,...})
{
	new _effects[sizeof(effects)*5];
	for(new i; i<sizeof(effects)*5; i++) _effects[i] = (i%5)==0?(((_:effects[i/5]&(127<<((i%5)*7)))<<1)>>((i%5)*7)):(((_:effects[i/5]&(127<<((i%5)*7)))>>((i%5)*7)-1)), _effects[i] |= 1;
	new _holdinfo[sizeof(holdinfo)*5];
	for(new i; i<sizeof(holdinfo)*5; i++) _holdinfo[i] = (i%5)==0?(((_:holdinfo[i/5]&(127<<((i%5)*7)))<<1)>>((i%5)*7)):(((_:holdinfo[i/5]&(127<<((i%5)*7)))>>((i%5)*7)-1)), _holdinfo[i] |= 1;
	new _wearattach[sizeof(wearattach)*5];
	for(new i; i<sizeof(wearattach)*5; i++) _wearattach[i] = (i%5)==0?(((_:wearattach[i/5]&(127<<((i%5)*7)))<<1)>>((i%5)*7)):(((_:wearattach[i/5]&(127<<((i%5)*7)))>>((i%5)*7)-1)), _wearattach[i] |= 1;
	wearinfo[0] = (wearinfo[0] << 1) | 1;
	wearinfo[1] = (wearinfo[1] << 1) | 1;
	return CallRemoteFunction("item__CreateItem","sddfdsddddsss",name,stacksize,value,weight,actions,_effects,properties,objectid,size,holdbone,_holdinfo,wearinfo,_wearattach);
}