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 "HotSpot.h"
|
|
|
|
|
#include "World.h"
|
|
|
|
|
|
|
|
|
|
CHotSpotWeenie::CHotSpotWeenie()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CHotSpotWeenie::~CHotSpotWeenie()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CHotSpotWeenie::ApplyQualityOverrides()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CHotSpotWeenie::PostSpawn()
|
|
|
|
|
{
|
|
|
|
|
CWeenieObject::PostSpawn();
|
|
|
|
|
|
|
|
|
|
SetNextCycleTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CHotSpotWeenie::SetNextCycleTime()
|
|
|
|
|
{
|
|
|
|
|
double cycleTime = m_Qualities.GetFloat(HOTSPOT_CYCLE_TIME_FLOAT, 5.0);
|
|
|
|
|
double cycleTimeVariance = m_Qualities.GetFloat(HOTSPOT_CYCLE_TIME_VARIANCE_FLOAT, 0.0);
|
2018-09-29 17:01:12 -05:00
|
|
|
|
|
|
|
|
if (cycleTime == 0.0)
|
2020-03-17 15:10:57 -07:00
|
|
|
return;
|
2018-03-29 17:01:57 -04:00
|
|
|
|
2020-03-17 15:10:57 -07:00
|
|
|
cycleTimeVariance = std::max(1.0 - std::min(cycleTimeVariance, 1.0), 0.0);
|
|
|
|
|
cycleTimeVariance = Random::RollDice(cycleTimeVariance, 1.0f);
|
|
|
|
|
|
|
|
|
|
m_fNextCycleTime = Timer::cur_time + (cycleTime * cycleTimeVariance);
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CHotSpotWeenie::Tick()
|
|
|
|
|
{
|
|
|
|
|
if (m_fNextCycleTime <= Timer::cur_time)
|
|
|
|
|
{
|
|
|
|
|
DoCycle();
|
|
|
|
|
SetNextCycleTime();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 14:18:02 +00:00
|
|
|
CWeenieObject::Tick();
|
2018-03-29 17:01:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CHotSpotWeenie::DoCollision(const class ObjCollisionProfile &prof)
|
|
|
|
|
{
|
|
|
|
|
if (prof._bitfield & Player_OCPB)
|
|
|
|
|
{
|
|
|
|
|
m_ContactedWeenies.insert(prof.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 20:56:15 +00:00
|
|
|
void CHotSpotWeenie::DoCollisionEnd(uint32_t object_id)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
|
|
|
|
m_ContactedWeenies.erase(object_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CHotSpotWeenie::DoCycle()
|
|
|
|
|
{
|
2019-07-07 20:56:15 +00:00
|
|
|
for (std::set<uint32_t>::iterator i = m_ContactedWeenies.begin(); i != m_ContactedWeenies.end();)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
2018-07-12 14:41:21 -07:00
|
|
|
CWeenieObject *other = g_pWorld->FindObject(*i);
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
//if (other && check_collision(other))
|
|
|
|
|
//{
|
|
|
|
|
DoCycleDamage(other);
|
|
|
|
|
i++;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// i = m_ContactedWeenies.erase(i);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-12 14:41:21 -07:00
|
|
|
void CHotSpotWeenie::DoCycleDamage(CWeenieObject *other)
|
2018-03-29 17:01:57 -04:00
|
|
|
{
|
|
|
|
|
DamageEventData damageEvent;
|
|
|
|
|
damageEvent.damage_type = (DAMAGE_TYPE) m_Qualities.GetInt(DAMAGE_TYPE_INT, 0);
|
|
|
|
|
damageEvent.damage_form = DAMAGE_FORM::DF_HOTSPOT;
|
2019-02-04 16:54:20 -06:00
|
|
|
damageEvent.damageAfterMitigation = damageEvent.damageBeforeMitigation = (int)(m_Qualities.GetInt(DAMAGE_INT, 0) * (1.0 - (Random::GenFloat(0.0f, (float)m_Qualities.GetFloat(DAMAGE_VARIANCE_FLOAT, 0.0)))));
|
2018-03-29 17:01:57 -04:00
|
|
|
damageEvent.target = other;
|
2018-07-12 14:41:21 -07:00
|
|
|
damageEvent.source = this;
|
2018-03-29 17:01:57 -04:00
|
|
|
|
|
|
|
|
TryToDealDamage(damageEvent);
|
|
|
|
|
}
|
|
|
|
|
|