Пример #1
0
qboolean Pickup_Rune (edict_t *ent, edict_t *other)
{
	item_t *slot;

	if (!other->client)
		return false;

	//Show the user what kind of rune it is
	if (level.time > other->msg_time)
	{
		V_PrintItemProperties(other, &ent->vrxitem);
		other->msg_time = level.time+1;
	}

	if (other->client->rune_delay > level.time)
		return false;

	//4.2 if it's worthless, then just destroy it
	if (ent->vrxitem.itemLevel < 1)
	{
		G_FreeEdict(ent);
		return false;
	}

	//Can we pick it up?
	if (!V_CanPickUpItem(other))
		return false;


	//Give them the rune
	slot = V_FindFreeItemSlot(other);
	V_ItemCopy(&ent->vrxitem, slot);

	//Save the player file (prevents lost runes)
	if (savemethod->value == 1)
		SaveCharacter(other);
	else if (savemethod->value == 0)
	{
		char path[MAX_QPATH];
		memset(path, 0, MAX_QPATH);
		VRXGetPath(path, other);
		VSF_SaveRunes(other, path);
	}

	other->client->rune_delay = level.time + RUNE_PICKUP_DELAY;

	//Done
	return true;
}
Пример #2
0
void GiveRuneToArmory(item_t *rune)
{
	armoryRune_t *firstItem;
	item_t *slot;
	int type = rune->itemtype;
	int newPrice = getBuyValue(rune);
	int i;

	//discard the rune if it's worthless
	if (newPrice == 0)
		return;

	//remove the unique flag if it's there
	if (type & ITEM_UNIQUE)
		type ^= ITEM_UNIQUE;

	//select the correct item list
	switch(type)
	{
	case ITEM_WEAPON:	firstItem = WeaponRunes;	break;
	case ITEM_ABILITY:	firstItem = AbilityRunes;	break;
	case ITEM_COMBO:	firstItem = ComboRunes;		break;
	default: return;	//The armory only sells the above items
	}

	//find an empty slot
	for (i = 0; i < ARMORY_MAX_RUNES; ++i)
	{
		slot = &((firstItem + i)->rune);
		if (slot->itemtype == TYPE_NONE)
			break;
		slot = NULL;
	}
    
	//if there is no empty slot, replace the slot with the
	//cheapest rune in it.
	if (slot == NULL)
	{
		item_t *check;
		slot = &(firstItem->rune);

		for (i = 1; i < ARMORY_MAX_RUNES; ++i)
		{
			check = &((firstItem + i)->rune);
			if ((getBuyValue(check) < getBuyValue(slot)) || (check->itemLevel < slot->itemLevel))
				slot = check;
		}
		if ((getBuyValue(slot) > newPrice) || (slot->itemLevel > rune->itemLevel))
			slot = NULL;
	}

	//If we found a place for this rune, add it!
	if (slot != NULL)
	{
        V_ItemCopy(rune, slot);
		gi.dprintf("Item sold to armory. Price = %d.\n", newPrice);
		SaveArmory();
	}
	//else item is discarded.

}