本文整理汇总了C++中AInventory类的典型用法代码示例。如果您正苦于以下问题:C++ AInventory类的具体用法?C++ AInventory怎么用?C++ AInventory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AInventory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Use
bool ATeleporterBeacon::Use (bool pickup)
{
AInventory *drop;
// [BC] This is handled server-side.
if (( NETWORK_GetState( ) == NETSTATE_CLIENT ) ||
( CLIENTDEMO_IsPlaying( )))
{
return ( true );
}
// Increase the amount by one so that when DropInventory decrements it,
// the actor will have the same number of beacons that he started with.
// When we return to UseInventory, it will take care of decrementing
// Amount again and disposing of this item if there are no more.
Amount++;
drop = Owner->DropInventory (this);
if (drop == NULL)
{
Amount--;
return false;
}
else
{
drop->SetState(drop->FindState(NAME_Drop));
drop->target = Owner;
return true;
}
}
示例2: FixedMul
AInventory *AAmmo::CreateCopy (AActor *other)
{
AInventory *copy;
int amount = Amount;
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
if (GetClass()->ParentClass != RUNTIME_CLASS(AAmmo) && GetClass() != RUNTIME_CLASS(AAmmo))
{
const PClass *type = GetParentAmmo();
assert (type->ActorInfo != NULL);
if (!GoAway ())
{
Destroy ();
}
copy = static_cast<AInventory *>(Spawn (type, 0, 0, 0, NO_REPLACE));
copy->Amount = amount;
copy->BecomeItem ();
}
else
{
copy = Super::CreateCopy (other);
copy->Amount = amount;
}
if (copy->Amount > copy->MaxAmount)
{ // Don't pick up more ammo than you're supposed to be able to carry.
copy->Amount = copy->MaxAmount;
}
return copy;
}
示例3: G_StartTravel
void G_StartTravel ()
{
if (deathmatch)
return;
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i])
{
AActor *pawn = players[i].mo;
AInventory *inv;
players[i].camera = NULL;
// Only living players travel. Dead ones get a new body on the new level.
if (players[i].health > 0)
{
pawn->UnlinkFromWorld ();
P_DelSector_List ();
int tid = pawn->tid; // Save TID
pawn->RemoveFromHash ();
pawn->tid = tid; // Restore TID (but no longer linked into the hash chain)
pawn->ChangeStatNum (STAT_TRAVELLING);
for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory)
{
inv->ChangeStatNum (STAT_TRAVELLING);
inv->UnlinkFromWorld ();
P_DelSector_List ();
}
}
}
}
}
示例4: DrawWeapons
static void DrawWeapons(player_t *CPlayer, int x, int y)
{
int k,j;
AInventory *inv;
// First draw all weapons in the inventory that are not assigned to a weapon slot
for(inv = CPlayer->mo->Inventory; inv; inv = inv->Inventory)
{
if (inv->IsKindOf(RUNTIME_CLASS(AWeapon)) &&
!CPlayer->weapons.LocateWeapon(static_cast<AWeapon*>(inv)->GetClass(), NULL, NULL))
{
DrawOneWeapon(CPlayer, x, y, static_cast<AWeapon*>(inv));
}
}
// And now everything in the weapon slots back to front
for (k = NUM_WEAPON_SLOTS - 1; k >= 0; k--) for(j = CPlayer->weapons.Slots[k].Size() - 1; j >= 0; j--)
{
PClassActor *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
if (weap)
{
inv=CPlayer->mo->FindInventory(weap);
if (inv)
{
DrawOneWeapon(CPlayer, x, y, static_cast<AWeapon*>(inv));
}
}
}
}
示例5: C_PrintInv
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);
}
示例6: TakeStrifeItem
static void TakeStrifeItem (const TypeInfo *itemtype, int amount)
{
if (itemtype == NULL || amount == 0)
return;
// Don't take quest items.
if (itemtype->IsDescendantOf (RUNTIME_CLASS(AQuestItem)))
return;
// Don't take keys
if (itemtype->IsDescendantOf (RUNTIME_CLASS(AKey)))
return;
// Don't take the sigil
if (itemtype == RUNTIME_CLASS(ASigil))
return;
AInventory *item = ConversationPC->FindInventory (itemtype);
if (item != NULL)
{
item->Amount -= amount;
if (item->Amount <= 0)
{
item->Destroy ();
}
}
}
示例7: DEFINE_ACTION_FUNCTION
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);
}
}
示例8: DEFINE_ACTION_FUNCTION_PARAMS
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);
}
}
示例9: check
bool check(AActor *owner)
{
if (owner->IsKindOf(RUNTIME_CLASS(AKey)))
{
// P_GetMapColorForKey() checks the key directly
return owner->IsA(key) || owner->GetSpecies() == key->TypeName;
}
else
{
// Other calls check an actor that may have a key in its inventory.
AInventory *item;
for (item = owner->Inventory; item != NULL; item = item->Inventory)
{
if (item->IsA(key))
{
return true;
}
else if (item->GetSpecies() == key->TypeName)
{
return true;
}
}
return false;
}
}
示例10: TakeStrifeItem
static void TakeStrifeItem (player_t *player, const PClass *itemtype, int amount)
{
if (itemtype == NULL || amount == 0)
return;
// Don't take quest items.
if (itemtype->IsDescendantOf (PClass::FindClass(NAME_QuestItem)))
return;
// Don't take keys.
if (itemtype->IsDescendantOf (RUNTIME_CLASS(AKey)))
return;
// Don't take the sigil.
if (itemtype == RUNTIME_CLASS(ASigil))
return;
AInventory *item = player->mo->FindInventory (itemtype);
if (item != NULL)
{
item->Amount -= amount;
if (item->Amount <= 0)
{
item->Destroy ();
}
}
}
示例11: P_PlayerOnSpecialFlat
void P_PlayerOnSpecialFlat (player_t *player, int floorType)
{
if (Terrains[floorType].DamageAmount &&
!(level.time & Terrains[floorType].DamageTimeMask))
{
AInventory *ironfeet = NULL;
if (Terrains[floorType].AllowProtection)
{
for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory)
{
if (ironfeet->IsKindOf (RUNTIME_CLASS(APowerIronFeet)))
break;
}
}
int damage = 0;
if (ironfeet == NULL)
{
damage = P_DamageMobj (player->mo, NULL, NULL, Terrains[floorType].DamageAmount,
Terrains[floorType].DamageMOD);
}
if (damage > 0 && Terrains[floorType].Splash != -1)
{
S_Sound (player->mo, CHAN_AUTO,
Splashes[Terrains[floorType].Splash].NormalSplashSound, 1,
ATTN_IDLE);
}
}
}
示例12: GetParentAmmo
AInventory *AAmmo::CreateCopy (AActor *other)
{
AInventory *copy;
if (GetClass()->ParentType != RUNTIME_CLASS(AAmmo))
{
const TypeInfo *type = GetParentAmmo();
if (!GoAway ())
{
Destroy ();
}
copy = static_cast<AInventory *>(Spawn (type, 0, 0, 0));
copy->Amount = Amount;
copy->BecomeItem ();
}
else
{
copy = Super::CreateCopy (other);
}
if (copy->Amount > copy->MaxAmount)
{ // Don't pick up more ammo than you're supposed to be able to carry.
copy->Amount = copy->MaxAmount;
}
return copy;
}
示例13: HandlePickup
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;
}
示例14: while
void AMinotaurFriend::Die (AActor *source, AActor *inflictor, int dmgflags)
{
Super::Die (source, inflictor, dmgflags);
if (tracer && tracer->health > 0 && tracer->player)
{
// Search thinker list for minotaur
TThinkerIterator<AMinotaurFriend> iterator;
AMinotaurFriend *mo;
while ((mo = iterator.Next()) != NULL)
{
if (mo->health <= 0) continue;
// [RH] Minotaurs can't be morphed, so this isn't needed
//if (!(mo->flags&MF_COUNTKILL)) continue; // for morphed minotaurs
if (mo->flags&MF_CORPSE) continue;
if (mo->StartTime >= 0 && (level.maptime - StartTime) >= MAULATORTICS) continue;
if (mo->tracer != NULL && mo->tracer->player == tracer->player) break;
}
if (mo == NULL)
{
AInventory *power = tracer->FindInventory(PClass::FindActor("PowerMinotaur"));
if (power != NULL)
{
power->Destroy ();
}
}
}
}
示例15: 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( ));
}
}
}