2018-03-29 17:01:57 -04:00
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
#include <StdAfx.h>
|
2018-03-29 17:01:57 -04:00
|
|
|
#include "PressurePlate.h"
|
|
|
|
|
#include "World.h"
|
|
|
|
|
#include "SpellcastingManager.h"
|
|
|
|
|
#include "WeenieFactory.h"
|
|
|
|
|
|
|
|
|
|
CPressurePlateWeenie::CPressurePlateWeenie()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CPressurePlateWeenie::~CPressurePlateWeenie()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPressurePlateWeenie::ApplyQualityOverrides()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPressurePlateWeenie::PostSpawn()
|
|
|
|
|
{
|
|
|
|
|
CWeenieObject::PostSpawn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPressurePlateWeenie::Tick()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CPressurePlateWeenie::DoCollision(const class ObjCollisionProfile &prof)
|
|
|
|
|
{
|
2018-10-01 18:50:03 -05:00
|
|
|
if (prof._bitfield & Player_OCPB && next_activation_time <= Timer::cur_time)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
|
|
|
|
Activate(prof.id);
|
2018-10-01 18:50:03 -05:00
|
|
|
next_activation_time = Timer::cur_time + 1.0;
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
int CPressurePlateWeenie::Activate(uint32_t activator_id)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-10-01 18:50:03 -05:00
|
|
|
//CWeenieObject::Activate(activator_id);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2018-07-12 14:41:21 -07:00
|
|
|
CWeenieObject *activator_weenie = g_pWorld->FindObject(activator_id);
|
2018-03-29 17:01:57 -04:00
|
|
|
if (activator_weenie && activator_weenie->_IsPlayer())
|
|
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
if (uint32_t use_sound_did = InqDIDQuality(USE_SOUND_DID, 0))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-07-12 14:41:21 -07:00
|
|
|
CWeenieObject *weenie = g_pWorld->FindObject(activator_id);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
if (weenie)
|
|
|
|
|
{
|
|
|
|
|
weenie->EmitSound(use_sound_did, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
if (uint32_t activation_target_id = InqIIDQuality(ACTIVATION_TARGET_IID, 0))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-07-12 14:41:21 -07:00
|
|
|
CWeenieObject *activation_target = g_pWorld->FindObject(activation_target_id);
|
2018-03-29 17:01:57 -04:00
|
|
|
if (activation_target)
|
|
|
|
|
activation_target->Activate(activator_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (InqIntQuality(ACTIVATION_RESPONSE_INT, 0) & CastSpell_ActivationResponse)
|
|
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
if (uint32_t spell_did = InqDIDQuality(SPELL_DID, 0))
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
|
|
|
|
MakeSpellcastingManager()->CastSpellInstant(activator_id, spell_did);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (InqIntQuality(ACTIVATION_RESPONSE_INT, 0) & Generate_ActivationResponse)
|
|
|
|
|
{
|
|
|
|
|
// spawn generated objects
|
|
|
|
|
|
|
|
|
|
if (m_Qualities._generator_table)
|
|
|
|
|
{
|
|
|
|
|
for (auto &entry : m_Qualities._generator_table->_profile_list)
|
|
|
|
|
{
|
|
|
|
|
if (!entry.maxNum)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int numToSpawn = entry.maxNum;
|
|
|
|
|
|
|
|
|
|
if (m_Qualities._generator_registry)
|
|
|
|
|
{
|
|
|
|
|
for (auto ®istered : m_Qualities._generator_registry->_registry)
|
|
|
|
|
{
|
|
|
|
|
if (entry.slot == registered.second.slot)
|
|
|
|
|
{
|
|
|
|
|
numToSpawn--;
|
|
|
|
|
|
|
|
|
|
if (!numToSpawn)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_Qualities._generator_queue)
|
|
|
|
|
{
|
|
|
|
|
for (auto &queued : m_Qualities._generator_queue->_queue)
|
|
|
|
|
{
|
|
|
|
|
if (entry.slot == queued.slot)
|
|
|
|
|
{
|
|
|
|
|
numToSpawn--;
|
|
|
|
|
|
|
|
|
|
if (!numToSpawn)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numToSpawn; i++)
|
|
|
|
|
{
|
2018-07-12 14:41:21 -07:00
|
|
|
g_pWeenieFactory->GenerateFromTypeOrWcid(this, &entry);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|