Skip to content

Commit 2748b74

Browse files
revolucasXottab-DUTY
authored andcommitted
+ Added cut-content AmebaZone
+ Added ZS_AMEBA and ZS_NGRAV class registrator ids
1 parent 8a423ed commit 2748b74

File tree

5 files changed

+145
-2
lines changed

5 files changed

+145
-2
lines changed

src/xrGame/AmebaZone.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#include "stdafx.h"
2+
3+
#include "AmebaZone.h"
4+
#include "ZoneVisual.h"
5+
#include "CustomZone.h"
6+
#include "xrEngine/xr_collide_form.h"
7+
#include "Include/xrRender/Kinematics.h"
8+
#include "PhysicsShellHolder.h"
9+
#include "PHMovementControl.h"
10+
#include "CharacterPhysicsSupport.h"
11+
#include "entity_alive.h"
12+
13+
14+
CAmebaZone::CAmebaZone() : m_fVelocityLimit(1.f) {}
15+
16+
CAmebaZone::~CAmebaZone() {}
17+
18+
void CAmebaZone::Load(LPCSTR section)
19+
{
20+
inherited::Load(section);
21+
m_fVelocityLimit = pSettings->r_float(section, "max_velocity_in_zone");
22+
}
23+
24+
bool CAmebaZone::BlowoutState()
25+
{
26+
bool result = inherited::BlowoutState();
27+
if (!result)
28+
UpdateBlowout();
29+
30+
// XXX: use range-based for
31+
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
32+
Affect(&(*it));
33+
34+
return result;
35+
}
36+
37+
void CAmebaZone::Affect(SZoneObjectInfo* O)
38+
{
39+
CPhysicsShellHolder* pGameObject = smart_cast<CPhysicsShellHolder*>(O->object);
40+
if (!pGameObject) return;
41+
42+
if (O->zone_ignore) return;
43+
44+
Fvector hit_dir;
45+
hit_dir.set(Random.randF(-.5f, .5f),
46+
Random.randF(.0f, 1.f),
47+
Random.randF(-.5f, .5f));
48+
hit_dir.normalize();
49+
50+
Fvector position_in_bone_space;
51+
52+
float power = Power(distance_to_center(O->object), m_fEffectiveRadius);
53+
float power_critical = 0.0f;
54+
float impulse = m_fHitImpulseScale * power * pGameObject->GetMass();
55+
56+
if (power > 0.01f)
57+
{
58+
//m_dwDeltaTime = 0;
59+
position_in_bone_space.set(0.f, 0.f, 0.f);
60+
61+
CreateHit(pGameObject->ID(), ID(), hit_dir, power, 0, position_in_bone_space, impulse, m_eHitTypeBlowout);
62+
63+
PlayHitParticles(pGameObject);
64+
}
65+
}
66+
67+
void CAmebaZone::PhTune(float step)
68+
{
69+
// XXX: use range-based for
70+
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
71+
{
72+
CEntityAlive* EA = smart_cast<CEntityAlive*>((*it).object);
73+
if (EA)
74+
{
75+
CPHMovementControl* mc = EA->character_physics_support()->movement();
76+
if (mc)
77+
{
78+
if (distance_to_center(EA) < effective_radius(m_fEffectiveRadius))
79+
mc->SetVelocityLimit(m_fVelocityLimit);
80+
}
81+
}
82+
}
83+
}
84+
85+
void CAmebaZone::SwitchZoneState(EZoneState new_state)
86+
{
87+
if (new_state == eZoneStateBlowout && m_eZoneState != eZoneStateBlowout)
88+
Activate();
89+
90+
if (new_state != eZoneStateBlowout && m_eZoneState == eZoneStateBlowout)
91+
Deactivate();
92+
93+
inherited::SwitchZoneState(new_state);
94+
}
95+
96+
float CAmebaZone::distance_to_center(CGameObject* O)
97+
{
98+
Fvector P;
99+
XFORM().transform_tiny(P, CForm->getSphere().P);
100+
Fvector OP;
101+
OP.set(O->Position());
102+
return _sqrt((P.x - OP.x) * (P.x - OP.x) + (P.x - OP.x) * (P.x - OP.x));
103+
}

src/xrGame/AmebaZone.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include "CustomZone.h"
4+
#include "Include/xrRender/KinematicsAnimated.h"
5+
#include "ZoneVisual.h"
6+
#include "xrPhysics/PHUpdateObject.h"
7+
8+
class CAmebaZone :
9+
public CVisualZone,
10+
public CPHUpdateObject
11+
{
12+
typedef CVisualZone inherited;
13+
float m_fVelocityLimit;
14+
15+
public:
16+
CAmebaZone();
17+
~CAmebaZone();
18+
void Affect(SZoneObjectInfo* O) override;
19+
20+
protected:
21+
void PhTune(float step) override;
22+
void PhDataUpdate(float step) override {}
23+
bool BlowoutState() override;
24+
void SwitchZoneState(EZoneState new_state) override;
25+
void Load(LPCSTR section) override;
26+
virtual float distance_to_center(CGameObject* O);
27+
};

