-
Notifications
You must be signed in to change notification settings - Fork 0
/
SquadAI.cpp
61 lines (53 loc) · 1.53 KB
/
SquadAI.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
/*
* AI.cpp
* TractionEdge
*
* Created by Steven Hamilton on 3/09/09.
* Copyright 2009 scorch.org. All rights reserved.
*
*/
#include <iostream>
#include "GameWorld.h"
#include "SquadAI.h"
#include "DisplayManager.h"
#include "defines.h"
#include "Logger.h"
#include "Utility.h"
void SquadAI::initAI()
{
//reset all our monsters
creatureList = WORLD.getCreatures(ENEMY, true);
for (int i=0;i < creatureList.size();i++){
creatureList[i]->resetAP();
creatureList[i]->endTurn=false;
creatureList[i]->setFiringMode(SNAPSHOT);
}
creatureIt = creatureList.begin();
endTurn=false;
}
void SquadAI::setInitialAIState()
{
//We need to change the state of all monsters to PatrolState()
creatureList = WORLD.getCreatures(ENEMY, true);
for (int i=0;i < creatureList.size();i++){
creatureList[i]->aiFSM.changeState(creatureList[i], AI_STATE_PATROL);
}
}
bool SquadAI::processTurn()
{
Utility tool;
if ((*creatureIt)->isAlive && !(*creatureIt)->endTurn)
{
std::cout << "------Processing-id:" << (*creatureIt)->objectId << " AP:" << (*creatureIt)->currentActionPoints << std::endl;
//update state
(*creatureIt)->aiFSM.update((*creatureIt));
//process reaction fire. PLacement of this here is a test. It may have
//to move inside states.
WORLD.checkReaction(FRIEND);
} else {
std::cout << "------End Turn id:" << (*creatureIt)->objectId << std::endl;
creatureIt++;
}
if (creatureIt==creatureList.end()) endTurn=true;
return endTurn;
}