Beispiel #1
0
void C_PrintInv(AActor *target)
{
	AInventory *item;
	int count = 0;

	if (target == NULL)
	{
		Printf("No target found!\n");
		return;
	}

	if (target->player)
		Printf("Inventory for Player '%s':\n", target->player->userinfo.GetName());
	else
		Printf("Inventory for Target '%s':\n", target->GetClass()->TypeName.GetChars());

	for (item = target->Inventory; item != NULL; item = item->Inventory)
	{
		Printf ("    %s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
			item->InventoryID,
			item->Amount, item->MaxAmount);
		count++;
	}
	Printf ("  List count: %d\n", count);
}
Beispiel #2
0
bool ABackpackItem::HandlePickup (AInventory *item)
{
    // Since you already have a backpack, that means you already have every
    // kind of ammo in your inventory, so we don't need to look at the
    // entire PClass list to discover what kinds of ammo exist, and we don't
    // have to alter the MaxAmount either.
    if (item->IsKindOf (RUNTIME_CLASS(ABackpackItem)))
    {
        for (AInventory *probe = Owner->Inventory; probe != NULL; probe = probe->Inventory)
        {
            if (probe->GetClass()->ParentClass == RUNTIME_CLASS(AAmmo))
            {
                if (probe->Amount < probe->MaxAmount || sv_unlimited_pickup)
                {
                    int amount = static_cast<AAmmo*>(probe->GetDefault())->BackpackAmount;
                    // extra ammo in baby mode and nightmare mode
                    if (!(item->ItemFlags&IF_IGNORESKILL))
                    {
                        amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
                    }
                    probe->Amount += amount;
                    if (probe->Amount > probe->MaxAmount && !sv_unlimited_pickup)
                    {
                        probe->Amount = probe->MaxAmount;
                    }
                }
            }
        }
        // The pickup always succeeds, even if you didn't get anything
        item->ItemFlags |= IF_PICKUPGOOD;
        return true;
    }
    return false;
}
Beispiel #3
0
static void DrawInventory(player_t * CPlayer, int x,int y)
{
	AInventory * rover;
	int numitems = (hudwidth - 2*x) / 32;
	int i;

	CPlayer->mo->InvFirst = rover = StatusBar->ValidateInvFirst(numitems);
	if (rover!=NULL)
	{
		if(rover->PrevInv())
		{
			screen->DrawTexture(invgems[!!(level.time&4)], x-10, y,
				DTA_KeepRatio, true,
				DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0x6666, TAG_DONE);
		}

		for(i=0;i<numitems && rover;rover=rover->NextInv())
		{
			if (rover->Amount>0)
			{
				FTextureID AltIcon = GetHUDIcon(rover->GetClass());

				if (AltIcon.Exists() && (rover->Icon.isValid() || AltIcon.isValid()) )
				{
					int trans = rover==CPlayer->mo->InvSel ? FRACUNIT : 0x6666;

					DrawImageToBox(TexMan[AltIcon.isValid()? AltIcon : rover->Icon], x, y, 19, 25, trans);
					if (rover->Amount>1)
					{
						char buffer[10];
						int xx;
						mysnprintf(buffer, countof(buffer), "%d", rover->Amount);
						if (rover->Amount>=1000) xx = 32 - IndexFont->StringWidth(buffer);
						else xx = 22;

						screen->DrawText(IndexFont, CR_GOLD, x+xx, y+20, buffer, 
							DTA_KeepRatio, true,
							DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans, TAG_DONE);
					}
					
					x+=32;
					i++;
				}
			}
		}
		if(rover)
		{
			screen->DrawTexture(invgems[2 + !!(level.time&4)], x-10, y,
				DTA_KeepRatio, true,
				DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0x6666, TAG_DONE);
		}
	}
}
Beispiel #4
0
void ABackpackItem::DetachFromOwner ()
{
	// When removing a backpack, drop the player's ammo maximums to normal
	AInventory *item;

	for (item = Owner->Inventory; item != NULL; item = item->Inventory)
	{
		if (item->GetClass()->ParentClass == RUNTIME_CLASS(AAmmo) &&
			item->MaxAmount == static_cast<AAmmo*>(item)->BackpackMaxAmount)
		{
			item->MaxAmount = static_cast<AInventory*>(item->GetDefault())->MaxAmount;
			if (item->Amount > item->MaxAmount)
			{
				item->Amount = item->MaxAmount;
			}
		}
	}
}
Beispiel #5
0
	void DrawPopScreen (int bottom)
	{
		char buff[64];
		const char *label;
		int i;
		AInventory *item;
		int xscale, yscale, left, top;
		int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2;
		int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2;
		// Extrapolate the height of the popscreen for smoother movement
		int height = clamp<int> (PopHeight + FixedMul (r_TicFrac, PopHeightChange), -POP_HEIGHT, 0);

		xscale = CleanXfac;
		yscale = CleanYfac;
		left = screen->GetWidth()/2 - 160*CleanXfac;
		top = bottom + height * yscale;

		screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE);
		screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE);
		screen->SetFont (SmallFont2);

		switch (CurrentPop)
		{
		case POP_Log:
			// Draw the latest log message.
			sprintf (buff, "%02d:%02d:%02d",
				(level.time/TICRATE)/3600,
				((level.time/TICRATE)%3600)/60,
				(level.time/TICRATE)%60);

			screen->DrawText (CR_UNTRANSLATED, left+210*xscale, top+8*yscale, buff,
				DTA_CleanNoMove, true, TAG_DONE);

			if (CPlayer->LogText != NULL)
			{
				brokenlines_t *lines = V_BreakLines (272, CPlayer->LogText);
				for (i = 0; lines[i].width >= 0; ++i)
				{
					screen->DrawText (CR_UNTRANSLATED, left+24*xscale, top+(18+i*12)*yscale,
						lines[i].string, DTA_CleanNoMove, true, TAG_DONE);
				}
				V_FreeBrokenLines (lines);
			}
			break;

		case POP_Keys:
			// List the keys the player has.
			int pos, endpos, leftcol;
			int clipleft, clipright;
			
			pos = KeyPopPos;
			endpos = pos + 10;
			leftcol = 20;
			clipleft = left + 17*xscale;
			clipright = left + (320-17)*xscale;
			if (KeyPopScroll > 0)
			{
				// Extrapolate the scroll position for smoother scrolling
				int scroll = MAX<int> (0,KeyPopScroll - FixedMul (r_TicFrac, 280/KEY_TIME));
				pos -= 10;
				leftcol = leftcol - 280 + scroll;
			}
			for (i = 0, item = CPlayer->mo->Inventory;
				i < endpos && item != NULL;
				item = item->Inventory)
			{
				if (!item->IsKindOf (RUNTIME_CLASS(AKey)))
					continue;
				
				if (i < pos)
				{
					i++;
					continue;
				}

				label = item->GetClass()->Meta.GetMetaString (AMETA_StrifeName);
				if (label == NULL)
				{
					label = item->GetClass()->Name + 1;
				}

				int colnum = ((i-pos) / 5) & (KeyPopScroll > 0 ? 3 : 1);
				int rownum = (i % 5) * 18;

				screen->DrawTexture (TexMan(item->Icon),
					left + (colnum * 140 + leftcol)*xscale,
					top + (6 + rownum)*yscale,
					DTA_CleanNoMove, true,
					DTA_ClipLeft, clipleft,
					DTA_ClipRight, clipright,
					TAG_DONE);
				screen->DrawText (CR_UNTRANSLATED,
					left + (colnum * 140 + leftcol + 17)*xscale,
					top + (11 + rownum)*yscale,
					label,
					DTA_CleanNoMove, true,
					DTA_ClipLeft, clipleft,
					DTA_ClipRight, clipright,
					TAG_DONE);
				i++;
			}
			break;

		case POP_Status:
			// Show miscellaneous status items.
			
			// Print stats
			DrINumber2 (CPlayer->accuracy, left+268*xscale, top+28*yscale, 7*xscale, imgFONY0);
			DrINumber2 (CPlayer->stamina, left+268*xscale, top+52*yscale, 7*xscale, imgFONY0);

			// How many keys does the player have?
			for (i = 0, item = CPlayer->mo->Inventory;
				item != NULL;
				item = item->Inventory)
			{
				if (item->IsKindOf (RUNTIME_CLASS(AKey)))
				{
					i++;
				}
			}
			DrINumber2 (i, left+268*xscale, top+76*yscale, 7*xscale, imgFONY0);

			// Does the player have a communicator?
			item = CPlayer->mo->FindInventory (RUNTIME_CLASS(ACommunicator));
			if (item != NULL)
			{
				screen->DrawTexture (TexMan(item->Icon),
					left + 280*xscale,
					top + 74*yscale,
					DTA_CleanNoMove, true, TAG_DONE);
			}

			// How much ammo does the player have?
			static const struct
			{
				const TypeInfo *AmmoType;
				int Y;
			} AmmoList[7] =
			{
				{ RUNTIME_CLASS(AClipOfBullets),			19 },
				{ RUNTIME_CLASS(APoisonBolts),				35 },
				{ RUNTIME_CLASS(AElectricBolts),			43 },
				{ RUNTIME_CLASS(AHEGrenadeRounds),			59 },
				{ RUNTIME_CLASS(APhosphorusGrenadeRounds),	67 },
				{ RUNTIME_CLASS(AMiniMissiles),				75 },
				{ RUNTIME_CLASS(AEnergyPod),				83 }
			};
			for (i = 0; i < 7; ++i)
			{
				item = CPlayer->mo->FindInventory (AmmoList[i].AmmoType);

				if (item == NULL)
				{
					DrINumber2 (0, left+206*xscale, top+AmmoList[i].Y*yscale, 7*xscale, imgFONY0);
					DrINumber2 (((AInventory *)GetDefaultByType (AmmoList[i].AmmoType))->MaxAmount,
						left+239*xscale, top+AmmoList[i].Y*yscale, 7*xscale, imgFONY0);
				}
				else
				{
					DrINumber2 (item->Amount, left+206*xscale, top+AmmoList[i].Y*yscale, 7*xscale, imgFONY0);
					DrINumber2 (item->MaxAmount, left+239*xscale, top+AmmoList[i].Y*yscale, 7*xscale, imgFONY0);
				}
			}

			// What weapons does the player have?
			static const struct
			{
				const char *TypeName;
				int X, Y;
			} WeaponList[6] =
			{
				{ "StrifeCrossbow",			23, 19 },
				{ "AssaultGun",				21, 41 },
				{ "FlameThrower",			57, 50 },
				{ "MiniMissileLauncher",	20, 64 },
				{ "StrifeGrenadeLauncher",	55, 20 },
				{ "Mauler",					52, 75 },
			};
			for (i = 0; i < 6; ++i)
			{
				item = CPlayer->mo->FindInventory (TypeInfo::FindType (WeaponList[i].TypeName));

				if (item != NULL)
				{
					screen->DrawTexture (TexMan(item->Icon),
						left + WeaponList[i].X*xscale,
						top + WeaponList[i].Y*yscale,
						DTA_CleanNoMove, true,
						DTA_LeftOffset, 0,
						DTA_TopOffset, 0,
						TAG_DONE);
				}
			}
			break;
		}

		screen->SetFont (SmallFont);
	}