src/xrGame/xrGame.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@
664664
<ClInclude Include="alife_time_manager.h" />
665665
<ClInclude Include="alife_time_manager_inline.h" />
666666
<ClInclude Include="alife_update_manager.h" />
667+
<ClInclude Include="AmebaZone.h" />
667668
<ClInclude Include="ammunition_groups.h" />
668669
<ClInclude Include="animation_movement_controller.h" />
669670
<ClInclude Include="animation_script_callback.h" />
@@ -2177,6 +2178,7 @@
21772178
<ClCompile Include="alife_trader.cpp" />
21782179
<ClCompile Include="alife_trader_abstract.cpp" />
21792180
<ClCompile Include="alife_update_manager.cpp" />
2181+
<ClCompile Include="AmebaZone.cpp" />
21802182
<ClCompile Include="ammunition_groups.cpp" />
21812183
<ClCompile Include="animation_movement_controller.cpp" />
21822184
<ClCompile Include="animation_script_callback.cpp">

src/xrGame/xrGame.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,9 @@
22902290
<Filter Include="PCH">
22912291
<UniqueIdentifier>{c2cce2fe-498b-4192-baf4-c5a1bf9717f0}</UniqueIdentifier>
22922292
</Filter>
2293+
<Filter Include="Core\Client\Objects\zones\Ameba">
2294+
<UniqueIdentifier>{0ca5d322-0181-4fae-9706-95107e18fdc5}</UniqueIdentifier>
2295+
</Filter>
22932296
</ItemGroup>
22942297
<ItemGroup>
22952298
<ClInclude Include="mt_config.h">
@@ -6658,6 +6661,9 @@
66586661
<ClInclude Include="raypick.h">
66596662
<Filter>Core\Common</Filter>
66606663
</ClInclude>
6664+
<ClInclude Include="AmebaZone.h">
6665+
<Filter>Core\Client\Objects\zones\Ameba</Filter>
6666+
</ClInclude>
66616667
</ItemGroup>
66626668
<ItemGroup>
66636669
<ClCompile Include="damage_manager.cpp">
@@ -10174,6 +10180,9 @@
1017410180
<ClCompile Include="raypick.cpp">
1017510181
<Filter>Core\Common</Filter>
1017610182
</ClCompile>
10183+
<ClCompile Include="AmebaZone.cpp">
10184+
<Filter>Core\Client\Objects\zones\Ameba</Filter>
10185+
</ClCompile>
1017710186
</ItemGroup>
1017810187
<ItemGroup>
1017910188
<CustomBuild Include="ai\monsters\chimera\chimera_attack_state.h">

src/xrServerEntities/object_factory_register.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
#include "torridZone.h"
136136
#include "ZoneVisual.h"
137137
#include "hairszone.h"
138-
//. # include "amebazone.h"
138+
#include "AmebaZone.h"
139139
#include "nogravityzone.h"
140140
#include "simpledetector.h"
141141
#include "elitedetector.h"
@@ -361,7 +361,7 @@ void CObjectFactory::register_classes()
361361
ADD(CTeamBaseZone, CSE_ALifeTeamBaseZone, CLSID_Z_TEAM_BASE, "team_base_zone");
362362
ADD(CTorridZone, CSE_ALifeTorridZone, CLSID_Z_TORRID, "torrid_zone");
363363
ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, CLSID_SPACE_RESTRICTOR, "space_restrictor");
364-
//. ADD(CAmebaZone ,CSE_ALifeZoneVisual ,CLSID_Z_AMEBA ,"ameba_zone");
364+
ADD(CAmebaZone, CSE_ALifeZoneVisual, CLSID_Z_AMEBA, "ameba_zone");
365365
ADD(CNoGravityZone, CSE_ALifeAnomalousZone, CLSID_Z_NOGRAVITY, "nogravity_zone");
366366
ADD(CZoneCampfire, CSE_ALifeAnomalousZone, CLSID_Z_CAMPFIRE, "zone_campfire");
367367
// Detectors
@@ -426,6 +426,8 @@ void CObjectFactory::register_classes()
426426
ADD(CMosquitoBald, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MBALD"), "zone_mbald_s");
427427
ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_GALAN"), "zone_galant_s");
428428
ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MINCE"), "zone_mincer_s");
429+
ADD(CAmebaZone, CSE_ALifeZoneVisual , TEXT2CLSID("ZS_AMEBA"), "zone_ameba_s");
430+
ADD(CNoGravityZone, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_NGRAV"), "zone_nograv_s");
429431
ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, TEXT2CLSID("SPC_RS_S"), "script_restr");
430432
#endif // NO_XR_GAME
431433
}

0 commit comments

Comments
 (0)