mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- scriptified the remains of AAmmo.
This commit is contained in:
parent
cfdd580044
commit
d9fd2d509f
22 changed files with 122 additions and 245 deletions
|
@ -21,7 +21,6 @@
|
|||
#include "d_event.h"
|
||||
#include "d_player.h"
|
||||
#include "vectors.h"
|
||||
#include "a_ammo.h"
|
||||
|
||||
static FRandom pr_botmove ("BotMove");
|
||||
|
||||
|
@ -346,12 +345,12 @@ void DBot::WhatToGet (AActor *item)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (item->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
||||
else if (item->IsKindOf (PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
AAmmo *ammo = static_cast<AAmmo *> (item);
|
||||
PClassActor *parent = ammo->GetParentAmmo ();
|
||||
AInventory *holdingammo = player->mo->FindInventory (parent);
|
||||
|
||||
auto ac = PClass::FindActor(NAME_Ammo);
|
||||
auto parent = item->GetClass();
|
||||
while (parent->ParentClass != ac) parent = (PClassActor*)(parent->ParentClass);
|
||||
AInventory *holdingammo = player->mo->FindInventory(parent);
|
||||
if (holdingammo != NULL && holdingammo->Amount >= holdingammo->MaxAmount)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
#include "v_text.h"
|
||||
#include "vmbuilder.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
|
||||
// [SO] Just the way Randy said to do it :)
|
||||
// [RH] Made this CVAR_SERVERINFO
|
||||
|
@ -1536,7 +1535,7 @@ static int PatchSprite (int sprNum)
|
|||
static int PatchAmmo (int ammoNum)
|
||||
{
|
||||
PClassActor *ammoType = NULL;
|
||||
AAmmo *defaultAmmo = NULL;
|
||||
AInventory *defaultAmmo = NULL;
|
||||
int result;
|
||||
int oldclip;
|
||||
int dummy;
|
||||
|
@ -1549,7 +1548,7 @@ static int PatchAmmo (int ammoNum)
|
|||
ammoType = AmmoNames[ammoNum];
|
||||
if (ammoType != NULL)
|
||||
{
|
||||
defaultAmmo = (AAmmo *)GetDefaultByType (ammoType);
|
||||
defaultAmmo = (AInventory*)GetDefaultByType (ammoType);
|
||||
if (defaultAmmo != NULL)
|
||||
{
|
||||
max = &defaultAmmo->MaxAmount;
|
||||
|
@ -1575,8 +1574,8 @@ static int PatchAmmo (int ammoNum)
|
|||
// Calculate the new backpack-given amounts for this ammo.
|
||||
if (ammoType != NULL)
|
||||
{
|
||||
defaultAmmo->BackpackMaxAmount = defaultAmmo->MaxAmount * 2;
|
||||
defaultAmmo->BackpackAmount = defaultAmmo->Amount;
|
||||
defaultAmmo->IntVar("BackpackMaxAmount") = defaultAmmo->MaxAmount * 2;
|
||||
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->Amount;
|
||||
}
|
||||
|
||||
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
|
||||
|
@ -1591,7 +1590,7 @@ static int PatchAmmo (int ammoNum)
|
|||
|
||||
if (type->IsDescendantOf (ammoType))
|
||||
{
|
||||
defaultAmmo = (AAmmo *)GetDefaultByType (type);
|
||||
defaultAmmo = (AInventory *)GetDefaultByType (type);
|
||||
defaultAmmo->MaxAmount = *max;
|
||||
defaultAmmo->Amount = Scale (defaultAmmo->Amount, *per, oldclip);
|
||||
}
|
||||
|
@ -1673,7 +1672,7 @@ static int PatchWeapon (int weapNum)
|
|||
info->AmmoType1 = (PClassInventory*)AmmoNames[val];
|
||||
if (info->AmmoType1 != NULL)
|
||||
{
|
||||
info->AmmoGive1 = ((AAmmo*)GetDefaultByType (info->AmmoType1))->Amount * 2;
|
||||
info->AmmoGive1 = ((AInventory*)GetDefaultByType (info->AmmoType1))->Amount * 2;
|
||||
if (info->AmmoUse1 == 0)
|
||||
{
|
||||
info->AmmoUse1 = 1;
|
||||
|
@ -2930,7 +2929,7 @@ static bool LoadDehSupp ()
|
|||
else
|
||||
{
|
||||
auto cls = PClass::FindActor(sc.String);
|
||||
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(AAmmo)))
|
||||
if (cls == NULL || !cls->IsDescendantOf(PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
sc.ScriptError("Unknown ammo type '%s'", sc.String);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "p_setup.h"
|
||||
#include "p_spec.h"
|
||||
#include "r_utility.h"
|
||||
#include "a_ammo.h"
|
||||
#include "math/cmath.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
@ -2478,14 +2477,7 @@ static void FS_TakeInventory (AActor *actor, const char * type, int amount)
|
|||
// If it's not ammo, destroy it. Ammo needs to stick around, even
|
||||
// when it's zero for the benefit of the weapons that use it and
|
||||
// to maintain the maximum ammo amounts a backpack might have given.
|
||||
if (item->GetClass()->ParentClass != RUNTIME_CLASS(AAmmo))
|
||||
{
|
||||
item->Destroy ();
|
||||
}
|
||||
else
|
||||
{
|
||||
item->Amount = 0;
|
||||
}
|
||||
item->DepleteOrDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2628,7 +2620,7 @@ void FParser::SF_MaxPlayerAmmo()
|
|||
if(amount < 0) amount = 0;
|
||||
if (!iammo)
|
||||
{
|
||||
iammo = static_cast<AAmmo *>(Spawn (ammotype));
|
||||
iammo = static_cast<AInventory *>(Spawn (ammotype));
|
||||
iammo->Amount = 0;
|
||||
iammo->AttachToOwner (players[playernum].mo);
|
||||
}
|
||||
|
@ -2644,13 +2636,13 @@ void FParser::SF_MaxPlayerAmmo()
|
|||
break;
|
||||
}
|
||||
}
|
||||
((AAmmo*)iammo)->BackpackMaxAmount=amount;
|
||||
iammo->IntVar("BackpackMaxAmount") = amount;
|
||||
}
|
||||
|
||||
t_return.type = svt_int;
|
||||
AInventory * iammo = players[playernum].mo->FindInventory(ammotype);
|
||||
if (iammo) t_return.value.i = iammo->MaxAmount;
|
||||
else t_return.value.i = ((AAmmo*)GetDefaultByType(ammotype))->MaxAmount;
|
||||
else t_return.value.i = ((AInventory*)GetDefaultByType(ammotype))->MaxAmount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
** a_ammo.cpp
|
||||
** Implements ammo and backpack items.
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2000-2016 Randy Heit
|
||||
** Copyright 2006-2016 Cheistoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "d_player.h"
|
||||
#include "serializer.h"
|
||||
|
||||
IMPLEMENT_CLASS(AAmmo, false, false)
|
||||
|
||||
DEFINE_FIELD(AAmmo, BackpackAmount)
|
||||
DEFINE_FIELD(AAmmo, BackpackMaxAmount)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AAmmo :: Serialize
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void AAmmo::Serialize(FSerializer &arc)
|
||||
{
|
||||
Super::Serialize (arc);
|
||||
auto def = (AAmmo*)GetDefault();
|
||||
arc("backpackamount", BackpackAmount, def->BackpackAmount)
|
||||
("backpackmaxamount", BackpackMaxAmount, def->BackpackMaxAmount);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AAmmo :: GetParentAmmo
|
||||
//
|
||||
// Returns the least-derived ammo type that this ammo is a descendant of.
|
||||
// That is, if this ammo is an immediate subclass of Ammo, then this ammo's
|
||||
// type is returned. If this ammo's superclass is not Ammo, then this
|
||||
// function travels up the inheritance chain until it finds a type that is
|
||||
// an immediate subclass of Ammo and returns that.
|
||||
//
|
||||
// The intent of this is that all unique ammo types will be immediate
|
||||
// subclasses of Ammo. To make different pickups with different ammo amounts,
|
||||
// you subclass the type of ammo you want a different amount for and edit
|
||||
// that.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassActor *AAmmo::GetParentAmmo () const
|
||||
{
|
||||
PClass *type = GetClass();
|
||||
|
||||
while (type->ParentClass != RUNTIME_CLASS(AAmmo) && type->ParentClass != NULL)
|
||||
{
|
||||
type = type->ParentClass;
|
||||
}
|
||||
return static_cast<PClassActor *>(type);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AAmmo, GetParentAmmo)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AAmmo);
|
||||
ACTION_RETURN_OBJECT(self->GetParentAmmo());
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
#include "a_pickups.h"
|
||||
|
||||
class AAmmo : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AAmmo, AInventory)
|
||||
public:
|
||||
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
PClassActor *GetParentAmmo () const;
|
||||
|
||||
int BackpackAmount, BackpackMaxAmount, DropAmount;
|
||||
};
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
#include "p_spec.h"
|
||||
#include "serializer.h"
|
||||
#include "virtual.h"
|
||||
#include "a_ammo.h"
|
||||
#include "c_functions.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
@ -1314,29 +1313,7 @@ bool AInventory::TryPickup (AActor *&toucher)
|
|||
ItemFlags &= ~IF_PICKUPGOOD;
|
||||
GoAwayAndDie ();
|
||||
}
|
||||
else if (MaxAmount == 0 && !IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||
{
|
||||
// Special case: If an item's MaxAmount is 0, you can still pick it
|
||||
// up if it is autoactivate-able.
|
||||
if (!(ItemFlags & IF_AUTOACTIVATE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// The item is placed in the inventory just long enough to be used.
|
||||
toucher->AddInventory (this);
|
||||
bool usegood = CallUse (true);
|
||||
toucher->RemoveInventory (this);
|
||||
|
||||
if (usegood)
|
||||
{
|
||||
GoAwayAndDie ();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (MaxAmount > 0)
|
||||
{
|
||||
// Add the item to the inventory. It is not already there, or HandlePickup
|
||||
// would have already taken care of it.
|
||||
|
@ -1374,6 +1351,25 @@ bool AInventory::TryPickup (AActor *&toucher)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (ItemFlags & IF_AUTOACTIVATE)
|
||||
{
|
||||
// Special case: If an item's MaxAmount is 0, you can still pick it
|
||||
// up if it is autoactivate-able.
|
||||
|
||||
// The item is placed in the inventory just long enough to be used.
|
||||
toucher->AddInventory(this);
|
||||
bool usegood = CallUse(true);
|
||||
toucher->RemoveInventory(this);
|
||||
|
||||
if (usegood)
|
||||
{
|
||||
GoAwayAndDie();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "serializer.h"
|
||||
#include "thingdef.h"
|
||||
#include "virtual.h"
|
||||
#include "a_ammo.h"
|
||||
|
||||
|
||||
#define BONUSADD 6
|
||||
|
||||
|
@ -499,9 +499,9 @@ void AWeapon::AttachToOwner (AActor *other)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
|
||||
AInventory *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
|
||||
{
|
||||
AAmmo *ammo;
|
||||
AInventory *ammo;
|
||||
|
||||
if (ammotype == NULL)
|
||||
{
|
||||
|
@ -518,10 +518,10 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
|
|||
{
|
||||
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
|
||||
}
|
||||
ammo = static_cast<AAmmo *>(other->FindInventory (ammotype));
|
||||
ammo = other->FindInventory (ammotype);
|
||||
if (ammo == NULL)
|
||||
{
|
||||
ammo = static_cast<AAmmo *>(Spawn (ammotype));
|
||||
ammo = static_cast<AInventory *>(Spawn (ammotype));
|
||||
ammo->Amount = MIN (amount, ammo->MaxAmount);
|
||||
ammo->AttachToOwner (other);
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
|
|||
//===========================================================================
|
||||
EXTERN_CVAR(Bool, sv_unlimited_pickup)
|
||||
|
||||
bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
|
||||
bool AWeapon::AddExistingAmmo (AInventory *ammo, int amount)
|
||||
{
|
||||
if (ammo != NULL && (ammo->Amount < ammo->MaxAmount || sv_unlimited_pickup))
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "a_ammo.h"
|
||||
|
||||
#include "a_pickups.h"
|
||||
class PClassWeapon;
|
||||
class AWeapon;
|
||||
|
||||
|
@ -126,7 +125,7 @@ public:
|
|||
float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
|
||||
|
||||
// In-inventory instance variables
|
||||
TObjPtr<AAmmo> Ammo1, Ammo2;
|
||||
TObjPtr<AInventory> Ammo1, Ammo2;
|
||||
TObjPtr<AWeapon> SisterWeapon;
|
||||
float FOVScale;
|
||||
int Crosshair; // 0 to use player's crosshair
|
||||
|
@ -182,8 +181,8 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
AAmmo *AddAmmo (AActor *other, PClassActor *ammotype, int amount);
|
||||
bool AddExistingAmmo (AAmmo *ammo, int amount);
|
||||
AInventory *AddAmmo (AActor *other, PClassActor *ammotype, int amount);
|
||||
bool AddExistingAmmo (AInventory *ammo, int amount);
|
||||
AWeapon *AddWeapon (PClassWeapon *weapon);
|
||||
};
|
||||
|
||||
|
|
|
@ -294,7 +294,6 @@ int FindMugShotStateIndex(FName state);
|
|||
// Base Status Bar ----------------------------------------------------------
|
||||
|
||||
class FTexture;
|
||||
class AAmmo;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -395,7 +394,7 @@ protected:
|
|||
|
||||
void RefreshBackground () const;
|
||||
|
||||
void GetCurrentAmmo (AAmmo *&ammo1, AAmmo *&ammo2, int &ammocount1, int &ammocount2) const;
|
||||
void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const;
|
||||
|
||||
public:
|
||||
AInventory *ValidateInvFirst (int numVisible) const;
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "gstrings.h"
|
||||
#include "version.h"
|
||||
#include "cmdlib.h"
|
||||
#include "a_ammo.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
|
||||
|
@ -1517,7 +1516,7 @@ public:
|
|||
return translationtables[TRANSLATION_Players][int(CPlayer - players)];
|
||||
}
|
||||
|
||||
AAmmo *ammo1, *ammo2;
|
||||
AInventory *ammo1, *ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
ABasicArmor *armor;
|
||||
FImageCollection Images;
|
||||
|
|
|
@ -244,31 +244,31 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
texture = TexMan(statusBar->CPlayer->mo->ScoreIcon);
|
||||
else if(type == AMMO1)
|
||||
{
|
||||
AAmmo *ammo = statusBar->ammo1;
|
||||
auto ammo = statusBar->ammo1;
|
||||
if(ammo != NULL)
|
||||
GetIcon(ammo);
|
||||
}
|
||||
else if(type == AMMO2)
|
||||
{
|
||||
AAmmo *ammo = statusBar->ammo2;
|
||||
auto ammo = statusBar->ammo2;
|
||||
if(ammo != NULL)
|
||||
GetIcon(ammo);
|
||||
}
|
||||
else if(type == ARMOR)
|
||||
{
|
||||
ABasicArmor *armor = statusBar->armor;
|
||||
auto armor = statusBar->armor;
|
||||
if(armor != NULL && armor->Amount != 0)
|
||||
GetIcon(armor);
|
||||
}
|
||||
else if(type == WEAPONICON)
|
||||
{
|
||||
AWeapon *weapon = statusBar->CPlayer->ReadyWeapon;
|
||||
auto weapon = statusBar->CPlayer->ReadyWeapon;
|
||||
if(weapon != NULL)
|
||||
GetIcon(weapon);
|
||||
}
|
||||
else if(type == SIGIL)
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
|
||||
auto item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
|
||||
if (item != NULL)
|
||||
texture = TexMan(item->Icon);
|
||||
}
|
||||
|
@ -1076,10 +1076,10 @@ class CommandDrawNumber : public CommandDrawString
|
|||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindActor(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
inventoryItem = PClass::FindActor(NAME_Ammo);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
|
@ -1092,10 +1092,10 @@ class CommandDrawNumber : public CommandDrawString
|
|||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindActor(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
inventoryItem = PClass::FindActor(NAME_Ammo);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
|
@ -1435,7 +1435,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
{
|
||||
// num = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem) / TICRATE + 1;
|
||||
static VMFunction *func = nullptr;
|
||||
if (func == nullptr) func = static_cast<PFunction*>(RUNTIME_CLASS(APlayerPawn)->Symbols.FindSymbol("GetEffectTicsForItem", false))->Variants[0].Implementation;
|
||||
if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem");
|
||||
VMValue params[] = { statusBar->CPlayer->mo, inventoryItem };
|
||||
int retv;
|
||||
VMReturn ret(&retv);
|
||||
|
@ -2630,10 +2630,10 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
sc.MustGetToken(TK_Identifier);
|
||||
type = AMMO;
|
||||
data.inventoryItem = PClass::FindActor(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
|
||||
if(data.inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
data.inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
data.inventoryItem = PClass::FindActor(NAME_Ammo);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
|
@ -2825,8 +2825,10 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
break;
|
||||
case POWERUPTIME:
|
||||
{
|
||||
// [value, max] = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem);
|
||||
// value++; max++;
|
||||
static VMFunction *func = nullptr;
|
||||
if (func == nullptr) func = static_cast<PFunction*>(RUNTIME_CLASS(APlayerPawn)->Symbols.FindSymbol("GetEffectTicsForItem", false))->Variants[0].Implementation;
|
||||
if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem");
|
||||
VMValue params[] = { statusBar->CPlayer->mo, data.inventoryItem };
|
||||
VMReturn ret[2];
|
||||
int ival;
|
||||
|
@ -3312,10 +3314,10 @@ class CommandWeaponAmmo : public SBarInfoNegatableFlowControl
|
|||
for(int i = 0;i < 2;i++)
|
||||
{
|
||||
ammo[i] = PClass::FindClass(sc.String);
|
||||
if(ammo[i] == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(ammo[i])) //must be a kind of ammo
|
||||
if(ammo[i] == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(ammo[i])) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
ammo[i] = RUNTIME_CLASS(AAmmo);
|
||||
ammo[i] = PClass::FindActor(NAME_Ammo);
|
||||
}
|
||||
|
||||
if(sc.CheckToken(TK_OrOr))
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "w_wad.h"
|
||||
#include "a_keys.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "sbar.h"
|
||||
#include "sc_man.h"
|
||||
#include "templates.h"
|
||||
|
@ -527,7 +526,7 @@ static void AddAmmoToList(AWeapon * weapdef)
|
|||
PClassInventory * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
|
||||
if (ti)
|
||||
{
|
||||
AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti);
|
||||
auto ammodef=(AInventory*)GetDefaultByType(ti);
|
||||
|
||||
if (ammodef && !(ammodef->ItemFlags&IF_INVBAR))
|
||||
{
|
||||
|
@ -561,9 +560,9 @@ static void GetAmmoTextLengths(player_t *CPlayer, int& ammocur, int& ammomax)
|
|||
{
|
||||
for (auto type : orderedammos)
|
||||
{
|
||||
AAmmo * ammoitem = static_cast<AAmmo*>(CPlayer->mo->FindInventory(type));
|
||||
AAmmo * inv = nullptr == ammoitem
|
||||
? static_cast<AAmmo*>(GetDefaultByType(type))
|
||||
auto ammoitem = CPlayer->mo->FindInventory(type);
|
||||
auto inv = nullptr == ammoitem
|
||||
? static_cast<AInventory*>(GetDefaultByType(type))
|
||||
: ammoitem;
|
||||
assert(nullptr != inv);
|
||||
|
||||
|
@ -648,9 +647,9 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
|
|||
{
|
||||
|
||||
PClassInventory * type = orderedammos[i];
|
||||
AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type);
|
||||
auto ammoitem = CPlayer->mo->FindInventory(type);
|
||||
|
||||
AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]);
|
||||
auto inv = ammoitem? ammoitem : (AInventory*)GetDefaultByType(orderedammos[i]);
|
||||
FTextureID AltIcon = GetHUDIcon(type);
|
||||
FTextureID icon = !AltIcon.isNull()? AltIcon : inv->Icon;
|
||||
if (!icon.isValid()) continue;
|
||||
|
|
|
@ -1794,7 +1794,7 @@ AInventory *DBaseStatusBar::ValidateInvFirst (int numVisible) const
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void DBaseStatusBar::GetCurrentAmmo (AAmmo *&ammo1, AAmmo *&ammo2, int &ammocount1, int &ammocount2) const
|
||||
void DBaseStatusBar::GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const
|
||||
{
|
||||
if (CPlayer->ReadyWeapon != NULL)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "templates.h"
|
||||
#include "a_keys.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "gi.h"
|
||||
#include "g_level.h"
|
||||
#include "colormatcher.h"
|
||||
|
@ -417,7 +416,7 @@ private:
|
|||
}
|
||||
|
||||
// Ammo
|
||||
AAmmo *ammo1, *ammo2;
|
||||
AInventory *ammo1, *ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
|
||||
GetCurrentAmmo (ammo1, ammo2, ammocount1, ammocount2);
|
||||
|
@ -485,7 +484,7 @@ private:
|
|||
}
|
||||
|
||||
// Draw ammo
|
||||
AAmmo *ammo1, *ammo2;
|
||||
AInventory *ammo1, *ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
|
||||
GetCurrentAmmo (ammo1, ammo2, ammocount1, ammocount2);
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "r_utility.h"
|
||||
#include "a_morph.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "virtual.h"
|
||||
|
||||
|
|
|
@ -716,6 +716,7 @@ xx(BlendColor)
|
|||
xx(Strength)
|
||||
xx(Mode)
|
||||
xx(PowerupType)
|
||||
xx(PlayerPawn)
|
||||
|
||||
// Decorate compatibility functions
|
||||
xx(BuiltinTypeCheck)
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
#include "thingdef.h"
|
||||
#include "a_pickups.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "stats.h"
|
||||
|
@ -8700,7 +8699,7 @@ scriptwait:
|
|||
PClass *type = PClass::FindClass (FBehavior::StaticLookupString (STACK(1)));
|
||||
AInventory *item;
|
||||
|
||||
if (type != NULL && type->ParentClass == RUNTIME_CLASS(AAmmo))
|
||||
if (type != NULL && type->ParentClass == PClass::FindActor(NAME_Ammo))
|
||||
{
|
||||
item = activator->FindInventory (static_cast<PClassActor *>(type));
|
||||
if (item != NULL)
|
||||
|
@ -8729,7 +8728,7 @@ scriptwait:
|
|||
PClassActor *type = PClass::FindActor (FBehavior::StaticLookupString (STACK(2)));
|
||||
AInventory *item;
|
||||
|
||||
if (type != NULL && type->ParentClass == RUNTIME_CLASS(AAmmo))
|
||||
if (type != NULL && type->ParentClass == PClass::FindActor(NAME_Ammo))
|
||||
{
|
||||
item = activator->FindInventory (type);
|
||||
if (item != NULL)
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "p_spec.h"
|
||||
#include "p_checkposition.h"
|
||||
#include "math/cmath.h"
|
||||
#include "a_ammo.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
#include "gi.h"
|
||||
|
@ -3228,7 +3227,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
|
|||
|
||||
if (dropamount > 0)
|
||||
{
|
||||
if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||
if (flagmask != 0 && inv->IsKindOf(PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
inv->Amount = int(dropamount * dropammofactor);
|
||||
inv->ItemFlags |= IF_IGNORESKILL;
|
||||
|
@ -3238,10 +3237,10 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
|
|||
inv->Amount = dropamount;
|
||||
}
|
||||
}
|
||||
else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
||||
else if (inv->IsKindOf (PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
// Half ammo when dropped by bad guys.
|
||||
int amount = static_cast<AAmmo *>(inv)->DropAmount;
|
||||
int amount = inv->IntVar("DropAmount");
|
||||
if (amount <= 0)
|
||||
{
|
||||
amount = MAX(1, int(inv->Amount * dropammofactor));
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include "d_player.h"
|
||||
#include "virtual.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "a_morph.h"
|
||||
|
||||
|
@ -906,7 +905,7 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate
|
|||
// and infinite ammo is on
|
||||
if (notakeinfinite &&
|
||||
((dmflags & DF_INFINITE_AMMO) || (player && player->cheats & CF_INFINITEAMMO)) &&
|
||||
item->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||
item->IsKindOf(PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
// Nothing to do here, except maybe res = false;? Would it make sense?
|
||||
result = false;
|
||||
|
@ -1171,7 +1170,7 @@ bool AActor::GiveAmmo (PClassInventory *type, int amount)
|
|||
DEFINE_ACTION_FUNCTION(AActor, GiveAmmo)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_CLASS(type, AAmmo);
|
||||
PARAM_CLASS(type, AInventory);
|
||||
PARAM_INT(amount);
|
||||
ACTION_RETURN_BOOL(self->GiveAmmo(type, amount));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "p_spec.h"
|
||||
#include "virtual.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
static FRandom pr_skullpop ("SkullPop");
|
||||
|
@ -1171,7 +1170,7 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
|
|||
item->Destroy();
|
||||
}
|
||||
else if ((dmflags & (DF_COOP_LOSE_AMMO | DF_COOP_HALVE_AMMO)) &&
|
||||
item->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||
item->IsKindOf(PClass::FindActor(NAME_Ammo)))
|
||||
{
|
||||
if (defitem == NULL)
|
||||
{
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "r_data/colormaps.h"
|
||||
#include "a_weaponpiece.h"
|
||||
#include "vmbuilder.h"
|
||||
#include "a_ammo.h"
|
||||
#include "a_keys.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
@ -98,9 +97,9 @@ static PClassActor *FindClassTentative(const char *name, PClass *ancestor, bool
|
|||
}
|
||||
return static_cast<PClassActor *>(cls);
|
||||
}
|
||||
static AAmmo::MetaClass *FindClassTentativeAmmo(const char *name, bool optional = false)
|
||||
static AInventory::MetaClass *FindClassTentativeAmmo(const char *name, bool optional = false)
|
||||
{
|
||||
return static_cast<AAmmo::MetaClass *>(FindClassTentative(name, RUNTIME_CLASS(AAmmo), optional));
|
||||
return static_cast<PClassInventory *>(FindClassTentative(name, PClass::FindActor(NAME_Ammo), optional));
|
||||
}
|
||||
static AWeapon::MetaClass *FindClassTentativeWeapon(const char *name, bool optional = false)
|
||||
{
|
||||
|
@ -1742,33 +1741,6 @@ DEFINE_CLASS_PROPERTY(forbiddento, Ssssssssssssssssssss, Inventory)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(backpackamount, I, Ammo)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
defaults->BackpackAmount = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(backpackmaxamount, I, Ammo)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
defaults->BackpackMaxAmount = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(dropamount, I, Ammo)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
defaults->DropAmount = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2000-2016 Randy Heit
|
||||
** Copyright 2006-2017 Cheistoph Oelckers
|
||||
** Copyright 2006-2017 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
@ -33,18 +33,49 @@
|
|||
**
|
||||
*/
|
||||
|
||||
class Ammo : Inventory native
|
||||
class Ammo : Inventory
|
||||
{
|
||||
native int BackpackAmount;
|
||||
native int BackpackMaxAmount;
|
||||
int BackpackAmount;
|
||||
int BackpackMaxAmount;
|
||||
/*meta*/ int DropAmount;
|
||||
|
||||
property BackpackAmount: BackpackAmount;
|
||||
property BackpackMaxAmount: BackpackMaxAmount;
|
||||
property DropAmount: DropAmount;
|
||||
|
||||
Default
|
||||
{
|
||||
+INVENTORY.KEEPDEPLETED
|
||||
Inventory.PickupSound "misc/ammo_pkup";
|
||||
}
|
||||
|
||||
native Class<Actor> GetParentAmmo ();
|
||||
//===========================================================================
|
||||
//
|
||||
// AAmmo :: GetParentAmmo
|
||||
//
|
||||
// Returns the least-derived ammo type that this ammo is a descendant of.
|
||||
// That is, if this ammo is an immediate subclass of Ammo, then this ammo's
|
||||
// type is returned. If this ammo's superclass is not Ammo, then this
|
||||
// function travels up the inheritance chain until it finds a type that is
|
||||
// an immediate subclass of Ammo and returns that.
|
||||
//
|
||||
// The intent of this is that all unique ammo types will be immediate
|
||||
// subclasses of Ammo. To make different pickups with different ammo amounts,
|
||||
// you subclass the type of ammo you want a different amount for and edit
|
||||
// that.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
Class<Ammo> GetParentAmmo ()
|
||||
{
|
||||
class<Object> type = GetClass();
|
||||
|
||||
while (type.GetParentClass() != "Ammo" && type.GetParentClass() != NULL)
|
||||
{
|
||||
type = type.GetParentClass();
|
||||
}
|
||||
return (class<Ammo>)(type);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
@ -113,7 +144,7 @@ class Ammo : Inventory native
|
|||
}
|
||||
|
||||
let type = GetParentAmmo();
|
||||
if (GetClass() == type)
|
||||
if (GetClass() != type && type != null)
|
||||
{
|
||||
if (!GoAway ())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue