MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / evaluate

Method evaluate

ogsr_engine/xrGame/enemy_manager.cpp:76–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74float CEnemyManager::do_evaluate(const CEntityAlive* object) const { return (m_object->evaluate(this, object)); }
75
76float CEnemyManager::evaluate(const CEntityAlive* object) const
77{
78 // Msg ("[%6d] enemy manager %s evaluates %s",Device.dwTimeGlobal,*m_object->cName(),*object->cName());
79
80 bool actor = (object->CLS_ID == CLSID_OBJECT_ACTOR);
81
82 const CAI_Stalker* stalker = smart_cast<const CAI_Stalker*>(object);
83 bool wounded = stalker ? stalker->wounded(&m_object->movement().restrictions()) : false;
84 if (wounded)
85 {
86 if (m_stalker && m_stalker->agent_manager().enemy().assigned_wounded(object, m_stalker))
87 return (0.f);
88
89 float distance = m_object->Position().distance_to_sqr(object->Position());
90 return (distance);
91 }
92
93 float penalty = 10000.f;
94
95 // if we are hit
96 if (object->ID() == m_object->memory().hit().last_hit_object_id())
97 {
98 if (actor)
99 penalty -= 1500.f;
100 else
101 penalty -= 500.f;
102 }
103
104 // if we see object
105 if (m_object->memory().visual().visible_now(object))
106 penalty -= 1000.f;
107
108 // if object is actor and he/she sees us
109 // if (actor) {
110 // if (smart_cast<const CActor*>(object)->memory().visual().visible_now(m_object))
111 // penalty -= 900.f;
112 // }
113 // else {
114 // // if object is npc and it sees us
115 // const CCustomMonster *monster = smart_cast<const CCustomMonster*>(object);
116 // if (monster && monster->memory().visual().visible_now(m_object))
117 // penalty -= 300.f;
118 // }
119
120#ifdef USE_EVALUATOR
121 ai().ef_storage().non_alife().member_item() = 0;
122 ai().ef_storage().non_alife().enemy_item() = 0;
123 ai().ef_storage().non_alife().member() = m_object;
124 ai().ef_storage().non_alife().enemy() = object;
125
126 float distance = m_object->Position().distance_to_sqr(object->Position());
127 return (penalty + distance / 100.f + ai().ef_storage().m_pfVictoryProbability->ffGetValue() / 100.f);
128#else // USE_EVALUATOR
129 float distance = m_object->Position().distance_to_sqr(object->Position());
130 return (1000.f * (visible ? 0.f : 1.f) + distance);
131#endif // USE_EVALUATOR
132}
133

Callers 1

do_evaluateMethod · 0.45

Calls 11

movementMethod · 0.80
assigned_woundedMethod · 0.80
distance_to_sqrMethod · 0.80
PositionMethod · 0.80
visible_nowMethod · 0.80
woundedMethod · 0.45
hitMethod · 0.45
memoryMethod · 0.45
visualMethod · 0.45
memberMethod · 0.45
ffGetValueMethod · 0.45

Tested by

no test coverage detected