Example #1
0
Item::Item(const uint16_t _type, uint16_t _count /*= 0*/) :
	ItemAttributes()
{
	id = _type;

	const ItemType& it = items[id];

	setItemCount(1);

	if(it.isFluidContainer() || it.isSplash()){
		setFluidType(_count);
	}
	else if(it.stackable){
		if(_count != 0){
			setItemCount(_count);
		}
		else if(it.charges != 0){
			setItemCount(it.charges);
		}
	}
	else if(it.charges != 0){
		//if count is higher than 1, override default charges
		if(_count > 1){
			setCharges(_count);
		}
		else{
			setCharges(it.charges);
		}
	}

	setDefaultDuration();
}
Example #2
0
Item::Item(const uint16_t _type, uint16_t _count /*= 0*/)
{
	parent = NULL;
	useCount = 0;

	id = _type;
	attributes = NULL;

	const ItemType& it = items[id];

	setItemCount(1);

	if (it.isFluidContainer() || it.isSplash()) {
		setFluidType(_count);
	} else if (it.stackable) {
		if (_count != 0) {
			setItemCount(_count);
		} else if (it.charges != 0) {
			setItemCount(it.charges);
		}
	} else if (it.charges != 0) {
		if (_count != 0) {
			setCharges(_count);
		} else {
			setCharges(it.charges);
		}
	}

	loadedFromMap = false;
	setDefaultDuration();
}
Example #3
0
void Item::setSubType(uint16_t n)
{
	const ItemType& it = items[id];
	if(it.isFluidContainer() || it.isSplash())
		setFluidType(n);
	else if(it.charges)
		setCharges(n);
	else
		count = n;
}
Example #4
0
void Item::setSubType(uint16_t n)
{
	const ItemType& it = items[id];

	if (it.isFluidContainer() || it.isSplash()) {
		setFluidType(n);
	} else if (it.stackable) {
		setItemCount(n);
	} else if (it.charges != 0) {
		setCharges(n);
	} else {
		setItemCount(n);
	}
}
Example #5
0
Item::Item(const uint16_t type, uint16_t amount/* = 0*/):
	ItemAttributes(), id(type)
{
	count = 1;
	raid = NULL;
	loadedFromMap = false;

	const ItemType& it = items[id];
	if(it.charges)
		setCharges(it.charges);

	setDefaultDuration();
	if(it.isFluidContainer() || it.isSplash())
		setFluidType(amount);
	else if(it.stackable && amount)
		count = amount;
	else if(it.charges && amount)
		setCharges(amount);
}
Example #6
0
Item::Item(const uint16_t type, uint16_t amount/* = 0*/):
	ItemAttributes(), id(type)
{
	count = 1;
	raid = NULL;
	loadedFromMap = false;

	setItemCount(1);
	setDefaultDuration();

	const ItemType& it = items[type];
	if(it.isFluidContainer() || it.isSplash())
		setFluidType(amount);
	else if(it.stackable)
	{
		if(amount)
			count = setItemCount(amount);
		else if(it.charges)
			setItemCount(it.charges);
	}
	else if(it.charges)
		setCharges(amount ? amount : it.charges);

	if(it.armorRndMin > -1 && it.armorRndMax > it.armorRndMin)
		setAttribute("armor", it.armorRndMin + rand() % (it.armorRndMax+1 - it.armorRndMin));
	if(it.defenseRndMin > -1 && it.defenseRndMax > it.defenseRndMin)
		setAttribute("defense", it.defenseRndMin + rand() % (it.defenseRndMax+1 - it.defenseRndMin));
	if(it.extraDefenseRndMin > -1 && it.extraDefenseRndMax > it.extraDefenseRndMin)
	if(it.extraDefenseChance == -1 || (it.extraDefenseChance >= rand() % 101) )
		setAttribute("extradefense", it.extraDefenseRndMin + rand() % (it.extraDefenseRndMax+1 - it.extraDefenseRndMin));
	if(it.attackRndMin > -1 && it.attackRndMax > it.attackRndMin)
		setAttribute("attack", it.attackRndMin + rand() % (it.attackRndMax - it.attackRndMin));
	if(it.extraAttackRndMin > -1 && it.extraAttackRndMax > it.extraAttackRndMin)
	if(it.extraAttackChance == -1 || (it.extraAttackChance >= rand() % 101) )
		setAttribute("extraattack", it.extraAttackRndMin + rand() % (it.extraAttackRndMax+1 - it.extraAttackRndMin));
	if(it.chargesRndMin > -1 && it.chargesRndMax > it.chargesRndMin)
		setAttribute("charges", it.chargesRndMin + rand() % (it.chargesRndMax+1 - it.chargesRndMin));
	if(it.attackSpeedRndMin > -1 && it.attackSpeedRndMax > it.attackSpeedRndMin)
	if(it.attackSpeedChance == -1 || (it.attackSpeedChance >= rand() % 101) )
		setAttribute("attackSpeed", it.attackSpeedRndMin + rand() % (it.attackSpeedRndMax+1 - it.attackSpeedRndMin) );
}
Example #7
0
Item::Item(const uint16_t type, uint16_t amount/* = 0*/):
	ItemAttributes(), id(type)
{
	raid = NULL;
	loadedFromMap = false;

	setItemCount(1);
	setDefaultDuration();

	const ItemType& it = items[type];
	if(it.isFluidContainer() || it.isSplash())
		setFluidType(amount);
	else if(it.stackable)
	{
		if(amount)
			setItemCount(amount);
		else if(it.charges)
			setItemCount(it.charges);
	}
	else if(it.charges)
		setCharges(amount ? amount : it.charges);
}
Example #8
0
Item::Item(const uint16_t _type, uint16_t _count /*= 0*/) :
	ItemAttributes()
{
	id = _type;

	const ItemType& it = items[id];

	count = 1;
	if(it.charges != 0){
		setCharges(it.charges);
	}

	if(it.isFluidContainer() || it.isSplash()){
		setFluidType(_count);
	}
	else if(it.stackable && _count != 0){
		count = _count;
	}
	else if(it.charges != 0 && _count != 0){
		setCharges(_count);
	}

	setDefaultDuration();
}