/
entity_alive.cpp
746 lines (620 loc) · 20.6 KB
/
entity_alive.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
#include "stdafx.h"
#include "entity_alive.h"
#include "inventoryowner.h"
#include "inventory.h"
#include "physicsshell.h"
#include "../xr_3da/gamemtllib.h"
#include "phmovementcontrol.h"
#include "wound.h"
#include "xrmessages.h"
#include "level.h"
#include "../Include/xrRender/Kinematics.h"
#include "relation_registry.h"
#include "monster_community.h"
#include "entitycondition.h"
#include "script_game_object.h"
#include "hit.h"
#include "PHDestroyable.h"
#include "CharacterPhysicsSupport.h"
#include "script_callback_ex.h"
#include "game_object_space.h"
#include "material_manager.h"
#include "game_base_space.h"
#define SMALL_ENTITY_RADIUS 0.6f
#define BLOOD_MARKS_SECT "bloody_marks"
//отметки крови на стенах
FactoryPtr<IWallMarkArray>* CEntityAlive::m_pBloodMarksVector = nullptr;
float CEntityAlive::m_fBloodMarkSizeMin = 0.f;
float CEntityAlive::m_fBloodMarkSizeMax = 0.f;
float CEntityAlive::m_fBloodMarkDistance = 0.f;
float CEntityAlive::m_fNominalHit = 0.f;
//капание крови
FactoryPtr<IWallMarkArray>* CEntityAlive::m_pBloodDropsVector = nullptr;
float CEntityAlive::m_fStartBloodWoundSize = 0.3f;
float CEntityAlive::m_fStopBloodWoundSize = 0.1f;
float CEntityAlive::m_fBloodDropSize = 0.03f;
//минимальный размер ожега, после которого горят партиклы
//минимальное время горения
u32 CEntityAlive::m_dwMinBurnTime = 10000;
//размер раны, чтоб запустить партиклы
float CEntityAlive::m_fStartBurnWoundSize = 0.3f;
//размер раны, чтоб остановить партиклы
float CEntityAlive::m_fStopBurnWoundSize = 0.1f;
STR_VECTOR* CEntityAlive::m_pFireParticlesVector = NULL;
/////////////////////////////////////////////
// CEntityAlive
/////////////////////////////////////////////
CEntityAlive::CEntityAlive()
{
monster_community = xr_new<MONSTER_COMMUNITY> ();
m_ef_weapon_type = u32(-1);
m_ef_detector_type = u32(-1);
b_eating = false;
m_use_timeout = 5000;
m_used_time = Device.dwTimeGlobal;
m_squad_index = u8(-1);
m_material_manager = 0;
}
CEntityAlive::~CEntityAlive()
{
xr_delete (monster_community);
xr_delete (m_material_manager);
}
void CEntityAlive::Load (LPCSTR section)
{
CEntity::Load (section);
conditions().LoadCondition (section);
conditions().LoadImmunities (pSettings->r_string(section,"immunities_sect"),pSettings);
m_fFood = 100*pSettings->r_float (section,"ph_mass");
//bloody wallmarks
if(0==m_pBloodMarksVector)
LoadBloodyWallmarks (BLOOD_MARKS_SECT);
if(0==m_pFireParticlesVector)
LoadFireParticles ("entity_fire_particles");
//биолог. вид к торому принадлежит монстр или персонаж
monster_community->set (pSettings->r_string(section, "species"));
}
void CEntityAlive::LoadBloodyWallmarks (LPCSTR section)
{
VERIFY (0==m_pBloodMarksVector);
VERIFY (0==m_pBloodDropsVector);
m_pBloodMarksVector = xr_new<FactoryPtr<IWallMarkArray>>();
m_pBloodDropsVector = xr_new<FactoryPtr<IWallMarkArray>>();
//кровавые отметки на стенах
string256 tmp;
LPCSTR wallmarks_name = pSettings->r_string(section, "wallmarks");
int cnt =_GetItemCount(wallmarks_name);
for (int k = 0; k < cnt; ++k)
(*m_pBloodMarksVector)->AppendMark(_GetItem(wallmarks_name, k, tmp));
m_fBloodMarkSizeMin = pSettings->r_float(section, "min_size");
m_fBloodMarkSizeMax = pSettings->r_float(section, "max_size");
m_fBloodMarkDistance = pSettings->r_float(section, "dist");
m_fNominalHit = pSettings->r_float(section, "nominal_hit");
//капли крови с открытых ран
wallmarks_name = pSettings->r_string(section, "blood_drops");
cnt =_GetItemCount(wallmarks_name);
for (int k = 0; k < cnt; ++k)
(*m_pBloodDropsVector)->AppendMark(_GetItem(wallmarks_name, k, tmp));
m_fStartBloodWoundSize = pSettings->r_float(section, "start_blood_size");
m_fStopBloodWoundSize = pSettings->r_float(section, "stop_blood_size");
m_fBloodDropSize = pSettings->r_float(section, "blood_drop_size");
}
void CEntityAlive::UnloadBloodyWallmarks ()
{
if (m_pBloodMarksVector){
//m_pBloodMarksVector->clear ();
xr_delete (m_pBloodMarksVector);
}
if (m_pBloodDropsVector){
//m_pBloodDropsVector->clear ();
xr_delete (m_pBloodDropsVector);
}
}
void CEntityAlive::LoadFireParticles(LPCSTR section)
{
m_pFireParticlesVector = xr_new<STR_VECTOR>();
string256 tmp;
LPCSTR particles_name = pSettings->r_string(section, "fire_particles");
int cnt =_GetItemCount(particles_name);
shared_str s;
for (int k=0; k<cnt; ++k)
{
s = _GetItem(particles_name,k,tmp);
m_pFireParticlesVector->push_back (s);
}
m_fStartBurnWoundSize = pSettings->r_float(section, "start_burn_size");
m_fStopBurnWoundSize = pSettings->r_float(section, "stop_burn_size");
m_dwMinBurnTime = pSettings->r_u32(section, "min_burn_time");
}
void CEntityAlive::UnloadFireParticles()
{
if (m_pFireParticlesVector) {
m_pFireParticlesVector->clear();
xr_delete(m_pFireParticlesVector);
}
}
void CEntityAlive::reinit()
{
CEntity::reinit ();
m_fAccuracy = 25.f;
m_fIntelligence = 25.f;
}
void CEntityAlive::reload (LPCSTR section)
{
CEntity::reload (section);
// CEntityCondition::reload(section);
m_ef_creature_type = pSettings->r_u32 (section,"ef_creature_type");
m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,section,"ef_weapon_type",u32(-1));
m_ef_detector_type = READ_IF_EXISTS(pSettings,r_u32,section,"ef_detector_type",u32(-1));
m_fFood = 100*pSettings->r_float (section,"ph_mass");
}
void CEntityAlive::shedule_Update(u32 dt)
{
inherited::shedule_Update (dt);
//condition update with the game time pass
conditions().UpdateConditionTime ();
conditions().UpdateCondition ();
//Обновление партиклов огня
UpdateFireParticles ();
//капли крови
UpdateBloodDrops ();
//обновить раны
conditions().UpdateWounds ();
//убить сущность
if(Local() && !g_Alive() && !AlreadyDie())
{
if(conditions().GetWhoHitLastTime()) {
// Msg ("%6d : KillEntity from CEntityAlive (using who hit last time) for object %s",Device.dwTimeGlobal,*cName());
KillEntity (conditions().GetWhoHitLastTimeID());
}
else {
// Msg ("%6d : KillEntity from CEntityAlive for object %s",Device.dwTimeGlobal,*cName());
KillEntity (ID());
}
}
}
BOOL CEntityAlive::net_Spawn (CSE_Abstract* DC)
{
//установить команду в соответствии с community
/* if(monster_community->team() != 255)
id_Team = monster_community->team();*/
conditions().reinit ();
inherited::net_Spawn (DC);
m_BloodWounds.clear ();
m_ParticleWounds.clear ();
//добавить кровь и огонь на партиклы, если нужно
for(WOUND_VECTOR::const_iterator it = conditions().wounds().begin(); conditions().wounds().end() != it; ++it)
{
CWound *pWound = *it;
StartFireParticles (pWound);
StartBloodDrops (pWound);
}
return (TRUE);
}
void CEntityAlive::net_Destroy ()
{
inherited::net_Destroy ();
}
void CEntityAlive::HitImpulse (float /**amount/**/, Fvector& /**vWorldDir/**/, Fvector& /**vLocalDir/**/)
{
// float Q = 2*float(amount)/m_PhysicMovementControl->GetMass();
// m_PhysicMovementControl->vExternalImpulse.mad (vWorldDir,Q);
}
//void CEntityAlive::Hit(float P, Fvector &dir,CObject* who, s16 element,Fvector position_in_object_space, float impulse, ALife::EHitType hit_type, float AP)
void CEntityAlive::Hit(SHit* pHDS)
{
SHit HDS = *pHDS;
//-------------------------------------------------------------------
if (HDS.hit_type == ALife::eHitTypeWound_2)
HDS.hit_type = ALife::eHitTypeWound;
//-------------------------------------------------------------------
CDamageManager::HitScale(HDS.boneID, conditions().hit_bone_scale(), conditions().wound_bone_scale(),HDS.aim_bullet);
//изменить состояние, перед тем как родительский класс обработает хит
CWound* pWound = conditions().ConditionHit(&HDS);
if(pWound){
if(ALife::eHitTypeBurn == HDS.hit_type)
StartFireParticles(pWound);
else if(ALife::eHitTypeWound == HDS.hit_type || ALife::eHitTypeFireWound == HDS.hit_type)
StartBloodDrops(pWound);
}
if (HDS.hit_type != ALife::eHitTypeTelepatic){
//добавить кровь на стены
if (!use_simplified_visual())
BloodyWallmarks (HDS.damage(), HDS.dir, HDS.bone(), HDS.p_in_bone_space);
}
//-------------------------------------------
conditions().SetConditionDeltaTime(0);
//-------------------------------------------
inherited::Hit(&HDS);
if (g_Alive()) {
CEntityAlive* EA = smart_cast<CEntityAlive*>(HDS.who);
if(EA && EA->g_Alive() && EA->ID() != ID())
{
RELATION_REGISTRY().FightRegister(EA->ID(), ID(), this->tfGetRelationType(EA), HDS.damage());
RELATION_REGISTRY().Action(EA, this, RELATION_REGISTRY::ATTACK);
}
}
}
void CEntityAlive::Die (CObject* who)
{
RELATION_REGISTRY().Action(smart_cast<CEntityAlive*>(who), this, RELATION_REGISTRY::KILL);
inherited::Die(who);
const CGameObject *who_object = smart_cast<const CGameObject*>(who);
callback(GameObject::eDeath)(lua_game_object(), who_object ? who_object->lua_game_object() : 0);
if (!getDestroy()) {
NET_Packet P;
u_EventGen (P,GE_ASSIGN_KILLER,ID());
P.w_u16(who ? who->ID() : u16(-1));
u_EventSend (P);
}
// disable react to sound
ISpatial* self = smart_cast<ISpatial*> (this);
if (self) self->spatial.type &=~STYPE_REACTTOSOUND;
}
//вывзывает при подсчете хита
float CEntityAlive::CalcCondition(float /**hit/**/)
{
conditions().UpdateCondition();
//dont call inherited::CalcCondition it will be meaningless
return conditions().GetHealthLost();//*100.f;
}
///////////////////////////////////////////////////////////////////////
u16 CEntityAlive::PHGetSyncItemsNumber()
{
if(character_physics_support()->movement()->CharacterExist()) return 1;
else return inherited::PHGetSyncItemsNumber();
}
CPHSynchronize* CEntityAlive::PHGetSyncItem (u16 item)
{
if(character_physics_support()->movement()->CharacterExist()) return character_physics_support()->movement()->GetSyncItem();
else return inherited::PHGetSyncItem(item);
}
void CEntityAlive::PHUnFreeze()
{
if(character_physics_support()->movement()->CharacterExist()) character_physics_support()->movement()->UnFreeze();
else if(m_pPhysicsShell) m_pPhysicsShell->UnFreeze();
}
void CEntityAlive::PHFreeze()
{
if(character_physics_support()->movement()->CharacterExist()) character_physics_support()->movement()->Freeze();
else if(m_pPhysicsShell) m_pPhysicsShell->Freeze();
}
//////////////////////////////////////////////////////////////////////
//добавление кровавых отметок на стенах, после получения хита
void CEntityAlive::BloodyWallmarks (float P, const Fvector &dir, s16 element,
const Fvector& position_in_object_space)
{
if(BI_NONE == (u16)element)
return;
//вычислить координаты попадания
IKinematics* V = smart_cast<IKinematics*>(Visual());
Fvector start_pos = position_in_object_space;
if(V)
{
Fmatrix& m_bone = (V->LL_GetBoneInstance(u16(element))).mTransform;
m_bone.transform_tiny(start_pos);
}
XFORM().transform_tiny(start_pos);
float small_entity = 1.f;
if(Radius()<SMALL_ENTITY_RADIUS) small_entity = 0.5;
float wallmark_size = m_fBloodMarkSizeMax;
wallmark_size *= (P/m_fNominalHit);
wallmark_size *= small_entity;
clamp(wallmark_size, m_fBloodMarkSizeMin, m_fBloodMarkSizeMax);
VERIFY(m_pBloodMarksVector);
PlaceBloodWallmark(dir, start_pos, m_fBloodMarkDistance,
wallmark_size, &**m_pBloodMarksVector);
}
void CEntityAlive::PlaceBloodWallmark(const Fvector& dir, const Fvector& start_pos, float trace_dist, float wallmark_size, IWallMarkArray* pwallmarks_vector)
{
collide::rq_result result;
if ( !Level().ObjectSpace.RayPick( start_pos, dir, trace_dist, collide::rqtBoth, result, this ) )
return;
//вычислить точку попадания
Fvector end_point;
end_point.set(0,0,0);
end_point.mad(start_pos, dir, result.range);
if(result.O) { // Dynamic object
/*
const auto pK = smart_cast<IKinematics*>(result.O->Visual());
if (!pK)
return;
const auto& bone_data = pK->LL_GetData((u16)result.element);
auto pMaterial = GMLib.GetMaterialByIdx(bone_data.game_mtl_idx);
if (pMaterial->Flags.is(SGameMtl::flBloodmark))
::Render->add_SkeletonWallmark(&result.O->renderable.xform, pK, pwallmarks_vector, end_point, dir, wallmark_size);
*/
}
else { //если кровь долетела до статического объекта
auto pTri = Level().ObjectSpace.GetStaticTris()+result.element;
auto pMaterial = GMLib.GetMaterialByIdx(pTri->material);
if(pMaterial->Flags.is(SGameMtl::flBloodmark))
{
//вычислить нормаль к пораженной поверхности
auto pVerts = Level().ObjectSpace.GetStaticVerts();
//добавить отметку на материале
::Render->add_StaticWallmark(pwallmarks_vector, end_point, wallmark_size, pTri, pVerts);
}
}
}
void CEntityAlive::StartFireParticles(CWound* pWound)
{
/*
if ( pWound->GetBoneNum() == BI_NONE ) {
Msg( "! [%s]: %s: can't handle BI_NONE", __FUNCTION__, cName().c_str() );
return;
}
*/
if(pWound->TypeSize(ALife::eHitTypeBurn)>m_fStartBurnWoundSize)
{
if(std::find(m_ParticleWounds.begin(),
m_ParticleWounds.end(),
pWound) == m_ParticleWounds.end())
{
m_ParticleWounds.push_back(pWound);
}
IKinematics* V = smart_cast<IKinematics*>(Visual());
u16 particle_bone = CParticlesPlayer::GetNearestBone(V, pWound->GetBoneNum());
VERIFY(particle_bone < 64 || BI_NONE == particle_bone);
pWound->SetParticleBoneNum(particle_bone);
pWound->SetParticleName((*m_pFireParticlesVector)[::Random.randI(0,m_pFireParticlesVector->size())]);
if(BI_NONE != particle_bone)
{
CParticlesPlayer::StartParticles(pWound->GetParticleName(),
pWound->GetParticleBoneNum(),
Fvector().set(0,1,0),
ID(),
u32(float(m_dwMinBurnTime)*::Random.randF(0.5f,1.5f)), false);
}
else
{
CParticlesPlayer::StartParticles(pWound->GetParticleName(),
Fvector().set(0,1,0),
ID(),
u32(float(m_dwMinBurnTime)*::Random.randF(0.5f,1.5f)), false);
}
}
}
void CEntityAlive::UpdateFireParticles()
{
if(m_ParticleWounds.empty()) return;
// WOUND_VECTOR_IT last_it;
for(WOUND_VECTOR_IT it = m_ParticleWounds.begin();
it != m_ParticleWounds.end();)
{
CWound* pWound = *it;
float burn_size = pWound->TypeSize(ALife::eHitTypeBurn);
if(pWound->GetDestroy() ||
(burn_size>0 && (burn_size<m_fStopBurnWoundSize || !g_Alive())))
{
CParticlesPlayer::AutoStopParticles(pWound->GetParticleName(),
pWound->GetParticleBoneNum(),
u32(float(m_dwMinBurnTime)*::Random.randF(0.5f,1.5f))
);
it = m_ParticleWounds.erase(it);
continue;
}
it++;
}
}
ALife::ERelationType CEntityAlive::tfGetRelationType (const CEntityAlive *tpEntityAlive) const
{
int relation = MONSTER_COMMUNITY::relation(this->monster_community->index(), tpEntityAlive->monster_community->index());
switch(relation) {
case 1: return(ALife::eRelationTypeFriend); break;
case 0: return(ALife::eRelationTypeNeutral); break;
case -1: return(ALife::eRelationTypeEnemy); break;
case -2: return(ALife::eRelationTypeWorstEnemy); break;
default: return(ALife::eRelationTypeDummy); break;
}
};
bool CEntityAlive::is_relation_enemy(const CEntityAlive *tpEntityAlive) const
{
return ((tfGetRelationType(tpEntityAlive) == ALife::eRelationTypeEnemy) ||
(tfGetRelationType(tpEntityAlive) == ALife::eRelationTypeWorstEnemy));
}
void CEntityAlive::StartBloodDrops (CWound* pWound)
{
if(pWound->BloodSize()>m_fStartBloodWoundSize)
{
if(std::find(m_BloodWounds.begin(), m_BloodWounds.end(),
pWound) == m_BloodWounds.end())
{
m_BloodWounds.push_back(pWound);
pWound->m_fDropTime = 0.f;
}
}
}
void CEntityAlive::UpdateBloodDrops()
{
static float m_fBloodDropTimeMax = pSettings->r_float(BLOOD_MARKS_SECT, "blood_drop_time_max");
static float m_fBloodDropTimeMin = pSettings->r_float(BLOOD_MARKS_SECT, "blood_drop_time_min");
if(m_BloodWounds.empty()) return;
if(!g_Alive())
{
m_BloodWounds.clear();
return;
}
// WOUND_VECTOR_IT last_it;
for(WOUND_VECTOR_IT it = m_BloodWounds.begin();
it != m_BloodWounds.end();)
{
CWound* pWound = *it;
float blood_size = pWound->BloodSize();
if(pWound->GetDestroy() || blood_size < m_fStopBloodWoundSize)
{
it = m_BloodWounds.erase(it);
continue;
}
if(pWound->m_fDropTime<Device.fTimeGlobal)
{
float size_k = blood_size - m_fStopBloodWoundSize;
size_k = size_k<1.f?size_k:1.f;
pWound->m_fDropTime = Device.fTimeGlobal + (m_fBloodDropTimeMax - (m_fBloodDropTimeMax-m_fBloodDropTimeMin)*size_k)*Random.randF(0.8f, 1.2f);
VERIFY(m_pBloodDropsVector);
if(pWound->GetBoneNum() != BI_NONE)
{
Fvector pos;
Fvector pos_distort;
pos_distort.random_dir();
pos_distort.mul(0.15f);
CParticlesPlayer::GetBonePos(this, pWound->GetBoneNum(), Fvector().set(0,0,0), pos);
pos.add(pos_distort);
PlaceBloodWallmark(Fvector().set(0.f, -1.f, 0.f),
pos, m_fBloodMarkDistance,
m_fBloodDropSize, &**m_pBloodDropsVector);
}
}
it++;
}
}
void CEntityAlive::save (NET_Packet &output_packet)
{
inherited::save(output_packet);
conditions().save(output_packet);
}
void CEntityAlive::load (IReader &input_packet)
{
inherited::load(input_packet);
conditions().load(input_packet);
}
BOOL CEntityAlive::net_SaveRelevant ()
{
return (TRUE);
}
CEntityConditionSimple* CEntityAlive::create_entity_condition (CEntityConditionSimple* ec)
{
if(!ec)
m_entity_condition = xr_new<CEntityCondition>(this);
else
m_entity_condition = smart_cast<CEntityCondition*>(ec);
return (inherited::create_entity_condition(m_entity_condition));
}
/*
float CEntityAlive::GetfHealth () const
{
return conditions().health()*100.f;
}
float CEntityAlive::SetfHealth (float value)
{
conditions().health() = value/100.f;
return value;
}
*/
float CEntityAlive::SetfRadiation (float value)
{
conditions().radiation() = value/100.f;
return value;
}
/*
float CEntityAlive::g_Health () const
{
return conditions().GetHealth()*100.f;
}
float CEntityAlive::g_MaxHealth () const
{
return conditions().GetMaxHealth()*100.f;
}
*/
float CEntityAlive::g_Radiation () const
{
return conditions().GetRadiation()*100.f;
}
DLL_Pure *CEntityAlive::_construct ()
{
inherited::_construct ();
if(character_physics_support())m_material_manager = xr_new<CMaterialManager>(this,character_physics_support()->movement());
return (this);
}
u32 CEntityAlive::ef_creature_type () const
{
return (m_ef_creature_type);
}
u32 CEntityAlive::ef_weapon_type () const
{
VERIFY (m_ef_weapon_type != u32(-1));
return (m_ef_weapon_type);
}
u32 CEntityAlive::ef_detector_type () const
{
VERIFY (m_ef_detector_type != u32(-1));
return (m_ef_detector_type);
}
void CEntityAlive::PHGetLinearVell(Fvector& velocity)
{
if(character_physics_support())
{
character_physics_support()->PHGetLinearVell(velocity);
}
else
inherited::PHGetLinearVell(velocity);
}
void CEntityAlive::set_lock_corpse(bool b_l_corpse)
{
if (b_eating && !b_l_corpse)
m_used_time = Device.dwTimeGlobal;
b_eating = b_l_corpse;
}
bool CEntityAlive::is_locked_corpse()
{
if (!b_eating)
{
if (m_used_time + m_use_timeout > Device.dwTimeGlobal)
return true;
}
return b_eating;
}
CIKLimbsController* CEntityAlive::character_ik_controller()
{
if(character_physics_support())
{
return character_physics_support()->ik_controller();
}
else
{
return NULL;
}
}
CPHSoundPlayer* CEntityAlive::ph_sound_player()
{
if(character_physics_support())
{
return character_physics_support()->ph_sound_player();
}
else
{
return NULL;
}
}
ICollisionHitCallback* CEntityAlive::get_collision_hit_callback()
{
CCharacterPhysicsSupport *pCPS = character_physics_support();
if (pCPS)
return pCPS->get_collision_hit_callback();
return nullptr;
}
void CEntityAlive::set_collision_hit_callback(ICollisionHitCallback *cc)
{
CCharacterPhysicsSupport* pCPS = character_physics_support();
if (pCPS)
pCPS->set_collision_hit_callback(cc);
}
void CEntityAlive::net_Relcase (CObject *object)
{
inherited::net_Relcase (object);
conditions().remove_links (object);
}
void CEntityAlive:: create_anim_mov_ctrl ( CBlend* b )
{
inherited::create_anim_mov_ctrl( b );
CCharacterPhysicsSupport *cs = character_physics_support( );
if( cs )
cs->on_create_anim_mov_ctrl( );
}
void CEntityAlive:: destroy_anim_mov_ctrl( )
{
inherited::destroy_anim_mov_ctrl();
CCharacterPhysicsSupport *cs =character_physics_support( );
if( cs )
cs->on_destroy_anim_mov_ctrl( );
}