case agent_set_attack_action:
if (mbCheckAgent(intValues[0]) && rglBetween(intValues[1], -2, 4) && rglBetween(intValues[2], 0, 2))
{
mbAgent *agent = g_mission->getAgent(intValues[0]);
agent->m_attackOverrideType = intValues[1];
agent->m_attackOverrideHold = intValues[2];
}
break;
case agent_set_defend_action:
if (mbCheckAgent(intValues[0]) && rglBetween(intValues[1], -2, 4) && values[2] >= 0)
{
mbAgent *agent = g_mission->getAgent(intValues[0]);
agent->m_defendOverrideType = intValues[1];
agent->m_defendOverrideDuration = values[2] / 1000.0f;
agent->m_defendOverrideTimer.reset();
}
break;
void mbAgent::updateAiControl()
{
m_control.m_flags1 = m_ai.m_control.m_flags1;
m_control.m_flags2 = m_ai.m_control.m_flags2;
setLookHeight(m_ai.m_control.m_lookDir.z);
changeLookDirf(m_ai.m_control.m_lookDir.vec2().getAngle());
__int64 missionTime = mbGetRawMissionTime();
bool found = false;
while (!m_ai.m_queuedControls.empty())
{
mbAgentAiQueuedControl *queuedControl = &m_ai.m_queuedControls.front();
if (queuedControl->m_time >= missionTime)
break;
m_control.m_flags2 |= queuedControl->m_control.m_flags2;
m_ai.m_actionControl = m_control;
m_ai.m_queuedControls.pop_front();
found = true;
}
if (!found)
m_control.m_flags2 |= m_ai.m_actionControl.m_flags2;
if (m_attackOverrideType >= 0)
{
m_control.m_flags2 &= ~(cf2_defend_mask|cf2_attack_mask);
if (m_attackAction == aa_releasing)
m_attackOverrideType = -1;
else if (m_attackAction != aa_readying || m_attackOverrideHold)
m_control.m_flags2 |= getAttackControlFlagsFromType(m_attackOverrideType);
}
else if (m_defendOverrideType >= 0)
{
m_control.m_flags2 &= ~(cf2_defend_mask|cf2_attack_mask);
if (m_defendAction != da_blocking && m_defendAction != da_parrying)
{
m_control.m_flags2 |= getDefendControlFlagsFromType(m_defendOverrideType);
m_defendOverrideTimer.reset();
}
else if (m_defendOverrideDuration > m_defendOverrideTimer.getElapsedTime())
{
m_control.m_flags2 |= getDefendControlFlagsFromType(m_defendOverrideType);
}
else
{
m_defendOverrideType = -1;
}
}
if (m_attackOverrideType == -2)
{
m_control.m_flags2 &= ~cf2_attack_mask;
m_attackOverrideType = -1;
}
if (m_defendOverrideType == -2)
{
m_control.m_flags2 &= ~cf2_defend_mask;
m_defendOverrideType = -1;
}
}