Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
ikarus.cpp
Go to the documentation of this file.
1
#include "
aggressive.h
"
2
#include "
event_xml.h
"
3
#include "
script.h
"
4
#include <list>
5
#include <vector>
6
#include "
vs_globals.h
"
7
#include "
config_xml.h
"
8
#include "
xml_support.h
"
9
#include "
cmd/unit_generic.h
"
10
#include "
communication.h
"
11
#include "
cmd/script/flightgroup.h
"
12
#include "
flybywire.h
"
13
#include "
hard_coded_scripts.h
"
14
#include "
cmd/script/mission.h
"
15
#include "
universe_util.h
"
16
#include "
gfx/cockpit_generic.h
"
17
#include "
ikarus.h
"
18
using namespace
Orders;
19
Ikarus::Ikarus
() :
AggressiveAI
(
"default.agg.xml"
)
20
{
21
last_time = cur_time = 0;
22
}
23
void
Ikarus::ExecuteStrategy(
Unit
*target )
24
{
25
WillFire( target );
26
if
(
queryType
(
Order::FACING
) == NULL) {
27
//we have nothing to do now
28
FaceTarget
(
false
);
29
AddReplaceLastOrder
(
true
);
//true stands for override any that are there
30
}
31
if
(
queryType
(
Order::MOVEMENT
) == NULL) {
32
MatchLinearVelocity
(
true
,
Vector
( 0, 0, 10000 ),
false
,
true
);
//all ahead full! (not with afterburners but in local coords)
33
AddReplaceLastOrder
(
true
);
34
}
35
//might want to enqueue both movement and facing at the same time as follows:
36
if
(0)
37
ReplaceOrder
(
new
AIScript
(
"++turntowards.xml"
) );
//find this list of names in script.cpp
38
39
cur_time +=
SIMULATION_ATOM
;
40
if
(cur_time-last_time > 5) {
41
//dosomething
42
43
last_time = cur_time;
44
}
45
}
46
47
void
Ikarus::WillFire(
Unit
*target )
48
{
49
bool
missilelockp =
false
;
50
if
(
ShouldFire
( target, missilelockp ) )
//this is a function from fire.cpp you probably want to write a better one
51
parent
->
Fire
(
false
);
52
if
(missilelockp) {
53
parent
->
Fire
(
true
);
//if missiles locked fire
54
parent
->
ToggleWeapon
(
true
);
55
}
56
}
58
void
Ikarus::DecideTarget()
59
{
60
Unit
*targ =
parent
->
Target
();
61
if
(!targ ||
/*some other qualifying factor for changing targets*/
0) {
62
Unit
*un = NULL;
63
for
(
UniverseUtil::PythonUnitIter
i =
UniverseUtil::getUnitList
(); (un = *
i
); ++
i
)
64
if
(
parent
->
getRelation
( un ) < 0) {
65
parent
->
Target
( un );
66
break
;
67
}
68
}
69
}
70
72
void
Ikarus::Execute
()
73
{
74
Flightgroup
*fg =
parent
->
getFlightgroup
();
75
ReCommandWing
( fg );
76
CommunicatingAI::Execute
();
77
DecideTarget();
78
if
( !
ProcessCurrentFgDirective
( fg ) ) {
79
Unit
*target =
parent
->
Target
();
80
bool
isjumpable = target ? ( ( !target->
GetDestinations
().empty() ) &&
parent
->
GetJumpStatus
().
drive
>= 0 ) :
false
;
81
if
(isjumpable)
82
AfterburnTurnTowards
(
this
,
parent
);
83
else
84
ExecuteStrategy( target );
85
}
86
}
87
src
cmd
ai
ikarus.cpp
Generated on Fri May 29 2015 23:07:08 for Vegastrike 0.5.1 rc1 by
1.8.4