mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-15 00:41:57 +00:00
66d28a24b8
Needless to say, this is simply too volatile and would require constant active maintenance, not to mention a huge amount of work up front to get going. It also hid a nasty problem with the Destroy method. Due to the way the garbage collector works, Destroy cannot be exposed to scripts as-is. It may be called from scripts but it may not be overridden from scripts because the garbage collector can call this function after all data needed for calling a scripted override has already been destroyed because if that data is also being collected there is no guarantee that proper order of destruction is observed. So for now Destroy is just a normal native method to scripted classes
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "info.h"
|
|
#include "a_pickups.h"
|
|
#include "a_artifacts.h"
|
|
#include "gstrings.h"
|
|
#include "p_local.h"
|
|
#include "s_sound.h"
|
|
#include "c_console.h"
|
|
#include "doomstat.h"
|
|
#include "v_font.h"
|
|
|
|
IMPLEMENT_CLASS(PClassPuzzleItem, false, false)
|
|
|
|
void PClassPuzzleItem::DeriveData(PClass *newclass)
|
|
{
|
|
Super::DeriveData(newclass);
|
|
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassPuzzleItem)));
|
|
static_cast<PClassPuzzleItem *>(newclass)->PuzzFailMessage = PuzzFailMessage;
|
|
}
|
|
|
|
IMPLEMENT_CLASS(APuzzleItem, false, false)
|
|
|
|
DEFINE_FIELD(APuzzleItem, PuzzleItemNumber)
|
|
|
|
bool APuzzleItem::HandlePickup (AInventory *item)
|
|
{
|
|
// Can't carry more than 1 of each puzzle item in coop netplay
|
|
if (multiplayer && !deathmatch && item->GetClass() == GetClass())
|
|
{
|
|
return true;
|
|
}
|
|
return Super::HandlePickup (item);
|
|
}
|
|
|
|
bool APuzzleItem::Use (bool pickup)
|
|
{
|
|
if (P_UsePuzzleItem (Owner, PuzzleItemNumber))
|
|
{
|
|
return true;
|
|
}
|
|
// [RH] Always play the sound if the use fails.
|
|
S_Sound (Owner, CHAN_VOICE, "*puzzfail", 1, ATTN_IDLE);
|
|
if (Owner != NULL && Owner->CheckLocalView (consoleplayer))
|
|
{
|
|
FString message = GetClass()->PuzzFailMessage;
|
|
if (message.IsNotEmpty() && message[0] == '$') message = GStrings[&message[1]];
|
|
if (message.IsEmpty()) message = GStrings("TXT_USEPUZZLEFAILED");
|
|
C_MidPrintBold (SmallFont, message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool APuzzleItem::ShouldStay ()
|
|
{
|
|
return !!multiplayer;
|
|
}
|
|
|