Skip to content

Commit

Permalink
+ Added cut-content AmebaZone
Browse files Browse the repository at this point in the history
+ Added ZS_AMEBA and ZS_NGRAV class registrator ids
  • Loading branch information
revolucas authored and Xottab-DUTY committed Dec 18, 2017
1 parent 8a423ed commit 2748b74
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 2 deletions.
103 changes: 103 additions & 0 deletions src/xrGame/AmebaZone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#include "stdafx.h"

#include "AmebaZone.h"
#include "ZoneVisual.h"
#include "CustomZone.h"
#include "xrEngine/xr_collide_form.h"
#include "Include/xrRender/Kinematics.h"
#include "PhysicsShellHolder.h"
#include "PHMovementControl.h"
#include "CharacterPhysicsSupport.h"
#include "entity_alive.h"


CAmebaZone::CAmebaZone() : m_fVelocityLimit(1.f) {}

CAmebaZone::~CAmebaZone() {}

void CAmebaZone::Load(LPCSTR section)
{
inherited::Load(section);
m_fVelocityLimit = pSettings->r_float(section, "max_velocity_in_zone");
}

bool CAmebaZone::BlowoutState()
{
bool result = inherited::BlowoutState();
if (!result)
UpdateBlowout();

// XXX: use range-based for
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
Affect(&(*it));

return result;
}

void CAmebaZone::Affect(SZoneObjectInfo* O)
{
CPhysicsShellHolder* pGameObject = smart_cast<CPhysicsShellHolder*>(O->object);
if (!pGameObject) return;

if (O->zone_ignore) return;

Fvector hit_dir;
hit_dir.set(Random.randF(-.5f, .5f),
Random.randF(.0f, 1.f),
Random.randF(-.5f, .5f));
hit_dir.normalize();

Fvector position_in_bone_space;

float power = Power(distance_to_center(O->object), m_fEffectiveRadius);
float power_critical = 0.0f;
float impulse = m_fHitImpulseScale * power * pGameObject->GetMass();

if (power > 0.01f)
{
//m_dwDeltaTime = 0;
position_in_bone_space.set(0.f, 0.f, 0.f);

CreateHit(pGameObject->ID(), ID(), hit_dir, power, 0, position_in_bone_space, impulse, m_eHitTypeBlowout);

PlayHitParticles(pGameObject);
}
}

void CAmebaZone::PhTune(float step)
{
// XXX: use range-based for
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
{
CEntityAlive* EA = smart_cast<CEntityAlive*>((*it).object);
if (EA)
{
CPHMovementControl* mc = EA->character_physics_support()->movement();
if (mc)
{
if (distance_to_center(EA) < effective_radius(m_fEffectiveRadius))
mc->SetVelocityLimit(m_fVelocityLimit);
}
}
}
}

void CAmebaZone::SwitchZoneState(EZoneState new_state)
{
if (new_state == eZoneStateBlowout && m_eZoneState != eZoneStateBlowout)
Activate();

if (new_state != eZoneStateBlowout && m_eZoneState == eZoneStateBlowout)
Deactivate();

inherited::SwitchZoneState(new_state);
}

float CAmebaZone::distance_to_center(CGameObject* O)
{
Fvector P;
XFORM().transform_tiny(P, CForm->getSphere().P);
Fvector OP;
OP.set(O->Position());
return _sqrt((P.x - OP.x) * (P.x - OP.x) + (P.x - OP.x) * (P.x - OP.x));
}
27 changes: 27 additions & 0 deletions src/xrGame/AmebaZone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "CustomZone.h"
#include "Include/xrRender/KinematicsAnimated.h"
#include "ZoneVisual.h"
#include "xrPhysics/PHUpdateObject.h"

