mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added ATTACK state for ground and navy units
This commit is contained in:
parent
4bd017e3c7
commit
17b8b35a43
@ -148,7 +148,7 @@ public:
|
||||
virtual DataTypes::Radio getRadio() { return radio; }
|
||||
virtual DataTypes::GeneralSettings getGeneralSettings() { return generalSettings; }
|
||||
virtual vector<DataTypes::Ammo> getAmmo() { return ammo; }
|
||||
virtual vector<DataTypes::Contact> getTargets() { return contacts; }
|
||||
virtual vector<DataTypes::Contact> getContacts() { return contacts; }
|
||||
virtual list<Coords> getActivePath() { return activePath; }
|
||||
virtual bool getIsLeader() { return isLeader; }
|
||||
virtual unsigned char getOperateAs() { return operateAs; }
|
||||
|
||||
@ -68,6 +68,10 @@ void GroundUnit::setState(unsigned char newState)
|
||||
case State::REACH_DESTINATION: {
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setTargetID(NULL);
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTargetPosition(Coords(NULL));
|
||||
break;
|
||||
@ -102,6 +106,13 @@ void GroundUnit::setState(unsigned char newState)
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
resetTask();
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
@ -174,6 +185,27 @@ void GroundUnit::AIloop()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
Unit* target = unitsManager->getUnit(getTargetID());
|
||||
if (target != nullptr) {
|
||||
setTask("Attacking " + target->getUnitName());
|
||||
|
||||
if (!getHasTask()) {
|
||||
/* Send the command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'AttackUnit', unitID = " << target->getID() << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setState(State::IDLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTask("Firing at area");
|
||||
|
||||
|
||||
@ -65,6 +65,10 @@ void NavyUnit::setState(unsigned char newState)
|
||||
case State::REACH_DESTINATION: {
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setTargetID(NULL);
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTargetPosition(Coords(NULL));
|
||||
break;
|
||||
@ -91,6 +95,13 @@ void NavyUnit::setState(unsigned char newState)
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
resetTask();
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
@ -148,6 +159,25 @@ void NavyUnit::AIloop()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
Unit* target = unitsManager->getUnit(getTargetID());
|
||||
if (target != nullptr) {
|
||||
setTask("Attacking " + target->getUnitName());
|
||||
|
||||
if (!getHasTask()) {
|
||||
/* Send the command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'AttackUnit', unitID = " << target->getID() << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setState(State::IDLE);
|
||||
}
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTask("Firing at area");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user