mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-07 08:21:04 +00:00
- Added Gez's dropammofactor submission with some necessary changes. Also merged
redundant ammo multiplication code from P_DropItem and ADehackedPickup::TryPickup. - Restricted native action function definitions to zdoom.pk3. SVN r1123 (trunk)
This commit is contained in:
parent
344f1072a6
commit
0ad1bfe87e
9 changed files with 82 additions and 34 deletions
|
@ -1,4 +1,6 @@
|
||||||
August 7, 2008 (Changes by Graf Zahl)
|
August 7, 2008 (Changes by Graf Zahl)
|
||||||
|
- Added Gez's dropammofactor submission with some necessary changes. Also merged
|
||||||
|
redundant ammo multiplication code from P_DropItem and ADehackedPickup::TryPickup.
|
||||||
- Fixed. The Firedemon was missing a game filter.
|
- Fixed. The Firedemon was missing a game filter.
|
||||||
|
|
||||||
August 7, 2008 (SBARINfO update)
|
August 7, 2008 (SBARINfO update)
|
||||||
|
|
|
@ -2603,6 +2603,8 @@ void FinishDehPatch ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModifyDropAmount(AInventory *inv, int dropamount);
|
||||||
|
|
||||||
bool ADehackedPickup::TryPickup (AActor *toucher)
|
bool ADehackedPickup::TryPickup (AActor *toucher)
|
||||||
{
|
{
|
||||||
const PClass *type = DetermineType ();
|
const PClass *type = DetermineType ();
|
||||||
|
@ -2618,18 +2620,10 @@ bool ADehackedPickup::TryPickup (AActor *toucher)
|
||||||
RealPickup->flags &= ~MF_DROPPED;
|
RealPickup->flags &= ~MF_DROPPED;
|
||||||
}
|
}
|
||||||
// If this item has been dropped by a monster the
|
// If this item has been dropped by a monster the
|
||||||
// amount of ammo this gives must be halved.
|
// amount of ammo this gives must be adjusted.
|
||||||
if (droppedbymonster)
|
if (droppedbymonster)
|
||||||
{
|
{
|
||||||
if (RealPickup->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
ModifyDropAmount(RealPickup, 0);
|
||||||
{
|
|
||||||
static_cast<AWeapon *>(RealPickup)->AmmoGive1 /= 2;
|
|
||||||
static_cast<AWeapon *>(RealPickup)->AmmoGive2 /= 2;
|
|
||||||
}
|
|
||||||
else if (RealPickup->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
|
||||||
{
|
|
||||||
RealPickup->Amount /= 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!RealPickup->TryPickup (toucher))
|
if (!RealPickup->TryPickup (toucher))
|
||||||
{
|
{
|
||||||
|
|
|
@ -3232,6 +3232,7 @@ static void ParseSkill (FScanner &sc)
|
||||||
|
|
||||||
skill.AmmoFactor = FRACUNIT;
|
skill.AmmoFactor = FRACUNIT;
|
||||||
skill.DoubleAmmoFactor = 2*FRACUNIT;
|
skill.DoubleAmmoFactor = 2*FRACUNIT;
|
||||||
|
skill.DropAmmoFactor = -1;
|
||||||
skill.DamageFactor = FRACUNIT;
|
skill.DamageFactor = FRACUNIT;
|
||||||
skill.FastMonsters = false;
|
skill.FastMonsters = false;
|
||||||
skill.DisableCheats = false;
|
skill.DisableCheats = false;
|
||||||
|
@ -3262,6 +3263,11 @@ static void ParseSkill (FScanner &sc)
|
||||||
sc.MustGetFloat ();
|
sc.MustGetFloat ();
|
||||||
skill.DoubleAmmoFactor = FLOAT2FIXED(sc.Float);
|
skill.DoubleAmmoFactor = FLOAT2FIXED(sc.Float);
|
||||||
}
|
}
|
||||||
|
else if (sc.Compare ("dropammofactor"))
|
||||||
|
{
|
||||||
|
sc.MustGetFloat ();
|
||||||
|
skill.DropAmmoFactor = FLOAT2FIXED(sc.Float);
|
||||||
|
}
|
||||||
else if (sc.Compare ("damagefactor"))
|
else if (sc.Compare ("damagefactor"))
|
||||||
{
|
{
|
||||||
sc.MustGetFloat ();
|
sc.MustGetFloat ();
|
||||||
|
@ -3387,6 +3393,9 @@ int G_SkillProperty(ESkillProperty prop)
|
||||||
}
|
}
|
||||||
return AllSkills[gameskill].AmmoFactor;
|
return AllSkills[gameskill].AmmoFactor;
|
||||||
|
|
||||||
|
case SKILLP_DropAmmoFactor:
|
||||||
|
return AllSkills[gameskill].DropAmmoFactor;
|
||||||
|
|
||||||
case SKILLP_DamageFactor:
|
case SKILLP_DamageFactor:
|
||||||
return AllSkills[gameskill].DamageFactor;
|
return AllSkills[gameskill].DamageFactor;
|
||||||
|
|
||||||
|
@ -3437,6 +3446,7 @@ FSkillInfo &FSkillInfo::operator=(const FSkillInfo &other)
|
||||||
Name = other.Name;
|
Name = other.Name;
|
||||||
AmmoFactor = other.AmmoFactor;
|
AmmoFactor = other.AmmoFactor;
|
||||||
DoubleAmmoFactor = other.DoubleAmmoFactor;
|
DoubleAmmoFactor = other.DoubleAmmoFactor;
|
||||||
|
DropAmmoFactor = other.DropAmmoFactor;
|
||||||
DamageFactor = other.DamageFactor;
|
DamageFactor = other.DamageFactor;
|
||||||
FastMonsters = other.FastMonsters;
|
FastMonsters = other.FastMonsters;
|
||||||
DisableCheats = other.DisableCheats;
|
DisableCheats = other.DisableCheats;
|
||||||
|
|
|
@ -406,6 +406,7 @@ void G_WriteSnapshots (FILE *file);
|
||||||
enum ESkillProperty
|
enum ESkillProperty
|
||||||
{
|
{
|
||||||
SKILLP_AmmoFactor,
|
SKILLP_AmmoFactor,
|
||||||
|
SKILLP_DropAmmoFactor,
|
||||||
SKILLP_DamageFactor,
|
SKILLP_DamageFactor,
|
||||||
SKILLP_FastMonsters,
|
SKILLP_FastMonsters,
|
||||||
SKILLP_Respawn,
|
SKILLP_Respawn,
|
||||||
|
@ -424,7 +425,7 @@ typedef TMap<FName, FString> SkillMenuNames;
|
||||||
struct FSkillInfo
|
struct FSkillInfo
|
||||||
{
|
{
|
||||||
FName Name;
|
FName Name;
|
||||||
fixed_t AmmoFactor, DoubleAmmoFactor;
|
fixed_t AmmoFactor, DoubleAmmoFactor, DropAmmoFactor;
|
||||||
fixed_t DamageFactor;
|
fixed_t DamageFactor;
|
||||||
bool FastMonsters;
|
bool FastMonsters;
|
||||||
bool DisableCheats;
|
bool DisableCheats;
|
||||||
|
|
|
@ -573,7 +573,7 @@ void FBehavior::StaticLoadDefaultModules ()
|
||||||
|
|
||||||
FBehavior *FBehavior::StaticLoadModule (int lumpnum, FileReader * fr, int len)
|
FBehavior *FBehavior::StaticLoadModule (int lumpnum, FileReader * fr, int len)
|
||||||
{
|
{
|
||||||
if (lumpnum == -1) return;
|
if (lumpnum == -1) return NULL;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < StaticModules.Size(); ++i)
|
for (unsigned int i = 0; i < StaticModules.Size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2378,14 +2378,64 @@ void A_XXScream (AActor *actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Modifies the drop amount of this item according to the current skill's
|
||||||
|
// settings (also called by ADehackedPickup::TryPickup)
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
void ModifyDropAmount(AInventory *inv, int dropamount)
|
||||||
|
{
|
||||||
|
int flagmask = IF_IGNORESKILL;
|
||||||
|
fixed_t dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
|
||||||
|
// Default drop amount is half of regular amount * regular ammo multiplication
|
||||||
|
if (dropammofactor == -1)
|
||||||
|
{
|
||||||
|
dropammofactor = FRACUNIT/2;
|
||||||
|
flagmask = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropamount > 0)
|
||||||
|
{
|
||||||
|
if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||||
|
{
|
||||||
|
inv->Amount = FixedMul(dropamount, dropammofactor);
|
||||||
|
inv->ItemFlags |= IF_IGNORESKILL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inv->Amount = dropamount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
||||||
|
{
|
||||||
|
// Half ammo when dropped by bad guys.
|
||||||
|
inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, FixedMul(inv->Amount, dropammofactor)));
|
||||||
|
inv->ItemFlags|=flagmask;
|
||||||
|
}
|
||||||
|
else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon)))
|
||||||
|
{
|
||||||
|
// The same goes for ammo from a weapon.
|
||||||
|
static_cast<AWeapon *>(inv)->AmmoGive1 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive1, dropammofactor);
|
||||||
|
static_cast<AWeapon *>(inv)->AmmoGive2 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive2, dropammofactor);
|
||||||
|
inv->ItemFlags|=flagmask;
|
||||||
|
}
|
||||||
|
else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
|
||||||
|
{
|
||||||
|
// For weapons and ammo modified by Dehacked we need to flag the item.
|
||||||
|
static_cast<ADehackedPickup *>(inv)->droppedbymonster = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// PROC P_DropItem
|
// PROC P_DropItem
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
CVAR(Int, sv_dropstyle, 0, CVAR_SERVERINFO | CVAR_ARCHIVE);
|
CVAR(Int, sv_dropstyle, 0, CVAR_SERVERINFO | CVAR_ARCHIVE);
|
||||||
|
|
||||||
AInventory *P_DropItem (AActor *source, const PClass *type, int special, int chance)
|
AInventory *P_DropItem (AActor *source, const PClass *type, int dropamount, int chance)
|
||||||
{
|
{
|
||||||
if (type != NULL && pr_dropitem() <= chance)
|
if (type != NULL && pr_dropitem() <= chance)
|
||||||
{
|
{
|
||||||
|
@ -2413,36 +2463,18 @@ AInventory *P_DropItem (AActor *source, const PClass *type, int special, int cha
|
||||||
if (mo->IsKindOf (RUNTIME_CLASS(AInventory)))
|
if (mo->IsKindOf (RUNTIME_CLASS(AInventory)))
|
||||||
{
|
{
|
||||||
AInventory * inv = static_cast<AInventory *>(mo);
|
AInventory * inv = static_cast<AInventory *>(mo);
|
||||||
if (special > 0)
|
ModifyDropAmount(inv, dropamount);
|
||||||
{
|
|
||||||
inv->Amount = special;
|
|
||||||
}
|
|
||||||
else if (mo->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
|
||||||
{
|
|
||||||
// Half ammo when dropped by bad guys.
|
|
||||||
inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, inv->Amount / 2 ));
|
|
||||||
}
|
|
||||||
else if (mo->IsKindOf (RUNTIME_CLASS(AWeapon)))
|
|
||||||
{
|
|
||||||
// The same goes for ammo from a weapon.
|
|
||||||
static_cast<AWeapon *>(mo)->AmmoGive1 /= 2;
|
|
||||||
static_cast<AWeapon *>(mo)->AmmoGive2 /= 2;
|
|
||||||
}
|
|
||||||
else if (mo->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
|
|
||||||
{
|
|
||||||
// For weapons and ammo modified by Dehacked we need to flag the item.
|
|
||||||
static_cast<ADehackedPickup *>(mo)->droppedbymonster = true;
|
|
||||||
}
|
|
||||||
if (inv->SpecialDropAction (source))
|
if (inv->SpecialDropAction (source))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return inv;
|
||||||
}
|
}
|
||||||
if (!(i_compatflags & COMPATF_NOTOSSDROPS))
|
if (!(i_compatflags & COMPATF_NOTOSSDROPS))
|
||||||
{
|
{
|
||||||
P_TossItem (mo);
|
P_TossItem (mo);
|
||||||
}
|
}
|
||||||
return static_cast<AInventory *>(mo);
|
// we can't really return an AInventory pointer to a non-inventory item here, can we?
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,7 @@ void FScanner::OpenFile (const char *name)
|
||||||
ScriptBuffer = FString((const char *)filebuf, filesize);
|
ScriptBuffer = FString((const char *)filebuf, filesize);
|
||||||
delete[] filebuf;
|
delete[] filebuf;
|
||||||
ScriptName = name; // This is used for error messages so the full file name is preferable
|
ScriptName = name; // This is used for error messages so the full file name is preferable
|
||||||
|
LumpNum = -1;
|
||||||
PrepareScript ();
|
PrepareScript ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +197,7 @@ void FScanner::OpenMem (const char *name, char *buffer, int size)
|
||||||
Close ();
|
Close ();
|
||||||
ScriptBuffer = FString(buffer, size);
|
ScriptBuffer = FString(buffer, size);
|
||||||
ScriptName = name;
|
ScriptName = name;
|
||||||
|
LumpNum = -1;
|
||||||
PrepareScript ();
|
PrepareScript ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +217,7 @@ void FScanner :: OpenLumpNum (int lump)
|
||||||
ScriptBuffer = mem.GetString();
|
ScriptBuffer = mem.GetString();
|
||||||
}
|
}
|
||||||
ScriptName = Wads.GetLumpFullPath(lump);
|
ScriptName = Wads.GetLumpFullPath(lump);
|
||||||
|
LumpNum = lump;
|
||||||
PrepareScript ();
|
PrepareScript ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ public:
|
||||||
int Line;
|
int Line;
|
||||||
bool End;
|
bool End;
|
||||||
bool Crossed;
|
bool Crossed;
|
||||||
|
int LumpNum;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void PrepareScript();
|
void PrepareScript();
|
||||||
|
|
|
@ -165,6 +165,11 @@ static void ParseActionDef (FScanner &sc, PClass *cls)
|
||||||
AFuncDesc *afd;
|
AFuncDesc *afd;
|
||||||
FName funcname;
|
FName funcname;
|
||||||
FString args;
|
FString args;
|
||||||
|
|
||||||
|
if (sc.LumpNum == -1 || Wads.GetLumpFile(sc.LumpNum) > 0)
|
||||||
|
{
|
||||||
|
sc.ScriptError ("action functions can only be imported by internal class and actor definitions!");
|
||||||
|
}
|
||||||
|
|
||||||
sc.MustGetToken(TK_Native);
|
sc.MustGetToken(TK_Native);
|
||||||
sc.MustGetToken(TK_Identifier);
|
sc.MustGetToken(TK_Identifier);
|
||||||
|
|
Loading…
Reference in a new issue