Esempio n. 1
0
void BuyRuneConfirmMenu_handler (edict_t *ent, int option)
{
	//Navigating the menu?
	if (option > 100)
	{
		int page_num = option / 1000;
		int selection = (option % 1000)-1;
		item_t *slot = V_FindFreeItemSlot(ent);
		int cost;

		armoryRune_t *firstItem;
		item_t *rune;

		switch(page_num)
		{
		case 1: firstItem = WeaponRunes;	break;
		case 2: firstItem = AbilityRunes;	break;
		case 3: firstItem = ComboRunes;		break;
		default: 
			gi.dprintf("Error in BuyRuneConfirmMenu_handler(). Invalid page number: %d\n", page_num);
			return;
		}

		rune = &((firstItem + selection)->rune);
		if (rune->itemtype == ITEM_NONE)
		{
			gi.cprintf(ent, PRINT_HIGH, "Sorry, someone else has purchased this rune.\n");
			closemenu(ent);
			return;
		}
		cost = getBuyValue(rune);

		//Do we have enough credits?
		if (ent->myskills.credits < cost)
		{
			gi.cprintf(ent, PRINT_HIGH, "You need %d more credits to buy this item.\n", cost - ent->myskills.credits);
		}
		//Check for free space
		else if (slot == NULL)
		{
			gi.cprintf(ent, PRINT_HIGH, "Not enough room in inventory.\n");
		}
		else
		{
			//log the purchase
			WriteToLogfile(ent, va("Buying rune for %d credits. [%s]", cost, rune->id));

			//Buy it!
			V_ItemSwap(rune, slot);
			ent->myskills.credits -= cost;
			SaveArmory();
			savePlayer(ent);
			gi.cprintf(ent, PRINT_HIGH, "Rune purchased for %d credits.\nYou have %d credits left.\n", cost, ent->myskills.credits);
			gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/gold.wav"), 1, ATTN_NORM, 0);
		}

		//done
		closemenu(ent);
		return;
	}
	else
	{
		int page_num = option / 10;
		int selection = option % 10;

		OpenBuyRuneMenu(ent, page_num, selection);
		return;
	}

}
Esempio n. 2
0
void V_EquipItem(edict_t *ent, int index)
{
	int i, wpts, apts, total_pts, clvl = ent->myskills.level;

	// calculate number of weapon and ability points separately
	wpts = V_GetRuneWeaponPts(ent, &ent->myskills.items[index]);
	apts = V_GetRuneAbilityPts(ent, &ent->myskills.items[index]);
	// calculate weighted total
	total_pts = ceil(0.5*wpts + 0.75*apts);//was 0.66,2.0
	//gi.dprintf("wpts = %d, apts = %d, total = %d\n", wpts, apts, total_pts);

	if(index < 3)
	{
		//remove an item
		item_t *slot = V_FindFreeItemSlot(ent);
		if (slot == NULL)
		{
			safe_cprintf(ent, PRINT_HIGH, "Not enough room in your stash.\n");
			return;
		}
		V_ItemSwap(&ent->myskills.items[index], slot);
		gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/boots.wav"), 1, ATTN_NORM, 0);
		safe_cprintf(ent, PRINT_HIGH, "Item successfully placed in your stash.\n");
	}
	//Everyone but admins have a minimum level requirement to use a rune. (easier for rune testing)
	// vrxchile 2.0: only 999 admins are able to test runes.
	else if ((ent->myskills.administrator < 999) && (ent->myskills.level < total_pts))
	{
		safe_cprintf(ent, PRINT_HIGH, "You need to be level %d to use this rune.\n", total_pts);
		return;
	}
	else if (index < MAX_VRXITEMS)
	{
		int type = ent->myskills.items[index].itemtype;

		if (type & ITEM_UNIQUE)
			type ^= ITEM_UNIQUE;

		//equip an item
		switch(type)
		{
		case ITEM_WEAPON:
			V_ItemSwap(&ent->myskills.items[index], &ent->myskills.items[0]); //put on hand slot
			if (eqSetItems(ent, &ent->myskills.items[0]) == 3)
				gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/blessedaim.wav"), 1, ATTN_NORM, 0);
			else gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/glovesmetal.wav"), 1, ATTN_NORM, 0);
			break;
		case ITEM_ABILITY:
			V_ItemSwap(&ent->myskills.items[index], &ent->myskills.items[1]); //put on neck slot
			if (eqSetItems(ent, &ent->myskills.items[0]) == 3)
				gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/blessedaim.wav"), 1, ATTN_NORM, 0);
			else gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/amulet.wav"), 1, ATTN_NORM, 0);
			break;
		case ITEM_COMBO:
			V_ItemSwap(&ent->myskills.items[index], &ent->myskills.items[2]); //put on neck slot
			if (eqSetItems(ent, &ent->myskills.items[0]) == 3)
				gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/blessedaim.wav"), 1, ATTN_NORM, 0);
			else gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/belt.wav"), 1, ATTN_NORM, 0);
			break;
		case ITEM_CLASSRUNE:
			V_ItemSwap(&ent->myskills.items[index], &ent->myskills.items[1]); //put on neck slot
			if (eqSetItems(ent, &ent->myskills.items[0]) == 3)
				gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/blessedaim.wav"), 1, ATTN_NORM, 0);
			else gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/amulet.wav"), 1, ATTN_NORM, 0);
			break;
		}
		safe_cprintf(ent, PRINT_HIGH, "Item successfully equipped.\n");
	}

	//Reset all rune info
	V_ResetAllStats(ent);
	for (i = 0; i < 3; ++i)
	{
		if (ent->myskills.items[i].itemtype != TYPE_NONE)
			V_ApplyRune(ent, &ent->myskills.items[i]);
	}
}