当前位置: 首页>>代码示例>>C++>>正文


C++ AInventory::DepleteOrDestroy方法代码示例

本文整理汇总了C++中AInventory::DepleteOrDestroy方法的典型用法代码示例。如果您正苦于以下问题:C++ AInventory::DepleteOrDestroy方法的具体用法?C++ AInventory::DepleteOrDestroy怎么用?C++ AInventory::DepleteOrDestroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AInventory的用法示例。


在下文中一共展示了AInventory::DepleteOrDestroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cht_Take

void cht_Take (player_t *player, const char *name, int amount)
{
    bool takeall;
    PClassActor *type;

    if (player->mo == NULL || player->health <= 0)
    {
        return;
    }

    takeall = (stricmp (name, "all") == 0);

    if (!takeall && stricmp (name, "health") == 0)
    {
        if (player->mo->health - amount <= 0
                || player->health - amount <= 0
                || amount == 0)
        {

            cht_Suicide (player);

            if (player == &players[consoleplayer])
                C_HideConsole ();

            return;
        }

        if (amount > 0)
        {
            if (player->mo)
            {
                player->mo->health -= amount;
                player->health = player->mo->health;
            }
            else
            {
                player->health -= amount;
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "backpack") == 0)
    {
        // Take away all types of backpacks the player might own.
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            PClass *type = PClassActor::AllActorClasses[i];

            if (type->IsDescendantOf(RUNTIME_CLASS (ABackpackItem)))
            {
                AInventory *pack = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (pack)
                    pack->Destroy();
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "ammo") == 0)
    {
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            PClass *type = PClassActor::AllActorClasses[i];

            if (type->ParentClass == RUNTIME_CLASS (AAmmo))
            {
                AInventory *ammo = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (ammo)
                    ammo->DepleteOrDestroy();
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "armor") == 0)
    {
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            type = PClassActor::AllActorClasses[i];

            if (type->IsDescendantOf (RUNTIME_CLASS (AArmor)))
            {
                AInventory *armor = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (armor)
                    armor->DepleteOrDestroy();
            }
        }

        if (!takeall)
            return;
//.........这里部分代码省略.........
开发者ID:MajorCooke,项目名称:GZDoom,代码行数:101,代码来源:m_cheat.cpp

示例2: P_MorphPlayer


//.........这里部分代码省略.........
		{ // Make a super chicken
			p->mo->GiveInventoryType (RUNTIME_CLASS(APowerWeaponLevel2));
		}
		return false;
	}
	if (p->health <= 0)
	{ // Dead players cannot morph
		return false;
	}
	if (spawntype == NULL)
	{
		return false;
	}
	if (!spawntype->IsDescendantOf (RUNTIME_CLASS(APlayerPawn)))
	{
		return false;
	}
	if (spawntype == p->mo->GetClass())
	{
		return false;
	}

	morphed = static_cast<APlayerPawn *>(Spawn (spawntype, actor->Pos(), NO_REPLACE));
	EndAllPowerupEffects(actor->Inventory);
	DObject::StaticPointerSubstitution (actor, morphed);
	if ((actor->tid != 0) && (style & MORPH_NEWTIDBEHAVIOUR))
	{
		morphed->tid = actor->tid;
		morphed->AddToHash ();
		actor->RemoveFromHash ();
		actor->tid = 0;
	}
	morphed->angle = actor->angle;
	morphed->target = actor->target;
	morphed->tracer = actor;
	morphed->Score = actor->Score;
	p->PremorphWeapon = p->ReadyWeapon;
	morphed->special2 = actor->flags & ~MF_JUSTHIT;
	morphed->player = p;
	if (actor->renderflags & RF_INVISIBLE)
	{
		morphed->special2 |= MF_JUSTHIT;
	}
	if (morphed->ViewHeight > p->viewheight && p->deltaviewheight == 0)
	{ // If the new view height is higher than the old one, start moving toward it.
		p->deltaviewheight = p->GetDeltaViewHeight();
	}
	morphed->flags  |= actor->flags & (MF_SHADOW|MF_NOGRAVITY);
	morphed->flags2 |= actor->flags2 & MF2_FLY;
	morphed->flags3 |= actor->flags3 & MF3_GHOST;
	AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE);
	actor->player = NULL;
	actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
	actor->flags |= MF_UNMORPHED;
	actor->renderflags |= RF_INVISIBLE;
	p->morphTics = (duration) ? duration : MORPHTICS;

	// [MH] Used by SBARINFO to speed up face drawing
	p->MorphedPlayerClass = spawntype;

	p->MorphStyle = style;
	p->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog);
	p->health = morphed->health;
	p->mo = morphed;
	p->velx = p->vely = 0;
	morphed->ObtainInventory (actor);
	// Remove all armor
	for (item = morphed->Inventory; item != NULL; )
	{
		AInventory *next = item->Inventory;
		if (item->IsKindOf (RUNTIME_CLASS(AArmor)))
		{
			if (item->IsKindOf (RUNTIME_CLASS(AHexenArmor)))
			{
				// Set the HexenArmor slots to 0, except the class slot.
				AHexenArmor *hxarmor = static_cast<AHexenArmor *>(item);
				hxarmor->Slots[0] = 0;
				hxarmor->Slots[1] = 0;
				hxarmor->Slots[2] = 0;
				hxarmor->Slots[3] = 0;
				hxarmor->Slots[4] = spawntype->HexenArmor[0];
			}
			else
			{
				item->DepleteOrDestroy();
			}
		}
		item = next;
	}
	InitAllPowerupEffects(morphed->Inventory);
	morphed->ActivateMorphWeapon ();
	if (p->camera == actor)
	{
		p->camera = morphed;
	}
	morphed->ScoreIcon = actor->ScoreIcon;	// [GRB]
	if (eflash)	
		eflash->target = p->mo;
	return true;
}
开发者ID:ibm5155,项目名称:zdoom,代码行数:101,代码来源:a_morph.cpp


注:本文中的AInventory::DepleteOrDestroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。