本文整理汇总了C++中AInventory::CallTryPickup方法的典型用法代码示例。如果您正苦于以下问题:C++ AInventory::CallTryPickup方法的具体用法?C++ AInventory::CallTryPickup怎么用?C++ AInventory::CallTryPickup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AInventory
的用法示例。
在下文中一共展示了AInventory::CallTryPickup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: countof
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem)
{
ACTION_PARAM_START(1);
ACTION_PARAM_INT(questitem, 0);
// Give one of these quest items to every player in the game
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i])
{
AInventory *item = static_cast<AInventory *>(Spawn (QuestItemClasses[questitem-1], 0,0,0, NO_REPLACE));
if (!item->CallTryPickup (players[i].mo))
{
item->Destroy ();
}
}
}
char messageid[64];
mysnprintf(messageid, countof(messageid), "TXT_QUEST_%d", questitem);
const char * name = GStrings[messageid];
if (name != NULL)
{
C_MidPrint (SmallFont, name);
}
}
示例2:
DEFINE_ACTION_FUNCTION(AActor, A_Summon)
{
AMinotaurFriend *mo;
mo = Spawn<AMinotaurFriend> (self->Pos(), ALLOW_REPLACE);
if (mo)
{
if (P_TestMobjLocation(mo) == false || !self->tracer)
{ // Didn't fit - change back to artifact
mo->Destroy ();
AActor *arti = Spawn<AArtiDarkServant> (self->Pos(), ALLOW_REPLACE);
if (arti) arti->flags |= MF_DROPPED;
return;
}
mo->StartTime = level.maptime;
if (self->tracer->flags & MF_CORPSE)
{ // Master dead
mo->tracer = NULL; // No master
}
else
{
mo->tracer = self->tracer; // Pointer to master
AInventory *power = Spawn<APowerMinotaur> (0, 0, 0, NO_REPLACE);
power->CallTryPickup (self->tracer);
mo->SetFriendPlayer(self->tracer->player);
}
// Make smoke puff
Spawn ("MinotaurSmoke", self->Pos(), ALLOW_REPLACE);
S_Sound (self, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM);
}
}
示例3: GiveSpawner
void GiveSpawner (player_t *player, const PClass *type, int amount)
{
if (player->mo == NULL || player->health <= 0)
{
return;
}
AInventory *item = static_cast<AInventory *>
(Spawn (type, player->mo->x, player->mo->y, player->mo->z, NO_REPLACE));
if (item != NULL)
{
if (amount > 0)
{
if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
{
if (static_cast<ABasicArmorPickup*>(item)->SaveAmount != 0)
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
else
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
}
else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
{
static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
// [BB]
static_cast<ABasicArmorBonus*>(item)->BonusCount *= amount;
}
else
{
item->Amount = MIN (amount, item->MaxAmount);
}
}
if(item->flags & MF_COUNTITEM) // Given items shouldn't count against the map's total,
{ // since they aren't added to the player's total.
level.total_items--;
item->flags &= ~MF_COUNTITEM;
}
if (!item->CallTryPickup (player->mo))
{
item->Destroy ();
}
else
{
// [BB] This construction is more or less a hack, but at least the give cheats are now working.
SERVER_GiveInventoryToPlayer( player, item );
// [BC] Play the announcer sound.
if ( players[consoleplayer].camera == players[consoleplayer].mo && cl_announcepickups )
ANNOUNCER_PlayEntry( cl_announcer, item->PickupAnnouncerEntry( ));
}
}
}
示例4: CallTryPickup
bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
{
TObjPtr<AInventory> Invstack = Inventory; // A pointer of the inventories item stack.
// unmorphed versions of a currently morphed actor cannot pick up anything.
if (toucher->flags & MF_UNMORPHED) return false;
bool res;
if (CanPickup(toucher))
res = TryPickup(toucher);
else if (!(ItemFlags & IF_RESTRICTABSOLUTELY))
res = TryPickupRestricted(toucher); // let an item decide for itself how it will handle this
else
return false;
// Morph items can change the toucher so we need an option to return this info.
if (toucher_return != NULL) *toucher_return = toucher;
if (!res && (ItemFlags & IF_ALWAYSPICKUP) && !ShouldStay())
{
res = true;
GoAwayAndDie();
}
if (res)
{
GiveQuest(toucher);
// Transfer all inventory accross that the old object had, if requested.
if ((ItemFlags & IF_TRANSFER))
{
while (Invstack)
{
AInventory* titem = Invstack;
Invstack = titem->Inventory;
if (titem->Owner == this)
{
if (!titem->CallTryPickup(toucher)) // The object no longer can exist
{
titem->Destroy();
}
}
}
}
}
return res;
}
示例5: TryPickup
bool AHealthTraining::TryPickup (AActor *&toucher)
{
if (Super::TryPickup (toucher))
{
toucher->GiveInventoryType (PClass::FindActor("GunTraining"));
AInventory *coin = Spawn<ACoin> ();
if (coin != NULL)
{
coin->Amount = toucher->player->mo->accuracy*5 + 300;
if (!coin->CallTryPickup (toucher))
{
coin->Destroy ();
}
}
return true;
}
return false;
}
示例6: GiveSpawner
void GiveSpawner (player_t *player, PClassInventory *type, int amount)
{
if (player->mo == NULL || player->health <= 0)
{
return;
}
AInventory *item = static_cast<AInventory *>
(Spawn (type, player->mo->Pos(), NO_REPLACE));
if (item != NULL)
{
if (amount > 0)
{
if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
{
if (static_cast<ABasicArmorPickup*>(item)->SaveAmount != 0)
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
else
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
}
else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
{
static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
}
else
{
item->Amount = MIN (amount, item->MaxAmount);
}
}
item->ClearCounters();
if (!item->CallTryPickup (player->mo))
{
item->Destroy ();
}
}
}