Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ID24 weapons #2897

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/common/scripting/backend/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6783,11 +6783,8 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
{
if (sym->mVersion <= ctx.Version)
{
// Allow use of deprecated symbols in deprecated functions of the internal code. This is meant to allow deprecated code to remain as it was,
// even if it depends on some deprecated symbol.
// The main motivation here is to keep the deprecated static functions accessing the global level variable as they were.
// Print these only if debug output is active and at the highest verbosity level.
const bool internal = (ctx.Function->Variants[0].Flags & VARF_Deprecated) && fileSystem.GetFileContainer(ctx.Lump) == 0;
// Allow use of deprecated symbols in the internal code.
const bool internal = fileSystem.GetFileContainer(ctx.Lump) == 0;
const FString &deprecationMessage = vsym->DeprecationMessage;

ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING,
Expand Down Expand Up @@ -6877,8 +6874,12 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType *
{
if (sym->mVersion <= ctx.Version)
{
// Allow use of deprecated symbols in internal code.
const bool internal = fileSystem.GetFileContainer(ctx.Lump) == 0;
const FString &deprecationMessage = vsym->DeprecationMessage;
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s - deprecated since %d.%d.%d%s%s", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision,

ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING,
"Accessing deprecated member variable %s - deprecated since %d.%d.%d%s%s", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision,
deprecationMessage.IsEmpty() ? "" : ", ", deprecationMessage.GetChars());
}
}
Expand Down Expand Up @@ -9661,8 +9662,12 @@ bool FxVMFunctionCall::CheckAccessibility(const VersionInfo &ver)
{
if (Function->mVersion <= ver)
{
// Allow use of deprecated symbols in internal code.
const bool internal = fileSystem.GetFileContainer(Function->OwningClass->mDefFileNo) == 0;
const FString &deprecationMessage = Function->Variants[0].DeprecationMessage;
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated function %s - deprecated since %d.%d.%d%s%s", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision,

ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING,
"Accessing deprecated function %s - deprecated since %d.%d.%d%s%s", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision,
deprecationMessage.IsEmpty() ? "" : ", ", deprecationMessage.GetChars());
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/common/scripting/core/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3231,12 +3231,11 @@ PFunctionPointer * NewFunctionPointer(PPrototype * proto, TArray<uint32_t> && ar
//==========================================================================

PStruct::PStruct(FName name, PTypeBase *outer, bool isnative, int fileno)
: PContainerType(name, outer)
: PContainerType(name, outer, fileno)
{
mDescriptiveName.Format("%sStruct<%s>", isnative? "Native" : "", name.GetChars());
Size = 0;
isNative = isnative;
mDefFileNo = fileno;
}

//==========================================================================
Expand Down
5 changes: 2 additions & 3 deletions src/common/scripting/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,14 @@ class PContainerType : public PCompoundType
public:
PTypeBase *Outer = nullptr; // object this type is contained within
FName TypeName = NAME_None; // this type's name
int mDefFileNo = 0;

PContainerType()
{
mDescriptiveName = "ContainerType";
Flags |= TYPE_Container;
}
PContainerType(FName name, PTypeBase *outer) : Outer(outer), TypeName(name)
PContainerType(FName name, PTypeBase *outer, int fileno) : Outer(outer), TypeName(name), mDefFileNo(fileno)
{
mDescriptiveName = name.GetChars();
Flags |= TYPE_Container;
Expand Down Expand Up @@ -648,7 +649,6 @@ class PStruct : public PContainerType
// Some internal structs require explicit construction and destruction of fields the VM cannot handle directly so use these two functions for it.
VMFunction *mConstructor = nullptr;
VMFunction *mDestructor = nullptr;
int mDefFileNo;

PField *AddField(FName name, PType *type, uint32_t flags=0) override;
PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0) override;
Expand Down Expand Up @@ -681,7 +681,6 @@ class PClassType : public PContainerType
public:
PClass *Descriptor;
PClassType *ParentType;
int mDefFileNo;

PClassType(PClass *cls = nullptr, int fileno = 0);
PField *AddField(FName name, PType *type, uint32_t flags = 0) override;
Expand Down
14 changes: 14 additions & 0 deletions wadsrc/static/filter/game-doomchex/sndinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,17 @@ $alias intermission/nextstage weapons/rocklx
$alias intermission/paststats weapons/shotgr
$alias intermission/pastcoopstats weapons/shotgr
$alias intermission/pastdmstats *gibbed


// id24 sounds

weapons/incinerator/fire1 DSINCFI1
weapons/incinerator/fire2 DSINCFI2
weapons/incinerator/burn DSINCBRN
weapons/incinerator/hot1 DSINCHT1
weapons/incinerator/hot2 DSINCHT2
weapons/incinerator/hot3 DSINCHT3

weapons/calamityblade/charge DSHETCHG
weapons/calamityblade/shoot DSHETSHT
weapons/calamityblade/explode DSHETXPL
4 changes: 4 additions & 0 deletions wadsrc/static/mapinfo/doomitems.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@ DoomEdNums
9109 = MarinePlasma
9110 = MarineRailgun
9111 = MarineBFG
-28622 = ID24Fuel
-28621 = ID24FuelTank
-28620 = ID24CalamityBlade
-28619 = ID24Incinerator
}
4 changes: 4 additions & 0 deletions wadsrc/static/zscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ version "4.12"
#include "zscript/actors/doom/weaponbfg.zs"
#include "zscript/actors/doom/dehacked.zs"

#include "zscript/actors/doom/id24/id24ammo.zs"
#include "zscript/actors/doom/id24/id24incinerator.zs"
#include "zscript/actors/doom/id24/id24calamityblade.zs"

#include "zscript/actors/doom/deadthings.zs"
#include "zscript/actors/doom/doomammo.zs"
#include "zscript/actors/doom/doomarmor.zs"
Expand Down
4 changes: 2 additions & 2 deletions wadsrc/static/zscript/actors/doom/doomplayer.zs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DoomPlayer : PlayerPawn
Player.WeaponSlot 3, "Shotgun", "SuperShotgun";
Player.WeaponSlot 4, "Chaingun";
Player.WeaponSlot 5, "RocketLauncher";
Player.WeaponSlot 6, "PlasmaRifle";
Player.WeaponSlot 7, "BFG9000";
Player.WeaponSlot 6, "ID24Incinerator", "PlasmaRifle";
Player.WeaponSlot 7, "ID24CalamityBlade", "BFG9000";

Player.ColorRange 112, 127;
Player.Colorset 0, "$TXT_COLOR_GREEN", 0x70, 0x7F, 0x72;
Expand Down
57 changes: 57 additions & 0 deletions wadsrc/static/zscript/actors/doom/id24/id24ammo.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*****************************************************************************
* Copyright (C) 1993-2024 id Software LLC, a ZeniMax Media company.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
****************************************************************************/

/*****************************************************************************
* id1 - decohack - ammo
****************************************************************************/

//converted from DECOHACK and from id24data.cpp

class ID24Fuel : Ammo
{
Default
{
Inventory.PickupMessage "$ID24_GOTFUELCAN";
Inventory.Amount 10;
Inventory.MaxAmount 150;
Ammo.BackpackAmount 10;
Ammo.BackpackMaxAmount 300;
Inventory.Icon "FTNKA0";
Tag "$AMMO_ID24FUEL";
}
States
{
Spawn:
FCPU A -1;
Stop;
}
}

class ID24FuelTank : ID24Fuel
{
Default
{
Inventory.PickupMessage "$ID24_GOTFUELTANK";
Inventory.Amount 50;
Ammo.DropAmmoFactorMultiplier 0.8; // tank has 20 drop amount, not 25, so multiply the factor by a further 0.8
// -- for custom dehacked ammo this can be calculated based on the drop amount and the default factor
Tag "$AMMO_ID24FUELTANK";
}
States
{
Spawn:
FTNK A -1;
Stop;
}
}
Loading