class CAmebaZone :
public CVisualZone,
public CPHUpdateObject
{
typedef CVisualZone inherited;
float m_fVelocityLimit;

public:
CAmebaZone();
~CAmebaZone();
void Affect(SZoneObjectInfo* O) override;

protected:
void PhTune(float step) override;
void PhDataUpdate(float step) override {}
bool BlowoutState() override;
void SwitchZoneState(EZoneState new_state) override;
void Load(LPCSTR section) override;
virtual float distance_to_center(CGameObject* O);
};
2 changes: 2 additions & 0 deletions src/xrGame/xrGame.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@
<ClInclude Include="alife_time_manager.h" />
<ClInclude Include="alife_time_manager_inline.h" />
<ClInclude Include="alife_update_manager.h" />
<ClInclude Include="AmebaZone.h" />
<ClInclude Include="ammunition_groups.h" />
<ClInclude Include="animation_movement_controller.h" />
<ClInclude Include="animation_script_callback.h" />
Expand Down Expand Up @@ -2177,6 +2178,7 @@
<ClCompile Include="alife_trader.cpp" />
<ClCompile Include="alife_trader_abstract.cpp" />
<ClCompile Include="alife_update_manager.cpp" />
<ClCompile Include="AmebaZone.cpp" />
<ClCompile Include="ammunition_groups.cpp" />
<ClCompile Include="animation_movement_controller.cpp" />
<ClCompile Include="animation_script_callback.cpp">
Expand Down
9 changes: 9 additions & 0 deletions src/xrGame/xrGame.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,9 @@
<Filter Include="PCH">
<UniqueIdentifier>{c2cce2fe-498b-4192-baf4-c5a1bf9717f0}</UniqueIdentifier>
</Filter>
<Filter Include="Core\Client\Objects\zones\Ameba">
<UniqueIdentifier>{0ca5d322-0181-4fae-9706-95107e18fdc5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mt_config.h">
Expand Down Expand Up @@ -6658,6 +6661,9 @@
<ClInclude Include="raypick.h">
<Filter>Core\Common</Filter>
</ClInclude>
<ClInclude Include="AmebaZone.h">
<Filter>Core\Client\Objects\zones\Ameba</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="damage_manager.cpp">
Expand Down Expand Up @@ -10174,6 +10180,9 @@
<ClCompile Include="raypick.cpp">
<Filter>Core\Common</Filter>
</ClCompile>
<ClCompile Include="AmebaZone.cpp">
<Filter>Core\Client\Objects\zones\Ameba</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="ai\monsters\chimera\chimera_attack_state.h">
Expand Down
6 changes: 4 additions & 2 deletions src/xrServerEntities/object_factory_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
#include "torridZone.h"
#include "ZoneVisual.h"
#include "hairszone.h"
//. # include "amebazone.h"
#include "AmebaZone.h"
#include "nogravityzone.h"
#include "simpledetector.h"
#include "elitedetector.h"
Expand Down Expand Up @@ -361,7 +361,7 @@ void CObjectFactory::register_classes()
ADD(CTeamBaseZone, CSE_ALifeTeamBaseZone, CLSID_Z_TEAM_BASE, "team_base_zone");
ADD(CTorridZone, CSE_ALifeTorridZone, CLSID_Z_TORRID, "torrid_zone");
ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, CLSID_SPACE_RESTRICTOR, "space_restrictor");
//. ADD(CAmebaZone ,CSE_ALifeZoneVisual ,CLSID_Z_AMEBA ,"ameba_zone");
ADD(CAmebaZone, CSE_ALifeZoneVisual, CLSID_Z_AMEBA, "ameba_zone");
ADD(CNoGravityZone, CSE_ALifeAnomalousZone, CLSID_Z_NOGRAVITY, "nogravity_zone");
ADD(CZoneCampfire, CSE_ALifeAnomalousZone, CLSID_Z_CAMPFIRE, "zone_campfire");
// Detectors
Expand Down Expand Up @@ -426,6 +426,8 @@ void CObjectFactory::register_classes()
ADD(CMosquitoBald, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MBALD"), "zone_mbald_s");
ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_GALAN"), "zone_galant_s");
ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MINCE"), "zone_mincer_s");
ADD(CAmebaZone, CSE_ALifeZoneVisual , TEXT2CLSID("ZS_AMEBA"), "zone_ameba_s");
ADD(CNoGravityZone, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_NGRAV"), "zone_nograv_s");
ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, TEXT2CLSID("SPC_RS_S"), "script_restr");
#endif // NO_XR_GAME
}

0 comments on commit 2748b74

Please sign in to comment.